Closed kwallis closed 12 years ago
The Invocation Framework takes the following attributes in an invoke target request, none of the attributes are required:
Bound Invocation - example 1
blackberry.invoke.invoke({
target: "sys.browser", // in order to know what target & action to specify, the developer needs to first call blackberry.invoke.queryTargets() to find out the possible targets * actions (to be designed)
action: "bb.action.VIEW",
uri: "http://www.rim.com"
}, function (error) {
if (error) {
console.log(error);
}
});
Unbound Invocation - example 1
blackberry.invoke.invoke({
uri: "http://www.rim.com"
}, function (error) {
if (error) {
console.log(error);
}
});
Unbound Invocation - example 2
blackberry.invoke.invoke({
uri: "file://accounts/1000/shared/camera/IMG_000000001.jpg",
action: "bb.action.OPEN"
}, function (error) {
if (error) {
console.log(error);
}
});
Unbound Invocation - example 3
blackberry.invoke.invoke({
type: "image/png"
data: <blob>
}, function (error) {
if (error) {
console.log(error);
}
});
Unbound Invocation - example 4
blackberry.invoke.invoke({
type: "text/plain"
data: "a string"
}, function (error) {
if (error) {
console.log(error);
}
});
How will the user convert data to a base64 string?
If they are lucky they will get the data in base64 string already; if not, they will have to google "Javascript: how to encode blob to base64 string".
Ok @jeffheifetz and I had a discussion and we think data field should accept a blob or a String. So that if the user wants to pass in JSON string they can and if they want to read a Blob as in unknown binary data they can still do that by passing a blob. @kwallis
@rwmtse - you should be able to use typeof to determine if data is blob or string and then act accordingly.
@kwallis @nukulb
Question for the data field: whether it is a blob or a string, client.js is going to call window.btoa(data)
on it so that it can pass the data as a base64 encoded string to the server side. Now window.btoa()
does not accept unicode string, it would throw this error:
Error: INVALID_CHARACTER_ERR: DOM Exception 5
Do I simply document this so that the user knows that it's his/her responsibility to convert the string first before calling the invoke function?
The alternative is to convert the string first so that it doesn't contain unicode characters (see MDN documentation), but that would affect the receiving end too.
My preference is to document it and leave it to the developer to convert the string prior to calling invoke.
I think that is fine, just document it and we can move on.
Docs can be found here, note that "source" is not documented for now, b/c it's not clear how it works yet: http://ci0000001875214:9080/hudson/view/WebWorks-API-Docs/job/WebWorks-API-Docs-next-BB10-invoke-other-apps/ws/output/view/blackberry.invoke.html#.invoke^2
What would be the implications of doing something like this for Unicode strings? http://ecmanaut.blogspot.ca/2006/07/encoding-decoding-utf8-in-javascript.html
Our code can do things to convert the string, but the bottom line is the handler app needs to know how to handle the string when it gets it from the invocation framework. If we do unescape( encodeURIComponent( s ) ), the app needs to know decodeURIComponent( escape( s ) ) when it gets it. (BTW, the MDN link that I sent uses the exact same way to deal with unicode strings)
It seems like this is something that the receiver would have to handle anyway. Is there a way, once they decode the base64, to check if the payload is unicode, and that they then need to decode/escape?
checking for unicode can be complicated if you have to check for all possible code points. The easiest solution is this but inefficient http://stackoverflow.com/questions/147824/javascript-how-to-find-whether-a-particular-string-has-unicode-characters-esp
Its atleast O(n) its not a big deal but still if the string is large it could be a big a hit. 8K being the maximum size for a data string, because it needs to be under 16K after being base64 for the invoke Framework.
@rwmtse - can you try a string of 8K length to see how much time it takes to go through an entire string? Simple experiment in a standalone WebWorks App is good enough that takes an 8K unicode string with the last character as unicode and everything else ASCII to tell us what the worst case scenario here is
In terms of docs, can we put the new invoke method below the old one. Reason I am asking is that it is difficult to understand that the constants only apply to the old invoke method and not the new, so let's group all the old stuff together and put the new invoke at the end. I assume this is easier because the template probably defines that methods come after constants/properties, etc.
@kwallis Moved the new invoke method below the old one, also added a code snippet about passing unicode data, please take a look:
At the top of the page description, let's clarify that the passing of arguments is related to the BBOS and PlayBook implementations of invoke(), and not to the BB10 version.
Will the invoke framework only respond on an error?
Related but separate, could we use the callback to report back on the error around passing unicode, rather than throwing an exception?
Finally, I believe "openMP3File" is intended to illustrate a bound invocation, and "openAnotherApp" for bound, correct? Can we make the comments more explicit that we are illustrating allowing the system to choose the appropriate target, as opposed to telling the system exactly which app to use? I think it could be described a bit more explicitly, especially openMP3File, that the system will choose.
Ken Wallis
Product Manager – BlackBerry WebWorks
Research In Motion
(905) 629-4746 x14369
From: Rosa Tse [reply@reply.github.com] Sent: Thursday, June 07, 2012 6:35 PM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6190029
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
@kwallis
Can you also look at the docs (by @tohman) for the receiver side? Should we include cross-reference links in both docs? http://blackberry-webworks.github.com/WebWorks-API-Docs/WebWorks-API-Docs-next-BB10-onInvoked/view/blackberry.invoke.html#.event:invoked
Ken Wallis
Product Manager – BlackBerry WebWorks
Research In Motion
(905) 629-4746 x14369
From: Rosa Tse [reply@reply.github.com] Sent: Friday, June 08, 2012 10:20 AM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
@kwallis
Can you also look at the docs (by @tohman) for the receiver side? Should we include cross-reference links in both docs? http://blackberry-webworks.github.com/WebWorks-API-Docs/WebWorks-API-Docs-next-BB10-onInvoked/view/blackberry.invoke.html#.event:invoked
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6203871
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
For onInvoked, I am specifically thinking about the unicode case. Do we need to have code sample there that illustrates what they have to do in their callback to get the unicode string back when they read from the blob?
onInvoked will be on the same page... Just thinking if the cross-reference (between sections) will make it easier for the developer to see the whole picture.
@nukulb thoughts on the callback topic?
OnInvoked: Ok, I see the potential benefits of an example that ties the two together especially for the unicode case.
----- Original Message ----- From: Rosa Tse [mailto:reply@reply.github.com] Sent: Friday, June 08, 2012 12:07 PM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
For onInvoked, I am specifically thinking about the unicode case. Do we need to have code sample there that illustrates what they have to do in their callback to get the unicode string back when they read from the blob?
onInvoked will be on the same page... Just thinking if the cross-reference (between sections) will make it easier for the developer to see the whole picture.
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6206626
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
@rwmtse @kwallis - I am ok with 2 callbacks, its an easy change and its more web like
For the overall example we should put together an example and a blog post a separate initiative. @kwallis - lets talk about it next week.
@nukulb @kwallis @rwmtse
My design for the signature of the invoke target query function is as follows:
static void query(response, onSuccess, onError);
The request object is the query to be performed on the Invocation Framework (iF). It's value corresponds to the query targets request object in the in the client API design @rwmtse referenced above.
The onSuccess callback is called whenever the query on the iF was successful. The only argument is a response object which corresponds to the query targets response object in the client API design.
The onError callback is called whenever the query on the iF was unsuccessful. The only argument is a string which contains the error message.
Example:
var request = {
"action": "bb.action.SHARE",
"type": "image/png",
"target-type": "ALL"
},
onSuccess = function (response) {
alert("response: " + JSON.stringify(response, null, 2);
},
onError = function (error) {
alert("error: " + error);
};
blackberry.invoke.query(request, onSuccess, onError);
@kwallis - can you give your blessing on the signature? We should expose actions as constants @kwallis - please comment on the constants as well.
Signature looks good.
Does the invoke framework have any pre-defined actions? We should make those constants.
yes, we should make them constants
Do we know what the general predefined actions are?
----- Original Message ----- From: Nukul Bhasin [mailto:reply@reply.github.com] Sent: Friday, June 15, 2012 04:05 PM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
yes, we should make them constants
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6365351
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
yes, we do. However, the iF wiki says this list will grow over the coming months. The list can be found at the Action Registry.
I would recommend putting in the current list, and we can open another issue to track changes in future releases. Thoughts?
----- Original Message ----- From: Henry Aghaulor [mailto:reply@reply.github.com] Sent: Friday, June 15, 2012 04:35 PM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
yes, we do. However, the iF wiki says this list will grow over the coming months. The list can be found at the Action Registry.
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6365947
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
I realize this comment comes really late, but it just struck me... Since we're changing this API completely, is there an opportunity to not have it be blackberry.invoke.invode(...)? Can we just make it blackberry.invoke(...)? I think it reads better :-)
What would the feature id be for whitelisting then?
----- Original Message ----- From: Dan Silivestru [mailto:reply@reply.github.com] Sent: Sunday, June 24, 2012 10:56 PM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
I realize this comment comes really late, but it just struck me... Since we're changing this API completely, is there an opportunity to not have it be blackberry.invoke.invode(...)? Can we just make it blackberry.invoke(...)? I think it reads better :-)
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6538848
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
Would blackberry.invoke not work?
Ken Wallis
Product Manager – BlackBerry WebWorks
Research In Motion
(905) 629-4746 x14369
From: Dan Silivestru [reply@reply.github.com] Sent: Monday, June 25, 2012 10:20 AM To: Ken Wallis Subject: Re: [BB10-Webworks-Packager] As a WebWorks developer, I can invoke other applications on the device from script (#112)
Would blackberry.invoke not work?
Reply to this email directly or view it on GitHub: https://github.com/blackberry/BB10-Webworks-Packager/issues/112#issuecomment-6548432
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
This summary has moved from closed blackberry-webworks/WebWorks-API-Docs#138 as was logged by @ishneur :
Testing for cards is done on trunk 1741.
Here is a summary of outstanding issues. They all seem to be OS related:
Pull request tested: blackberry-webworks/BB10-Webworks-Packager#71
@kwallis @nukulb @cdelcol @EricLeiLi @tohman Please take a look at this client API design for bound and unbound invocation: http://wikis.rim.net/display/bbxwebworks/Client+API+to+allow+WebWorks+app+to+invoke+other+apps