Package papyon :: Package event :: Module conversation

Source Code for Module papyon.event.conversation

  1  # -*- coding: utf-8 -*- 
  2  # 
  3  # Copyright (C) 2007  Ali Sabil <ali.sabil@gmail.com> 
  4  # Copyright (C) 2007  Johann Prieur <johann.prieur@gmail.com> 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 19  # 
 20   
 21  """Conversation event interfaces 
 22   
 23  The interfaces defined in this module allow receiving notification events 
 24  from a L{Conversation<papyon.conversation.ConversationInterface>} object.""" 
 25   
 26  from papyon.event import BaseEventInterface 
 27   
 28  __all__ = ["ConversationEventInterface", "ConversationErrorType", 
 29          "ContactInviteError", "MessageError"] 
 30   
 31   
32 -class ConversationErrorType(object):
33 """L{Client<papyon.Client>} error types 34 @see: L{ClientEventInterface.on_client_error}""" 35 36 NETWORK = 0 37 "Network related errors" 38 AUTHENTICATION = 1 39 "Authentication related errors" 40 PROTOCOL = 2 41 "Protocol related errors" 42 CONTACT_INVITE = 3 43 "Contact invitation related errors" 44 MESSAGE = 4 45 "Message sending related errors"
46 47
48 -class ContactInviteError(object):
49 "Contact invitation related errors" 50 UNKNOWN = 0 51 52 NOT_AVAILABLE = 1
53 54
55 -class MessageError(object):
56 "Message related errors" 57 UNKNOWN = 0 58 59 DELIVERY_FAILED = 1
60 61
62 -class ConversationEventInterface(BaseEventInterface):
63 """Interfaces allowing the user to get notified about events 64 from a L{Conversation<papyon.conversation.ConversationInterface>} object.""" 65
66 - def __init__(self, conversation):
67 """Initializer 68 @param conversation: the conversation we want to be notified for its events 69 @type conversation: L{Conversation<papyon.conversation.ConversationInterface>}""" 70 BaseEventInterface.__init__(self, conversation)
71
72 - def on_conversation_state_changed(self, state):
73 """@attention: not implemented""" 74 pass
75
76 - def on_conversation_error(self, type, error):
77 """Called when an error occurs in the L{Client<papyon.conversation>}. 78 79 @param type: the error type 80 @type type: L{ClientErrorType} 81 82 @param error: the error code 83 @type error: L{NetworkError} or L{AuthenticationError} or 84 L{ProtocolError} or L{ContactInviteError} or 85 L{MessageError}""" 86 pass
87
88 - def on_conversation_user_joined(self, contact):
89 """Called when an user joins the conversation. 90 @param contact: the contact whose presence changed 91 @type contact: L{Contact<papyon.profile.Contact>}""" 92 pass
93
94 - def on_conversation_user_left(self, contact):
95 """Called when an user leaved the conversation. 96 @param contact: the contact whose presence changed 97 @type contact: L{Contact<papyon.profile.Contact>}""" 98 pass
99
100 - def on_conversation_user_typing(self, contact):
101 """Called when an user is typing. 102 @param contact: the contact whose presence changed 103 @type contact: L{Contact<papyon.profile.Contact>}""" 104 pass
105
106 - def on_conversation_message_received(self, sender, message):
107 """Called when an user sends a message. 108 @param sender: the contact who sent the message 109 @type sender: L{Contact<papyon.profile.Contact>} 110 111 @param message: the message 112 @type message: L{ConversationMessage<papyon.conversation.ConversationMessage>}""" 113 pass
114
115 - def on_conversation_nudge_received(self, sender):
116 """Called when an user sends a nudge. 117 @param sender: the contact who sent the nudge 118 @type sender: L{Contact<papyon.profile.Contact>}""" 119 pass
120