summaryrefslogtreecommitdiffstats
path: root/fportbkpevendata.py
blob: cfaa39bb95d2cc6d7be044da38e4034dffb031d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#/***************************************************************************
#                             fportbkpevendata.h
#                             -----------
#    begin                : sam nov 2 2002
#    copyright            : (C) 1992-2004 by Fabian Padilla
#    email                : fp@bridgethink.com
# ***************************************************************************/

# /***************************************************************************
#  *                                                                         *
#  *   This program is free software; you can redistribute it and/or modify  *
#  *   it under the terms of the Foundation Public License as published by   *
#  *   bridgethink sarl; either version 2 of the License, or                 *
#  *   (at your option) any later version.                                   *
#  *                                                                         *
#  ***************************************************************************/

#
#  from C++ to python by Jeremy Zurcher <jeremy@asynk.ch>
#

"""/** Inherited from Fport to add a listHash.

  function : secure the use of evenData send to evenPrg or evebDoor.

  description : work as Fport.

  *@author Fabian Padilla
  */"""

__all__ = ["FportBkpEvenData"]

from fport import Fport
from evenjastrings import ACT_ERROR

class FportBkpEvenData(Fport):
    """This class is a wrapper arounf Fport class for security purpose"""

    def __init__(self):
        Fport.__init__(self)    # force constructor
        self.evenDataA = None    #/** Backup of the evenDatas that need to be sends by sendEvenData */

    def __str__(self):
        return "\t"+Fport.__str__(self)+\
                "FportBkpEvenData - evenDataA : "+str(self.evenDataA)+"\n"

    def justDoIt(self,evenData):
        """/** Methods called by Fstarter */"""
        self.evenDataA = evenData
        ret = Fport.justDoIt(self,evenData)
        if self.evenDataA:
            self.evenDataA.definePortAction(ACT_ERROR)
            self.sendEvenData(self.evenDataA)
        return ret

    def sendEvenData(self,evenData,portDestination = None):
        """/** Methods to enable all ports to sends evenDatas to a port */"""
        if (self.evenDataA == evenData):
            self.evenDataA = None
        Fport.sendEvenData(self,evenData,portDestination)

    def sendEvenDataSys(self,evenData,portDestination = None):
        """/** Methods to enable all ports to sends evenDatas to a port */"""
        if (self.evenDataA == evenData):
            self.evenDataA = None
        Fport.sendEvenDataSys(self,evenData,portDestination)