Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-9395: Blackberry: implement decode/encode URIComponent #75

Closed
Closed
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
4 changes: 0 additions & 4 deletions apidoc/Global/Global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ methods:
For more information, see the MDN website for
[encodeURIComponent](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent)
and [decodeURIComponent](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/decodeURIComponent).

On BlackBerry: NYI
returns:
summary: Decoded string.
type: String
Expand All @@ -98,8 +96,6 @@ methods:
For more information, see the MDN website for
[encodeURIComponent](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent)
and [decodeURIComponent](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/decodeURIComponent).

On BlackBerry: NYI
returns:
summary: Encoded string.
type: String
Expand Down
32 changes: 28 additions & 4 deletions blackberry/tibb/TiRootObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

#include "TiGenericFunctionObject.h"
#include "TiJSONObject.h"
#include "TiMessageStrings.h"
#include "TiStringObject.h"
#include "TiTitaniumObject.h"
#include "TiV8EventContainerFactory.h"

#include <QString>
#include <QUrl>

TiRootObject::TiRootObject()
: TiObject("")
{
Expand Down Expand Up @@ -116,14 +120,34 @@ Handle<Value> TiRootObject::_clearTimeout(void* userContext, TiObject* caller, c

Handle<Value> TiRootObject::_decodeURIComponent(void* userContext, TiObject* caller, const Arguments& args)
{
// TODO: finish this
return Undefined();
// TODO: Test using StringObjects
if (args.Length() < 1 || (!args[0]->IsString() && !args[0]->IsStringObject()))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO note to test using StringObjects, as we currently don't have them working and therefore cannot test them. Same for encodeURIComponent

That is unless you know a way to test with StringObjects, in which case i'm interested to know how.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO added

{
ThrowException(String::New(Ti::Msg::Expected_argument_of_type_string));
return Undefined();
}

const String::Utf8Value v8UtfString(args[0]->ToString());
QString decoded = QUrl::fromPercentEncoding(*v8UtfString);

Handle<String> result = String::New(decoded.toUtf8());
return result;
}

Handle<Value> TiRootObject::_encodeURIComponent(void* userContext, TiObject* caller, const Arguments& args)
{
// TODO: finish this
return Undefined();
// TODO: Test using StringObjects
if (args.Length() < 1 || (!args[0]->IsString() && !args[0]->IsStringObject()))
{
ThrowException(String::New(Ti::Msg::Expected_argument_of_type_string));
return Undefined();
}

const String::Utf8Value v8UtfString(args[0]->ToString());
QString encoded = QUrl(*v8UtfString).toEncoded();

Handle<String> result = String::New(encoded.toUtf8());
return result;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as for the _decodeURIComponent function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

Handle<Value> TiRootObject::_require(void* userContext, TiObject* caller, const Arguments& args)
Expand Down