Module Rmobio::ClientInfo
In: client_info.rb

Methods

Public Instance methods

checkClient

The method checks the client type, version and family by analyzing the request header.

HTTP_ACCEPT

  • If header contains application/pxml => ‘xf’ (xforms client)
  • If header contains wml or wap => ‘wap‘
  • If header contains applicaton/html => ‘html‘
  • Otherwise, default to html => ‘html‘
 If xf cient, the "POST" parameters are parsed to name/value pairs in params

HTTP_CLIENT_INFO_URL

  • If header exists => 0.8 client
  • If header doesn‘t exist => 0.6 client
 Samle of what HTTP_CLIENT_INFO_URL returns:
 http://homer.mobiolabs.com/hub/devicecap/devices/capability?id=0.6.28:Motorola:V3

HTTP_MOBIO_AGENT

  • If header contains WM5 => Window Mobile family

Return Codes

 The method returns the following instance varables:
 @client     => 'xf' or 'html' or 'wap'
 params[]   => array contains name/value pairs of all parameters from POST request
 @paramsdoc  => POST request in xml (parsed by hpricot)
 @xml => rxml transformer for the client type
 @client_version => '0.6' or '0.8'

getDeviceAttrValue(attribute, default)

To get the value for a device attribute

 This utility queries the device capability service to get the value for
 a particular device attribute.

Sample device url:

 http://homer.mobiolabs.com/hub/devicecap/devices/capability?id=0.6.28:Motorola:V3

Sample device attributes:

 <mob:Client>
  <mob:client-id>.0.6.28:Sony-Ericsson:Z800</mob:client-id>
  <mob:name>Sony-Ericsson/Z800</mob:name>
  <mob:height>220</mob:height>
  <mob:width>176</mob:width>
  <mob:bit-depth>0</mob:bit-depth>
  <mob:memory>1.5 MB</mob:memory>
  <mob:memory-heap>0</mob:memory-heap>
  <mob:memory-rms>0</mob:memory-rms>
 </mob:Client>

parameter

  • attribute => the device attribute string, ex: "width", "height"
  • default => default value if attribute is not available in the client_info_url

return

 Value of the attribute

get_device_info

For asset management

Sample device url:

 http://homer.mobiolabs.com/hub/devicecap/devices/capability?id=0.6.28:Motorola:V3

 All client attributes are stored in Hash plus "iconsize" which is "13" or "17"
 If device width is null or 0, it defaults to '176' for asset to work.

creates params[] array from xml in argument xml

[Validate]