In a multipart/encrypted encrypted message,
find the encrypted message payload part.

@return rcube_message_part
512570
public function get_multipart_encrypted_part()
    {
        foreach ($this->mime_parts as $mime_id => $mpart) {
            if ($mpart->mimetype == 'multipart/encrypted') {
                $this->pgp_mime = true;
            }
            if ($this->pgp_mime && ($mpart->mimetype == 'application/octet-stream' ||
                    (!empty($mpart->filename) && $mpart->filename != 'version.txt'))) {
                $this->encrypted_part = $mime_id;
                return $mpart;
            }
        }

        return false;
    }
1083892
function message_ready($p)
    {
        $savedraft      = !empty($_POST['_draft']) && empty($_GET['_saveonly']);
        $sign_enable    = (bool) rcube_utils::get_input_value('_enigma_sign', rcube_utils::INPUT_POST);
        $encrypt_enable = (bool) rcube_utils::get_input_value('_enigma_encrypt', rcube_utils::INPUT_POST);
        $pubkey_enable  = (bool) rcube_utils::get_input_value('_enigma_attachpubkey', rcube_utils::INPUT_POST);
        $locks          = (array) $this->rc->config->get('enigma_options_lock');

        if (in_array('sign', $locks)) {
            $sign_enable = (bool) $this->rc->config->get('enigma_sign_all');
        }
        if (in_array('encrypt', $locks)) {
            $encrypt_enable = (bool) $this->rc->config->get('enigma_encrypt_all');
        }
        if (in_array('pubkey', $locks)) {
            $pubkey_enable = (bool) $this->rc->config->get('enigma_attach_pubkey');
        }

        if (!$savedraft && $pubkey_enable) {
            $engine = $this->enigma->load_engine();
            $engine->attach_public_key($p['message']);
        }

        if ($encrypt_enable) {
            $engine = $this->enigma->load_engine();
            $mode   = !$savedraft && $sign_enable ? enigma_engine::ENCRYPT_MODE_SIGN : null;
            $status = $engine->encrypt_message($p['message'], $mode, $savedraft);
            $mode   = 'encrypt';
        }
        else if (!$savedraft && $sign_enable) {
            $engine = $this->enigma->load_engine();
            $status = $engine->sign_message($p['message'], enigma_engine::SIGN_MODE_MIME);
            $mode   = 'sign';
        }

        if ($mode && ($status instanceof enigma_error)) {
            $code = $status->getCode();

            if ($code == enigma_error::KEYNOTFOUND) {
                $vars = array('email' => $status->getData('missing'));
                $msg  = 'enigma.' . $mode . 'nokey';
            }
            else if ($code == enigma_error::BADPASS) {
                $this->password_prompt($status);
            }
            else {
                $msg = 'enigma.' . $mode . 'error';
            }

            if ($msg) {
                if ($vars && $vars['email']) {
                    $this->rc->output->command('enigma_key_not_found', array(
                            'email'  => $vars['email'],
                            'text'   => $this->rc->gettext(array('name' => $msg, 'vars' => $vars)),
                            'title'  => $this->enigma->gettext('keynotfound'),
                            'button' => $this->enigma->gettext('findkey'),
                    ));
                }
                else {
                    $this->rc->output->show_message($msg, 'error', $vars);
                }
            }

            $this->rc->output->send('iframe');
        }

        return $p;
    }
1102043
public function generatePlainPartFromBody()
    {
        $plainPart = $this->findPlainPart();
        if ($plainPart) {
            $this->getSwiftMessage()->detach($plainPart);
        }
        unset($plainPart);

        $this->getSwiftMessage()->addPart(
            Convert::xml2raw($this->getBody()),
            'text/plain',
            'utf-8'
        );

        return $this;
    }
10799
public function serializePartialToString() {
    $enc = new Encoder();
    $this->outputPartial($enc);
    $res = $enc->toString();

    # Continue to be a little paranoid about the correctness of the protocol
    # buffer implementation.
    if (mt_rand(0, 99) === 0 && $this->byteSizePartial() !== strlen($res)) {
      throw new ProtocolBufferEncodeError(
        "Internal bug: Encoded size doesn't match predicted");
    }
    return $res;
  }
1271161
public function getMsgAlternativeBody()
    {
        if (
            !empty($this->_parts)
            && (
                $this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_ALTERNATIVE
                || $this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_MIXED
            )
        ) {
            foreach ($this->_parts as $part) {
                if ($part->contentType == Content::CT_TEXT_PLAIN) {
                    return $part->getContentDecode();
                }
            }
        }

        return null;
    }
1040163
public function getPayload()
    {
        // APNS base payload structure
        $payload = array(
            'aps' => array(),
        );

        // Build notification
        if ($this->getPayloadAlertKeyValue()) {
            $payload['aps']['alert'] = $this->getPayloadAlertKeyValue();
        }

        // Build extra content
        if (!is_null($this->getBadge())) {
            $payload['aps']['badge'] = $this->getBadge();
        }
        if ($this->getSound() !== self::DEFAULT_SOUND) {
            $payload['aps']['sound'] = $this->getSound();
        }
        if (!is_null($this->getContentAvailable())) {
            $payload['aps']['content-available'] = $this->getContentAvailable();
        }
        if ($this->getCategory()) {
            $payload['aps']['category'] = $this->getCategory();
        }
        if ($this->getData()) {
            $payload['data'] = $this->getData();
        }

        // Return payload
        return $payload;
    }
433512
function message_load($p)
    {
        $engine = $this->enigma->load_engine();

        // handle keys/certs in attachments
        foreach ((array) $p['object']->attachments as $attachment) {
            if ($engine->is_keys_part($attachment)) {
                $this->keys_parts[] = $attachment->mime_id;
            }
        }

        // the same with message bodies
        foreach ((array) $p['object']->parts as $part) {
            if ($engine->is_keys_part($part)) {
                $this->keys_parts[]  = $part->mime_id;
                $this->keys_bodies[] = $part->mime_id;
            }
        }

        // @TODO: inline PGP keys

        if ($this->keys_parts) {
            $this->enigma->add_texts('localization');
        }

        return $p;
    }
105183
final public function getBodyText(): ?string
    {
        $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $part) {
            if (self::SUBTYPE_PLAIN === $part->getSubtype()) {
                return $part->getDecodedContent();
            }
        }

        // If message has no parts, return content of message itself.
        if (self::SUBTYPE_PLAIN === $this->getSubtype()) {
            return $this->getDecodedContent();
        }

        return null;
    }
429620
public function getMultipartHelper()
    {
        if ($this->multipartHelper === null) {
            $this->multipartHelper = new MultipartHelper(
                $this->partFactoryService->getMimePartFactory(),
                $this->partFactoryService->getUUEncodedPartFactory(),
                $this->partBuilderFactory,
                $this->getGenericHelper()
            );
        }
        return $this->multipartHelper;
    }
1059189
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        foreach ($this->texts as $text) {
            $this->message[] = [
                'type' => MessageType::TEXT,
                'text' => $text,
            ];
        }

        if ($this->quickReply) {
            $lastKey = count($this->message) - 1;

            // If the user receives multiple message objects.
            // The quickReply property of the last message object is displayed.
            $this->message[$lastKey]['quickReply'] = $this->quickReply->buildQuickReply();
        }

        return $this->message;
    }
6166
private function getPayload()
    {
        $payloads = [
            'json' => Utils::findKey($this->options, 'json', false),
            'query' => Utils::findKey($this->options, 'query', false),
            'similar' => [
                'query' => [
                    'more_like_this' => [
                        'fields' => $this->fields,
                        'like_text' => $this->term,
                        'min_doc_freq' => 1,
                        'min_term_freq' => 1,
                        'analyzer' => "larasearch_search2"
                    ]
                ]
            ],
            'autocomplete' => [
                'query' => [
                    'multi_match' => [
                        'fields' => $this->fields,
                        'query' => $this->term,
                        'analyzer' => "larasearch_autocomplete_search"
                    ]
                ]
            ]
        ];

        // Find the correct payload based on the options
        $payload_key = array_intersect_key($this->options, $payloads);

        $operator = Utils::findKey($this->options, 'operator', 'and');

        if (count($payload_key) == 1)
        {
            $this->payload = array_merge($this->payload, $payloads[key($payload_key)]);
        } elseif (count($payload_key) == 0)
        {
            if ($this->term == '*')
            {
                $payload = ['match_all' => []];
            } else
            {
                $queries = [];

                foreach ($this->fields as $field)
                {
                    $qs = [];

                    $shared_options = [
                        'query' => $this->term,
                        'operator' => $operator,
                        'boost' => 1
                    ];

                    if ($field == '_all' || substr_compare($field, '.analyzed', -9, 9) === 0)
                    {
                        $qs = array_merge($qs, [
                                array_merge($shared_options, ['boost' => 10, 'analyzer' => "larasearch_search"]),
                                array_merge($shared_options, ['boost' => 10, 'analyzer' => "larasearch_search2"])
                            ]
                        );
                        if ($misspellings = Utils::findKey($this->options, 'misspellings', false))
                        {
                            $distance = 1;
                            $qs = array_merge($qs, [
                                    array_merge($shared_options, ['fuzziness' => $distance, 'max_expansions' => 3, 'analyzer' => "larasearch_search"]),
                                    array_merge($shared_options, ['fuzziness' => $distance, 'max_expansions' => 3, 'analyzer' => "larasearch_search2"])
                                ]
                            );

                        }
                    } elseif (substr_compare($field, '.exact', -6, 6) === 0)
                    {
                        $f = substr($field, 0, -6);
                        $queries[] = [
                            'match' => [
                                $f => array_merge($shared_options, ['analyzer' => 'keyword'])
                            ]
                        ];
                    } else
                    {
                        $analyzer = preg_match('/\.word_(start|middle|end)\z/', $field) ? "larasearch_word_search" : "larasearch_autocomplete_search";
                        $qs[] = array_merge($shared_options, ['analyzer' => $analyzer]);
                    }

                    $queries = array_merge($queries, array_map(function ($q) use ($field)
                    {
                        return ['match' => [$field => $q]];
                    }, $qs));
                }

                $payload = ['dis_max' => ['queries' => $queries]];
            }

            $this->payload['query'] = $payload;
        } else
        {
            // We have multiple query definitions, so abort
            throw new \InvalidArgumentException('Cannot use multiple query definitions.');
        }

        if ($load = Utils::findKey($this->options, 'load', false))
        {
            $this->payload['fields'] = is_array($load) ? $load : [];
        } elseif ($select = Utils::findKey($this->options, 'select', false))
        {
            $this->payload['fields'] = $select;
        }
    }
32670
public function getPayload()
    {
        $payload = $this->payload;

        // The "message" property is deprecated and replaced by "error_description"
        // TODO: remove "message" property
        if (isset($payload['error_description']) && !isset($payload['message'])) {
            $payload['message'] = $payload['error_description'];
        }

        return $payload;
    }
564153
public function getPart($num)
    {
        --$num;
        if (!isset($this->_partPos[$num])) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('part not found');
        }

        return new self(array('file' => $this->_fh, 'startPos' => $this->_partPos[$num][0],
                              'endPos' => $this->_partPos[$num][1]));
    }
76238
public function getPublicKey() {
        return (string) $this->encryptor->decrypt($this->getValue(
            self::KEY_PUBLIC_KEY,
            $this->storeManager->getStore()
        ));
    }
464444
public function get_body($uid, $part = 1)
    {
        $headers = $this->get_message_headers($uid);
        return rcube_charset::convert($this->get_message_part($uid, $part, null),
            $headers->charset ?: $this->default_charset);
    }
203833
public function assembleAttachmentBody()
    {
        $body = array();
        $body[] = "This is a multi-part message in MIME format.";
        $body[] = "--{$this->_uid}";
        $body[] = "Content-Type: text/html; charset=\"utf-8\"";
        $body[] = "Content-Transfer-Encoding: quoted-printable";
        $body[] = "";
        $body[] = quoted_printable_encode($this->_message);
        $body[] = "";
        $body[] = "--{$this->_uid}";

        foreach ($this->_attachments as $attachment) {
            $body[] = $this->getAttachmentMimeTemplate($attachment);
        }

        return implode(PHP_EOL, $body) . '--';
    }
249918
function payload()
    {
        if ( $this->IsFault )
        {
            $payload = xmlrpc_encode( array(
                "faultCode" => $this->FaultCode,
                "faultString" => $this->FaultString ) );
            return str_replace( array( '<fault>', '</fault>' ), array( '<methodResponse><fault>', '</fault></methodResponse>' ), $payload );
        }
        else
        {
            $payload = xmlrpc_encode( $this->Value );
            /// @todo verify if user gave us back an array with faultString / faultCode members,
            ///       as we will be sending back junk in that case...
            return str_replace( array( '<params>', '</params>' ), array( '<methodResponse><params>', '</params></methodResponse>' ), $payload );
        }
    }