imip-agent

Change of imiptools/__init__.py

96:0eba4667b645
imiptools/__init__.py
     1.1 --- a/imiptools/__init__.py	Thu Oct 30 19:07:40 2014 +0100
     1.2 +++ b/imiptools/__init__.py	Thu Oct 30 19:08:19 2014 +0100
     1.3 @@ -33,7 +33,7 @@
     1.4          self.messenger = messenger or Messenger()
     1.5          self.lmtp_socket = None
     1.6  
     1.7 -    def process(self, f, original_recipients, recipients):
     1.8 +    def process(self, f, original_recipients, recipients, outgoing_only):
     1.9  
    1.10          """
    1.11          Process content from the stream 'f' accompanied by the given
    1.12 @@ -56,6 +56,12 @@
    1.13                  all_responses += handle_itip_part(part, senders, original_recipients, self.handlers, self.messenger)
    1.14                  handled = True
    1.15  
    1.16 +        # When processing outgoing messages, no replies or deliveries are
    1.17 +        # performed.
    1.18 +
    1.19 +        if outgoing_only:
    1.20 +            return
    1.21 +
    1.22          # Pack any returned parts into a single message.
    1.23  
    1.24          if all_responses:
    1.25 @@ -109,11 +115,17 @@
    1.26          recipients = []
    1.27          senders = []
    1.28          lmtp = []
    1.29 +        outgoing_only = False
    1.30  
    1.31          l = []
    1.32  
    1.33          for arg in args:
    1.34  
    1.35 +            # Detect outgoing processing mode.
    1.36 +
    1.37 +            if arg == "-O":
    1.38 +                outgoing_only = True
    1.39 +
    1.40              # Switch to collecting recipients.
    1.41  
    1.42              if arg == "-o":
    1.43 @@ -140,7 +152,7 @@
    1.44  
    1.45          self.messenger.sender = senders and senders[0] or self.messenger.sender
    1.46          self.lmtp_socket = lmtp and lmtp[0] or None
    1.47 -        self.process(stream, original_recipients, recipients)
    1.48 +        self.process(stream, original_recipients, recipients, outgoing_only)
    1.49  
    1.50      def __call__(self):
    1.51