[piwi] r579 committed - added swiftmailer as mailing component to piwi

37 views
Skip to first unread message

pi...@googlecode.com

unread,
Nov 19, 2010, 8:23:06 AM11/19/10
to piwi...@googlegroups.com
Revision: 579
Author: grobmeier
Date: Fri Nov 19 05:21:09 2010
Log: added swiftmailer as mailing component to piwi
http://code.google.com/p/piwi/source/detail?r=579

Added:
/framework/trunk/piwi/lib/swiftmailer
/framework/trunk/piwi/lib/swiftmailer/README
/framework/trunk/piwi/lib/swiftmailer/classes
/framework/trunk/piwi/lib/swiftmailer/classes/Swift
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Attachment.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/ArrayByteStream.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/FileByteStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/GenericFixedWidthReader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/UsAsciiReader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/Utf8Reader.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReaderFactory

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReaderFactory.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream/ArrayCharacterStream.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream/NgCharacterStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/DependencyContainer.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/DependencyException.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/EmbeddedFile.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/Base64Encoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/QpEncoder.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/Rfc2231Encoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoding.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/CommandEvent.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/CommandListener.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/Event.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventDispatcher.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventListener.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventObject.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/ResponseEvent.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/ResponseListener.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SendEvent.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SendListener.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportChangeEvent.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportChangeListener.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportExceptionListener.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/FailoverTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/FileStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Filterable.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Image.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/InputByteStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/IoException.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache/ArrayKeyCache.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache/DiskKeyCache.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache/KeyCacheInputStream.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache/NullKeyCache.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/KeyCache.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/LoadBalancedTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/MailTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mailer

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mailer/ArrayRecipientIterator.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mailer/RecipientIterator.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mailer.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Message.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Attachment.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/CharsetObserver.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ContentEncoder

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ContentEncoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/EmbeddedFile.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/EncodingObserver.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Header.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderEncoder

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderEncoder.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderFactory.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/HeaderSet.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/AbstractHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/DateHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/IdentificationHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/ParameterizedHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/PathHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Headers/UnstructuredHeader.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/Message.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/MimeEntity.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/MimePart.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/ParameterizedHeader.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/SimpleHeaderFactory.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/SimpleHeaderSet.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/SimpleMessage.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/MimePart.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/OutputByteStream.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Decorator

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Decorator/Replacements.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Logger.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Loggers

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Loggers/ArrayLogger.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Loggers/EchoLogger.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Pop

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Pop/Pop3Connection.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Reporter.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Reporters

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Sleeper.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Plugins/Timer.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Preferences.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ReplacementFilterFactory.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/RfcComplianceException.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/SendmailTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/SmtpTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/StreamFilter.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/StreamFilters

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/StreamFilters/StringReplacementFilter.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/StreamFilters/StringReplacementFilterFactory.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/SwiftException.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/Auth

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/AuthHandler.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/Esmtp/Authenticator.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/EsmtpHandler.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/EsmtpTransport.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/FailoverTransport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/IoBuffer.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/LoadBalancedTransport.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/MailInvoker.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/MailTransport.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/SendmailTransport.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/SimpleMailInvoker.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/SmtpAgent.php

/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport/StreamBuffer.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Transport.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/TransportException.php
/framework/trunk/piwi/lib/swiftmailer/classes/Swift.php
/framework/trunk/piwi/lib/swiftmailer/dependency_maps
/framework/trunk/piwi/lib/swiftmailer/dependency_maps/cache_deps.php
/framework/trunk/piwi/lib/swiftmailer/dependency_maps/mime_deps.php
/framework/trunk/piwi/lib/swiftmailer/dependency_maps/transport_deps.php
/framework/trunk/piwi/lib/swiftmailer/mime_types.php
/framework/trunk/piwi/lib/swiftmailer/preferences.php
/framework/trunk/piwi/lib/swiftmailer/swift_init.php
/framework/trunk/piwi/lib/swiftmailer/swift_required.php
/framework/trunk/piwi/lib/swiftmailer/swift_required_pear.php
Modified:
/framework/trunk/piwi/index.php

=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/README Fri Nov 19 05:21:09 2010
@@ -0,0 +1,1 @@
+Swift 4.0.6
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Attachment.php Fri
Nov 19 05:21:09 2010
@@ -0,0 +1,75 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Mime/Attachment.php';
+//@require 'Swift/ByteStream/FileByteStream.php';
+//@require 'Swift/DependencyContainer.php';
+
+/**
+ * Attachment class for attaching files to a {@link Swift_Mime_Message}.
+ * @package Swift
+ * @subpackage Mime
+ * @author Chris Corbyn
+ */
+class Swift_Attachment extends Swift_Mime_Attachment
+{
+
+ /**
+ * Create a new Attachment.
+ * Details may be optionally provided to the constructor.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ */
+ public function __construct($data = null, $filename = null,
+ $contentType = null)
+ {
+ call_user_func_array(
+ array($this, 'Swift_Mime_Attachment::__construct'),
+ Swift_DependencyContainer::getInstance()
+ ->createDependenciesFor('mime.attachment')
+ );
+
+ $this->setBody($data);
+ $this->setFilename($filename);
+ if ($contentType)
+ {
+ $this->setContentType($contentType);
+ }
+ }
+
+ /**
+ * Create a new Attachment.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ * @return Swift_Mime_Attachment
+ */
+ public static function newInstance($data = null, $filename = null,
+ $contentType = null)
+ {
+ return new self($data, $filename, $contentType);
+ }
+
+ /**
+ * Create a new Attachment from a filesystem path.
+ * @param string $path
+ * @param string $contentType optional
+ * @return Swift_Mime_Attachment
+ */
+ public static function fromPath($path, $contentType = null)
+ {
+ return self::newInstance()->setFile(
+ new Swift_ByteStream_FileByteStream($path),
+ $contentType
+ );
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,178 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/InputByteStream.php';
+//@require 'Swift/Filterable.php';
+//@require 'Swift/StreamFilter.php';
+
+/**
+ * Provides the base functionality for an InputStream supporting filters.
+ * @package Swift
+ * @subpackage ByteStream
+ * @author Chris Corbyn
+ */
+abstract class Swift_ByteStream_AbstractFilterableInputStream
+ implements Swift_InputByteStream, Swift_Filterable
+{
+
+ /** Write sequence */
+ private $_sequence = 0;
+
+ /** StreamFilters */
+ private $_filters = array();
+
+ /** A buffer for writing */
+ private $_writeBuffer = '';
+
+ /** Bound streams */
+ private $_mirrors = array();
+
+ /**
+ * Commit the given bytes to the storage medium immediately.
+ * @param string $bytes
+ * @access protected
+ */
+ abstract protected function _commit($bytes);
+
+ /**
+ * Flush any buffers/content with immediate effect.
+ * @access protected
+ */
+ abstract protected function _flush();
+
+ /**
+ * Add a StreamFilter to this InputByteStream.
+ * @param Swift_StreamFilter $filter
+ * @param string $key
+ */
+ public function addFilter(Swift_StreamFilter $filter, $key)
+ {
+ $this->_filters[$key] = $filter;
+ }
+
+ /**
+ * Remove an already present StreamFilter based on its $key.
+ * @param string $key
+ */
+ public function removeFilter($key)
+ {
+ unset($this->_filters[$key]);
+ }
+
+ /**
+ * Writes $bytes to the end of the stream.
+ * @param string $bytes
+ * @throws Swift_IoException
+ */
+ public function write($bytes)
+ {
+ $this->_writeBuffer .= $bytes;
+ foreach ($this->_filters as $filter)
+ {
+ if ($filter->shouldBuffer($this->_writeBuffer))
+ {
+ return;
+ }
+ }
+ $this->_doWrite($this->_writeBuffer);
+ return ++$this->_sequence;
+ }
+
+ /**
+ * For any bytes that are currently buffered inside the stream, force
them
+ * off the buffer.
+ *
+ * @throws Swift_IoException
+ */
+ public function commit()
+ {
+ $this->_doWrite($this->_writeBuffer);
+ }
+
+ /**
+ * Attach $is to this stream.
+ * The stream acts as an observer, receiving all data that is written.
+ * All {@link write()} and {@link flushBuffers()} operations will be
mirrored.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function bind(Swift_InputByteStream $is)
+ {
+ $this->_mirrors[] = $is;
+ }
+
+ /**
+ * Remove an already bound stream.
+ * If $is is not bound, no errors will be raised.
+ * If the stream currently has any buffered data it will be written to
$is
+ * before unbinding occurs.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function unbind(Swift_InputByteStream $is)
+ {
+ foreach ($this->_mirrors as $k => $stream)
+ {
+ if ($is === $stream)
+ {
+ if ($this->_writeBuffer !== '')
+ {
+ $stream->write($this->_filter($this->_writeBuffer));
+ }
+ unset($this->_mirrors[$k]);
+ }
+ }
+ }
+
+ /**
+ * Flush the contents of the stream (empty it) and set the internal
pointer
+ * to the beginning.
+ * @throws Swift_IoException
+ */
+ public function flushBuffers()
+ {
+ if ($this->_writeBuffer !== '')
+ {
+ $this->_doWrite($this->_writeBuffer);
+ }
+ $this->_flush();
+
+ foreach ($this->_mirrors as $stream)
+ {
+ $stream->flushBuffers();
+ }
+ }
+
+ // -- Private methods
+
+ /** Run $bytes through all filters */
+ private function _filter($bytes)
+ {
+ foreach ($this->_filters as $filter)
+ {
+ $bytes = $filter->filter($bytes);
+ }
+ return $bytes;
+ }
+
+ /** Just write the bytes to the stream */
+ private function _doWrite($bytes)
+ {
+ $this->_commit($this->_filter($bytes));
+
+ foreach ($this->_mirrors as $stream)
+ {
+ $stream->write($bytes);
+ }
+
+ $this->_writeBuffer = '';
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/ArrayByteStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,190 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/InputByteStream.php';
+//@require 'Swift/OutputByteStream.php';
+
+/**
+ * Allows reading and writing of bytes to and from an array.
+ * @package Swift
+ * @subpackage ByteStream
+ * @author Chris Corbyn
+ */
+class Swift_ByteStream_ArrayByteStream
+ implements Swift_InputByteStream, Swift_OutputByteStream
+{
+
+ /**
+ * The internal stack of bytes.
+ * @var string[]
+ * @access private
+ */
+ private $_array = array();
+
+ /**
+ * The size of the stack
+ * @var int
+ * @access private
+ */
+ private $_arraySize = 0;
+
+ /**
+ * The internal pointer offset.
+ * @var int
+ * @access private
+ */
+ private $_offset = 0;
+
+ /** Bound streams */
+ private $_mirrors = array();
+
+ /**
+ * Create a new ArrayByteStream.
+ * If $stack is given the stream will be populated with the bytes it
contains.
+ * @param mixed $stack of bytes in string or array form, optional
+ */
+ public function __construct($stack = null)
+ {
+ if (is_array($stack))
+ {
+ $this->_array = $stack;
+ $this->_arraySize = count($stack);
+ }
+ elseif (is_string($stack))
+ {
+ $this->write($stack);
+ }
+ else
+ {
+ $this->_array = array();
+ }
+ }
+
+ /**
+ * Reads $length bytes from the stream into a string and moves the
pointer
+ * through the stream by $length. If less bytes exist than are requested
the
+ * remaining bytes are given instead. If no bytes are remaining at all,
boolean
+ * false is returned.
+ * @param int $length
+ * @return string
+ */
+ public function read($length)
+ {
+ if ($this->_offset == $this->_arraySize)
+ {
+ return false;
+ }
+
+ // Don't use array slice
+ $end = $length + $this->_offset;
+ $end = $this->_arraySize<$end
+ ?$this->_arraySize
+ :$end;
+ $ret = '';
+ for (; $this->_offset < $end; ++$this->_offset)
+ {
+ $ret .= $this->_array[$this->_offset];
+ }
+ return $ret;
+ }
+
+ /**
+ * Writes $bytes to the end of the stream.
+ * @param string $bytes
+ */
+ public function write($bytes)
+ {
+ $to_add = str_split($bytes);
+ foreach ($to_add as $value)
+ {
+ $this->_array[] = $value;
+ }
+ $this->_arraySize = count($this->_array);
+
+ foreach ($this->_mirrors as $stream)
+ {
+ $stream->write($bytes);
+ }
+ }
+
+ /**
+ * Not used.
+ */
+ public function commit()
+ {
+ }
+
+ /**
+ * Attach $is to this stream.
+ * The stream acts as an observer, receiving all data that is written.
+ * All {@link write()} and {@link flushBuffers()} operations will be
mirrored.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function bind(Swift_InputByteStream $is)
+ {
+ $this->_mirrors[] = $is;
+ }
+
+ /**
+ * Remove an already bound stream.
+ * If $is is not bound, no errors will be raised.
+ * If the stream currently has any buffered data it will be written to
$is
+ * before unbinding occurs.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function unbind(Swift_InputByteStream $is)
+ {
+ foreach ($this->_mirrors as $k => $stream)
+ {
+ if ($is === $stream)
+ {
+ unset($this->_mirrors[$k]);
+ }
+ }
+ }
+
+ /**
+ * Move the internal read pointer to $byteOffset in the stream.
+ * @param int $byteOffset
+ * @return boolean
+ */
+ public function setReadPointer($byteOffset)
+ {
+ if ($byteOffset > $this->_arraySize)
+ {
+ $byteOffset = $this->_arraySize;
+ }
+ elseif ($byteOffset < 0)
+ {
+ $byteOffset = 0;
+ }
+
+ $this->_offset = $byteOffset;
+ }
+
+ /**
+ * Flush the contents of the stream (empty it) and set the internal
pointer
+ * to the beginning.
+ */
+ public function flushBuffers()
+ {
+ $this->_offset = 0;
+ $this->_array = array();
+ $this->_arraySize = 0;
+
+ foreach ($this->_mirrors as $stream)
+ {
+ $stream->flushBuffers();
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/ByteStream/FileByteStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,177 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/ByteStream/AbstractFilterableInputStream.php';
+//@require 'Swift/InputByteStream.php';
+//@require 'Swift/FileStream.php';
+//@require 'Swift/IoException.php';
+
+/**
+ * Allows reading and writing of bytes to and from a file.
+ * @package Swift
+ * @subpackage ByteStream
+ * @author Chris Corbyn
+ */
+class Swift_ByteStream_FileByteStream
+ extends Swift_ByteStream_AbstractFilterableInputStream
+ implements Swift_FileStream
+{
+
+ /** The internal pointer offset */
+ private $_offset = 0;
+
+ /** The path to the file */
+ private $_path;
+
+ /** The mode this file is opened in for writing */
+ private $_mode;
+
+ /** A lazy-loaded resource handle for reading the file */
+ private $_reader;
+
+ /** A lazy-loaded resource handle for writing the file */
+ private $_writer;
+
+ /** If magic_quotes_runtime is on, this will be true */
+ private $_quotes = false;
+
+ /**
+ * Create a new FileByteStream for $path.
+ * @param string $path
+ * @param string $writable if true
+ */
+ public function __construct($path, $writable = false)
+ {
+ $this->_path = $path;
+ $this->_mode = $writable ? 'w+b' : 'rb';
+ $this->_quotes = get_magic_quotes_runtime();
+ }
+
+ /**
+ * Get the complete path to the file.
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->_path;
+ }
+
+ /**
+ * Reads $length bytes from the stream into a string and moves the
pointer
+ * through the stream by $length. If less bytes exist than are requested
the
+ * remaining bytes are given instead. If no bytes are remaining at all,
boolean
+ * false is returned.
+ * @param int $length
+ * @return string
+ * @throws Swift_IoException
+ */
+ public function read($length)
+ {
+ $fp = $this->_getReadHandle();
+ if (!feof($fp))
+ {
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(0);
+ }
+ $bytes = fread($fp, $length);
+ if ($this->_quotes)
+ {
+ set_magic_quotes_runtime(1);
+ }
+ $this->_offset = ftell($fp);
+ return $bytes;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Move the internal read pointer to $byteOffset in the stream.
+ * @param int $byteOffset
+ * @return boolean
+ */
+ public function setReadPointer($byteOffset)
+ {
+ if (isset($this->_reader))
+ {
+ fseek($this->_reader, $byteOffset, SEEK_SET);
+ }
+ $this->_offset = $byteOffset;
+ }
+
+ // -- Private methods
+
+ /** Just write the bytes to the file */
+ protected function _commit($bytes)
+ {
+ fwrite($this->_getWriteHandle(), $bytes);
+ $this->_resetReadHandle();
+ }
+
+ /** Not used */
+ protected function _flush()
+ {
+ }
+
+ /** Get the resource for reading */
+ private function _getReadHandle()
+ {
+ if (!isset($this->_reader))
+ {
+ if (!$this->_reader = fopen($this->_path, 'rb'))
+ {
+ throw new Swift_IoException(
+ 'Unable to open file for reading [' . $this->_path . ']'
+ );
+ }
+ fseek($this->_reader, $this->_offset, SEEK_SET);
+ }
+ return $this->_reader;
+ }
+
+ /** Get the resource for writing */
+ private function _getWriteHandle()
+ {
+ if (!isset($this->_writer))
+ {
+ if (!$this->_writer = fopen($this->_path, $this->_mode))
+ {
+ throw new Swift_IoException(
+ 'Unable to open file for writing [' . $this->_path . ']'
+ );
+ }
+ }
+ return $this->_writer;
+ }
+
+ /** Force a reload of the resource for writing */
+ private function _resetWriteHandle()
+ {
+ if (isset($this->_writer))
+ {
+ fclose($this->_writer);
+ $this->_writer = null;
+ }
+ }
+
+ /** Force a reload of the resource for reading */
+ private function _resetReadHandle()
+ {
+ if (isset($this->_reader))
+ {
+ fclose($this->_reader);
+ $this->_reader = null;
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/GenericFixedWidthReader.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,96 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterReader.php';
+
+/**
+ * Provides fixed-width byte sizes for reading fixed-width character sets.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ * @author Xavier De Cock <xde...@gmail.com>
+ */
+class Swift_CharacterReader_GenericFixedWidthReader
+ implements Swift_CharacterReader
+{
+
+ /**
+ * The number of bytes in a single character.
+ * @var int
+ * @access private
+ */
+ private $_width;
+
+ /**
+ * Creates a new GenericFixedWidthReader using $width bytes per
character.
+ * @param int $width
+ */
+ public function __construct($width)
+ {
+ $this->_width = $width;
+ }
+
+ /**
+ * Returns the complete charactermap
+ *
+ * @param string $string
+ * @param int $startOffset
+ * @param array $currentMap
+ * @param mixed $ignoredChars
+ * @return $int
+ */
+ public function getCharPositions($string, $startOffset, &$currentMap,
&$ignoredChars)
+ {
+ $strlen = strlen($string);
+ // % and / are CPU intensive, so, maybe find a better way
+ $ignored = $strlen%$this->_width;
+ $ignoredChars = substr($string, - $ignored);
+ $currentMap = $this->_width;
+ return ($strlen - $ignored)/$this->_width;
+
+ }
+
+ /**
+ * Returns mapType
+ * @int mapType
+ */
+ public function getMapType()
+ {
+ return self::MAP_TYPE_FIXED_LEN;
+ }
+
+ /**
+ * Returns an integer which specifies how many more bytes to read.
+ * A positive integer indicates the number of more bytes to fetch before
invoking
+ * this method again.
+ * A value of zero means this is already a valid character.
+ * A value of -1 means this cannot possibly be a valid character.
+ * @param string $bytes
+ * @return int
+ */
+ public function validateByteSequence($bytes, $size)
+ {
+ $needed = $this->_width - $size;
+ return ($needed > -1)
+ ? $needed
+ : -1
+ ;
+ }
+
+ /**
+ * Returns the number of bytes which should be read to start each
character.
+ * @return int
+ */
+ public function getInitialByteSize()
+ {
+ return $this->_width;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/UsAsciiReader.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,83 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterReader.php';
+
+/**
+ * Analyzes US-ASCII characters.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_CharacterReader_UsAsciiReader
+ implements Swift_CharacterReader
+{
+ /**
+ * Returns the complete charactermap
+ *
+ * @param string $string
+ * @param int $startOffset
+ * @param string $ignoredChars
+ */
+ public function getCharPositions($string, $startOffset, &$currentMap,
&$ignoredChars)
+ {
+ $strlen=strlen($string);
+ $ignoredChars='';
+ for( $i = 0; $i < $strlen; ++$i)
+ {
+ if ($string[$i]>"\x07F")
+ { // Invalid char
+ $currentMap[$i+$startOffset]=$string[$i];
+ }
+ }
+ return $strlen;
+ }
+
+ /**
+ * Returns mapType
+ * @int mapType
+ */
+ public function getMapType()
+ {
+ return self::MAP_TYPE_INVALID;
+ }
+
+ /**
+ * Returns an integer which specifies how many more bytes to read.
+ * A positive integer indicates the number of more bytes to fetch before
invoking
+ * this method again.
+ * A value of zero means this is already a valid character.
+ * A value of -1 means this cannot possibly be a valid character.
+ * @param string $bytes
+ * @return int
+ */
+ public function validateByteSequence($bytes, $size)
+ {
+ $byte = reset($bytes);
+ if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F)
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * Returns the number of bytes which should be read to start each
character.
+ * @return int
+ */
+ public function getInitialByteSize()
+ {
+ return 1;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader/Utf8Reader.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,183 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterReader.php';
+
+/**
+ * Analyzes UTF-8 characters.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ * @author Xavier De Cock <xde...@gmail.com>
+ */
+class Swift_CharacterReader_Utf8Reader
+ implements Swift_CharacterReader
+{
+
+ /** Pre-computed for optimization */
+ private static $length_map=array(
+//N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x0N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x1N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x2N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x3N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x4N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x5N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x6N
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //0x7N
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0x8N
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0x9N
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0xAN
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0xBN
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, //0xCN
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, //0xDN
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, //0xEN
+ 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0 //0xFN
+ );
+ private static $s_length_map=array(
+ "\x00"=>1, "\x01"=>1, "\x02"=>1, "\x03"=>1, "\x04"=>1, "\x05"=>1, "\x06"=>1, "\x07"=>1,
+ "\x08"=>1, "\x09"=>1, "\x0a"=>1, "\x0b"=>1, "\x0c"=>1, "\x0d"=>1, "\x0e"=>1, "\x0f"=>1,
+ "\x10"=>1, "\x11"=>1, "\x12"=>1, "\x13"=>1, "\x14"=>1, "\x15"=>1, "\x16"=>1, "\x17"=>1,
+ "\x18"=>1, "\x19"=>1, "\x1a"=>1, "\x1b"=>1, "\x1c"=>1, "\x1d"=>1, "\x1e"=>1, "\x1f"=>1,
+ "\x20"=>1, "\x21"=>1, "\x22"=>1, "\x23"=>1, "\x24"=>1, "\x25"=>1, "\x26"=>1, "\x27"=>1,
+ "\x28"=>1, "\x29"=>1, "\x2a"=>1, "\x2b"=>1, "\x2c"=>1, "\x2d"=>1, "\x2e"=>1, "\x2f"=>1,
+ "\x30"=>1, "\x31"=>1, "\x32"=>1, "\x33"=>1, "\x34"=>1, "\x35"=>1, "\x36"=>1, "\x37"=>1,
+ "\x38"=>1, "\x39"=>1, "\x3a"=>1, "\x3b"=>1, "\x3c"=>1, "\x3d"=>1, "\x3e"=>1, "\x3f"=>1,
+ "\x40"=>1, "\x41"=>1, "\x42"=>1, "\x43"=>1, "\x44"=>1, "\x45"=>1, "\x46"=>1, "\x47"=>1,
+ "\x48"=>1, "\x49"=>1, "\x4a"=>1, "\x4b"=>1, "\x4c"=>1, "\x4d"=>1, "\x4e"=>1, "\x4f"=>1,
+ "\x50"=>1, "\x51"=>1, "\x52"=>1, "\x53"=>1, "\x54"=>1, "\x55"=>1, "\x56"=>1, "\x57"=>1,
+ "\x58"=>1, "\x59"=>1, "\x5a"=>1, "\x5b"=>1, "\x5c"=>1, "\x5d"=>1, "\x5e"=>1, "\x5f"=>1,
+ "\x60"=>1, "\x61"=>1, "\x62"=>1, "\x63"=>1, "\x64"=>1, "\x65"=>1, "\x66"=>1, "\x67"=>1,
+ "\x68"=>1, "\x69"=>1, "\x6a"=>1, "\x6b"=>1, "\x6c"=>1, "\x6d"=>1, "\x6e"=>1, "\x6f"=>1,
+ "\x70"=>1, "\x71"=>1, "\x72"=>1, "\x73"=>1, "\x74"=>1, "\x75"=>1, "\x76"=>1, "\x77"=>1,
+ "\x78"=>1, "\x79"=>1, "\x7a"=>1, "\x7b"=>1, "\x7c"=>1, "\x7d"=>1, "\x7e"=>1, "\x7f"=>1,
+ "\x80"=>0, "\x81"=>0, "\x82"=>0, "\x83"=>0, "\x84"=>0, "\x85"=>0, "\x86"=>0, "\x87"=>0,
+ "\x88"=>0, "\x89"=>0, "\x8a"=>0, "\x8b"=>0, "\x8c"=>0, "\x8d"=>0, "\x8e"=>0, "\x8f"=>0,
+ "\x90"=>0, "\x91"=>0, "\x92"=>0, "\x93"=>0, "\x94"=>0, "\x95"=>0, "\x96"=>0, "\x97"=>0,
+ "\x98"=>0, "\x99"=>0, "\x9a"=>0, "\x9b"=>0, "\x9c"=>0, "\x9d"=>0, "\x9e"=>0, "\x9f"=>0,
+ "\xa0"=>0, "\xa1"=>0, "\xa2"=>0, "\xa3"=>0, "\xa4"=>0, "\xa5"=>0, "\xa6"=>0, "\xa7"=>0,
+ "\xa8"=>0, "\xa9"=>0, "\xaa"=>0, "\xab"=>0, "\xac"=>0, "\xad"=>0, "\xae"=>0, "\xaf"=>0,
+ "\xb0"=>0, "\xb1"=>0, "\xb2"=>0, "\xb3"=>0, "\xb4"=>0, "\xb5"=>0, "\xb6"=>0, "\xb7"=>0,
+ "\xb8"=>0, "\xb9"=>0, "\xba"=>0, "\xbb"=>0, "\xbc"=>0, "\xbd"=>0, "\xbe"=>0, "\xbf"=>0,
+ "\xc0"=>2, "\xc1"=>2, "\xc2"=>2, "\xc3"=>2, "\xc4"=>2, "\xc5"=>2, "\xc6"=>2, "\xc7"=>2,
+ "\xc8"=>2, "\xc9"=>2, "\xca"=>2, "\xcb"=>2, "\xcc"=>2, "\xcd"=>2, "\xce"=>2, "\xcf"=>2,
+ "\xd0"=>2, "\xd1"=>2, "\xd2"=>2, "\xd3"=>2, "\xd4"=>2, "\xd5"=>2, "\xd6"=>2, "\xd7"=>2,
+ "\xd8"=>2, "\xd9"=>2, "\xda"=>2, "\xdb"=>2, "\xdc"=>2, "\xdd"=>2, "\xde"=>2, "\xdf"=>2,
+ "\xe0"=>3, "\xe1"=>3, "\xe2"=>3, "\xe3"=>3, "\xe4"=>3, "\xe5"=>3, "\xe6"=>3, "\xe7"=>3,
+ "\xe8"=>3, "\xe9"=>3, "\xea"=>3, "\xeb"=>3, "\xec"=>3, "\xed"=>3, "\xee"=>3, "\xef"=>3,
+ "\xf0"=>4, "\xf1"=>4, "\xf2"=>4, "\xf3"=>4, "\xf4"=>4, "\xf5"=>4, "\xf6"=>4, "\xf7"=>4,
+ "\xf8"=>5, "\xf9"=>5, "\xfa"=>5, "\xfb"=>5, "\xfc"=>6, "\xfd"=>6, "\xfe"=>0, "\xff"=>0,
+ );
+
+ /**
+ * Returns the complete charactermap
+ *
+ * @param string $string
+ * @param int $startOffset
+ * @param array $currentMap
+ * @param mixed $ignoredChars
+ */
+ public function getCharPositions($string, $startOffset, &$currentMap,
&$ignoredChars)
+ {
+ if (!isset($currentMap['i']) || !isset($currentMap['p']))
+ {
+ $currentMap['p'] = $currentMap['i'] = array();
+ }
+ $strlen=strlen($string);
+ $charPos=count($currentMap['p']);
+ $foundChars=0;
+ $invalid=false;
+ for ($i=0; $i<$strlen; ++$i)
+ {
+ $char=$string[$i];
+ $size=self::$s_length_map[$char];
+ if ($size==0)
+ {
+ /* char is invalid, we must wait for a resync */
+ $invalid=true;
+ continue;
+ }
+ else
+ {
+ if ($invalid==true)
+ {
+ /* We mark the chars as invalid and start a new char */
+ $currentMap['p'][$charPos+$foundChars]=$startOffset+$i;
+ $currentMap['i'][$charPos+$foundChars]=true;
+ ++$foundChars;
+ $invalid=false;
+ }
+ if (($i+$size) > $strlen){
+ $ignoredChars=substr($string, $i);
+ break;
+ }
+ for ($j=1; $j<$size; ++$j)
+ {
+ $char=$string[$i+$j];
+ if ($char>"\x7F" && $char<"\xC0")
+ {
+ // Valid - continue parsing
+ }
+ else
+ {
+ /* char is invalid, we must wait for a resync */
+ $invalid=true;
+ continue 2;
+ }
+ }
+ /* Ok we got a complete char here */
+
$lastChar=$currentMap['p'][$charPos+$foundChars]=$startOffset+$i+$size;
+ $i+=$j-1;
+ ++$foundChars;
+ }
+ }
+ return $foundChars;
+ }
+
+ /**
+ * Returns mapType
+ * @int mapType
+ */
+ public function getMapType()
+ {
+ return self::MAP_TYPE_POSITIONS;
+ }
+
+ /**
+ * Returns an integer which specifies how many more bytes to read.
+ * A positive integer indicates the number of more bytes to fetch before
invoking
+ * this method again.
+ * A value of zero means this is already a valid character.
+ * A value of -1 means this cannot possibly be a valid character.
+ * @param string $bytes
+ * @return int
+ */
+ public function validateByteSequence($bytes, $size)
+ {
+ if ($size<1){
+ return -1;
+ }
+ $needed = self::$length_map[$bytes[0]] - $size;
+ return ($needed > -1)
+ ? $needed
+ : -1
+ ;
+ }
+
+ /**
+ * Returns the number of bytes which should be read to start each
character.
+ * @return int
+ */
+ public function getInitialByteSize()
+ {
+ return 1;
+ }
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReader.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,60 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Analyzes characters for a specific character set.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ * @author Xavier De Cock <xde...@gmail.com>
+ */
+interface Swift_CharacterReader
+{
+ const MAP_TYPE_INVALID = 0x01;
+ const MAP_TYPE_FIXED_LEN = 0x02;
+ const MAP_TYPE_POSITIONS = 0x03;
+
+ /**
+ * Returns the complete charactermap
+ *
+ * @param string $string
+ * @param int $startOffset
+ * @param array $currentMap
+ * @param mixed $ignoredChars
+ * @return int
+ */
+ public function getCharPositions($string, $startOffset, &$currentMap,
&$ignoredChars);
+
+ /**
+ * Returns mapType
+ * @int mapType
+ */
+ public function getMapType();
+
+ /**
+ * Returns an integer which specifies how many more bytes to read.
+ * A positive integer indicates the number of more bytes to fetch before
invoking
+ * this method again.
+ * A value of zero means this is already a valid character.
+ * A value of -1 means this cannot possibly be a valid character.
+ * @param int[] $bytes
+ * @return int
+ */
+ public function validateByteSequence($bytes, $size);
+
+ /**
+ * Returns the number of bytes which should be read to start each
character.
+ * For fixed width character sets this should be the number of
+ * octets-per-character. For multibyte character sets this will probably
be 1.
+ * @return int
+ */
+ public function getInitialByteSize();
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,119 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterReaderFactory.php';
+
+/**
+ * Standard factory for creating CharacterReaders.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory
+ implements Swift_CharacterReaderFactory
+{
+
+ /**
+ * A map of charset patterns to their implementation classes.
+ * @var array
+ * @access private
+ */
+ private $_map = array();
+
+ /**
+ * Factories which have already been loaded.
+ * @var Swift_CharacterReaderFactory[]
+ * @access private
+ */
+ private $_loaded = array();
+
+ /**
+ * Creates a new CharacterReaderFactory.
+ */
+ public function __construct()
+ {
+ $prefix = 'Swift_CharacterReader_';
+
+ $singleByte = array(
+ 'class' => $prefix . 'GenericFixedWidthReader',
+ 'constructor' => array(1)
+ );
+
+ $doubleByte = array(
+ 'class' => $prefix . 'GenericFixedWidthReader',
+ 'constructor' => array(2)
+ );
+
+ $fourBytes = array(
+ 'class' => $prefix . 'GenericFixedWidthReader',
+ 'constructor' => array(4)
+ );
+
+ //Utf-8
+ $this->_map['utf-?8'] = array(
+ 'class' => $prefix . 'Utf8Reader',
+ 'constructor' => array()
+ );
+
+ //7-8 bit charsets
+ $this->_map['(us-)?ascii'] = $singleByte;
+ $this->_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte;
+ $this->_map['windows-?125[0-9]'] = $singleByte;
+ $this->_map['cp-?[0-9]+'] = $singleByte;
+ $this->_map['ansi'] = $singleByte;
+ $this->_map['macintosh'] = $singleByte;
+ $this->_map['koi-?7'] = $singleByte;
+ $this->_map['koi-?8-?.+'] = $singleByte;
+ $this->_map['mik'] = $singleByte;
+ $this->_map['(cork|t1)'] = $singleByte;
+ $this->_map['v?iscii'] = $singleByte;
+
+ //16 bits
+ $this->_map['(ucs-?2|utf-?16)'] = $doubleByte;
+
+ //32 bits
+ $this->_map['(ucs-?4|utf-?32)'] = $fourBytes;
+
+ //Fallback
+ $this->_map['.*'] = $singleByte;
+ }
+
+ /**
+ * Returns a CharacterReader suitable for the charset applied.
+ * @param string $charset
+ * @return Swift_CharacterReader
+ */
+ public function getReaderFor($charset)
+ {
+ $charset = trim(strtolower($charset));
+ foreach ($this->_map as $pattern => $spec)
+ {
+ $re = '/^' . $pattern . '$/D';
+ if (preg_match($re, $charset))
+ {
+ if (!array_key_exists($pattern, $this->_loaded))
+ {
+ $reflector = new ReflectionClass($spec['class']);
+ if ($reflector->getConstructor())
+ {
+ $reader = $reflector->newInstanceArgs($spec['constructor']);
+ }
+ else
+ {
+ $reader = $reflector->newInstance();
+ }
+ $this->_loaded[$pattern] = $reader;
+ }
+ return $this->_loaded[$pattern];
+ }
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterReaderFactory.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterReader.php';
+
+/**
+ * A factory for creating CharacterReaders.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+interface Swift_CharacterReaderFactory
+{
+
+ /**
+ * Returns a CharacterReader suitable for the charset applied.
+ * @param string $charset
+ * @return Swift_CharacterReader
+ */
+ public function getReaderFor($charset);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream/ArrayCharacterStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,319 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/CharacterStream.php';
+//@require 'Swift/OutputByteStream.php';
+
+
+/**
+ * A CharacterStream implementation which stores characters in an internal
array.
+ * @package Swift
+ * @subpackage CharacterStream
+ * @author Chris Corbyn
+ */
+class Swift_CharacterStream_ArrayCharacterStream
+ implements Swift_CharacterStream
+{
+
+ /** A map of byte values and their respective characters */
+ private static $_charMap;
+
+ /** A map of characters and their derivative byte values */
+ private static $_byteMap;
+
+ /** The char reader (lazy-loaded) for the current charset */
+ private $_charReader;
+
+ /** A factory for creatiing CharacterReader instances */
+ private $_charReaderFactory;
+
+ /** The character set this stream is using */
+ private $_charset;
+
+ /** Array of characters */
+ private $_array = array();
+
+ /** Size of the array of character */
+ private $_array_size = array();
+
+ /** The current character offset in the stream */
+ private $_offset = 0;
+
+ /**
+ * Create a new CharacterStream with the given $chars, if set.
+ * @param Swift_CharacterReaderFactory $factory for loading validators
+ * @param string $charset used in the stream
+ */
+ public function __construct(Swift_CharacterReaderFactory $factory,
+ $charset)
+ {
+ self::_initializeMaps();
+ $this->setCharacterReaderFactory($factory);
+ $this->setCharacterSet($charset);
+ }
+
+ /**
+ * Set the character set used in this CharacterStream.
+ * @param string $charset
+ */
+ public function setCharacterSet($charset)
+ {
+ $this->_charset = $charset;
+ $this->_charReader = null;
+ }
+
+ /**
+ * Set the CharacterReaderFactory for multi charset support.
+ * @param Swift_CharacterReaderFactory $factory
+ */
+ public function setCharacterReaderFactory(
+ Swift_CharacterReaderFactory $factory)
+ {
+ $this->_charReaderFactory = $factory;
+ }
+
+ /**
+ * Overwrite this character stream using the byte sequence in the byte
stream.
+ * @param Swift_OutputByteStream $os output stream to read from
+ */
+ public function importByteStream(Swift_OutputByteStream $os)
+ {
+ if (!isset($this->_charReader))
+ {
+ $this->_charReader = $this->_charReaderFactory
+ ->getReaderFor($this->_charset);
+ }
+
+ $startLength = $this->_charReader->getInitialByteSize();
+ while (false !== $bytes = $os->read($startLength))
+ {
+ $c = array();
+ for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
+ {
+ $c[] = self::$_byteMap[$bytes[$i]];
+ }
+ $size = count($c);
+ $need = $this->_charReader
+ ->validateByteSequence($c, $size);
+ if ($need > 0 &&
+ false !== $bytes = $os->read($need))
+ {
+ for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
+ {
+ $c[] = self::$_byteMap[$bytes[$i]];
+ }
+ }
+ $this->_array[] = $c;
+ ++$this->_array_size;
+ }
+ }
+
+ /**
+ * Import a string a bytes into this CharacterStream, overwriting any
existing
+ * data in the stream.
+ * @param string $string
+ */
+ public function importString($string)
+ {
+ $this->flushContents();
+ $this->write($string);
+ }
+
+ /**
+ * Read $length characters from the stream and move the internal pointer
+ * $length further into the stream.
+ * @param int $length
+ * @return string
+ */
+ public function read($length)
+ {
+ if ($this->_offset == $this->_array_size)
+ {
+ return false;
+ }
+
+ // Don't use array slice
+ $arrays = array();
+ $end = $length + $this->_offset;
+ for ($i = $this->_offset; $i < $end; ++$i)
+ {
+ if (!isset($this->_array[$i]))
+ {
+ break;
+ }
+ $arrays[] = $this->_array[$i];
+ }
+ $this->_offset += $i - $this->_offset; // Limit function calls
+ $chars = false;
+ foreach ($arrays as $array)
+ {
+ $chars .= implode('', array_map('chr', $array));
+ }
+ return $chars;
+ }
+
+ /**
+ * Read $length characters from the stream and return a 1-dimensional
array
+ * containing there octet values.
+ * @param int $length
+ * @return int[]
+ */
+ public function readBytes($length)
+ {
+ if ($this->_offset == $this->_array_size)
+ {
+ return false;
+ }
+ $arrays = array();
+ $end = $length + $this->_offset;
+ for ($i = $this->_offset; $i < $end; ++$i)
+ {
+ if (!isset($this->_array[$i]))
+ {
+ break;
+ }
+ $arrays[] = $this->_array[$i];
+ }
+ $this->_offset += ($i - $this->_offset); // Limit function calls
+ return call_user_func_array('array_merge', $arrays);
+ }
+
+ /**
+ * Write $chars to the end of the stream.
+ * @param string $chars
+ */
+ public function write($chars)
+ {
+ if (!isset($this->_charReader))
+ {
+ $this->_charReader = $this->_charReaderFactory->getReaderFor(
+ $this->_charset);
+ }
+
+ $startLength = $this->_charReader->getInitialByteSize();
+
+ $fp = fopen('php://memory', 'w+b');
+ fwrite($fp, $chars);
+ unset($chars);
+ fseek($fp, 0, SEEK_SET);
+
+ $buffer = array(0);
+ $buf_pos = 1;
+ $buf_len = 1;
+ $has_datas = true;
+ do
+ {
+ $bytes = array();
+ // Buffer Filing
+ if ($buf_len - $buf_pos < $startLength)
+ {
+ $buf = array_splice($buffer, $buf_pos);
+ $new = $this->_reloadBuffer($fp, 100);
+ if ($new)
+ {
+ $buffer = array_merge($buf, $new);
+ $buf_len = count($buffer);
+ $buf_pos = 0;
+ }
+ else
+ {
+ $has_datas = false;
+ }
+ }
+ if ($buf_len - $buf_pos > 0)
+ {
+ $size = 0;
+ for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i)
+ {
+ ++$size;
+ $bytes[] = $buffer[$buf_pos++];
+ }
+ $need = $this->_charReader->validateByteSequence(
+ $bytes, $size);
+ if ($need > 0)
+ {
+ if ($buf_len - $buf_pos < $need)
+ {
+ $new = $this->_reloadBuffer($fp, $need);
+
+ if ($new)
+ {
+ $buffer = array_merge($buffer, $new);
+ $buf_len = count($buffer);
+ }
+ }
+ for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i)
+ {
+ $bytes[] = $buffer[$buf_pos++];
+ }
+ }
+ $this->_array[] = $bytes;
+ ++$this->_array_size;
+ }
+ }
+ while ($has_datas);
+
+ fclose($fp);
+ }
+
+ /**
+ * Move the internal pointer to $charOffset in the stream.
+ * @param int $charOffset
+ */
+ public function setPointer($charOffset)
+ {
+ if ($charOffset > $this->_array_size)
+ {
+ $charOffset = $this->_array_size;
+ }
+ elseif ($charOffset < 0)
+ {
+ $charOffset = 0;
+ }
+ $this->_offset = $charOffset;
+ }
+
+ /**
+ * Empty the stream and reset the internal pointer.
+ */
+ public function flushContents()
+ {
+ $this->_offset = 0;
+ $this->_array = array();
+ $this->_array_size = 0;
+ }
+
+ private function _reloadBuffer($fp, $len)
+ {
+ if (!feof($fp) && ($bytes = fread($fp, $len)) !== false)
+ {
+ $buf = array();
+ for ($i = 0, $len = strlen($bytes); $i < $len; ++$i)
+ {
+ $buf[] = self::$_byteMap[$bytes[$i]];
+ }
+ return $buf;
+ }
+ return false;
+ }
+
+ private static function _initializeMaps()
+ {
+ if (!isset(self::$_charMap))
+ {
+ self::$_charMap = array();
+ for ($byte = 0; $byte < 256; ++$byte)
+ {
+ self::$_charMap[$byte] = chr($byte);
+ }
+ self::$_byteMap = array_flip(self::$_charMap);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream/NgCharacterStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,300 @@
+<?php
+
+/*
+ CharacterStream implementation using an array in Swift Mailer.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+
+//@require 'Swift/CharacterStream.php';
+//@require 'Swift/OutputByteStream.php';
+
+
+/**
+ * A CharacterStream implementation which stores characters in an internal
array.
+ * @package Swift
+ * @subpackage CharacterStream
+ * @author Xavier De Cock <xde...@gmail.com>
+ */
+
+Class Swift_CharacterStream_NgCharacterStream
+ implements Swift_CharacterStream
+{
+
+ /**
+ * The char reader (lazy-loaded) for the current charset.
+ * @var Swift_CharacterReader
+ * @access private
+ */
+ private $_charReader;
+
+ /**
+ * A factory for creatiing CharacterReader instances.
+ * @var Swift_CharacterReaderFactory
+ * @access private
+ */
+ private $_charReaderFactory;
+
+ /**
+ * The character set this stream is using.
+ * @var string
+ * @access private
+ */
+ private $_charset;
+
+ /**
+ * The datas stored as is
+ *
+ * @var string
+ */
+ private $_datas = "";
+
+ /**
+ * Number of bytes in the stream
+ *
+ * @var int
+ */
+ private $_datasSize = 0;
+
+ /**
+ * Map
+ *
+ * @var mixed
+ */
+ private $_map;
+
+ /**
+ * Map Type
+ *
+ * @var int
+ */
+ private $_mapType = 0;
+
+ /**
+ * Number of characters in the stream
+ *
+ * @var int
+ */
+ private $_charCount = 0;
+
+ /**
+ * Position in the stream
+ *
+ * @var unknown_type
+ */
+ private $_currentPos = 0;
+
+ /**
+ * The constructor
+ *
+ * @param Swift_CharacterReaderFactory $factory
+ * @param unknown_type $charset
+ */
+ public function __construct(Swift_CharacterReaderFactory $factory,
+ $charset)
+ {
+ $this->setCharacterReaderFactory($factory);
+ $this->setCharacterSet($charset);
+ }
+
+ /* -- Changing parameters of the stream -- */
+
+ /**
+ * Set the character set used in this CharacterStream.
+ * @param string $charset
+ */
+ public function setCharacterSet($charset)
+ {
+ $this->_charset = $charset;
+ $this->_charReader = null;
+ $this->_mapType = 0;
+ }
+
+ /**
+ * Set the CharacterReaderFactory for multi charset support.
+ * @param Swift_CharacterReaderFactory $factory
+ */
+ public function setCharacterReaderFactory(
+ Swift_CharacterReaderFactory $factory)
+ {
+ $this->_charReaderFactory = $factory;
+ }
+
+ /**
+ * @see Swift_CharacterStream::flushContents()
+ *
+ */
+ public function flushContents()
+ {
+ $this->_datas = null;
+ $this->_map = null;
+ $this->_charCount = 0;
+ $this->_currentPos = 0;
+ $this->_datasSize = 0;
+ }
+
+ /**
+ * @see Swift_CharacterStream::importByteStream()
+ *
+ * @param Swift_OutputByteStream $os
+ */
+ public function importByteStream(Swift_OutputByteStream $os)
+ {
+ $this->flushContents();
+ $blocks=512;
+ $os->setReadPointer(0);
+ while(false!==($read = $os->read($blocks)))
+ $this->write($read);
+ }
+
+ /**
+ * @see Swift_CharacterStream::importString()
+ *
+ * @param string $string
+ */
+ public function importString($string)
+ {
+ $this->flushContents();
+ $this->write($string);
+ }
+
+ /**
+ * @see Swift_CharacterStream::read()
+ *
+ * @param int $length
+ * @return string
+ */
+ public function read($length)
+ {
+ if ($this->_currentPos>=$this->_charCount)
+ {
+ return false;
+ }
+ $ret=false;
+ $length = ($this->_currentPos+$length > $this->_charCount)
+ ? $this->_charCount - $this->_currentPos
+ : $length;
+ switch ($this->_mapType)
+ {
+ case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
+ $len = $length*$this->_map;
+ $ret = substr($this->_datas,
+ $this->_currentPos * $this->_map,
+ $len);
+ $this->_currentPos += $length;
+ break;
+
+ case Swift_CharacterReader::MAP_TYPE_INVALID:
+ $end = $this->_currentPos + $length;
+ $end = $end > $this->_charCount
+ ?$this->_charCount
+ :$end;
+ $ret = '';
+ for (; $this->_currentPos < $length; ++$this->_currentPos)
+ {
+ if (isset ($this->_map[$this->_currentPos]))
+ {
+ $ret .= '?';
+ }
+ else
+ {
+ $ret .= $this->_datas[$this->_currentPos];
+ }
+ }
+ break;
+
+ case Swift_CharacterReader::MAP_TYPE_POSITIONS:
+ $end = $this->_currentPos + $length;
+ $end = $end > $this->_charCount
+ ?$this->_charCount
+ :$end;
+ $ret = '';
+ $start = 0;
+ if ($this->_currentPos>0)
+ {
+ $start = $this->_map['p'][$this->_currentPos-1];
+ }
+ $to = $start;
+ for (; $this->_currentPos < $end; ++$this->_currentPos)
+ {
+ if (isset($this->_map['i'][$this->_currentPos])) {
+ $ret .= substr($this->_datas, $start, $to - $start).'?';
+ $start = $this->_map['p'][$this->_currentPos];
+ } else {
+ $to = $this->_map['p'][$this->_currentPos];
+ }
+ }
+ $ret .= substr($this->_datas, $start, $to - $start);
+ break;
+ }
+ return $ret;
+ }
+
+ /**
+ * @see Swift_CharacterStream::readBytes()
+ *
+ * @param int $length
+ * @return int[]
+ */
+ public function readBytes($length)
+ {
+ $read=$this->read($length);
+ if ($read!==false)
+ {
+ $ret = array_map('ord', str_split($read, 1));
+ return $ret;
+ }
+ return false;
+ }
+
+ /**
+ * @see Swift_CharacterStream::setPointer()
+ *
+ * @param int $charOffset
+ */
+ public function setPointer($charOffset)
+ {
+ if ($this->_charCount<$charOffset){
+ $charOffset=$this->_charCount;
+ }
+ $this->_currentPos = $charOffset;
+ }
+
+ /**
+ * @see Swift_CharacterStream::write()
+ *
+ * @param string $chars
+ */
+ public function write($chars)
+ {
+ if (!isset($this->_charReader))
+ {
+ $this->_charReader = $this->_charReaderFactory->getReaderFor(
+ $this->_charset);
+ $this->_map = array();
+ $this->_mapType = $this->_charReader->getMapType();
+ }
+ $ignored='';
+ $this->_datas .= $chars;
+ $this->_charCount +=
$this->_charReader->getCharPositions(substr($this->_datas,
$this->_datasSize), $this->_datasSize, $this->_map, $ignored);
+ if ($ignored!==false) {
+ $this->_datasSize=strlen($this->_datas)-strlen($ignored);
+ }
+ else
+ {
+ $this->_datasSize=strlen($this->_datas);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/CharacterStream.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,86 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once dirname(__FILE__) . '/OutputByteStream.php';
+require_once dirname(__FILE__) . '/CharacterReaderFactory.php';
+
+
+/**
+ * An abstract means of reading and writing data in terms of characters as
opposed
+ * to bytes.
+ * Classes implementing this interface may use a subsystem which requires
less
+ * memory than working with large strings of data.
+ * @package Swift
+ * @subpackage CharacterStream
+ * @author Chris Corbyn
+ */
+interface Swift_CharacterStream
+{
+
+ /**
+ * Set the character set used in this CharacterStream.
+ * @param string $charset
+ */
+ public function setCharacterSet($charset);
+
+ /**
+ * Set the CharacterReaderFactory for multi charset support.
+ * @param Swift_CharacterReaderFactory $factory
+ */
+ public function setCharacterReaderFactory(
+ Swift_CharacterReaderFactory $factory);
+
+ /**
+ * Overwrite this character stream using the byte sequence in the byte
stream.
+ * @param Swift_OutputByteStream $os output stream to read from
+ */
+ public function importByteStream(Swift_OutputByteStream $os);
+
+ /**
+ * Import a string a bytes into this CharacterStream, overwriting any
existing
+ * data in the stream.
+ * @param string $string
+ */
+ public function importString($string);
+
+ /**
+ * Read $length characters from the stream and move the internal pointer
+ * $length further into the stream.
+ * @param int $length
+ * @return string
+ */
+ public function read($length);
+
+ /**
+ * Read $length characters from the stream and return a 1-dimensional
array
+ * containing there octet values.
+ * @param int $length
+ * @return int[]
+ */
+ public function readBytes($length);
+
+ /**
+ * Write $chars to the end of the stream.
+ * @param string $chars
+ */
+ public function write($chars);
+
+ /**
+ * Move the internal pointer to $charOffset in the stream.
+ * @param int $charOffset
+ */
+ public function setPointer($charOffset);
+
+ /**
+ * Empty the stream and reset the internal pointer.
+ */
+ public function flushContents();
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/DependencyContainer.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,349 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/DependencyException.php';
+
+/**
+ * Dependency Injection container.
+ * @package Swift
+ * @author Chris Corbyn
+ */
+class Swift_DependencyContainer
+{
+
+ /** Constant for literal value types */
+ const TYPE_VALUE = 0x0001;
+
+ /** Constant for new instance types */
+ const TYPE_INSTANCE = 0x0010;
+
+ /** Constant for shared instance types */
+ const TYPE_SHARED = 0x0100;
+
+ /** Constant for aliases */
+ const TYPE_ALIAS = 0x1000;
+
+ /** Singleton instance */
+ private static $_instance = null;
+
+ /** The data container */
+ private $_store = array();
+
+ /** The current endpoint in the data container */
+ private $_endPoint;
+
+ /**
+ * Constructor should not be used.
+ * Use {@link getInstance()} instead.
+ */
+ public function __construct() { }
+
+ /**
+ * Returns a singleton of the DependencyContainer.
+ * @return Swift_DependencyContainer
+ */
+ public static function getInstance()
+ {
+ if (!isset(self::$_instance))
+ {
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * List the names of all items stored in the Container.
+ * @return array
+ */
+ public function listItems()
+ {
+ return array_keys($this->_store);
+ }
+
+ /**
+ * Test if an item is registered in this container with the given name.
+ * @param string $itemName
+ * @return boolean
+ * @see register()
+ */
+ public function has($itemName)
+ {
+ return array_key_exists($itemName, $this->_store)
+ && isset($this->_store[$itemName]['lookupType']);
+ }
+
+ /**
+ * Lookup the item with the given $itemName.
+ * @param string $itemName
+ * @return mixed
+ * @throws Swift_DependencyException If the dependency is not found
+ * @see register()
+ */
+ public function lookup($itemName)
+ {
+ if (!$this->has($itemName))
+ {
+ throw new Swift_DependencyException(
+ 'Cannot lookup dependency "' . $itemName . '" since it is not
registered.'
+ );
+ }
+
+ switch ($this->_store[$itemName]['lookupType'])
+ {
+ case self::TYPE_ALIAS:
+ return $this->_createAlias($itemName);
+ case self::TYPE_VALUE:
+ return $this->_getValue($itemName);
+ case self::TYPE_INSTANCE:
+ return $this->_createNewInstance($itemName);
+ case self::TYPE_SHARED:
+ return $this->_createSharedInstance($itemName);
+ }
+ }
+
+ /**
+ * Create an array of arguments passed to the constructor of $itemName.
+ * @param string $itemName
+ * @return array
+ */
+ public function createDependenciesFor($itemName)
+ {
+ $args = array();
+ if (isset($this->_store[$itemName]['args']))
+ {
+ $args = $this->_resolveArgs($this->_store[$itemName]['args']);
+ }
+ return $args;
+ }
+
+ /**
+ * Register a new dependency with $itemName.
+ * This method returns the current DependencyContainer instance because
it
+ * requires the use of the fluid interface to set the specific details
for the
+ * dependency.
+ *
+ * @param string $itemName
+ * @return Swift_DependencyContainer
+ * @see asNewInstanceOf(), asSharedInstanceOf(), asValue()
+ */
+ public function register($itemName)
+ {
+ $this->_store[$itemName] = array();
+ $this->_endPoint =& $this->_store[$itemName];
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a literal value.
+ * {@link register()} must be called before this will work.
+ *
+ * @param mixed $value
+ * @return Swift_DependencyContainer
+ */
+ public function asValue($value)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_VALUE;
+ $endPoint['value'] = $value;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as an alias of another item.
+ * @param string $lookup
+ * @return Swift_DependencyContainer
+ */
+ public function asAliasOf($lookup)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_ALIAS;
+ $endPoint['ref'] = $lookup;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a new instance of
$className.
+ * {@link register()} must be called before this will work.
+ * Any arguments can be set with {@link withDependencies()},
+ * {@link addConstructorValue()} or {@link addConstructorLookup()}.
+ *
+ * @param string $className
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorValue(), addConstructorLookup()
+ */
+ public function asNewInstanceOf($className)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_INSTANCE;
+ $endPoint['className'] = $className;
+ return $this;
+ }
+
+ /**
+ * Specify the previously registered item as a shared instance of
$className.
+ * {@link register()} must be called before this will work.
+ * @param string $className
+ * @return Swift_DependencyContainer
+ */
+ public function asSharedInstanceOf($className)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['lookupType'] = self::TYPE_SHARED;
+ $endPoint['className'] = $className;
+ return $this;
+ }
+
+ /**
+ * Specify a list of injected dependencies for the previously registered
item.
+ * This method takes an array of lookup names.
+ *
+ * @param array $lookups
+ * @return Swift_DependencyContainer
+ * @see addConstructorValue(), addConstructorLookup()
+ */
+ public function withDependencies(array $lookups)
+ {
+ $endPoint =& $this->_getEndPoint();
+ $endPoint['args'] = array();
+ foreach ($lookups as $lookup)
+ {
+ $this->addConstructorLookup($lookup);
+ }
+ return $this;
+ }
+
+ /**
+ * Specify a literal (non looked up) value for the constructor of the
+ * previously registered item.
+ *
+ * @param mixed $value
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorLookup()
+ */
+ public function addConstructorValue($value)
+ {
+ $endPoint =& $this->_getEndPoint();
+ if (!isset($endPoint['args']))
+ {
+ $endPoint['args'] = array();
+ }
+ $endPoint['args'][] = array('type' => 'value', 'item' => $value);
+ return $this;
+ }
+
+ /**
+ * Specify a dependency lookup for the constructor of the previously
+ * registered item.
+ *
+ * @param string $lookup
+ * @return Swift_DependencyContainer
+ * @see withDependencies(), addConstructorValue()
+ */
+ public function addConstructorLookup($lookup)
+ {
+ $endPoint =& $this->_getEndPoint();
+ if (!isset($this->_endPoint['args']))
+ {
+ $endPoint['args'] = array();
+ }
+ $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup);
+ return $this;
+ }
+
+ // -- Private methods
+
+ /** Get the literal value with $itemName */
+ private function _getValue($itemName)
+ {
+ return $this->_store[$itemName]['value'];
+ }
+
+ /** Resolve an alias to another item */
+ private function _createAlias($itemName)
+ {
+ return $this->lookup($this->_store[$itemName]['ref']);
+ }
+
+ /** Create a fresh instance of $itemName */
+ private function _createNewInstance($itemName)
+ {
+ $reflector = new
ReflectionClass($this->_store[$itemName]['className']);
+ if ($reflector->getConstructor())
+ {
+ return $reflector->newInstanceArgs(
+ $this->createDependenciesFor($itemName)
+ );
+ }
+ else
+ {
+ return $reflector->newInstance();
+ }
+ }
+
+ /** Create and register a shared instance of $itemName */
+ private function _createSharedInstance($itemName)
+ {
+ if (!isset($this->_store[$itemName]['instance']))
+ {
+ $this->_store[$itemName]['instance'] =
$this->_createNewInstance($itemName);
+ }
+ return $this->_store[$itemName]['instance'];
+ }
+
+ /** Get the current endpoint in the store */
+ private function &_getEndPoint()
+ {
+ if (!isset($this->_endPoint))
+ {
+ throw new BadMethodCallException(
+ 'Component must first be registered by calling register()'
+ );
+ }
+ return $this->_endPoint;
+ }
+
+ /** Get an argument list with dependencies resolved */
+ private function _resolveArgs(array $args)
+ {
+ $resolved = array();
+ foreach ($args as $argDefinition)
+ {
+ switch ($argDefinition['type'])
+ {
+ case 'lookup':
+ $resolved[] = $this->_lookupRecursive($argDefinition['item']);
+ break;
+ case 'value':
+ $resolved[] = $argDefinition['item'];
+ break;
+ }
+ }
+ return $resolved;
+ }
+
+ /** Resolve a single dependency with an collections */
+ private function _lookupRecursive($item)
+ {
+ if (is_array($item))
+ {
+ $collection = array();
+ foreach ($item as $k => $v)
+ {
+ $collection[$k] = $this->_lookupRecursive($v);
+ }
+ return $collection;
+ }
+ else
+ {
+ return $this->lookup($item);
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/DependencyException.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/SwiftException.php';
+
+/**
+ * DependencyException thrown when a requested dependeny is missing.
+ * @package Swift
+ * @author Chris Corbyn
+ */
+class Swift_DependencyException extends Swift_SwiftException
+{
+
+ /**
+ * Create a new DependencyException with $message.
+ * @param string $message
+ */
+ public function __construct($message)
+ {
+ parent::__construct($message);
+ }
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/EmbeddedFile.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,73 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Mime/Attachment.php';
+//@require 'Swift/DependencyContainer.php';
+//@require 'Swift/ByteStream/FileByteStream.php';
+
+/**
+ * An embedded file, in a multipart message.
+ * @package Swift
+ * @subpackage Mime
+ * @author Chris Corbyn
+ */
+class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
+{
+
+ /**
+ * Create a new EmbeddedFile.
+ * Details may be optionally provided to the constructor.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ */
+ public function __construct($data = null, $filename = null,
+ $contentType = null)
+ {
+ call_user_func_array(
+ array($this, 'Swift_Mime_EmbeddedFile::__construct'),
+ Swift_DependencyContainer::getInstance()
+ ->createDependenciesFor('mime.embeddedfile')
+ );
+
+ $this->setBody($data);
+ $this->setFilename($filename);
+ if ($contentType)
+ {
+ $this->setContentType($contentType);
+ }
+ }
+
+ /**
+ * Create a new EmbeddedFile.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function newInstance($data = null, $filename = null,
+ $contentType = null)
+ {
+ return new self($data, $filename, $contentType);
+ }
+
+ /**
+ * Create a new EmbeddedFile from a filesystem path.
+ * @param string $path
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function fromPath($path)
+ {
+ return self::newInstance()->setFile(
+ new Swift_ByteStream_FileByteStream($path)
+ );
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/Base64Encoder.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Encoder.php';
+
+/**
+ * Handles Base 64 Encoding in Swift Mailer.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_Encoder_Base64Encoder implements Swift_Encoder
+{
+
+ /**
+ * Takes an unencoded string and produces a Base64 encoded string from
it.
+ * Base64 encoded strings have a maximum line length of 76 characters.
+ * If the first line needs to be shorter, indicate the difference with
+ * $firstLineOffset.
+ * @param string $string to encode
+ * @param int $firstLineOffset
+ * @param int $maxLineLength, optional, 0 indicates the default of 76
bytes
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ if (0 >= $maxLineLength || 76 < $maxLineLength)
+ {
+ $maxLineLength = 76;
+ }
+
+ $encodedString = base64_encode($string);
+ $firstLine = '';
+
+ if (0 != $firstLineOffset)
+ {
+ $firstLine = substr(
+ $encodedString, 0, $maxLineLength - $firstLineOffset
+ ) . "\r\n";
+ $encodedString = substr(
+ $encodedString, $maxLineLength - $firstLineOffset
+ );
+ }
+
+ return $firstLine . trim(chunk_split($encodedString,
$maxLineLength, "\r\n"));
+ }
+
+ /**
+ * Does nothing.
+ */
+ public function charsetChanged($charset)
+ {
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/QpEncoder.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,263 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Encoder.php';
+//@require 'Swift/CharacterStream.php';
+
+/**
+ * Handles Quoted Printable (QP) Encoding in Swift Mailer.
+ * Possibly the most accurate RFC 2045 QP implementation found in PHP.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_Encoder_QpEncoder implements Swift_Encoder
+{
+
+ /**
+ * The CharacterStream used for reading characters (as opposed to bytes).
+ * @var Swift_CharacterStream
+ * @access protected
+ */
+ protected $_charStream;
+
+ /**
+ * A filter used if input should be canonicalized.
+ * @var Swift_StreamFilter
+ * @access protected
+ */
+ protected $_filter;
+
+ /**
+ * Pre-computed QP for HUGE optmization.
+ * @var string[]
+ * @access protected
+ */
+ protected static $_qpMap = array(
+ 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04',
+ 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09',
+ 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E',
+ 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13',
+ 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18',
+ 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D',
+ 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22',
+ 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27',
+ 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C',
+ 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31',
+ 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36',
+ 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B',
+ 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40',
+ 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45',
+ 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A',
+ 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F',
+ 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54',
+ 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59',
+ 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E',
+ 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63',
+ 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68',
+ 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D',
+ 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72',
+ 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77',
+ 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C',
+ 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81',
+ 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86',
+ 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B',
+ 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90',
+ 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95',
+ 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A',
+ 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F',
+ 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4',
+ 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9',
+ 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE',
+ 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3',
+ 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8',
+ 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD',
+ 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2',
+ 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7',
+ 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC',
+ 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1',
+ 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6',
+ 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB',
+ 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0',
+ 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5',
+ 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA',
+ 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF',
+ 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4',
+ 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9',
+ 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE',
+ 255 => '=FF'
+ );
+
+ /**
+ * A map of non-encoded ascii characters.
+ * @var string[]
+ * @access protected
+ */
+ protected static $_safeMap = array();
+
+ /**
+ * Creates a new QpEncoder for the given CharacterStream.
+ * @param Swift_CharacterStream $charStream to use for reading characters
+ * @param Swift_StreamFilter $filter if input should be canonicalized
+ */
+ public function __construct(Swift_CharacterStream $charStream,
+ Swift_StreamFilter $filter = null)
+ {
+ $this->_charStream = $charStream;
+ if (empty(self::$_safeMap))
+ {
+ foreach (array_merge(
+ array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte)
+ {
+ self::$_safeMap[$byte] = chr($byte);
+ }
+ }
+ $this->_filter = $filter;
+ }
+
+ /**
+ * Takes an unencoded string and produces a QP encoded string from it.
+ * QP encoded strings have a maximum line length of 76 characters.
+ * If the first line needs to be shorter, indicate the difference with
+ * $firstLineOffset.
+ * @param string $string to encode
+ * @param int $firstLineOffset, optional
+ * @param int $maxLineLength, optional, 0 indicates the default of 76
chars
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ if ($maxLineLength > 76 || $maxLineLength <= 0)
+ {
+ $maxLineLength = 76;
+ }
+
+ $thisLineLength = $maxLineLength - $firstLineOffset;
+
+ $lines = array();
+ $lNo = 0;
+ $lines[$lNo] = '';
+ $currentLine =& $lines[$lNo++];
+ $size=$lineLen=0;
+
+ $this->_charStream->flushContents();
+ $this->_charStream->importString($string);
+
+ //Fetching more than 4 chars at one is slower, as is fetching fewer
bytes
+ // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to
6
+ // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes
+ while (false !== $bytes = $this->_nextSequence())
+ {
+ //If we're filtering the input
+ if (isset($this->_filter))
+ {
+ //If we can't filter because we need more bytes
+ while ($this->_filter->shouldBuffer($bytes))
+ {
+ //Then collect bytes into the buffer
+ if (false === $moreBytes = $this->_nextSequence(1))
+ {
+ break;
+ }
+
+ foreach ($moreBytes as $b)
+ {
+ $bytes[] = $b;
+ }
+ }
+ //And filter them
+ $bytes = $this->_filter->filter($bytes);
+ }
+
+ $enc = $this->_encodeByteSequence($bytes, $size);
+ if ($currentLine && $lineLen+$size >= $thisLineLength)
+ {
+ $lines[$lNo] = '';
+ $currentLine =& $lines[$lNo++];
+ $thisLineLength = $maxLineLength;
+ $lineLen=0;
+ }
+ $lineLen+=$size;
+ $currentLine .= $enc;
+ }
+
+ return $this->_standardize(implode("=\r\n", $lines));
+ }
+
+ /**
+ * Updates the charset used.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_charStream->setCharacterSet($charset);
+ }
+
+ // -- Protected methods
+
+ /**
+ * Encode the given byte array into a verbatim QP form.
+ * @param int[] $bytes
+ * @return string
+ * @access protected
+ */
+ protected function _encodeByteSequence(array $bytes, &$size)
+ {
+ $ret = '';
+ $size=0;
+ foreach ($bytes as $b)
+ {
+ if (isset(self::$_safeMap[$b]))
+ {
+ $ret .= self::$_safeMap[$b];
+ ++$size;
+ }
+ else
+ {
+ $ret .= self::$_qpMap[$b];
+ $size+=3;
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * Get the next sequence of bytes to read from the char stream.
+ * @param int $size number of bytes to read
+ * @return int[]
+ * @access protected
+ */
+ protected function _nextSequence($size = 4)
+ {
+ return $this->_charStream->readBytes($size);
+ }
+
+ /**
+ * Make sure CRLF is correct and HT/SPACE are in valid places.
+ * @param string $string
+ * @return string
+ * @access protected
+ */
+ protected function _standardize($string)
+ {
+ $string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"),
+ array("=09\r\n", "=20\r\n", "\r\n"), $string
+ );
+ switch ($end = ord(substr($string, -1)))
+ {
+ case 0x09:
+ case 0x20:
+ $string = substr_replace($string, self::$_qpMap[$end], -1);
+ }
+ return $string;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder/Rfc2231Encoder.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,89 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Encoder.php';
+//@require 'Swift/CharacterStream.php';
+
+/**
+ * Handles RFC 2231 specified Encoding in Swift Mailer.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
+{
+
+ /**
+ * A character stream to use when reading a string as characters instead
of bytes.
+ * @var Swift_CharacterStream
+ * @access private
+ */
+ private $_charStream;
+
+ /**
+ * Creates a new Rfc2231Encoder using the given character stream
instance.
+ * @param Swift_CharacterStream
+ */
+ public function __construct(Swift_CharacterStream $charStream)
+ {
+ $this->_charStream = $charStream;
+ }
+
+ /**
+ * Takes an unencoded string and produces a string encoded according to
+ * RFC 2231 from it.
+ * @param string $string to encode
+ * @param int $firstLineOffset
+ * @param int $maxLineLength, optional, 0 indicates the default of 75
bytes
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0)
+ {
+ $lines = array(); $lineCount = 0;
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+
+ if (0 >= $maxLineLength)
+ {
+ $maxLineLength = 75;
+ }
+
+ $this->_charStream->flushContents();
+ $this->_charStream->importString($string);
+
+ $thisLineLength = $maxLineLength - $firstLineOffset;
+
+ while (false !== $char = $this->_charStream->read(4))
+ {
+ $encodedChar = rawurlencode($char);
+ if (0 != strlen($currentLine)
+ && strlen($currentLine . $encodedChar) > $thisLineLength)
+ {
+ $lines[] = '';
+ $currentLine =& $lines[$lineCount++];
+ $thisLineLength = $maxLineLength;
+ }
+ $currentLine .= $encodedChar;
+ }
+
+ return implode("\r\n", $lines);
+ }
+
+ /**
+ * Updates the charset used.
+ * @param string $charset
+ */
+ public function charsetChanged($charset)
+ {
+ $this->_charStream->setCharacterSet($charset);
+ }
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoder.php Fri Nov
19 05:21:09 2010
@@ -0,0 +1,32 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Mime/CharsetObserver.php';
+
+/**
+ * Interface for all Encoder schemes.
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+interface Swift_Encoder extends Swift_Mime_CharsetObserver
+{
+
+ /**
+ * Encode a given string to produce an encoded string.
+ * @param string $string
+ * @param int $firstLineOffset if first line needs to be shorter
+ * @param int $maxLineLength - 0 indicates the default length for this
encoding
+ * @return string
+ */
+ public function encodeString($string, $firstLineOffset = 0,
+ $maxLineLength = 0);
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Encoding.php Fri
Nov 19 05:21:09 2010
@@ -0,0 +1,70 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/DependencyContainer.php';
+
+/**
+ * Provides quick access to each encoding type.
+ *
+ * @package Swift
+ * @subpackage Encoder
+ * @author Chris Corbyn
+ */
+class Swift_Encoding
+{
+
+ /**
+ * Get the Encoder that provides 7-bit encoding.
+ *
+ * @return Swift_Mime_ContentEncoder
+ */
+ public static function get7BitEncoding()
+ {
+ return self::_lookup('mime.7bitcontentencoder');
+ }
+
+ /**
+ * Get the Encoder that provides 8-bit encoding.
+ *
+ * @return Swift_Mime_ContentEncoder
+ */
+ public static function get8BitEncoding()
+ {
+ return self::_lookup('mime.8bitcontentencoder');
+ }
+
+ /**
+ * Get the Encoder that provides Quoted-Printable (QP) encoding.
+ *
+ * @return Swift_Mime_ContentEncoder
+ */
+ public static function getQpEncoding()
+ {
+ return self::_lookup('mime.qpcontentencoder');
+ }
+
+ /**
+ * Get the Encoder that provides Base64 encoding.
+ *
+ * @return Swift_Mime_ContentEncoder
+ */
+ public static function getBase64Encoding()
+ {
+ return self::_lookup('mime.base64contentencoder');
+ }
+
+ // -- Private Static Methods
+
+ private static function _lookup($key)
+ {
+ return Swift_DependencyContainer::getInstance()->lookup($key);
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/CommandEvent.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,67 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventObject.php';
+//@require 'Swift/Transport.php';
+
+/**
+ * Generated when a command is sent over an SMTP connection.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_CommandEvent extends Swift_Events_EventObject
+{
+
+ /**
+ * The command sent to the server.
+ * @var string
+ */
+ private $_command;
+
+ /**
+ * An array of codes which a successful response will contain.
+ * @var int[]
+ */
+ private $_successCodes = array();
+
+ /**
+ * Create a new CommandEvent for $source with $command.
+ * @param Swift_Transport $source
+ * @param string $command
+ * @param array $successCodes
+ */
+ public function __construct(Swift_Transport $source,
+ $command, $successCodes = array())
+ {
+ parent::__construct($source);
+ $this->_command = $command;
+ $this->_successCodes = $successCodes;
+ }
+
+ /**
+ * Get the command which was sent to the server.
+ * @return string
+ */
+ public function getCommand()
+ {
+ return $this->_command;
+ }
+
+ /**
+ * Get the numeric response codes which indicate success for this
command.
+ * @return int[]
+ */
+ public function getSuccessCodes()
+ {
+ return $this->_successCodes;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/CommandListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/CommandEvent.php';
+
+/**
+ * Listens for Transports to send commands to the server.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_CommandListener extends Swift_Events_EventListener
+{
+
+ /**
+ * Invoked immediately following a command being sent.
+ * @param Swift_Events_ResponseEvent $evt
+ */
+ public function commandSent(Swift_Events_CommandEvent $evt);
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/Event.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * The minimum interface for an Event.
+ *
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_Event
+{
+
+ /**
+ * Get the source object of this event.
+ * @return object
+ */
+ public function getSource();
+
+ /**
+ * Prevent this Event from bubbling any further up the stack.
+ * @param boolean $cancel, optional
+ */
+ public function cancelBubble($cancel = true);
+
+ /**
+ * Returns true if this Event will not bubble any further up the stack.
+ * @return boolean
+ */
+ public function bubbleCancelled();
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventDispatcher.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,81 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Event.php';
+
+/**
+ * Interface for the EventDispatcher which handles the event dispatching
layer.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_EventDispatcher
+{
+
+ /**
+ * Create a new SendEvent for $source and $message.
+ * @param Swift_Transport $source
+ * @param Swift_Mime_Message
+ * @return Swift_Events_SendEvent
+ */
+ public function createSendEvent(Swift_Transport $source,
+ Swift_Mime_Message $message);
+
+ /**
+ * Create a new CommandEvent for $source and $command.
+ * @param Swift_Transport $source
+ * @param string $command That will be executed
+ * @param array $successCodes That are needed
+ * @return Swift_Events_CommandEvent
+ */
+ public function createCommandEvent(Swift_Transport $source,
+ $command, $successCodes = array());
+
+ /**
+ * Create a new ResponseEvent for $source and $response.
+ * @param Swift_Transport $source
+ * @param string $response
+ * @param boolean $valid If the response is valid
+ * @return Swift_Events_ResponseEvent
+ */
+ public function createResponseEvent(Swift_Transport $source,
+ $response, $valid);
+
+ /**
+ * Create a new TransportChangeEvent for $source.
+ * @param Swift_Transport $source
+ * @return Swift_Events_TransportChangeEvent
+ */
+ public function createTransportChangeEvent(Swift_Transport $source);
+
+ /**
+ * Create a new TransportExceptionEvent for $source.
+ * @param Swift_Transport $source
+ * @param Swift_TransportException $ex
+ * @return Swift_Events_TransportExceptionEvent
+ */
+ public function createTransportExceptionEvent(Swift_Transport $source,
+ Swift_TransportException $ex);
+
+ /**
+ * Bind an event listener to this dispatcher.
+ * @param Swift_Events_EventListener $listener
+ */
+ public function bindEventListener(Swift_Events_EventListener $listener);
+
+ /**
+ * Dispatch the given Event to all suitable listeners.
+ * @param Swift_Events_EventObject $evt
+ * @param string $target method
+ */
+ public function dispatchEvent(Swift_Events_EventObject $evt, $target);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,19 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * An identity interface which all EventListeners must extend.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_EventListener
+{
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/EventObject.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,65 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/Event.php';
+
+/**
+ * A base Event which all Event classes inherit from.
+ *
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_EventObject implements Swift_Events_Event
+{
+
+ /** The source of this Event */
+ private $_source;
+
+ /** The state of this Event (should it bubble up the stack?) */
+ private $_bubbleCancelled = false;
+
+ /**
+ * Create a new EventObject originating at $source.
+ * @param object $source
+ */
+ public function __construct($source)
+ {
+ $this->_source = $source;
+ }
+
+ /**
+ * Get the source object of this event.
+ * @return object
+ */
+ public function getSource()
+ {
+ return $this->_source;
+ }
+
+ /**
+ * Prevent this Event from bubbling any further up the stack.
+ * @param boolean $cancel, optional
+ */
+ public function cancelBubble($cancel = true)
+ {
+ $this->_bubbleCancelled = $cancel;
+ }
+
+ /**
+ * Returns true if this Event will not bubble any further up the stack.
+ * @return boolean
+ */
+ public function bubbleCancelled()
+ {
+ return $this->_bubbleCancelled;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/ResponseEvent.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,65 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventObject.php';
+
+/**
+ * Generated when a response is received on a SMTP connection.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_ResponseEvent extends Swift_Events_EventObject
+{
+
+ /**
+ * The overall result.
+ * @var boolean
+ */
+ private $_valid;
+
+ /**
+ * The response received from the server.
+ * @var string
+ */
+ private $_response;
+
+ /**
+ * Create a new ResponseEvent for $source and $response.
+ * @param Swift_Transport $source
+ * @param string $response
+ * @param boolean $valid
+ */
+ public function __construct(Swift_Transport $source, $response, $valid =
false)
+ {
+ parent::__construct($source);
+ $this->_response = $response;
+ $this->_valid = $valid;
+ }
+
+ /**
+ * Get the response which was received from the server.
+ * @return string
+ */
+ public function getResponse()
+ {
+ return $this->_response;
+ }
+
+ /**
+ * Get the success status of this Event.
+ * @return boolean
+ */
+ public function isValid()
+ {
+ return $this->_valid;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/ResponseListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/ResponseEvent.php';
+
+/**
+ * Listens for responses from a remote SMTP server.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_ResponseListener extends Swift_Events_EventListener
+{
+
+ /**
+ * Invoked immediately following a response coming back.
+ * @param Swift_Events_ResponseEvent $evt
+ */
+ public function responseReceived(Swift_Events_ResponseEvent $evt);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SendEvent.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,127 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventObject.php';
+
+/**
+ * Generated when a message is being sent.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_SendEvent extends Swift_Events_EventObject
+{
+
+ /** Sending has yet to occur */
+ const RESULT_PENDING = 0x0001;
+
+ /** Sending was successful */
+ const RESULT_SUCCESS = 0x0010;
+
+ /** Sending worked, but there were some failures */
+ const RESULT_TENTATIVE = 0x0100;
+
+ /** Sending failed */
+ const RESULT_FAILED = 0x1000;
+
+ /**
+ * The Message being sent.
+ * @var Swift_Mime_Message
+ */
+ private $_message;
+
+ /**
+ * The Transport used in sending.
+ * @var Swift_Transport
+ */
+ private $_transport;
+
+ /**
+ * Any recipients which failed after sending.
+ * @var string[]
+ */
+ private $failedRecipients = array();
+
+ /**
+ * The overall result as a bitmask from the class constants.
+ * @var int
+ */
+ private $result;
+
+ /**
+ * Create a new SendEvent for $source and $message.
+ * @param Swift_Transport $source
+ * @param Swift_Mime_Message $message
+ */
+ public function __construct(Swift_Transport $source,
+ Swift_Mime_Message $message)
+ {
+ parent::__construct($source);
+ $this->_message = $message;
+ $this->_result = self::RESULT_PENDING;
+ }
+
+ /**
+ * Get the Transport used to send the Message.
+ * @return Swift_Transport
+ */
+ public function getTransport()
+ {
+ return $this->getSource();
+ }
+
+ /**
+ * Get the Message being sent.
+ * @return Swift_Mime_Message
+ */
+ public function getMessage()
+ {
+ return $this->_message;
+ }
+
+ /**
+ * Set the array of addresses that failed in sending.
+ * @param array $recipients
+ */
+ public function setFailedRecipients($recipients)
+ {
+ $this->_failedRecipients = $recipients;
+ }
+
+ /**
+ * Get an recipient addresses which were not accepted for delivery.
+ * @return string[]
+ */
+ public function getFailedRecipients()
+ {
+ return $this->_failedRecipients;
+ }
+
+ /**
+ * Set the result of sending.
+ * @return int
+ */
+ public function setResult($result)
+ {
+ $this->_result = $result;
+ }
+
+ /**
+ * Get the result of this Event.
+ * The return value is a bitmask from
+ * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE,
RESULT_FAILED}
+ * @return int
+ */
+ public function getResult()
+ {
+ return $this->_result;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SendListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,35 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/SendEvent.php';
+
+/**
+ * Listens for Messages being sent from within the Transport system.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_SendListener extends Swift_Events_EventListener
+{
+
+ /**
+ * Invoked immediately before the Message is sent.
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt);
+
+ /**
+ * Invoked immediately after the Message is sent.
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,175 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventDispatcher.php';
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/EventObject.php';
+//@require 'Swift/Events/CommandEvent.php';
+//@require 'Swift/Events/ResponseEvent.php';
+//@require 'Swift/Events/SendEvent.php';
+//@require 'Swift/Events/TransportChangeEvent.php';
+//@require 'Swift/Events/TransportExceptionEvent.php';
+
+/**
+ * The EventDispatcher which handles the event dispatching layer.
+ *
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_SimpleEventDispatcher implements
Swift_Events_EventDispatcher
+{
+
+ /** A map of event types to their associated listener types */
+ private $_eventMap = array();
+
+ /** Event listeners bound to this dispatcher */
+ private $_listeners = array();
+
+ /** Listeners queued to have an Event bubbled up the stack to them */
+ private $_bubbleQueue = array();
+
+ /**
+ * Create a new EventDispatcher.
+ */
+ public function __construct()
+ {
+ $this->_eventMap = array(
+ 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener',
+ 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener',
+ 'Swift_Events_SendEvent' => 'Swift_Events_SendListener',
+ 'Swift_Events_TransportChangeEvent'
=> 'Swift_Events_TransportChangeListener',
+ 'Swift_Events_TransportExceptionEvent'
=> 'Swift_Events_TransportExceptionListener'
+ );
+ }
+
+ /**
+ * Create a new SendEvent for $source and $message.
+ *
+ * @param Swift_Transport $source
+ * @param Swift_Mime_Message
+ * @return Swift_Events_SendEvent
+ */
+ public function createSendEvent(Swift_Transport $source,
+ Swift_Mime_Message $message)
+ {
+ return new Swift_Events_SendEvent($source, $message);
+ }
+
+ /**
+ * Create a new CommandEvent for $source and $command.
+ *
+ * @param Swift_Transport $source
+ * @param string $command That will be executed
+ * @param array $successCodes That are needed
+ * @return Swift_Events_CommandEvent
+ */
+ public function createCommandEvent(Swift_Transport $source,
+ $command, $successCodes = array())
+ {
+ return new Swift_Events_CommandEvent($source, $command, $successCodes);
+ }
+
+ /**
+ * Create a new ResponseEvent for $source and $response.
+ *
+ * @param Swift_Transport $source
+ * @param string $response
+ * @param boolean $valid If the response is valid
+ * @return Swift_Events_ResponseEvent
+ */
+ public function createResponseEvent(Swift_Transport $source,
+ $response, $valid)
+ {
+ return new Swift_Events_ResponseEvent($source, $response, $valid);
+ }
+
+ /**
+ * Create a new TransportChangeEvent for $source.
+ *
+ * @param Swift_Transport $source
+ * @return Swift_Events_TransportChangeEvent
+ */
+ public function createTransportChangeEvent(Swift_Transport $source)
+ {
+ return new Swift_Events_TransportChangeEvent($source);
+ }
+
+ /**
+ * Create a new TransportExceptionEvent for $source.
+ *
+ * @param Swift_Transport $source
+ * @param Swift_TransportException $ex
+ * @return Swift_Events_TransportExceptionEvent
+ */
+ public function createTransportExceptionEvent(Swift_Transport $source,
+ Swift_TransportException $ex)
+ {
+ return new Swift_Events_TransportExceptionEvent($source, $ex);
+ }
+
+ /**
+ * Bind an event listener to this dispatcher.
+ *
+ * @param Swift_Events_EventListener $listener
+ */
+ public function bindEventListener(Swift_Events_EventListener $listener)
+ {
+ foreach ($this->_listeners as $l)
+ {
+ //Already loaded
+ if ($l === $listener)
+ {
+ return;
+ }
+ }
+ $this->_listeners[] = $listener;
+ }
+
+ /**
+ * Dispatch the given Event to all suitable listeners.
+ *
+ * @param Swift_Events_EventObject $evt
+ * @param string $target method
+ */
+ public function dispatchEvent(Swift_Events_EventObject $evt, $target)
+ {
+ $this->_prepareBubbleQueue($evt);
+ $this->_bubble($evt, $target);
+ }
+
+ // -- Private methods
+
+ /** Queue listeners on a stack ready for $evt to be bubbled up it */
+ private function _prepareBubbleQueue(Swift_Events_EventObject $evt)
+ {
+ $this->_bubbleQueue = array();
+ $evtClass = get_class($evt);
+ foreach ($this->_listeners as $listener)
+ {
+ if (array_key_exists($evtClass, $this->_eventMap)
+ && ($listener instanceof $this->_eventMap[$evtClass]))
+ {
+ $this->_bubbleQueue[] = $listener;
+ }
+ }
+ }
+
+ /** Bubble $evt up the stack calling $target() on each listener */
+ private function _bubble(Swift_Events_EventObject $evt, $target)
+ {
+ if (!$evt->bubbleCancelled() && $listener =
array_shift($this->_bubbleQueue))
+ {
+ $listener->$target($evt);
+ $this->_bubble($evt, $target);
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportChangeEvent.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventObject.php';
+
+/**
+ * Generated when the state of a Transport is changed (i.e.
stopped/started).
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject
+{
+
+ /**
+ * Get the Transport.
+ * @return Swift_Transport
+ */
+ public function getTransport()
+ {
+ return $this->getSource();
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportChangeListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,53 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/TransportChangeEvent.php';
+
+/**
+ * Listens for changes within the Transport system.
+ *
+ * @package Swift
+ * @subpackage Events
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Events_TransportChangeListener extends
Swift_Events_EventListener
+{
+
+ /**
+ * Invoked just before a Transport is started.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function beforeTransportStarted(Swift_Events_TransportChangeEvent
$evt);
+
+ /**
+ * Invoked immediately after the Transport is started.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function transportStarted(Swift_Events_TransportChangeEvent $evt);
+
+ /**
+ * Invoked just before a Transport is stopped.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function beforeTransportStopped(Swift_Events_TransportChangeEvent
$evt);
+
+ /**
+ * Invoked immediately after the Transport is stopped.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function transportStopped(Swift_Events_TransportChangeEvent $evt);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,50 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventObject.php';
+//@require 'Swift/TransportException.php';
+
+/**
+ * Generated when a TransportException is thrown from the Transport system.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject
+{
+
+ /**
+ * The Exception thrown.
+ * @var Swift_TransportException
+ */
+ private $_exception;
+
+ /**
+ * Create a new TransportExceptionEvent for $transport.
+ * @param Swift_Transport $transport
+ * @param Swift_TransportException $ex
+ */
+ public function __construct(Swift_Transport $transport,
+ Swift_TransportException $ex)
+ {
+ parent::__construct($transport);
+ $this->_exception = $ex;
+ }
+
+ /**
+ * Get the TransportException thrown.
+ * @return Swift_TransportException
+ */
+ public function getException()
+ {
+ return $this->_exception;
+ }
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/Events/TransportExceptionListener.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Events/EventListener.php';
+//@require 'Swift/Events/TransportExceptionEvent.php';
+
+/**
+ * Listens for Exceptions thrown from within the Transport system.
+ * @package Swift
+ * @subpackage Events
+ * @author Chris Corbyn
+ */
+interface Swift_Events_TransportExceptionListener
+ extends Swift_Events_EventListener
+{
+
+ /**
+ * Invoked as a TransportException is thrown in the Transport system.
+ * @param Swift_Events_TransportExceptionEvent $evt
+ */
+ public function exceptionThrown(Swift_Events_TransportExceptionEvent
$evt);
+
+}
=======================================
--- /dev/null
+++
/framework/trunk/piwi/lib/swiftmailer/classes/Swift/FailoverTransport.php
Fri Nov 19 05:21:09 2010
@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Transport/FailoverTransport.php';
+//@require 'Swift/DependencyContainer.php';
+
+/**
+ * Contains a list of redundant Transports so when one fails, the next is
used.
+ * @package Swift
+ * @subpackage Transport
+ * @author Chris Corbyn
+ */
+class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
+{
+
+ /**
+ * Creates a new FailoverTransport with $transports.
+ * @param array $transports
+ */
+ public function __construct($transports = array())
+ {
+ call_user_func_array(
+ array($this, 'Swift_Transport_FailoverTransport::__construct'),
+ Swift_DependencyContainer::getInstance()
+ ->createDependenciesFor('transport.failover')
+ );
+
+ $this->setTransports($transports);
+ }
+
+ /**
+ * Create a new FailoverTransport instance.
+ * @param string $transports
+ * @return Swift_FailoverTransport
+ */
+ public static function newInstance($transports = array())
+ {
+ return new self($transports);
+ }
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/FileStream.php Fri
Nov 19 05:21:09 2010
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/OutputByteStream.php';
+
+/**
+ * An OutputByteStream which specifically reads from a file.
+ * @package Swift
+ * @subpackage ByteStream
+ * @author Chris Corbyn
+ */
+interface Swift_FileStream extends Swift_OutputByteStream
+{
+
+ /**
+ * Get the complete path to the file.
+ * @return string
+ */
+ public function getPath();
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Filterable.php Fri
Nov 19 05:21:09 2010
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/StreamFilter.php';
+
+/**
+ * Allows StreamFilters to operate on a stream.
+ * @package Swift
+ * @author Chris Corbyn
+ */
+interface Swift_Filterable
+{
+
+ /**
+ * Add a new StreamFilter, referenced by $key.
+ * @param Swift_StreamFilter $filter
+ * @param string $key
+ */
+ public function addFilter(Swift_StreamFilter $filter, $key);
+
+ /**
+ * Remove an existing filter using $key.
+ * @param string $key
+ */
+ public function removeFilter($key);
+
+}
=======================================
--- /dev/null
+++ /framework/trunk/piwi/lib/swiftmailer/classes/Swift/Image.php Fri Nov
19 05:21:09 2010
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Image.php';
+//@require 'Swift/ByteStream/FileByteStream.php';
+
+/**
+ * An image, embedded in a multipart message.
+ * @package Swift
+ * @subpackage Mime
+ * @author Chris Corbyn
+ */
+class Swift_Image extends Swift_EmbeddedFile
+{
+
+ /**
+ * Create a new EmbeddedFile.
+ * Details may be optionally provided to the constructor.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ */
+ public function __construct($data = null, $filename = null,
+ $contentType = null)
+ {
+ parent::__construct($data, $filename, $contentType);
+ }
+
+ /**
+ * Create a new Image.
+ * @param string|Swift_OutputByteStream $data
+ * @param string $filename
+ * @param string $contentType
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function newInstance($data = null, $filename = null,
+ $contentType = null)
+ {
+ return new self($data, $filename, $contentType);
+ }
+
+ /**
+ * Create a new Image from a filesystem path.
+ * @param string $path
+ * @return Swift_Mime_EmbeddedFile
+ */
+ public static function fromPath($path)
+ {
+ $image = self::newInstance()->setFile(
+ new Swift_ByteStream_FileByteStream($path)
+ );
+ return $image;
+ }
+
+}
=======================================
***Additional files exist in this changeset.***

Reply all
Reply to author
Forward
0 new messages