1
# -*- coding: utf-8 -*-
3
# Copyright (C) 2007-2008 Johann Prieur <johann.prieur@gmail.com>
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.
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.
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
19
from pymsn.service.AddressBook.scenario.base import BaseScenario
20
from pymsn.service.AddressBook.scenario.base import Scenario
21
from update_memberships import UpdateMembershipsScenario
23
from pymsn.profile import Membership
24
from pymsn.profile import NetworkID
26
__all__ = ['BlockContactScenario']
28
class BlockContactScenario(BaseScenario):
29
def __init__(self, sharing, callback, errback, account='',
30
network=NetworkID.MSN, membership=Membership.NONE,
34
@param sharing: the membership service
35
@param callback: tuple(callable, *args)
36
@param errback: tuple(callable, *args)
38
BaseScenario.__init__(self, Scenario.BLOCK_UNBLOCK, callback, errback)
39
self.__sharing = sharing
41
self.account = account
42
self.network = network
43
self.membership = membership
47
new_membership = self.membership & ~Membership.ALLOW | Membership.BLOCK
48
um = UpdateMembershipsScenario(self.__sharing,
50
(self.__update_memberships_errback,),
59
def __update_memberships_errback(self, error_code, done, failed):
60
errcode = AddressBookError.UNKNOWN
61
errback = self._errback[0]
62
args = self._errback[1:]
63
errback(errcode, *args)