summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/smb/src/Connection.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src/Connection.php')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Connection.php40
1 files changed, 11 insertions, 29 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Connection.php b/apps/files_external/3rdparty/icewind/smb/src/Connection.php
index d24cdc1f6d0..c1ebb861711 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Connection.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Connection.php
@@ -17,6 +17,14 @@ class Connection extends RawConnection {
const DELIMITER = 'smb:';
const DELIMITER_LENGTH = 4;
+ /** @var Parser */
+ private $parser;
+
+ public function __construct($command, Parser $parser, $env = array()) {
+ parent::__construct($command, $env);
+ $this->parser = $parser;
+ }
+
/**
* send input to smbclient
*
@@ -30,7 +38,7 @@ class Connection extends RawConnection {
* get all unprocessed output from smbclient until the next prompt
*
* @param callable $callback (optional) callback to call for every line read
- * @return string
+ * @return string[]
* @throws AuthenticationException
* @throws ConnectException
* @throws ConnectionException
@@ -42,7 +50,7 @@ class Connection extends RawConnection {
throw new ConnectionException('Connection not valid');
}
$promptLine = $this->readLine(); //first line is prompt
- $this->checkConnectionError($promptLine);
+ $this->parser->checkConnectionError($promptLine);
$output = array();
$line = $this->readLine();
@@ -54,6 +62,7 @@ class Connection extends RawConnection {
$result = $callback($line);
if ($result === false) { // allow the callback to close the connection for infinite running commands
$this->close(true);
+ break;
}
} else {
$output[] .= $line;
@@ -90,33 +99,6 @@ class Connection extends RawConnection {
}
}
- /**
- * check if the first line holds a connection failure
- *
- * @param $line
- * @throws AuthenticationException
- * @throws InvalidHostException
- * @throws NoLoginServerException
- */
- private function checkConnectionError($line) {
- $line = rtrim($line, ')');
- if (substr($line, -23) === ErrorCodes::LogonFailure) {
- throw new AuthenticationException('Invalid login');
- }
- if (substr($line, -26) === ErrorCodes::BadHostName) {
- throw new InvalidHostException('Invalid hostname');
- }
- if (substr($line, -22) === ErrorCodes::Unsuccessful) {
- throw new InvalidHostException('Connection unsuccessful');
- }
- if (substr($line, -28) === ErrorCodes::ConnectionRefused) {
- throw new InvalidHostException('Connection refused');
- }
- if (substr($line, -26) === ErrorCodes::NoLogonServers) {
- throw new NoLoginServerException('No login server');
- }
- }
-
public function close($terminate = true) {
if (is_resource($this->getInputStream())) {
$this->write('close' . PHP_EOL);