Skip to content

Commit

Permalink
Merge pull request #132 from pec1985/timob-14589
Browse files Browse the repository at this point in the history
[TIMOB-14589] Added encodeURIComponent to Ti.Network
  • Loading branch information
Russ McMahon committed Jul 25, 2013
2 parents 1f3391e + 5cb0446 commit 4f7c4eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/tibb/TiNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "TiSocketObject.h"
#include "TiHTTPClientObject.h"
#include "TiGenericFunctionObject.h"
#include "V8Utils.h"
#include <QUrl>

TiNetwork::TiNetwork()
: TiProxy("Network")
Expand Down Expand Up @@ -42,9 +44,21 @@ void TiNetwork::onCreateStaticMembers()
TiHTTPClientObject::addObjectToParent(this, objectFactory_);
// TODO: Add class methods, constants, properties
TiGenericFunctionObject::addGenericFunctionToParent(this, "createHTTPClient", this, _createHTTPClient);
TiGenericFunctionObject::addGenericFunctionToParent(this, "encodeURIComponent", this, _encodeURIComponent);

}

Handle<Value> TiNetwork::_encodeURIComponent(void* userContext, TiObject* /*caller*/, const Arguments& args)
{
HandleScope scope;
if(args.Length() > 0 && args[0]->IsString())
{
QByteArray url = QUrl::toPercentEncoding(titanium::V8ValueToQString(args[0]));
return scope.Close(String::New(url.data()));
}
return Undefined();
}

Handle<Value> TiNetwork::_createHTTPClient(void* userContext, TiObject* /*caller*/, const Arguments& args)
{
HandleScope handleScope;
Expand Down
1 change: 1 addition & 0 deletions src/tibb/TiNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TiNetwork : public TiProxy
virtual ~TiNetwork();
virtual void onCreateStaticMembers();
static Handle<Value> _createHTTPClient(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _encodeURIComponent(void* userContext, TiObject* /*caller*/, const Arguments& args)

private:
TiNetwork();
Expand Down

0 comments on commit 4f7c4eb

Please sign in to comment.