Package archipelcore :: Module archipelEntity :: Class TNArchipelEntity
[hide private]
[frames] | no frames]

Class TNArchipelEntity

source code

object --+
         |
        TNArchipelEntity

This class represent a basic XMPP Client.

Instance Methods [hide private]
 
__init__(self, jid, password, configuration, name, auto_register=True, auto_reconnect=True)
The constructor of the class.
source code
 
initialize_modules(self, group)
This will initialize all plugins.
source code
object
get_plugin(self, identifier)
Return the plugin object with given identifier.
source code
string or none
check_acp(self, conn, iq)
Check if iq is a valid ACP and return action.
source code
 
init_vocabulary(self)
Initialize the vocabulary.
source code
 
init_permissions(self)
Initializes the permissions.
source code
 
check_perm(self, conn, stanza, action_name, error_code=-1, prefix='')
Check if given from of stanza has a given permission.
source code
Boolean
connect_xmpp(self)
Initialize the connection to the the XMPP server.
source code
 
auth_xmpp(self)
Authentify the client to the XMPP server.
source code
 
connect(self)
Connect and auth to XMPP Server.
source code
 
disconnect(self)
Close the connections from XMPP server.
source code
 
recover_pubsubs(self, origin, user_info, arguments)
Create or get the current hypervisor pubsub node.
source code
 
remove_pubsubs(self)
Delete own entity pubsubs.
source code
 
on_new_admin_account_publication(self, event)
Called when a new admin accounts as been added to the pubsub
source code
 
register_handlers(self)
This method have to be overloaded in order to register handler for XMPP events.
source code
 
unregister_handlers(self)
Unregister all XMPP handlers.
source code
 
process_presence(self, conn, presence)
Process presence stanzas.
source code
 
process_subscription_iq(self, conn, iq)
Process presence iq with namespace ARCHIPEL_NS_SUBSCRIPTION.
source code
 
iq_add_subscription(self, iq)
Add a JID in the entity roster.
source code
 
iq_remove_subscription(self, iq)
Remove a JID from the entity roster.
source code
 
change_presence(self, presence_show=None, presence_status=None, callback=None)
Change the presence of the entity.
source code
 
change_status(self, presence_status)
Change only the status of the entity.
source code
 
push_change(self, namespace, change, content_node=None)
Push a change using archipel push system.
source code
 
shout(self, subject, message)
Send a message to everybody in roster.
source code
 
add_jid(self, jid, groups=[])
Add a jid to the VM Roster and authorizes it.
source code
 
remove_jid(self, jid)
Remove a jid from roster and unauthorizes it.
source code
 
subscribe(self, jid)
Perform a subscription.
source code
 
unsubscribe(self, jid)
Perform a unsubscription.
source code
 
authorize(self, jid)
Authorize the given JID.
source code
 
unauthorize(self, jid)
Unauthorize the given JID.
source code
 
is_subscribed(self, jid)
Check if the JID is authorized or not.
source code
 
manage_vcard(self)
Retrieve vCard from server.
source code
 
did_receive_vcard(self, conn, vcard)
Callback of manage_vcard()
source code
 
set_vcard(self, params={})
Allows to define a vCard type for the entry.
source code
 
send_update_vcard(self, conn, presence, photo_hash=None)
This method is called by set_vcard_entity_type when the update of the vCard is OK.
source code
 
inband_registration(self)
Do a in-band registration if auth fail.
source code
 
inband_unregistration(self)
Do a in-band unregistration.
source code
 
process_inband_unregistration(self)
Perform the inband unregistration.
source code
 
process_message(self, conn, msg)
Handler for incoming message.
source code
 
add_message_registrar_item(self, item)
Register a method described in item.
source code
 
add_message_registrar_items(self, items)
Register an array of item see @add_message_registrar_item
source code
 
filter_message(self, msg)
This method filter archipel push messages and archipel service messages.
source code
 
build_reply(self, reply_stanza, msg)
Parse the registrar and execute commands if necessary.
source code
 
build_help(self, msg)
Build the help message according to the current registrar.
source code
 
process_permission_iq(self, conn, iq)
This method is invoked when a ARCHIPEL_NS_PERMISSIONS IQ is received.
source code
 
iq_set_permission(self, iq, onlyown)
Set a list of permissions.
source code
 
iq_get_permission(self, iq, onlyown)
Return the list of permissions of a user.
source code
 
iq_list_permission(self, iq)
Return the list of available permissions.
source code
 
loop(self)
This is the main loop of the client.
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, jid, password, configuration, name, auto_register=True, auto_reconnect=True)
(Constructor)

source code 

The constructor of the class.

Parameters:
  • jid (string) - the jid of the client.
  • password (string) - the password of the JID account.
  • configuration (Config object) - the configuration object
  • name (string) - the name of the entity
  • auto_register (Boolean) - if rTue, entity will try to create a XMPP account if needed
  • auto_reconnect (Boolean) - if True, entity will try to reconnect if disconnected
Overrides: object.__init__

initialize_modules(self, group)

source code 

This will initialize all plugins.

Parameters:
  • group (string) - the name of the entry point group to load

get_plugin(self, identifier)

source code 

Return the plugin object with given identifier.

Parameters:
  • identifier (string) - the identifier of the plugin
Returns: object
the requested plugin or None

check_acp(self, conn, iq)

source code 

Check if iq is a valid ACP and return action. If it's not valid, this will terminate the stanza processing and will return to the origin client a standard Archipel error IQ.

Parameters:
  • conn (xmpp connection) - the current current XMPP connection
  • iq (xmpp.Iq) - the iq to check
Returns: string or none
if the ACP is valid, it will return the requested action. otherwise it'll send ARCHIPEL_NS_ERROR_QUERY_NOT_WELL_FORMED iq to the sender and raise xmpp.protocol.NodeProcessed

init_permissions(self)

source code 

Initializes the permissions. Overrides this to add custom permissions.

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

source code 

Check if given from of stanza has a given permission.

Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the message
  • stanza (xmpp.Node) - the original stanza
  • action_name (string) - the name of action to check permission
  • error_code (int) - the return code of permission denied
  • prefix (string) - the prefix of action_name (for example if permission if health_get and action is get, you can give 'health_' as prefix)

connect_xmpp(self)

source code 

Initialize the connection to the the XMPP server. Exit on any error.

Returns: Boolean
True in case of success

recover_pubsubs(self, origin, user_info, arguments)

source code 

Create or get the current hypervisor pubsub node. Arguments here are used to be HOOK compliant see @register_hook

on_new_admin_account_publication(self, event)

source code 

Called when a new admin accounts as been added to the pubsub

Parameters:
  • event (xmpp.Node) - the pubsub event node

process_presence(self, conn, presence)

source code 

Process presence stanzas.

Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the message
  • presence (xmpp.Protocol.Iq) - the received IQ

process_subscription_iq(self, conn, iq)

source code 

Process presence iq with namespace ARCHIPEL_NS_SUBSCRIPTION. This allows to ask entity to subscribe to others users. it understands:

  • add
  • remove
Parameters:
  • conn (xmpp.Dispatcher) - the instance of the current connection that send the message
  • iq (xmpp.Protocol.Iq) - the received IQ

iq_add_subscription(self, iq)

source code 

Add a JID in the entity roster.

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

iq_remove_subscription(self, iq)

source code 

Remove a JID from the entity roster.

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

change_presence(self, presence_show=None, presence_status=None, callback=None)

source code 

Change the presence of the entity.

Parameters:
  • presence_show (string) - the value of the XMPP show
  • presence_status (string) - the value of the XMPP status

change_status(self, presence_status)

source code 

Change only the status of the entity.

Parameters:
  • presence_status (string) - the value of the XMPP status

push_change(self, namespace, change, content_node=None)

source code 

Push a change using archipel push system. This system will change with inclusion of pubsub.

Parameters:
  • namespace (string) - the namespace of the push. it will be prefixed with @ARCHIPEL_NS_IQ_PUSH
  • change (string) - the change value (can be anything, like 'newvm' in the context of the namespace)

shout(self, subject, message)

source code 

Send a message to everybody in roster.

Parameters:
  • subject (string) - the xmpp subject of the message
  • message (string) - the content of the message

add_jid(self, jid, groups=[])

source code 

Add a jid to the VM Roster and authorizes it.

Parameters:
  • jid (xmpp.JID) - this jid to add

remove_jid(self, jid)

source code 

Remove a jid from roster and unauthorizes it.

Parameters:
  • jid (xmpp.JID) - this jid to remove

subscribe(self, jid)

source code 

Perform a subscription. we do not user the xmpp.roster.Subscribe() because it doesn't support the name

Parameters:
  • jid (xmpp.JID) - this jid to remove

unsubscribe(self, jid)

source code 

Perform a unsubscription.

Parameters:
  • jid (xmpp.JID) - this jid to remove

authorize(self, jid)

source code 

Authorize the given JID.

Parameters:
  • jid (xmpp.JID) - this jid to remove

unauthorize(self, jid)

source code 

Unauthorize the given JID.

Parameters:
  • jid (xmpp.JID) - this jid to remove

is_subscribed(self, jid)

source code 

Check if the JID is authorized or not.

Parameters:
  • jid (string) - the jid to check in policy @rtype : boolean
Returns:
False if not subscribed or True if subscribed

set_vcard(self, params={})

source code 

Allows to define a vCard type for the entry. set the vcard of the entity

Parameters:
  • params (dict) - the parameters of the vCard

send_update_vcard(self, conn, presence, photo_hash=None)

source code 

This method is called by set_vcard_entity_type when the update of the vCard is OK. It will send the presence stanza to indicates the update of the vCard.

Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the message
  • presence (xmpp.Protocol.Iq) - the received IQ
  • photo_hash (string) - the SHA-1 hash of the photo that changes (optionnal)

process_inband_unregistration(self)

source code 

Perform the inband unregistration. The account will be removed from the server, and so, the loop will be interrupted.

process_message(self, conn, msg)

source code 

Handler for incoming message.

Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the message
  • msg (xmpp.Protocol.Message) - the received message

add_message_registrar_item(self, item)

source code 

Register a method described in item.
The item use the following form:
    {   "commands" :     ["command trigger 1", "command trigger 2"],
        "parameters":   [
                            {"name": "param1", "description": "the description of the first param"},
                            {"name": "param2", "description": "the description of the second param"}],
        "method":       self.a_method_to_launch,
        "permissions":   "the permissions in a array you need to process the command",
        "description":  "A general description of the command"}
The "method" key take any method with type (string)aMethod(raw_command_message). The return string
will be sent to the requester.
@type item: dictionnary
@param item: the dictionnary describing the registrar item

add_message_registrar_items(self, items)

source code 

Register an array of item see @add_message_registrar_item

Parameters:
  • items (array) - an array of messages_registrar items

filter_message(self, msg)

source code 

This method filter archipel push messages and archipel service messages.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message

build_reply(self, reply_stanza, msg)

source code 

Parse the registrar and execute commands if necessary.

Parameters:
  • reply_stanza (xmpp.Node) - the stanza to use to reply
  • msg (xmpp.Protocol.Message) - the received message

build_help(self, msg)

source code 

Build the help message according to the current registrar.

Parameters:
  • msg (xmpp.Protocol.Message) - the received message @return the string containing the help message

process_permission_iq(self, conn, iq)

source code 

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

  • get
  • getown
  • list
  • set
  • setown
Parameters:
  • conn (xmpp.Dispatcher) - ths instance of the current connection that send the stanza
  • iq (xmpp.Protocol.Iq) - the received IQ

iq_set_permission(self, iq, onlyown)

source code 

Set a list of permissions.

Parameters:
  • iq (xmpp.Node) - the original request IQ
  • onlyown (Boolean) - if True, will raise an exception if user trying to set permission for other user

iq_get_permission(self, iq, onlyown)

source code 

Return the list of permissions of a user.

Parameters:
  • iq (xmpp.Node) - the original request IQ
  • onlyown (Boolean) - if True, will raise an exception if user trying to set permission for other user

iq_list_permission(self, iq)

source code 

Return the list of available permissions.

Parameters:
  • iq (xmpp.Node) - the original request IQ