Skip to content

Commit

Permalink
Merge pull request #132 from alexandergalstyan/networkBranch
Browse files Browse the repository at this point in the history
TIMOB-10137: BlackBerry: Implement Ti.Network.Socket and Ti.Network.Socket.TCP [part1]
  • Loading branch information
alexandergalstyan committed Aug 16, 2012
2 parents f9b2bb1 + 7ec8469 commit 9ddeaad
Show file tree
Hide file tree
Showing 15 changed files with 691 additions and 2 deletions.
14 changes: 14 additions & 0 deletions apidoc/Titanium/Network/Network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ methods:
type: Dictionary<Titanium.Network.TCPSocket>
- name: decodeURIComponent
summary: Returns a decoded version of a URI encoded value.
platforms: [android, iphone, ipad, mobileweb]
returns:
type: String
parameters:
Expand All @@ -106,6 +107,7 @@ methods:
type: String
- name: encodeURIComponent
summary: Returns a URI encoded version of the specified URI component.
platforms: [android, iphone, ipad, mobileweb]
description: |
On iOS, this also escapes the following characters, which are allowed in a
URL but may not be allowed or desirable inside a path component:
Expand Down Expand Up @@ -141,6 +143,7 @@ methods:
platforms: [iphone, ipad]
- name: unregisterForPushNotifications
summary: Unregisters the application for push notifications.
platforms: [iphone, ipad]
description: |
Per Apple's documentation, it is rarely necessary to call this method. See:
[unregisterForRemoteNotifications in the UIApplication Class
Expand Down Expand Up @@ -197,6 +200,7 @@ properties:
[change](Titanium.Network.change) event.
type: Number
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: NETWORK_NONE
summary: |
A [networkType](Titanium.Network.networkType) value indicating that no
Expand All @@ -206,6 +210,7 @@ properties:
[change](Titanium.Network.change) event.
type: Number
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: NETWORK_UNKNOWN
summary: |
A [networkType](Titanium.Network.networkType) value indicating that the
Expand All @@ -215,6 +220,7 @@ properties:
[change](Titanium.Network.change) event.
type: Number
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: NETWORK_WIFI
summary: |
A [networkType](Titanium.Network.networkType) value indicating that the
Expand All @@ -224,6 +230,7 @@ properties:
[change](Titanium.Network.change) event.
type: Number
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: NOTIFICATION_TYPE_ALERT
summary: Constant value for an Alert style push notification.
platforms: [iphone, ipad]
Expand Down Expand Up @@ -353,17 +360,20 @@ properties:
One of the `NETWORK` constants defined in <Titanium.Network>.
type: Number
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: networkTypeName
summary: Network type as a String. Returns one of `NONE`, `WIFI`, `LAN`, `MOBILE`, or `UNKNOWN`.
type: String
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: online
summary: Boolean value indicating if the device can reach the Internet.
description: |
The `online` property is `true` if the device can currently reach the Internet
using either WiFi, mobile network or LAN.
type: Boolean
permission: read-only
platforms: [android, iphone, ipad, mobileweb]
- name: remoteDeviceUUID
summary: |
Remote device UUID if the device is registered with the Apple Push Notification
Expand Down Expand Up @@ -400,6 +410,7 @@ name: PushNotificationConfig
summary: |
Simple object for specifying push notification options to
[registerForPushNotifications](Titanium.Network.registerForPushNotifications).
platforms: [iphone, ipad]
properties:
- name: types
summary: Array of `NOTIFICATION_TYPE` constants that the application would like to receive.
Expand All @@ -421,6 +432,7 @@ name: PushNotificationSuccessArg
summary: |
A simple object passed to the
[registerForPushNotifications](Titanium.Network.registerForPushNotifications) success callback.
platforms: [iphone, ipad]
properties:
- name: type
summary: The value of this string is always "remote".
Expand All @@ -434,6 +446,7 @@ name: PushNotificationErrorArg
summary: |
A simple object passed to the
[registerForPushNotifications](Titanium.Network.registerForPushNotifications) error callback.
platforms: [iphone, ipad]
properties:
- name: type
summary: The value of this string is always "remote".
Expand All @@ -445,6 +458,7 @@ properties:
---
name: PushNotificationData
summary: A simple object representing a push notification.
platforms: [iphone, ipad]
properties:
- name: data
summary: The `userinfo` dictionary passed to the Apple Push Notification Service.
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/Network/Socket/Socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Titanium.Network.Socket
summary: Socket module, used for creating sockets.
extends: Titanium.Module
since: "1.7"
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, blackberry]

properties:
- name: INITIALIZED
Expand Down
18 changes: 17 additions & 1 deletion apidoc/Titanium/Network/Socket/TCP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ description: |
Use the <Titanium.Network.Socket.createTCP> method to create a TCP socket.
extends: Titanium.IOStream
since: "1.7"
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, blackberry]
examples:
- title: Simple Socket IO using Stream.pump
example: |
Expand Down Expand Up @@ -168,33 +168,38 @@ properties:
- name: host
type: String
summary: The host to connect to or listen on.
platforms: [android, iphone, ipad, blackberry]
description: |
Can only be modified when this socket is in the [INITIALIZED](Titanium.Network.Socket.INITIALIZED) state.

Supports both IPv4 and IPv6 addresses.
- name: port
type: Number
summary: The port to connect to or listen on.
platforms: [android, iphone, ipad, blackberry]
description: |
Can only be modified when this socket is in the [INITIALIZED](Titanium.Network.Socket.INITIALIZED) state.

- name: listenQueueSize
type: Number
summary: Max number of pending incoming connections to be allowed when the socket is
in the [LISTENING](Titanium.Network.Socket.LISTENING) state.
platforms: [android, iphone, ipad]
description: |
Any incoming connections received while the max number of pending connections has
been reached will be rejected.

- name: timeout
type: Number
summary: Timeout, in milliseconds, for `connect` and all `write` operations.
platforms: [android, iphone, ipad]
description: |
Can only be modified when this socket is in the [INITIALIZED](Titanium.Network.Socket.INITIALIZED) state.

- name: connected
type: Callback<ConnectedCallbackArgs>
summary: Callback to be fired when the socket enters the "connected" state.
platforms: [android, iphone, ipad]
description: |
Only invoked following a successful [connect](Titanium.Network.Socket.TCP.connect)
call.
Expand All @@ -203,15 +208,18 @@ properties:
- name: error
type: Callback<ErrorCallbackArgs>
summary: Callback to be fired when the socket enters the [ERROR](Titanium.Network.Socket.ERROR) state.
platforms: [android, iphone, ipad]

- name: accepted
type: Callback<AcceptedCallbackArgs>
summary: Callback to be fired when a listener accepts a connection.
platforms: [android, iphone, ipad]

- name: state
type: Number
permission: read-only
summary: Current state of the socket.
platforms: [android, iphone, ipad]
description: |
One of: [INITIALIZED](Titanium.Network.Socket.INITIALIZED),
[CONNECTED](Titanium.Network.Socket.CONNECTED),
Expand All @@ -223,6 +231,7 @@ properties:
methods:
- name: connect
summary: Attempts to connect the socket to its host/port.
platforms: [android, iphone, ipad, blackberry]
description: |
Throws an exception if the socket is in a [CONNECTED](Titanium.Network.Socket.CONNECTED)
or [LISTENING](Titanium.Network.Socket.LISTENING) state.
Expand All @@ -232,6 +241,7 @@ methods:

- name: listen
summary: Attempts to start listening on the socket's host/port.
platforms: [android, iphone, ipad]
description: |
The `listen` call will attempt to listen on the specified host and/or port
property for the socket if they are set.
Expand All @@ -248,6 +258,7 @@ methods:

- name: accept
summary: Tells a [LISTENING](Titanium.Network.Socket.LISTENING) socket to accept a connection request at the top of a listener's request queue when one becomes available.
platforms: [android, iphone, ipad]
description: |
Nonblocking; if there are no connections in the queue, sets a flag so that
the socket accepts the next incoming connection immediately.
Expand Down Expand Up @@ -275,13 +286,15 @@ methods:

- name: close
summary: Closes a socket.
platforms: [android, iphone, ipad, blackberry]
description: |
Throws exception if the socket is not in a [CONNECTED](Titanium.Network.Socket.CONNECTED)
or [LISTENING](Titanium.Network.Socket.LISTENING) state. Blocking.

---
name: ConnectedCallbackArgs
summary: Argument object passed to the [connected](Titanium.Network.Socket.TCP.connected) callback when the socket connects.
platforms: [android, iphone, ipad]
description: |
Only invoked following a successful [connect](Titanium.Network.Socket.TCP.connect)
call.
Expand All @@ -296,6 +309,7 @@ properties:
name: ErrorCallbackArgs
summary: Object passed to the error callback when the socket enters
the [ERROR](Titanium.Network.Socket.ERROR) state.
platforms: [android, iphone, ipad]
since: "1.7"

properties:
Expand All @@ -316,6 +330,7 @@ name: AcceptedCallbackArgs
summary: |
Argument object passed to the [accepted](Titanium.Network.Socket.TCP.accepted)
callback when a listener accepts a connection.
platforms: [android, iphone, ipad]
since: "1.7"

properties:
Expand All @@ -333,6 +348,7 @@ properties:
---
name: AcceptDict
summary: Options object for the [accept](Titanium.Network.Socket.TCP.accept) method.
platforms: [android, iphone, ipad]
description: |
Simple object that defines properties to be set on the next accepted socket.
since: "1.7"
Expand Down
1 change: 1 addition & 0 deletions blackberry/tibb/NativeObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum NATIVE_TYPE
, N_TYPE_SLIDER
, N_TYPE_TAB
, N_TYPE_TABGROUP
, N_TYPE_TCPSOCKET
, N_TYPE_TEXT_FIELD
, N_TYPE_TOGGLEBUTTON
, N_TYPE_VIEW
Expand Down
5 changes: 5 additions & 0 deletions blackberry/tibb/NativeObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "NativeTabGroupObject.h"
#include "NativeSliderObject.h"
#include "NativeStringInterface.h"
#include "NativeTCPSocketObject.h"
#include "NativeTextFieldObject.h"
#include "NativeToggleButtonObject.h"
#include "TiCascadesApp.h"
Expand Down Expand Up @@ -118,6 +119,10 @@ NativeObject* NativeObjectFactory::createNativeObject(int type)
obj = NativeTabGroupObject::createTabGroup(this);
break;

case N_TYPE_TCPSOCKET:
obj = NativeTCPSocketObject::createTCPSocket();
break;

case N_TYPE_DATE_TIME_PICKER:
obj = NativeDateTimePickerObject::createDateTimePicker();
break;
Expand Down

0 comments on commit 9ddeaad

Please sign in to comment.