|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
|
4
|
|
|
* |
|
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace ZBateson\MailMimeParser\Message; |
|
8
|
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\MailMimeParser; |
|
10
|
|
|
use ZBateson\MailMimeParser\Message\PartStreamContainer; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Implementation of a non-mime message's uuencoded attachment part. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Zaahid Bateson |
|
16
|
|
|
*/ |
|
17
|
|
|
class UUEncodedPart extends NonMimePart implements IUUEncodedPart |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var int the unix file permission |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $mode = null; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string the name of the file in the uuencoding 'header'. |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $filename = null; |
|
28
|
|
|
|
|
29
|
10 |
|
public function __construct($mode = null, $filename = null, IMimePart $parent = null, PartStreamContainer $streamContainer = null) |
|
30
|
|
|
{ |
|
31
|
10 |
|
if ($streamContainer === null) { |
|
32
|
|
|
$di = MailMimeParser::getDependencyContainer(); |
|
33
|
|
|
$streamContainer = $di['ZBateson\MailMimeParser\Message\PartStreamContainer']; |
|
34
|
|
|
$streamFactory = $di['ZBateson\MailMimeParser\Stream\StreamFactory']; |
|
35
|
|
|
$streamContainer->setStream($streamFactory->newMessagePartStream($this)); |
|
36
|
|
|
} |
|
37
|
10 |
|
parent::__construct( |
|
38
|
10 |
|
$streamContainer, |
|
39
|
10 |
|
$parent |
|
40
|
|
|
); |
|
41
|
10 |
|
$this->mode = $mode; |
|
42
|
10 |
|
$this->filename = $filename; |
|
43
|
10 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Returns the filename included in the uuencoded 'begin' line for this |
|
47
|
|
|
* part. |
|
48
|
|
|
* |
|
49
|
|
|
* @return string |
|
50
|
|
|
*/ |
|
51
|
4 |
|
public function getFilename() |
|
52
|
|
|
{ |
|
53
|
4 |
|
return $this->filename; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
public function setFilename($filename) |
|
57
|
|
|
{ |
|
58
|
1 |
|
$this->filename = $filename; |
|
59
|
1 |
|
$this->notify(); |
|
60
|
1 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns false. |
|
64
|
|
|
* |
|
65
|
|
|
* Although the part may be plain text, there is no reliable way of |
|
66
|
|
|
* determining its type since uuencoded 'begin' lines only include a file |
|
67
|
|
|
* name and no mime type. The file name's extension may be a hint. |
|
68
|
|
|
* |
|
69
|
|
|
* @return bool |
|
70
|
|
|
*/ |
|
71
|
3 |
|
public function isTextPart() |
|
72
|
|
|
{ |
|
73
|
3 |
|
return false; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns 'application/octet-stream'. |
|
78
|
|
|
* |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
4 |
|
public function getContentType($default = 'application/octet-stream') |
|
82
|
|
|
{ |
|
83
|
4 |
|
return 'application/octet-stream'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Returns null |
|
88
|
|
|
* |
|
89
|
|
|
* @return string |
|
90
|
|
|
*/ |
|
91
|
4 |
|
public function getCharset() |
|
92
|
|
|
{ |
|
93
|
4 |
|
return null; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Returns 'attachment'. |
|
98
|
|
|
* |
|
99
|
|
|
* @return string |
|
100
|
|
|
*/ |
|
101
|
4 |
|
public function getContentDisposition($default = 'attachment') |
|
102
|
|
|
{ |
|
103
|
4 |
|
return 'attachment'; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Returns 'x-uuencode'. |
|
108
|
|
|
* |
|
109
|
|
|
* @return string |
|
110
|
|
|
*/ |
|
111
|
3 |
|
public function getContentTransferEncoding($default = 'x-uuencode') |
|
112
|
|
|
{ |
|
113
|
3 |
|
return 'x-uuencode'; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
1 |
|
public function getUnixFileMode() |
|
117
|
|
|
{ |
|
118
|
1 |
|
return $this->mode; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
1 |
|
public function setUnixFileMode($mode) |
|
122
|
|
|
{ |
|
123
|
1 |
|
$this->mode = $mode; |
|
124
|
1 |
|
$this->notify(); |
|
125
|
1 |
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|