Package archipelcore :: Module archipelAvatarControllableEntity :: Class TNAvatarControllableEntity
[hide private]
[frames] | no frames]

Class TNAvatarControllableEntity

source code

object --+
         |
        TNAvatarControllableEntity

This class makes TNArchipelEntity avatar controllable. It allows to get and set avatars of the entity.

Instance Methods [hide private]
 
__init__(self, configuration, permission_center, xmppclient, log)
Initialize the TNAvatarControllableEntity.
source code
 
check_acp(conn, iq)
Function that verify if the ACP is valid.
source code
 
check_perm(self, conn, stanza, action_name, error_code=-1, prefix='')
Function that verify if the permissions are granted.
source code
 
set_vcard(self, params={})
Set the vcard of the entity.
source code
 
init_permissions(self)
Initialize the Avatar permissions.
source code
 
register_handlers(self)
Initialize the avatar handlers.
source code
 
unregister_handlers(self)
Unregister the handlers.
source code
 
get_available_avatars(self, supported_file_extensions=['png', 'jpg', 'jpeg', 'gif'])
Return a stanza with a list of availables avatars base64 encoded.
source code
 
set_avatar(self, name)
Change the current avatar of the entity.
source code
string @return base64 encoded file content
b64avatar_from_filename(self, image)
Create a base64 encoded avatar from filename.
source code
 
process_avatar_iq(self, conn, iq)
This method is invoked when a ARCHIPEL_NS_AVATAR IQ is received.
source code
 
iq_get_available_avatars(self, iq)
Return a list of availables avatars.
source code
 
iq_set_available_avatars(self, iq)
Set the current avatar of the virtual machine.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, configuration, permission_center, xmppclient, log)
(Constructor)

source code 

Initialize the TNAvatarControllableEntity.

Parameters:
  • configuration (configuration object) - the configuration
  • permission_center (TNPermissionCenter) - the permission center of the entity
  • xmppclient (xmpp.Dispatcher) - the entity xmpp client
  • log (TNArchipelLog) - the logger of the entity
Overrides: object.__init__

check_acp(conn, iq)

source code 

Function that verify if the ACP is valid.

Parameters:
  • conn (xmpp.Dispatcher) - the connection
  • iq (xmpp.Protocol.Iq) - the IQ to check
Raises:
  • Exception - Exception if not implemented

check_perm(self, conn, stanza, action_name, error_code=-1, prefix='')

source code 

Function that verify if the permissions are granted.

Parameters:
  • conn (xmpp.Dispatcher) - the connection
  • stanza (xmpp.Node) - the stanza containing the action
  • action_name (string) - the action to check
  • error_code (int) - the error code to return
  • prefix (string) - the prefix of the action
Raises:
  • Exception - Exception if not implemented

set_vcard(self, params={})

source code 

Set the vcard of the entity.

Parameters:
  • params (dict) - the parameters of the vCard
Raises:
  • Exception - Exception if not implemented

set_avatar(self, name)

source code 

Change the current avatar of the entity.

Parameters:
  • name (string) - the file name of avatar. base path is the configuration key "machine_avatar_directory"

b64avatar_from_filename(self, image)

source code 

Create a base64 encoded avatar from filename.

Parameters:
  • image (string) - relative file path of the image from conf token 'machine_avatar_directory'
Returns: string @return base64 encoded file content

process_avatar_iq(self, conn, iq)

source code 

This method is invoked when a ARCHIPEL_NS_AVATAR IQ is received. It understands IQ of type:

  • alloc
  • free
Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the stanza
  • iq (xmpp.Protocol.Iq) - the received IQ

iq_get_available_avatars(self, iq)

source code 

Return a list of availables avatars.

Parameters:
  • iq (xmpp.Protocol.Iq) - the IQ containing the request

iq_set_available_avatars(self, iq)

source code 

Set the current avatar of the virtual machine.

Parameters:
  • iq (xmpp.Protocol.Iq) - the IQ containing the request