protected function _loginTasks($firstlogin = true, array $resp = array())
    {
        /* If reusing an imapproxy connection, no need to do any of these
         * login tasks again. */
        if (!$firstlogin && !empty($resp['proxyreuse'])) {
            if (isset($this->_init['enabled'])) {
                foreach ($this->_init['enabled'] as $val) {
                    $this->_capability()->enable($val);
                }
            }

            // If we have not yet set the language, set it now.
            if (!isset($this->_init['lang'])) {
                $this->_temp['lang_queue'] = true;
                $this->setLanguage();
                unset($this->_temp['lang_queue']);
            }
            return false;
        }

        /* If we logged in for first time, and server did not return
         * capability information, we need to mark for retrieval. */
        if ($firstlogin && empty($resp['capability_set'])) {
            $this->_setInit('capability');
        }

        $this->_temp['lang_queue'] = true;
        $this->setLanguage();
        unset($this->_temp['lang_queue']);

        /* Only active QRESYNC/CONDSTORE if caching is enabled. */
        $enable = array();
        if ($this->_initCache()) {
            if ($this->_capability('QRESYNC')) {
                $enable[] = 'QRESYNC';
            } elseif ($this->_capability('CONDSTORE')) {
                $enable[] = 'CONDSTORE';
            }
        }

        /* Use UTF8=ACCEPT, if available. */
        if ($this->_capability('UTF8', 'ACCEPT')) {
            $enable[] = 'UTF8=ACCEPT';
        }

        $this->_enable($enable);

        return true;
    }