~emesene-team/emesene/master

« back to all changes in this revision

Viewing changes to emesene/e3/dummy/Session.py

  • Committer: Riccardo (C10uD)
  • Date: 2012-07-01 16:54:34 UTC
  • Revision ID: git-v1:17ed298a3acb830f76aa2703351993cff749ed35
import2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import Worker
 
2
import e3
 
3
import extension
 
4
import gobject
 
5
 
 
6
class Session(e3.Session):
 
7
    '''a specialization of e3.Session'''
 
8
    NAME = 'Dummy session'
 
9
    DESCRIPTION = 'Session to test the client (no connection)'
 
10
    AUTHOR = 'Mariano Guerra'
 
11
    WEBSITE = 'www.emesene.org'
 
12
 
 
13
    SERVICES = {
 
14
        "dummy": {
 
15
            "host": "dummy.server.com",
 
16
            "port": "1337"
 
17
        }
 
18
    }
 
19
 
 
20
    CAPABILITIES = [e3.Session.SERVICE_CONTACT_INVITE,
 
21
                    e3.Session.SERVICE_PROFILE_PICTURE,
 
22
                    e3.Session.SERVICE_STATUS,
 
23
                    e3.Session.SERVICE_CONTACT_NICK,
 
24
                    e3.Session.SERVICE_CONTACT_PM,
 
25
                    e3.Session.SERVICE_ENDPOINTS]
 
26
 
 
27
    def __init__(self, id_=None, account=None):
 
28
        '''constructor'''
 
29
        e3.Session.__init__(self, id_, account)
 
30
 
 
31
    def login(self, account, password, status, proxy, host, port,
 
32
              use_http=False, use_ipv6=False):
 
33
        '''start the login process'''
 
34
        self.account = e3.Account(account, password, status, host)
 
35
        worker = Worker.Worker(self, proxy, use_http, use_ipv6)
 
36
        worker.start()
 
37
 
 
38
        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status))
 
39
 
 
40
    def send_message(self, cid, text, style=None, cedict=None, celist=None):
 
41
        '''send a common message'''
 
42
        if cedict is None:
 
43
            cedict = {}
 
44
 
 
45
        if celist is None:
 
46
            celist = []
 
47
 
 
48
        account = self.account.account
 
49
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account,
 
50
            style)
 
51
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))
 
52
 
 
53
    def send_typing_notification(self, cid):
 
54
        '''send typing notification to contact'''
 
55
        pass
 
56
 
 
57
    def request_attention(self, cid):
 
58
        '''request the attention of the contact'''
 
59
        account = self.account.account
 
60
        message = e3.Message(e3.Message.TYPE_NUDGE,
 
61
            '%s requests your attention' % (account, ), account)
 
62
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))
 
63
 
 
64
extension.implements(Session, 'session')