Commit 45c60521 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 94066044 b7abc03e
......@@ -9,7 +9,7 @@
#define BOTAN_VERSION_PATCH 8
#ifndef BOTAN_DLL
#define BOTAN_DLL
#define BOTAN_DLL __attribute__ ((visibility("default")))
#endif
/* Chunk sizes */
......
......@@ -15,6 +15,7 @@
***************************************************************************/
#include <signal.h>
#include <string.h>
#include <time.h>
#include <botan/init.h>
#include <botan/auto_rng.h>
......@@ -634,6 +635,35 @@ const char* ne7ssh::read (int channel, bool do_lock)
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)
{
uint32 i;
......
......@@ -245,6 +245,17 @@ class SSH_EXPORT ne7ssh
*/
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.
* @param channel Channel to read data on.
......
......@@ -450,3 +450,7 @@ bool ne7ssh_channel::adjustRecvWindow (int bufferSize)
return true;
}
void ne7ssh_channel::resetReceiveBuffer()
{
inBuffer.clear();
}
......@@ -220,6 +220,9 @@ class ne7ssh_channel
* @return Size of the send window.
*/
uint32 getSendWindow () { return windowSend; }
/** Empties the receive buffer. */
void resetReceiveBuffer();
};
#endif
......@@ -338,3 +338,8 @@ bool ne7ssh_connection::isSftpActive ()
if (sftp) return true;
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.
*/
bool isSftpActive ();
/** Empties this connection's receive buffer. */
void resetReceiveBuffer();
};
#endif
......@@ -39,7 +39,7 @@
# endif
#else
# include <inttypes.h>
# define SSH_EXPORT
# define SSH_EXPORT __attribute__ ((visibility("default")))
#endif
#ifndef int64_defined
......@@ -88,7 +88,7 @@ typedef uint8_t Byte;
#endif
#if defined(WIN32) || defined(__MINGW32__)
# define usleep(time) Sleep(time)
# define usleep(time) Sleep(time / 1000)
#endif
#endif
......
......@@ -15,7 +15,7 @@ win32 {
win32-msvc*: QMAKE_CXXFLAGS += -wd4250 -wd4251 -wd4290
DEFINES += _CRT_SECURE_NO_WARNINGS
DEFINES += NE7SSH_EXPORTS _WINDLL _USRDLL _CONSOLE _WINDOWS
DEFINES += NE7SSH_EXPORTS=1 _WINDLL _USRDLL _CONSOLE _WINDOWS
}
# Input
......
......@@ -41,9 +41,10 @@ class CORE_EXPORT IVersionControl : public QObject
{
Q_OBJECT
public:
enum Operation { AddOperation, DeleteOperation, OpenOperation };
enum Operation { AddOperation, DeleteOperation, OpenOperation,
CreateRepositoryOperation };
IVersionControl(QObject *parent = 0) : QObject(parent) {}
explicit IVersionControl(QObject *parent = 0) : QObject(parent) {}
virtual ~IVersionControl() {}
virtual QString displayName() const = 0;
......@@ -93,12 +94,14 @@ public:
/*!
* Called after a file has been removed from the project (if the user
* wants), e.g. 'p4 delete', 'svn delete'.
*
* You probably want to call VcsManager::showDeleteDialog, which asks the
* user to confirm the deletion.
*/
virtual bool vcsDelete(const QString &filename) = 0;
/*!
* Called to initialize the version control systemin a directory.
*/
virtual bool vcsCreateRepository(const QString &directory) = 0;
signals:
void repositoryChanged(const QString &repository);
void filesChanged(const QStringList &files);
......
......@@ -605,7 +605,6 @@ CPPEditor::CPPEditor(QWidget *parent)
, m_inRename(false)
, m_inRenameChanged(false)
, m_firstRenameChange(false)
, m_allowSkippingOfBlockEnd(false)
{
m_initialized = false;
qRegisterMetaType<SemanticInfo>("SemanticInfo");
......@@ -1510,209 +1509,19 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
return false;
}
static void countBracket(QChar open, QChar close, QChar c, int *errors, int *stillopen)
QString CPPEditor::insertMatchingBrace(const QTextCursor &tc, const QString &text,
const QChar &la, int *skippedChars) const
{
if (c == open)
++*stillopen;
else if (c == close)
--*stillopen;
if (*stillopen < 0) {
*errors += -1 * (*stillopen);
*stillopen = 0;
}
}
void countBrackets(QTextCursor cursor, int from, int end, QChar open, QChar close, int *errors, int *stillopen)
{
cursor.setPosition(from);
QTextBlock block = cursor.block();
while (block.isValid() && block.position() < end) {
TextEditor::Parentheses parenList = TextEditor::TextEditDocumentLayout::parentheses(block);
if (!parenList.isEmpty() && !TextEditor::TextEditDocumentLayout::ifdefedOut(block)) {
for (int i = 0; i < parenList.count(); ++i) {
TextEditor::Parenthesis paren = parenList.at(i);
int position = block.position() + paren.pos;
if (position < from || position >= end)
continue;
countBracket(open, close, paren.chr, errors, stillopen);
}
}
block = block.next();
}
MatchingText m;
return m.insertMatchingBrace(tc, text, la, skippedChars);
}
QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert) const
QString CPPEditor::insertParagraphSeparator(const QTextCursor &tc) const
{
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
m_allowSkippingOfBlockEnd = false; // consume blockEnd.
if (!contextAllowsAutoParentheses(cursor, textToInsert))
return QString();
QString text = textToInsert;
const QChar lookAhead = characterAt(cursor.selectionEnd());
QChar character = textToInsert.at(0);
QString parentheses = QLatin1String("()");
QString brackets = QLatin1String("[]");
if (parentheses.contains(character) || brackets.contains(character)) {
QTextCursor tmp= cursor;
TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
int blockStart = tmp.isNull() ? 0 : tmp.position();
tmp = cursor;
TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp);
int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position();
QChar openChar = parentheses.contains(character) ? QLatin1Char('(') : QLatin1Char('[');
QChar closeChar = parentheses.contains(character) ? QLatin1Char(')') : QLatin1Char(']');
int errors = 0;
int stillopen = 0;
countBrackets(cursor, blockStart, blockEnd, openChar, closeChar, &errors, &stillopen);
int errorsBeforeInsertion = errors + stillopen;
errors = 0;
stillopen = 0;
countBrackets(cursor, blockStart, cursor.position(), openChar, closeChar, &errors, &stillopen);
countBracket(openChar, closeChar, character, &errors, &stillopen);
countBrackets(cursor, cursor.position(), blockEnd, openChar, closeChar, &errors, &stillopen);
int errorsAfterInsertion = errors + stillopen;
if (errorsAfterInsertion < errorsBeforeInsertion)
return QString(); // insertion fixes parentheses or bracket errors, do not auto complete
}
MatchingText matchingText;
int skippedChars = 0;
const QString autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);
if (checkBlockEnd && textToInsert.at(0) == QLatin1Char('}')) {
if (textToInsert.length() > 1)
qWarning() << "*** handle event compression";
int startPos = cursor.selectionEnd(), pos = startPos;
while (characterAt(pos).isSpace())
++pos;
if (characterAt(pos) == QLatin1Char('}'))
skippedChars += (pos - startPos) + 1;
}
if (skippedChars) {
const int pos = cursor.position();
cursor.setPosition(pos + skippedChars);
cursor.setPosition(pos, QTextCursor::KeepAnchor);
}
return autoText;
MatchingText m;
return m.insertParagraphSeparator(tc);
}
bool CPPEditor::autoBackspace(QTextCursor &cursor)
{
m_allowSkippingOfBlockEnd = false;
int pos = cursor.position();
QTextCursor c = cursor;
c.setPosition(pos - 1);
QChar lookAhead = characterAt(pos);
QChar lookBehind = characterAt(pos-1);
QChar lookFurtherBehind = characterAt(pos-2);
QChar character = lookBehind;
if (character == QLatin1Char('(') || character == QLatin1Char('[')) {
QTextCursor tmp = cursor;
TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
int blockStart = tmp.isNull() ? 0 : tmp.position();
tmp = cursor;
TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp);
int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position();
QChar openChar = character;
QChar closeChar = (character == QLatin1Char('(')) ? QLatin1Char(')') : QLatin1Char(']');
int errors = 0;
int stillopen = 0;
countBrackets(cursor, blockStart, blockEnd, openChar, closeChar, &errors, &stillopen);
int errorsBeforeDeletion = errors + stillopen;
errors = 0;
stillopen = 0;
countBrackets(cursor, blockStart, pos - 1, openChar, closeChar, &errors, &stillopen);
countBrackets(cursor, pos, blockEnd, openChar, closeChar, &errors, &stillopen);
int errorsAfterDeletion = errors + stillopen;
if (errorsAfterDeletion < errorsBeforeDeletion)
return false; // insertion fixes parentheses or bracket errors, do not auto complete
}
if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
&& lookFurtherBehind != QLatin1Char('\\'))
|| (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'')
&& lookFurtherBehind != QLatin1Char('\\'))) {
if (! isInComment(c)) {
cursor.beginEditBlock();
cursor.deleteChar();
cursor.deletePreviousChar();
cursor.endEditBlock();
return true;
}
}
return false;
}
int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
{
if (characterAt(cursor.position()-1) != QLatin1Char('{'))
return 0;
if (!contextAllowsAutoParentheses(cursor))
return 0;
// verify that we indeed do have an extra opening brace in the document
int braceDepth = document()->lastBlock().userState();
if (braceDepth >= 0)
braceDepth >>= 8;
else
braceDepth= 0;
if (braceDepth <= 0)
return 0; // braces are all balanced or worse, no need to do anything
// we have an extra brace , let's see if we should close it
/* verify that the next block is not further intended compared to the current block.
This covers the following case:
if (condition) {|
statement;
*/
const TabSettings &ts = tabSettings();
QTextBlock block = cursor.block();
int indentation = ts.indentationColumn(block.text());
if (block.next().isValid()
&& ts.indentationColumn(block.next().text()) > indentation)
return 0;
int pos = cursor.position();
MatchingText matchingText;
const QString textToInsert = matchingText.insertParagraphSeparator(cursor);
cursor.insertText(textToInsert);
cursor.setPosition(pos);
if (ts.m_autoIndent) {
cursor.insertBlock();
indent(document(), cursor, QChar::Null);
} else {
QString previousBlockText = cursor.block().text();
cursor.insertBlock();
cursor.insertText(ts.indentationString(previousBlockText));
}
cursor.setPosition(pos);
m_allowSkippingOfBlockEnd = true;
return 1;
}
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor,
const QString &textToInsert) const
......
......@@ -214,15 +214,17 @@ protected:
TextEditor::BaseTextEditorEditable *createEditableInterface();
// These override BaseTextEditor
bool isElectricCharacter(const QChar &ch) const;
QString autoComplete(QTextCursor &cursor, const QString &text) const;
bool autoBackspace(QTextCursor &cursor);
int paragraphSeparatorAboutToBeInserted(QTextCursor &cursor);
virtual bool isElectricCharacter(const QChar &ch) const;
bool contextAllowsAutoParentheses(const QTextCursor &cursor,
const QString &textToInsert = QString()) const;
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
const QChar &la, int *skippedChars) const;
bool isInComment(const QTextCursor &cursor) const;
virtual QString insertParagraphSeparator(const QTextCursor &tc) const;
virtual bool contextAllowsAutoParentheses(const QTextCursor &cursor,
const QString &textToInsert = QString()) const;
virtual bool isInComment(const QTextCursor &cursor) const;
CPlusPlus::Symbol *findCanonicalSymbol(const QTextCursor &cursor,
CPlusPlus::Document::Ptr doc,
......@@ -304,8 +306,6 @@ private:
QTextCursor m_currentRenameSelectionBegin;
QTextCursor m_currentRenameSelectionEnd;
mutable bool m_allowSkippingOfBlockEnd;
SemanticHighlighter *m_semanticHighlighter;
SemanticInfo m_lastSemanticInfo;
QList<QuickFixOperationPtr> m_quickFixes;
......
......@@ -76,6 +76,7 @@ public:
QStringList sourceFiles;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
};
class WorkingCopy
......
......@@ -54,6 +54,7 @@ bool CVSControl::supportsOperation(Operation operation) const
case DeleteOperation:
break;
case OpenOperation:
case CreateRepositoryOperation:
rc = false;
break;
}
......@@ -78,6 +79,11 @@ bool CVSControl::vcsDelete(const QString &fileName)
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
}
bool CVSControl::vcsCreateRepository(const QString &)
{
return false;
}
bool CVSControl::managesDirectory(const QString &directory) const
{
return m_plugin->managesDirectory(directory);
......
......@@ -52,6 +52,7 @@ public:
virtual bool vcsOpen(const QString &fileName);
virtual bool vcsAdd(const QString &fileName);
virtual bool vcsDelete(const QString &filename);
virtual bool vcsCreateRepository(const QString &directory);
void emitRepositoryChanged(const QString &s);
void emitFilesChanged(const QStringList &l);
......
......@@ -498,7 +498,7 @@ CVSSubmitEditor *CVSPlugin::openCVSSubmitEditor(const QString &fileName)
void CVSPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
{
if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction))
if (!enableMenuAction(as, m_menuAction))
return;
m_logRepositoryAction->setEnabled(currentState().hasTopLevel());
......
......@@ -841,7 +841,11 @@ void GdbEngine::commandTimeout()
const GdbCommand &cmd = m_cookieForToken.value(key);
if (!(cmd.flags & NonCriticalResponse))
killIt = true;
debugMessage(_(" %1: %2 => %3").arg(key).arg(_(cmd.command)).arg(_(cmd.callbackName)));
QByteArray msg = QByteArray::number(key);
msg += ": " + cmd.command + " => ";
QTC_ASSERT(cmd.callbackName, /**/);
msg += cmd.callbackName;
debugMessage(_(msg));
}
if (killIt) {
debugMessage(_("TIMED OUT WAITING FOR GDB REPLY. COMMANDS STILL IN PROGRESS:"));
......@@ -851,7 +855,7 @@ void GdbEngine::commandTimeout()
"to a command within %1 seconds. This may been it is stuck "
"in an endless loop or taking longer than expected to perform "
"the operation it was reqested.\nYou have a choice of waiting "
"longer or abort debugging.").arg(timeOut);
"longer or abort debugging.").arg(timeOut / 1000);
QMessageBox *mb = showMessageBox(QMessageBox::Critical,
tr("Gdb not responding"), msg,
QMessageBox::Ok | QMessageBox::Cancel);
......@@ -865,6 +869,8 @@ void GdbEngine::commandTimeout()
} else {
debugMessage(_("CONTINUE DEBUGGER AS REQUESTED BY USER"));
}
} else {
debugMessage(_("\nNON-CRITICAL TIMEOUT\n"));
}
}
......@@ -4495,6 +4501,8 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
postCommand("set breakpoint pending on");
postCommand("set print elements 10000");
// Produces a few messages during symtab loading
//postCommand("set verbose on");
//postCommand("set substitute-path /var/tmp/qt-x11-src-4.5.0 "
// "/home/sandbox/qtsdk-2009.01/qt");
......
......@@ -446,6 +446,22 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
return true;
}
// Initialize repository
bool GitClient::synchronousInit(const QString &workingDirectory)
{
if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << workingDirectory;
QByteArray outputText;
QByteArray errorText;
const QStringList arguments(QLatin1String("init"));
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
// '[Re]Initialized...'
VCSBase::VCSBaseOutputWindow::instance()->append(QString::fromLocal8Bit(outputText));
if (!rc)
VCSBase::VCSBaseOutputWindow::instance()->append(QString::fromLocal8Bit(errorText));
return rc;
}
bool GitClient::synchronousCheckout(const QString &workingDirectory,
const QStringList &files,
QString *errorMessage)
......
......@@ -92,6 +92,7 @@ public:
bool synchronousAdd(const QString &workingDirectory, const QStringList &files);
bool synchronousReset(const QString &workingDirectory, const QStringList &files);
bool synchronousReset(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
bool synchronousInit(const QString &workingDirectory);
bool synchronousCheckout(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
bool synchronousStash(const QString &workingDirectory, QString *errorMessage);
bool synchronousBranchCmd(const QString &workingDirectory, QStringList branchArgs,
......
......@@ -122,6 +122,7 @@ GitPlugin::GitPlugin() :
m_undoFileAction(0),
m_logRepositoryAction(0),
m_undoRepositoryAction(0),
m_createRepositoryAction(0),
m_showAction(0),
m_stageAction(0),
m_unstageAction(0),
......@@ -306,6 +307,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_undoRepositoryAction, SIGNAL(triggered()), this, SLOT(undoRepositoryChanges()));
gitContainer->addAction(command);
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
command = actionManager->registerAction(m_createRepositoryAction, "Git.CreateRepository", globalcontext);
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
gitContainer->addAction(command);
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Global"), this));
m_stashAction = new QAction(tr("Stash"), this);
......@@ -677,9 +683,10 @@ void GitPlugin::stashList()
void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
{
if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction))
if (!enableMenuAction(as, m_menuAction))
return;
// Note: This menu is visible if there is no repository. Only
// 'Create Repository'/'Show' actions should be available.
const QString fileName = currentState().currentFileName();
m_diffAction->setParameter(fileName);
m_logAction->setParameter(fileName);
......@@ -708,9 +715,13 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_statusRepositoryAction->setEnabled(repositoryEnabled);
m_branchListAction->setEnabled(repositoryEnabled);
m_stashListAction->setEnabled(repositoryEnabled);
m_stashAction->setEnabled(repositoryEnabled);