6.11.1 GetInfo

GetInfo retrieves the value of a system attribute. It can be used in both synchronous and asynchronous mode.

The following are the examples for using GetInfo:

Synchronous

self.sysinfo_handle.call("GetInfo", {"Entity": u"General", 
                                     "Key": u"VibraActive", 
                                     "SystemData": {"Status": 1}})

Asynchronous

event_id = sysinfo_handle.call("GetInfo", {"Entity": u"Network", 
                                           "Key": u"LocationArea"}, 
                               callback=print_location_area)

where, print_location_area is user defined function.

The following table summarizes the specification of GetInfo:

Interface ISysinfo
Description Retrieves the value of a system attribute.
Response Model Synchronous and asynchronous
Pre-condition ISysInfo Interface is loaded.
Post-condition Returns an object on success.

Input Parameters

Input parameter specifies the Entity of system attribute information returned.

Table 6.205: Input parameters for GetInfo
Name Type Range Description
Entity unicode string For complete list of supported Entities, refer Key Values 6.11.4 section. Entity of system attribute. For example, Battery
Network and so on.
Key unicode string For complete list of supported Keys, refer Key Values 6.11.4 section. Key of system attribute. For example, BatteryStrenth
HomeNetwork and so on.
[SystemData] map DriveInfo
Drive: unicode string
This is an optional parameter from API definition point of view. For some system attributes, you need to specify input.

This map must contain one of the input data specifiers defined in System Data.

For more information on input specifier refer the section Key Values 6.11.4.


Output Parameters

Output parameter returns an object that contains the requested information. It also contains ErrorCode and an ErrorMessage, if the operation fails.

Table 6.206: Output parameters for GetInfo
Name Type Range Description
ErrorCode int NA Contains the SAPI specific error code when the operation fails.
ErrorMessage string NA Error Description in Engineering English.
ReturnValue map(System Data)
Entity: string
Key: string
For complete range of keys for the particular map, refer to System Data in Key Value section. Output map always contains Entity and Key. Rest of the elements in the map depends on requested system attribute (Entity-Key). It will be one of the data specifiers defined in System Data.

On requesting drive information using system attribute (for example: Memory, DriveInfo), ReturnValue map will contain Keys defined in DriveInfo Map.


Errors

The following table lists the error codes and their values:

Table 6.207: Error codes
Error code value Description
-304 General Error
1002 Bad argument type
1003 Missing argument
1004 Service not supported
1010 Entry exists
1012 Item not found


Error Messages

The following table lists the error messages and their description:

Table 6.208: Error messages
Error messages Description
SysInfo:GetInfo: Insufficient Arguments to process At least two input arguments are expected to process GetInfo service request.
SysInfo:GetInfo: Entity:Input Parameter Missing Indicates mandatory parameter Entity is missing in the service request.
SysInfo:GetInfo: Key:Input Parameter Missing Indicates mandatory parameter Key is missing in the service request.
SysInfo:GetInfo: Incorrect SystemData Type, SystemData Must be a Map Indicates that either the optional parameter SystemData specified is not a map or content of the map is inappropriate to process request.
SysInfo:GetInfo: CallBack and CmdOptions not matching Indicates that the situation where user specified callback and CmdOptions is set to Synchronous and vice-versa.


Example

The following sample code illustrates how to retrieve the current location area in synchronous mode:

import scriptext
import e32

# Using e32.Ao_lock() so that the main function can wait 
# till the callback is hit.
lock = e32.Ao_lock()

# Callback function will be called when the requested service is complete
def print_location_area(trans_id, event_id, input_params):
    if event_id != scriptext.EventCompleted:   
# Check the event status
        print "Error in retrieving required info"
        print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"])
        if "ErrorMessage" in input_params["ReturnValue"]:
            print "Error message is: " + input_params["ReturnValue"]["ErrorMessage"]
    else:
        print "Current Location Area is: " + input_params["ReturnValue"]["Status"]

    lock.signal()

# Load sysinfo service
sysinfo_handle = scriptext.load("Service.SysInfo", "ISysInfo")

# Make a request to query the required information
event_id = sysinfo_handle.call("GetInfo", {"Entity": u"Network", "Key": u"LocationArea"}, callback=print_location_area)

print "Waiting for the request to be processed!"
lock.wait()
print "Request complete!"

See About this document... for information on suggesting changes.