forked from qt-creator/qt-creator
Maemo: Patch Net7 library to enable continuous reading.
This commit is contained in:
30
src/libs/3rdparty/net7ssh/src/ne7ssh.cpp
vendored
30
src/libs/3rdparty/net7ssh/src/ne7ssh.cpp
vendored
@@ -15,6 +15,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <botan/init.h>
|
#include <botan/init.h>
|
||||||
#include <botan/auto_rng.h>
|
#include <botan/auto_rng.h>
|
||||||
@@ -634,6 +635,35 @@ const char* ne7ssh::read (int channel, bool do_lock)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *ne7ssh::readAndReset(int channel, char *(*alloc)(size_t))
|
||||||
|
{
|
||||||
|
if (channel == -1)
|
||||||
|
{
|
||||||
|
errs->push (-1, "Bad channel: %i specified for reading.", channel);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!lock()) return 0;
|
||||||
|
char *buffer = 0;
|
||||||
|
for (uint32 i = 0; i < conCount; i++)
|
||||||
|
{
|
||||||
|
SecureVector<Botan::byte> data;
|
||||||
|
if (channel == connections[i]->getChannelNo())
|
||||||
|
{
|
||||||
|
data = connections[i]->getReceived();
|
||||||
|
if (data.size())
|
||||||
|
{
|
||||||
|
buffer = alloc(connections[i]->getReceived().size());
|
||||||
|
strcpy(buffer, reinterpret_cast<char*>(connections[i]->getReceived().begin()));
|
||||||
|
connections[i]->resetReceiveBuffer();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!unlock()) return false;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void* ne7ssh::readBinary (int channel)
|
void* ne7ssh::readBinary (int channel)
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|||||||
11
src/libs/3rdparty/net7ssh/src/ne7ssh.h
vendored
11
src/libs/3rdparty/net7ssh/src/ne7ssh.h
vendored
@@ -245,6 +245,17 @@ class SSH_EXPORT ne7ssh
|
|||||||
*/
|
*/
|
||||||
const char* read (int channel, bool do_lock=true);
|
const char* read (int channel, bool do_lock=true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads all data from receiving buffer on specified channel into a newly
|
||||||
|
* allocated buffer and empties the receive buffer afterwards.
|
||||||
|
* @param channel Channel to read data on.
|
||||||
|
* @param alloc Pointer to function allocating the memory for the buffer
|
||||||
|
* to return.
|
||||||
|
* @return Returns string read from receiver buffer or 0 if buffer is empty.
|
||||||
|
* Freeing the returned buffer is the user's responsibility.
|
||||||
|
*/
|
||||||
|
char* readAndReset (int channel, char* (*alloc)(size_t));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads all data from receiving buffer on specified channel. Returns pointer to void. Together with getReceivedSize and sendCmd can be used to read remote files.
|
* Reads all data from receiving buffer on specified channel. Returns pointer to void. Together with getReceivedSize and sendCmd can be used to read remote files.
|
||||||
* @param channel Channel to read data on.
|
* @param channel Channel to read data on.
|
||||||
|
|||||||
@@ -450,3 +450,7 @@ bool ne7ssh_channel::adjustRecvWindow (int bufferSize)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ne7ssh_channel::resetReceiveBuffer()
|
||||||
|
{
|
||||||
|
inBuffer.clear();
|
||||||
|
}
|
||||||
|
|||||||
@@ -220,6 +220,9 @@ class ne7ssh_channel
|
|||||||
* @return Size of the send window.
|
* @return Size of the send window.
|
||||||
*/
|
*/
|
||||||
uint32 getSendWindow () { return windowSend; }
|
uint32 getSendWindow () { return windowSend; }
|
||||||
|
|
||||||
|
/** Empties the receive buffer. */
|
||||||
|
void resetReceiveBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -338,3 +338,8 @@ bool ne7ssh_connection::isSftpActive ()
|
|||||||
if (sftp) return true;
|
if (sftp) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ne7ssh_connection::resetReceiveBuffer()
|
||||||
|
{
|
||||||
|
channel->resetReceiveBuffer();
|
||||||
|
}
|
||||||
|
|||||||
@@ -228,6 +228,9 @@ class ne7ssh_connection
|
|||||||
* @return True if SFTP subsystem is active, otherwise false.
|
* @return True if SFTP subsystem is active, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool isSftpActive ();
|
bool isSftpActive ();
|
||||||
|
|
||||||
|
/** Empties this connection's receive buffer. */
|
||||||
|
void resetReceiveBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
#include "maemodeviceconfigurations.h"
|
#include "maemodeviceconfigurations.h"
|
||||||
|
|
||||||
#include "/opt/ne7sshModified/include/ne7ssh.h"
|
#include <ne7ssh.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QStringBuilder>
|
#include <QtCore/QStringBuilder>
|
||||||
@@ -57,6 +57,11 @@ namespace Qt4ProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace {
|
namespace {
|
||||||
ne7ssh ssh;
|
ne7ssh ssh;
|
||||||
|
|
||||||
|
char *alloc(size_t n)
|
||||||
|
{
|
||||||
|
return new char[n];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Which encoding to use for file names? Unicode? Latin1? ASCII?
|
// TODO: Which encoding to use for file names? Unicode? Latin1? ASCII?
|
||||||
@@ -127,13 +132,11 @@ void MaemoInteractiveSshConnection::runCommand(const QString &command)
|
|||||||
const char * const error = lastError();
|
const char * const error = lastError();
|
||||||
if (error)
|
if (error)
|
||||||
throw MaemoSshException(tr("SSH error: %1").arg(error));
|
throw MaemoSshException(tr("SSH error: %1").arg(error));
|
||||||
ssh.lock();
|
const char * output = ssh.readAndReset(channel(), alloc);
|
||||||
const char * output = ssh.read(channel(), false);
|
|
||||||
if (output) {
|
if (output) {
|
||||||
emit remoteOutput(QString::fromUtf8(output));
|
emit remoteOutput(QString::fromUtf8(output));
|
||||||
ssh.resetInput(channel(), false);
|
delete[] output;
|
||||||
}
|
}
|
||||||
ssh.unlock();
|
|
||||||
} while (!done && !stopRequested());
|
} while (!done && !stopRequested());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ SUPPORT_QT_MAEMO = $$(QTCREATOR_WITH_MAEMO)
|
|||||||
!isEmpty(SUPPORT_QT_MAEMO) {
|
!isEmpty(SUPPORT_QT_MAEMO) {
|
||||||
message("Adding experimental support for Qt/Maemo applications.")
|
message("Adding experimental support for Qt/Maemo applications.")
|
||||||
DEFINES += QTCREATOR_WITH_MAEMO
|
DEFINES += QTCREATOR_WITH_MAEMO
|
||||||
|
# DEFINES += USE_SSH_LIB
|
||||||
# DEFINES += USE_SSH_LIB
|
# INCLUDEPATH += $$PWD/../../../libs/3rdparty/net7ssh/src
|
||||||
# LIBS += -L/opt/ne7sshModified/lib/ \
|
# LIBS += -L$$PWD/../../../../lib/qtcreator -lNet7ssh
|
||||||
# -lnet7ssh
|
|
||||||
HEADERS += $$PWD/maemorunconfiguration.h \
|
HEADERS += $$PWD/maemorunconfiguration.h \
|
||||||
$$PWD/maemomanager.h \
|
$$PWD/maemomanager.h \
|
||||||
$$PWD/maemotoolchain.h \
|
$$PWD/maemotoolchain.h \
|
||||||
|
|||||||
Reference in New Issue
Block a user