~ubuntu-branches/ubuntu/hardy/pymsn/hardy-proposed

« back to all changes in this revision

Viewing changes to pymsn/service/OfflineIM/scenario/send_message.py

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville, Sjoerd Simons, Laurent Bigonville, Jonny Lamb
  • Date: 2008-01-17 18:23:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080117182314-lwymmpnk2ut3rvr1
Tags: 0.3.1-0ubuntu1
[ Sjoerd Simons ]
* debian/rules: remove dh_python, it's no longer needed

[ Laurent Bigonville ]
* New upstream release (0.3.1)
* debian/control:
  - Add myself as an Uploaders
  - Add python:Provides for binary package
  - Add python-ctypes and python-crypto to build-deps/deps
* debian/rules: remove binary-install rule
* Add watch file
* remove pycompat file, not needed anymore
* Modify Maintainer value to match the DebianMaintainerField
  specification.

[ Jonny Lamb ]
* Added python-adns to build-deps/deps.
* Added python-pyopenssl to build-deps/deps.
* Updated copyright.
* Upped Standards-Version to 3.7.3.
* Added "XS-Dm-Upload-Allowed: yes" under the request of Sjoerd Simons.
* Added myself to Uploaders.
* Added Homepage to control.
* Added Vcs-Bzr to control.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
#
 
19
from pymsn.service.OfflineIM.constants import *
 
20
from pymsn.service.OfflineIM.scenario.base import BaseScenario
 
21
from pymsn.msnp.challenge import _msn_challenge
 
22
 
 
23
__all__ = ['SendMessageScenario']
 
24
 
 
25
class SendMessageScenario(BaseScenario):
 
26
    def __init__(self, oim, client, recipient, message, callback, errback):
 
27
        """Accepts an invitation.
 
28
 
 
29
            @param oim: the oim service
 
30
            @param client: the client object sending the OIM
 
31
            @param recipient: the contact to send the OIM to
 
32
            @param message: the message to send
 
33
            @param callback: tuple(callable, *args)
 
34
            @param errback: tuple(callable, *args)
 
35
        """
 
36
        BaseScenario.__init__(self, callback, errback)
 
37
        self.__oim = oim
 
38
        self.__client = client
 
39
        self.__from = client.profile
 
40
        self.__to = recipient
 
41
        
 
42
        self.run_id = ""
 
43
        self.sequence_num = -1
 
44
 
 
45
        self.__msg = message
 
46
 
 
47
    def execute(self):
 
48
        self.__oim.Store2((self.__store2_callback,),
 
49
                          (self.__store2_errback,), 
 
50
                          self.__from.account,
 
51
                          self.__from.display_name,
 
52
                          self.__to.account,
 
53
                          self.run_id,
 
54
                          self.sequence_num,
 
55
                          "text",
 
56
                          self.__msg)
 
57
            
 
58
    def __store2_callback(self):
 
59
        callback = self._callback
 
60
        callback[0](*callback[1:])
 
61
 
 
62
    def __store2_errback(self, error_code,  auth_policy, lock_key_challenge):
 
63
        if error_code == OfflineMessagesBoxError.AUTHENTICATION_FAILED:
 
64
            if lock_key_challenge != None:
 
65
                self.__oim.set_lock_key(_msn_challenge(lock_key_challenge))
 
66
            if auth_policy != None:
 
67
                self._client._sso.DiscardSecurityTokens([LiveService.CONTACTS])
 
68
                self._client._sso.RequestMultipleSecurityTokens((self.execute, ), None, LiveService.CONTACTS)
 
69
                return
 
70
 
 
71
            self.execute()
 
72
            return
 
73
 
 
74
        errback = self._errback
 
75
        errback[0](error_code, *errback[1:])