diff --git a/.gitignore b/.gitignore index c5566d40fa3..38c2d41a532 100644 --- a/.gitignore +++ b/.gitignore @@ -72,7 +72,7 @@ doc/pluginhowto/html/* # Binaries # -------- bin/*.dll -bin/qtcreator.bin +bin/qtcreator bin/qtcreator_process_stub* bin/qtcreator.exe share/doc/qtcreator/qtcreator.qch diff --git a/doc/api/qtcreator-api.qdoc b/doc/api/qtcreator-api.qdoc index aca770d8b7b..f22ef491fee 100644 --- a/doc/api/qtcreator-api.qdoc +++ b/doc/api/qtcreator-api.qdoc @@ -142,7 +142,7 @@ \row \o Add a find filter for the find dialog. \o Implement any kind of search term based search. - \o \l{Find::IFindFilter}, \l{Find::SearchResultWindow}, \l{Find::ResultWindowItem} + \o \l{Find::IFindFilter}, \l{Find::SearchResultWindow} \row \o Add support for the find tool bar to a widget. diff --git a/doc/examples/batteryindicator/main.cpp b/doc/examples/batteryindicator/main.cpp index 2674f5de173..4d85d5cdc76 100644 --- a/doc/examples/batteryindicator/main.cpp +++ b/doc/examples/batteryindicator/main.cpp @@ -5,11 +5,14 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); BatteryIndicator w; + +//! [0] #if defined(Q_WS_S60) w.showMaximized(); #else w.show(); #endif +//! [0] return a.exec(); } diff --git a/doc/examples/doc_src_plugins.qdoc b/doc/examples/doc_src_plugins.qdoc new file mode 100644 index 00000000000..efcdab026c2 --- /dev/null +++ b/doc/examples/doc_src_plugins.qdoc @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +otool -L /Developer/Applications/Qt/plugins/designer/libqwt_designer_plugin.dylib +//! [0] + + +//! [1] +/Developer/Applications/Qt/plugins/designer/libqwt_designer_plugin.dylib: + libqwt_designer_plugin.dylib (compatibility version 0.0.0, current version 0.0.0) + libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1) + QtDesigner.framework/Versions/4/QtDesigner (compatibility version 4.6.0, current version 4.6.2) + QtScript.framework/Versions/4/QtScript (compatibility version 4.6.0, current version 4.6.2) + QtXml.framework/Versions/4/QtXml (compatibility version 4.6.0, current version 4.6.2) + QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2) + QtCore.framework/Versions/4/QtCore (compatibility version 4.6.0, current version 4.6.2) + /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0) + /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 438.0.0) + /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1) +//! [1] + +//! [2] +otool -L /usr/local/qwt-5.2.1/lib/libqwt.5.dylib +//! [2] + + +//! [3] +/usr/local/qwt-5.2.1/lib/libqwt.5.dylib: + libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1) + QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2) + QtCore.framework/Versions/4/QtCore (compatibility version 4.6.0, current version 4.6.2) + /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0) + /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 438.0.0) + /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1) +//! [3] + + +//! [4] +sudo cp /Developer/Applications/Qt/plugins/designer/libqwt_designer_plugin.dylib \ + /Developer/Applications/Qt/Qt\ Creator.app/Contents/MacOS/designer +sudo cp -R /usr/local/qwt-5.2.1/lib/* \ + /Developer/Applications/Qt/Qt\ Creator.app/Contents/Frameworks/ +//! [4] + + +//! [5] +cd /Developer/Applications/Qt/Qt\ Creator.app/Contents/MacOS/designer +sudo install_name_tool -change + QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/libQtCore.4.dylib \ + libqwt_designer_plugin.dylib +sudo install_name_tool -change QtGui.framework/Versions/4/QtGui \ + @executable_path/../Frameworks/libQtGui.4.dylib \ + libqwt_designer_plugin.dylib +sudo install_name_tool -change QtXml.framework/Versions/4/QtXml \ + @executable_path/../Frameworks/libQtXml.4.dylib \ + libqwt_designer_plugin.dylib +sudo install_name_tool -change QtScript.framework/Versions/4/QtScript \ + @executable_path/../Frameworks/libQtScript.4.dylib \ + libqwt_designer_plugin.dylib +sudo install_name_tool -change QtDesigner.framework/Versions/4/QtDesigner \ + @executable_path/../Frameworks/libQtDesigner.4.dylib \ + libqwt_designer_plugin.dylib +sudo install_name_tool -change libqwt.5.dylib \ + @executable_path/../Frameworks/libqwt.5.dylib \ + libqwt_designer_plugin.dylib + +cd /Developer/Applications/Qt/Qt\ Creator.app/Contents/Frameworks +sudo install_name_tool -change \ + QtCore.framework/Versions/4/QtCore \ + @executable_path/../Frameworks/libQtCore.4.dylib \ + libqwt.5.2.1.dylib +sudo install_name_tool -change \ + QtGui.framework/Versions/4/QtGui \ + @executable_path/../Frameworks/libQtGui.4.dylib \ + libqwt.5.2.1.dylib +//! [5] diff --git a/doc/images/qtcreator-overview.png b/doc/images/qtcreator-overview.png index 3f5dd24020c..aeb62029c15 100644 Binary files a/doc/images/qtcreator-overview.png and b/doc/images/qtcreator-overview.png differ diff --git a/doc/images/qtcreator-texfinder-filter.png b/doc/images/qtcreator-texfinder-filter.png new file mode 100644 index 00000000000..b40ea9b37ee Binary files /dev/null and b/doc/images/qtcreator-texfinder-filter.png differ diff --git a/doc/qt-defines.qdocconf b/doc/qt-defines.qdocconf index 3a857bd28e8..a9e8bbd23f7 100644 --- a/doc/qt-defines.qdocconf +++ b/doc/qt-defines.qdocconf @@ -32,6 +32,7 @@ extraimages.HTML = qt-logo \ bg_ll_blank.png \ bg_l_blank.png \ breadcrumb.png \ + bullet_up.png \ bullet_dn.png \ bullet_gt.png \ bullet_sq.png \ diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 8bfa5d5c87b..0e01f2caca7 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -92,19 +92,12 @@ \o \l{Using the Maemo Emulator} \o \l{Debugging} - \list - \o \l {Debugging Qt Applications} \list \o \l{Debugging the Example Application} \o \l{Interacting with the Debugger} \o \l{Setting Up Debugger} \o \l{Using Debugging Helpers} \endlist - \o \l{Debugging Qt Quick Applications} - \list - \o \l{Using the QML Inspector} - \endlist - \endlist \o \l{Using the Maemo Emulator} \o \l{Using Version Control Systems} @@ -551,6 +544,11 @@ an open output pane, click the \gui {Maximize Output Pane} button or press \key {Alt+9}. + To search within the \gui{Application Output} and \gui{Compile Output} + panes, press \key {Ctrl+F} when the pane is active. Enter search + criteria in the \gui Find field and click the left and right arrows to + search down and up in the pane. + To open the \gui{General Messages} and \gui{Version Control} panes, select \gui {Window > Output Panes}. @@ -824,20 +822,20 @@ \image qtcreator-editortoolbar-symbols.png - Use the toolbar to navigate between open files and symbols in use: - \list - \o To browse forward or backward through your location history, click + Use the toolbar to navigate between open files and symbols in use. + To browse forward or backward through your location history, click \inlineimage qtcreator-back.png and \inlineimage qtcreator-forward.png . - \o To go to any open file, select it from the \gui{Open files} - drop-down menu. - \o To jump to any symbol used in the current file, select it from the - \gui Symbols drop-down menu. - \endlist - When you create or edit forms in a \c{.ui} file, the toolbar contains - Qt Designer specific tools. + To go to any open file, select it from the \gui{Open files} drop-down menu. + Right-click the menu title and select \gui {Copy Full Path to Clipboard} to + copy the path and name of the current file to the clipboard. + + To jump to any symbol used in the current file, select it from the + \gui Symbols drop-down menu. By default, the symbols are displayed in the + order in which they appear in the file. Right-click the menu title and select + \gui {Sort Alphabetically} to arrange the symbols in alphabetic order. \section1 Splitting the Editor View @@ -1438,7 +1436,7 @@ \section1 Renaming Symbols - The functions used to rename symbols depends on whether you are + The functions available for renaming symbols depend on whether you are writing C++ or QML code. For QML, you can only rename IDs. To rename a specific symbol in a Qt project: @@ -1601,6 +1599,8 @@ The wizards prompt you to enter the settings needed for that particular type of project and create the necessary files for you. + To display other types of files in the \gui Projects pane, specify them in + the project file. \image qtcreator-new-project.png @@ -1637,6 +1637,25 @@ \image qtcreator-new-project-summary.png \endlist + \section1 Displaying Additional File Types in Projects Pane + + Qt Creator determines whether to display files from the project folder + in the \gui Projects pane depending on the file type (.pro, .pri, .cpp, + .h, .ui, .qrc, and so on). To display other types of files, edit the the + project file. Add filenames as values of the \c {OTHER_FILES} variable. + You can also use wildcards. + + For example, the following code specifies that text files are displayed + in the \gui Projects pane: + + \code + + OTHER_FILES += *.txt + + \endcode + + This also makes the files available in the \gui Locator. + \section1 Adding New Project Wizards If you have a team working on a large application or several applications, @@ -2818,6 +2837,17 @@ \o In the \gui Properties pane, change the \gui objectName to \bold batteryLevelBar. + \o Right-click the \gui BatteryIndicator object and select + \gui {Lay Out > Lay Out Horizontally} to ensure that the battery + indicator widget size is adjusted correctly on Maemo devices. + + To adjust widget size correctly on Qt Simulator, remove the condition + from the main.cpp file (displayed in the following code snippet) and just + leave the \c {w.showMaximized();} line: + + \snippet examples/batteryindicator/main.cpp 0 + + \endlist \section1 Completing the Header File @@ -3222,6 +3252,12 @@ \image qtcreator-textfinder-ui-widgets.png "Adding widgets to Text Finder UI" + \note To easily locate the widgets, use the search box at the top of the + \gui Sidebar. For example, to find the \gui Label widget, start typing + the word \bold label. + + \image qtcreator-texfinder-filter.png "Filter field" + \o Double-click the \gui{Label} widget and enter the text \bold{Keyword}. \o Double-click the \gui{Push Button} widget and enter the text \bold{Find}. @@ -3755,7 +3791,7 @@ \section1 Using the Locator Filters - The \gui Locator allows you to browse not only files, but any items + The locator allows you to browse not only files, but any items defined by \bold{locator filters}. By default, the locator contains filters which locate: \list @@ -3927,13 +3963,10 @@ \contentspage index.html \previouspage creator-build-dependencies.html \page creator-debugging.html - \nextpage creator-debugging-cpp.html + \nextpage creator-debugging-example.html \title Debugging - You can use the Qt Creator \gui Debug mode to inspect the state of your - Qt and Qt Quick projects while debugging. - Qt Creator does not include a debugger. It provides a debugger plugin that acts as an interface between the Qt Creator core and external native debuggers such as the GNU Symbolic Debugger (gdb), the Microsoft Console Debugger (CDB), @@ -4155,8 +4188,11 @@ \previouspage creator-debugging.html \page creator-debugging-cpp.html \nextpage creator-debugging-example.html + + You can use the Qt Creator \gui Debug mode to inspect the state of your + Qt projects while debugging. - \title Debugging Qt Applications + \image qtcreator-debugger-views.png "Native debugger views" In the \gui Debug mode you can interact with the debugger in several ways, including the following: @@ -4496,7 +4532,7 @@ around as described in the link provided below: \l http://bugreports.qt.nokia.com/browse/QTBUG-4962. - \endtable + \endtable \section1 Setting the Symbol Server in Windows @@ -4534,12 +4570,14 @@ In \gui Debug mode, you can use several views to interact with the program you are debugging. Frequently used views are shown by default and rarely used ones are hidden. To change the default settings, - select \gui Debug > \gui Views, and then select views to display - or hide. You can also lock views. The position of views is saved for future - sessions. + select \gui {Window > Views}, and then select views to display or hide. \image qtcreator-debugger-views.png "Debug mode views" + By default, the views are locked into place in the workspace. Select + \gui {Window > Views > Locked} to unlock the views. Drag and drop the + views into new positions on the screen. Drag view borders to resize the + views. The size and position of views are saved for future sessions. \section1 Starting the Debugger @@ -4585,6 +4623,14 @@ It is also possible to continue executing the program until the current function completes or jump to an arbitrary position in the current function. + \section2 Stepping into Frameworks in Mac OS + + In Mac OS X, external libraries are usually built into so-called Frameworks, + which may contain both release and debug versions of the library. When you run + applications on the Mac OS desktop, the release version of Frameworks is used + by default. To step into Frameworks, select the \gui {Use debug versions of + Frameworks} option in the project run settings for \gui Desktop and + \gui {Qt Simulator} targets. \section1 Setting Breakpoints @@ -4756,7 +4802,7 @@ /*! \contentspage index.html - \previouspage creator-debugging-cpp.html + \previouspage creator-debugging.html \page creator-debugging-example.html \nextpage creator-debug-mode.html @@ -4841,7 +4887,7 @@ \contentspage index.html \previouspage creator-debugger-engines.html \page creator-debugging-helpers.html - \nextpage creator-debugging-qml.html + \nextpage creator-maemo-emulator.html \title Using Debugging Helpers @@ -5383,7 +5429,7 @@ \contentspage index.html \previouspage creator-visual-editor.html \page quick-projects.html - \nextpage quick-ui.html + \nextpage quick-components.html \title Creating Qt Quick Projects @@ -5421,9 +5467,9 @@ /*! \contentspage index.html - \previouspage quick-ui.html + \previouspage quick-projects.html \page quick-components.html - \nextpage quick-buttons.html + \nextpage quick-screens.html \title Creating Components @@ -5462,9 +5508,9 @@ /*! \contentspage index.html - \previouspage quick-scalable-image.html + \previouspage quick-components.html \page quick-screens.html - \nextpage quick-list-views.html + \nextpage quick-animations.html \title Creating Screens @@ -5496,7 +5542,7 @@ /*! \contentspage index.html - \previouspage quick-list-views.html + \previouspage quick-screens.html \page quick-animations.html \nextpage quick-user-interaction.html @@ -6023,7 +6069,7 @@ /*! \contentspage index.html - \previouspage creator-qml-inspector.html + \previouspage creator-debugging-helpers.html \page creator-maemo-emulator.html \nextpage creator-version-control.html @@ -6293,7 +6339,10 @@ which one you use. The integrated \QD fetches plugins from the \c {%SDK%\bin\designer} folder on Windows - and Linux and \c {QtCreator.app/Contents/MacOS/designer} folder on Mac. To check which plugins + and Linux. For information about how to configure plugins on Mac OS, see + \l{Configuring Qt Designer Plugins on Mac OS}. + + To check which plugins were loaded successfully and which failed, choose \gui{Tools > Form Editor > About Qt Designer Plugins}. @@ -6302,6 +6351,62 @@ \c {%SDK%\qt\plugins\designer}. To check which plugins were loaded successfully and which failed, choose \gui{Help > About Plugins}. + \section2 Configuring Qt Designer Plugins on Mac OS + + On the Mac, a GUI application must be built and run from a bundle. A bundle is a + directory structure that appears as a single entity when viewed in the Finder. + A bundle for an application typcially contains the executable and all the resources + it needs. + + Qt Creator uses its own set of Qt Libraries located in the bundle, and therefore, + you need to configure the \QD plugins that you want to use with Qt Creator. + Fore more information about how to deploy applications on Mac OS, see + \l{http://doc.qt.nokia.com/4.6/deployment-mac.html}{Deploying an Application on Mac OS X}. + + The following example illustrates how to configure version 5.2.1 of the + \l{http://qwt.sourceforge.net/}{Qwt - Qt Widgets for Technical Applications} library + for use with Qt Creator: + + \list 1 + + \o To check the paths used in the Qwt library, enter the following \c otool command: + + \snippet examples/doc_src_plugins.qdoc 0 + + The output for Qwt 5.2.1 indicates that the plugin uses Qt core libraries (QtDesigner, + QtScript, QtXml, QtGui and QtCore) and libqwt.5.dylib: + + \snippet examples/doc_src_plugins.qdoc 1 + + + \o You must copy the \QD plugin and the Qwt library files to the following locations: + + \list + \o \c {libqwt_designer_plugin.dylib} to \c {QtCreator.app/Contents/MacOS/designer} + \o \c {libqwt.*.dylib} to \c {QtCreator.app/Contents/Frameworks} + \endlist + + Enter the following commands: + + \snippet examples/doc_src_plugins.qdoc 4 + + \o Enter the following \c otool command to check the libraries that are used by the + Qwt library: + + \snippet examples/doc_src_plugins.qdoc 2 + + The command returns the following output: + + \snippet examples/doc_src_plugins.qdoc 3 + + \o Enter the following \c install_name_tool command to fix the references of the + libraries: + + \snippet examples/doc_src_plugins.qdoc 5 + + \endlist + + \section1 Matching Build Keys The Qt Creator that is included in pre-built SDK packages on Windows is built with the @@ -6419,7 +6524,7 @@ \title Tips and Tricks - \section1 Switching between modes + \section1 Switching Between Modes Qt Creator uses different modes for different purposes. You can quickly switch between these modes with the following keyboard shortcuts: @@ -6442,6 +6547,12 @@ To quickly move between currently open files, press \key Ctrl+Tab. + To move forward in the location history, press \key {Alt+Right} + (\key {Cmd+Opt+Right} on Mac OS). To move backward, press \key {Alt+Left} + (\key {Cmd+Opt+Right} on Mac OS). For example, if you use the \gui Locator + to jump to a symbol in the same file, you can jump back to your original + location in that file by pressing \key {Alt+Left}. + \section1 Moving To the Edit Mode @@ -6459,10 +6570,34 @@ To find specific settings you require in \gui{Tools} > \gui{Options...} use the filter located at the top left of the \gui Options dialog box. + \section1 Opening Output Panes + + The output panes provide a list of errors and warnings encountered during + a build, detailed output from the compiler, status of a program when it is + executed and debug output, as well as search results. + + To open output panes, use the following shortcuts: + + \list + + \o \gui{Build Issues} pane Alt+1 (Cmd+1 on Mac OS X) + + \o \gui{Search Results} pane Alt+2 (Cmd+2 on Mac OS X) + + \o \gui{Application Output} pane Alt+3 (Cmd+3 on Mac OS X) + + \o \gui{Compile Output} pane Alt+4 (Cmd+4 on Mac OS X) + + \endlist + + For more information about output panes, see \l{Viewing Output}. + \section1 Using Keyboard Shortcuts Qt Creator provides \l{Keyboard Shortcuts}{many useful keyboard shortcuts}. + You can see the keyboard shortcut for a menu command in the menu + or the tooltip for a button. To customize, import or export keyboard shortcuts, select \gui Tools > \gui Options... > \gui Environment > \gui Keyboard. @@ -6497,11 +6632,19 @@ \section1 Moving To Symbols To move straight to a symbol used in a project, select the symbol in the - \gui Editor toolbar drop-down menu. - - For more information on the editor toolbar, + \gui Editor toolbar drop-down menu. For more information on the editor toolbar, see \l {Using the Editor Toolbar}. + To jump to a symbol in the current file, press \key {Ctrl+K} to open the + \gui Locator, enter a period (.), and start typing the symbol name. Then + select the symbol in the list. For more information on using the locator, + see \l{Searching With the Locator}. + + Press \key Ctrl (\key Cmd on Mac OS) and click a symbol to move directly to + the definition or the declaration of the symbol. You can also move the cursor + on the symbol and press \key {F2}. For more information, see + \l{Moving to Symbol Definition or Declaration}. + \section1 Displaying Signals and Slots @@ -6515,6 +6658,9 @@ the slot in the \e slots subitem. The objects connected to this slot are shown as children of the slot. This method works with signals too. + For more information about the \gui{Locals and Watchers} view, see + \l{Locals and Watchers}. + \section1 Displaying Low Level Data @@ -6529,6 +6675,19 @@ \o Uncheck the \gui{Use debugging helper} checkbox. \endlist + + \section1 Locating Files + + The \gui Locator provides one of the easiest ways in Qt Creator to browse + through projects, files, classes, methods, documentation and file systems. + To quickly access files not directly mentioned in your project, you can + create your own locator filters. That way you can locate files in a + directory structure you have defined. + + To create locator filters, select \gui {Tools > Options... > Locator > Add}. + + For more information, see \l{Creating Locator Filters}. + */ diff --git a/doc/qtcreator.qdocconf b/doc/qtcreator.qdocconf index 876ceb92483..360be06b6e0 100644 --- a/doc/qtcreator.qdocconf +++ b/doc/qtcreator.qdocconf @@ -55,7 +55,8 @@ qhp.QtCreator.extraFiles = \ images/page_bg.png \ images/page.png \ images/qt-logo.png \ - images/sprites-combined.png + images/sprites-combined.png \ + images/bullet_up.png qhp.QtCreator.subprojects = manual qhp.QtCreator.subprojects.manual.title = Qt Creator Manual @@ -218,3 +219,5 @@ Cpp.ignoredirectives = Q_DECLARE_HANDLE \ K_DECLARE_PRIVATE \ PHONON_OBJECT \ PHONON_HEIR + +creator = true diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index af7ff85a4b6..036d40bb3bc 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -124,6 +124,10 @@ def lookupType(typestring): #if not type is None: # warn(" FIELDS: '%s'" % type.fields()) typeCache[typestring] = type + if type is None: + # could be gdb.lookup_type("char[3]") generating + # "RuntimeError: No type named char[3]" + pass return type def cleanType(type): @@ -600,7 +604,11 @@ def isNull(p): # for invalid char *, as their "contents" is being examined #s = str(p) #return s == "0x0" or s.startswith("0x0 ") - return p.cast(lookupType("void").pointer()) == 0 + try: + # Can fail with: "RuntimeError: Cannot access memory at address 0x5" + return p.cast(lookupType("void").pointer()) == 0 + except: + return False movableTypes = set([ "QBrush", "QBitArray", "QByteArray", @@ -805,7 +813,10 @@ def extractFields(type): #warn("TYPE 0: %s" % type) type = stripTypedefs(type) #warn("TYPE 1: %s" % type) - type = lookupType(str(type)) + # This fails for arrays. See comment in lookupType. + type2 = lookupType(str(type)) + if not type2 is None: + type = type2 #warn("TYPE 2: %s" % type) fields = type.fields() #warn("FIELDS: %s" % fields) @@ -1038,11 +1049,14 @@ class Dumper: # Special handling for char** argv. n = 0 p = item.value - # p is 0 for "optimized out" cases. - if not isNull(p): - while not isNull(p.dereference()) and n <= 100: - p += 1 - n += 1 + # p is 0 for "optimized out" cases. Or contains rubbish. + try: + if not isNull(p): + while not isNull(p.dereference()) and n <= 100: + p += 1 + n += 1 + except: + pass with SubItem(self): self.put('iname="%s",' % item.iname) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index ce620d955d9..555236cd14c 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -273,17 +273,6 @@ static bool startsWith(const char *s, const char *t) return true; } -static bool couldBePointer(const void *p) -{ - // we assume valid pointer to be 4-aligned at least. - // So use this check only when this is guaranteed. - // FIXME: this breaks e.g. in the QString dumper... - const quintptr d = quintptr(p); - //qDebug() << "CHECKING : " << p << ((d & 3) == 0 && (d > 1000 || d == 0)); - //return (d & 3) == 0 && (d > 1000 || d == 0); - return d > 1000 || d == 0; -} - // Check memory for read access and provoke segfault if nothing else helps. // On Windows, try to be less crash-prone by checking memory using WinAPI @@ -314,6 +303,17 @@ static bool couldBePointer(const void *p) qProvokeSegFaultHelper = *(char*)d; \ } while (0) +static bool couldBePointer(const void *p) +{ + // we assume valid pointer to be 4-aligned at least. + // So use this check only when this is guaranteed. + // FIXME: this breaks e.g. in the QString dumper... + const quintptr d = quintptr(p); + //qDebug() << "CHECKING : " << p << ((d & 3) == 0 && (d > 1000 || d == 0)); + //return (d & 3) == 0 && (d > 1000 || d == 0); + return d > 1000 || d == 0; +} + #endif #ifdef QT_NAMESPACE diff --git a/share/qtcreator/qmlicons/Qt/16x16/BorderImage.png b/share/qtcreator/qmlicons/Qt/16x16/BorderImage.png new file mode 100644 index 00000000000..ef21dd97107 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/BorderImage.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Flickable.png b/share/qtcreator/qmlicons/Qt/16x16/Flickable.png new file mode 100644 index 00000000000..963a7afea35 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Flickable.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Flipable.png b/share/qtcreator/qmlicons/Qt/16x16/Flipable.png new file mode 100644 index 00000000000..354f5bd91c3 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Flipable.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/FocusScope.png b/share/qtcreator/qmlicons/Qt/16x16/FocusScope.png new file mode 100644 index 00000000000..3a65e43525e Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/FocusScope.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/GridView.png b/share/qtcreator/qmlicons/Qt/16x16/GridView.png new file mode 100644 index 00000000000..011392dc557 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/GridView.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Image.png b/share/qtcreator/qmlicons/Qt/16x16/Image.png new file mode 100644 index 00000000000..fc4c7eccc1f Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Image.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Item.png b/share/qtcreator/qmlicons/Qt/16x16/Item.png new file mode 100644 index 00000000000..6d1e0f214d5 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Item.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/ListView.png b/share/qtcreator/qmlicons/Qt/16x16/ListView.png new file mode 100644 index 00000000000..b2e62ca068f Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/ListView.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/MouseArea.png b/share/qtcreator/qmlicons/Qt/16x16/MouseArea.png new file mode 100644 index 00000000000..b28576ac877 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/MouseArea.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/PathView.png b/share/qtcreator/qmlicons/Qt/16x16/PathView.png new file mode 100644 index 00000000000..23c3a2f5dae Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/PathView.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Rectangle.png b/share/qtcreator/qmlicons/Qt/16x16/Rectangle.png new file mode 100644 index 00000000000..f6c33cacd7b Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Rectangle.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/State.png b/share/qtcreator/qmlicons/Qt/16x16/State.png new file mode 100644 index 00000000000..d400b013aeb Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/State.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Text.png b/share/qtcreator/qmlicons/Qt/16x16/Text.png new file mode 100644 index 00000000000..a49a39c33c6 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Text.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/TextEdit.png b/share/qtcreator/qmlicons/Qt/16x16/TextEdit.png new file mode 100644 index 00000000000..4f41cd9bc52 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/TextEdit.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/TextInput.png b/share/qtcreator/qmlicons/Qt/16x16/TextInput.png new file mode 100644 index 00000000000..394ac907cf6 Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/TextInput.png differ diff --git a/share/qtcreator/qmlicons/Qt/16x16/Transition.png b/share/qtcreator/qmlicons/Qt/16x16/Transition.png new file mode 100644 index 00000000000..86f591ff7bd Binary files /dev/null and b/share/qtcreator/qmlicons/Qt/16x16/Transition.png differ diff --git a/share/qtcreator/qmlicons/QtWebkit/16x16/WebView.png b/share/qtcreator/qmlicons/QtWebkit/16x16/WebView.png new file mode 100644 index 00000000000..3f61ad0b1c0 Binary files /dev/null and b/share/qtcreator/qmlicons/QtWebkit/16x16/WebView.png differ diff --git a/share/qtcreator/templates/wizards/helloworld/project.pro b/share/qtcreator/templates/wizards/helloworld/project.pro index 4b791337a1b..f33dcf1d99e 100644 --- a/share/qtcreator/templates/wizards/helloworld/project.pro +++ b/share/qtcreator/templates/wizards/helloworld/project.pro @@ -1,6 +1,8 @@ QT = core %NETWORK%QT += network - +@if "%SCRIPT%" == "true" +QT += script +@endif CONFIG += console CONFIG -= app_bundle diff --git a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml index fe5c1fbaad0..dfcf4e00aae 100644 --- a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml @@ -55,11 +55,17 @@ leave room for the Qt 4 target page. Hello world message: Hallo-Welt-Nachricht: - + Include network module Netzwerk-Modul verwenden + + + + Include script module + Script-Modul verwenden + diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp index e68c6d97d99..1ccad3bd609 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -47,7 +48,7 @@ bool %PluginName%Impl::initialize(const QStringList &arguments, QString *errorSt QAction *action = new QAction(tr("%PluginName% action"), this); Core::Command *cmd = am->registerAction(action, QLatin1String(ACTION_ID), - QList() << Core::Constants::C_GLOBAL_ID); + Core::Context(Core::Constants::C_GLOBAL)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A"))); connect(action, SIGNAL(triggered()), this, SLOT(triggerAction())); @@ -66,10 +67,12 @@ void %PluginName%Impl::extensionsInitialized() // plugins that depend on it are completely initialized." } -void %PluginName%Impl::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag %PluginName%Impl::aboutToShutdown() { // Save settings // Disconnect from signals that are not needed during shutdown + // Hide UI (if you add UI that is not in the main window directly) + return SynchronousShutdown; } void %PluginName%Impl::triggerAction() diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h index ac28bdffe7c..4e33d3354ed 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h @@ -18,7 +18,7 @@ public: bool initialize(const QStringList &arguments, QString *errorString); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); private slots: void triggerAction(); diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index 798c38d6fb1..96d02068ad6 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -14,7 +14,7 @@ Die Kommandozeilen-Argumente konnten nicht an die laufende Instanz übermittelt werden. Sie antwortet nicht. - + Could not find 'Core.pluginspec' in %1 Die Datei 'Core.pluginspec' konnte im Verzeichnis %1 nicht gefunden werden @@ -58,7 +58,7 @@ BINEditor::Internal::BinEditorPlugin - + &Undo &Rückgängig @@ -96,7 +96,7 @@ Neuer Ordner - + @@ -304,7 +304,7 @@ CMakeProjectManager::Internal::CMakeBuildConfigurationFactory - + Build Erstellen @@ -338,7 +338,7 @@ CMakeProjectManager::Internal::CMakeRunConfigurationWidget - + Arguments: Argumente: @@ -466,12 +466,12 @@ CMakeProjectManager::Internal::CMakeSettingsPage - + CMake CMake - + Executable: Ausführbare Datei: @@ -811,7 +811,7 @@ - + No cvs executable specified! Es wurde keine ausführbare Datei angegeben! @@ -857,10 +857,6 @@ CVS::Internal::CheckoutWizard - - Checks out a project from a CVS repository and tries to load the contained project. - Holt ein Projekt aus einem CVS-Repository und versucht, das darin enthaltene Projekt zu laden. - Checks out a CVS repository and tries to load the contained project. @@ -959,7 +955,7 @@ CVSPlugin - + Cannot find repository for '%1' Das Repository der Datei '%1' konnte nicht gefunden werden @@ -1322,7 +1318,7 @@ Core::BaseFileWizard - + @@ -1331,12 +1327,12 @@ - + Existing files Bereits existierende Dateien - + Unable to create the directory %1. Das Verzeichnis %1 kann nicht erstellt werden. @@ -1356,7 +1352,7 @@ Es konnte kein Editor für die Datei '%1' geöffnet werden. - + [read only] [schreibgeschützt] @@ -1371,7 +1367,7 @@ [symbolischer Link] - + The project directory %1 contains files which cannot be overwritten: %2. Das Projektverzeichnis %1 enthält Dateien, die nicht überschrieben werden können: @@ -1682,7 +1678,7 @@ Sollen sie überschrieben werden? Core::FileManager - + Cannot save file Die Datei kann nicht gespeichert werden @@ -1921,12 +1917,12 @@ Sollen sie überschrieben werden? Core::Internal::MainWindow - + Qt Creator Qt Creator - + &File &Datei @@ -2102,12 +2098,7 @@ Sollen sie überschrieben werden? Neu - - Open Project - Projekt öffnen - - - + Settings... Einstellungen... @@ -2476,7 +2467,7 @@ Sollen sie überschrieben werden? Alphabetisch sortieren - + This change cannot be undone. Diese Änderung kann nicht rückgängig gemacht werden. @@ -2486,7 +2477,7 @@ Sollen sie überschrieben werden? Ja, Ich bin mir dessen bewusst. - + Unused variable Unbenutzte Variable @@ -2530,14 +2521,6 @@ Sollen sie überschrieben werden? Details - - CppEditor::Internal::CppHoverHandler - - - Unfiltered - Kein - - CppEditor::Internal::CppPlugin @@ -2816,12 +2799,12 @@ Sollen sie überschrieben werden? - + Interrupt Anhalten - + Step Over Einzelschritt über @@ -2879,7 +2862,7 @@ Sollen sie überschrieben werden? Umgekehrte Richtung - + Running... Läuft... @@ -2904,7 +2887,7 @@ Sollen sie überschrieben werden? Warnung - + Turn off helper usage Ausgabe-Hilfsbibliothek deaktivieren @@ -2919,12 +2902,12 @@ Sollen sie überschrieben werden? Die Ausgabe-Hilfsbibliothek dient zur Ausgabe der Werte einiger Datentypen aus Qt- und den Standardbibliotheken. Sie muss mit jeder benutzten Qt-Version compiliert werden. Das geschieht in der Seite 'Qt-Einstellungen' durch Auswahl der Qt-Installation und Klicken auf 'Erstellen' für die Ausgabe-Hilfsbibliothek. - + Cannot debug '%1' (tool chain: '%2'): %3 Der Debugger kann nicht mit '%1' (Toolchain '%2') gestartet werden: %3 - + Abort Debugging Debuggen abbrechen @@ -2934,7 +2917,7 @@ Sollen sie überschrieben werden? Bricht das Debuggen ab und setzt den Debugger in den Ausgangszustand. - + Stopped Angehalten @@ -2944,7 +2927,7 @@ Sollen sie überschrieben werden? Beendet - + Save Debugger Log Debugger Log speichern @@ -3569,7 +3552,7 @@ Sollen sie überschrieben werden? Debugger::Internal::DebuggerOutputWindow - + Debugger Debugger @@ -3725,12 +3708,12 @@ Would you like to terminate it? Weist den Debugger an, auf Anweisungsebene zu arbeiten. In diesem Modus arbeitet die Einzelschritt-Funktion auf Maschinenanweisungen und die Quelltextanzeige zeigt die disassemblierten Anweisungen an. - + This switches the Locals&Watchers view to automatically derefence pointers. This saves a level in the tree view, but also loses data for the now-missing intermediate level. Bewirkt, dass Zeiger im Fenster "Lokale Variablen und Überwachte Ausdrücke" automatisch dereferenziert werden. Das vereinfacht die Baumanzeige, allerdings fehlt die Information über die Zwischenebene. - + Debugger Properties... Debugger-Einstellungen... @@ -3765,7 +3748,7 @@ Would you like to terminate it? Auf Anweisungsebene arbeiten - + Dereference Pointers Automatically Zeiger automatisch dereferenzieren @@ -4012,7 +3995,7 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. Der Prozess konnte nicht gestartet werden. - + <p>The inferior stopped because it received a signal from the Operating System.<p><table><tr><td>Signal name : </td><td>%1</td></tr><tr><td>Signal meaning : </td><td>%2</td></tr></table> <p>Der Prozess wurde nach Erhalt eines Signals vom Betriebssystem angehalten.<p><table><tr><td>Name des Signals : </td><td>%1</td></tr><tr><td>Bedeutung : </td><td>%2</td></tr></table> @@ -4022,17 +4005,12 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. Signal erhalten - + Reading %1... Lese %1... - - Jumped. Stopped. - Sprung ausgeführt/ Angehalten. - - - + Application exited with exit code %1 Die Anwendung wurde beendet, Rückgabewert %1 @@ -4062,32 +4040,27 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. Angehalten: %1, Signal %2 - - The debugger you are using identifies itself as: - Der benutzte Debugger ist: - - - + Processing queued commands. Kommando-Warteschlange wird abgearbeitet. - - + + Stopped. Angehalten. - + Execution Error Fehler bei der Ausführung - + - + Cannot continue debugged process: Der zu debuggende Prozess kann nicht fortgesetzt werden: @@ -4099,7 +4072,7 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. Die Ausgabe-Hilfsbibliothek konnte nicht unter %1 gefunden werden. - + Unable to start gdb '%1': %2 Der gdb-Debugger '%1' kann nicht ausgeführt werden: %2 @@ -4155,7 +4128,7 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. - + An unknown error in the Gdb process occurred. Im Gdb-Prozess trat ein unbekannter Fehler auf. @@ -4235,12 +4208,22 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. Fehler bei Ausführung: %1 - + <unknown> <unbekannt> - + + Jumped. Stopped + Übersprungen / Angehalten + + + + Target line hit. Stopped + Zeile erreicht / Angehalten + + + Stopped at breakpoint %1 in thread %2. An Haltepunkt %1 im Thread %2 angehalten. @@ -4257,16 +4240,7 @@ Sie haben die Wahl zwischen Abwarten oder Abbrechen. <Unbekannt> - - This version is not officially supported by Qt Creator. -Debugging will most likely not work well. -Using gdb 7.1 or later is strongly recommended. - Diese Version wird von Qt Creator nicht offiziell unterstützt. -Das Debuggen wird wahrscheinlich nicht richtig funktionieren. -Es wird empfohlen, gdb 7.1 oder später zu benutzen. - - - + Failed to shut down application Die Anwendung konnte nicht beendet werden @@ -4301,7 +4275,7 @@ Es wird empfohlen, gdb 7.1 oder später zu benutzen. Einzelschritt über Anweisung angefordert... - + Finish function requested... Ausführung bis Funktionsende angefordert... @@ -4321,7 +4295,7 @@ Es wird empfohlen, gdb 7.1 oder später zu benutzen. Ausführung bis Zeile %1 angefordert... - + Run to function %1 requested... Ausführung bis Funktion %1 angefordert... @@ -4499,7 +4473,7 @@ Möchten Sie den zu debuggenden Prozess anhalten und den gewählten Snapshot lad Speicher $ - + No memory viewer available Es ist kein Speicher-Anzeigemodul verfügbar @@ -5060,7 +5034,7 @@ Möchten Sie den zu debuggenden Prozess anhalten und den gewählten Snapshot lad Debugger::Internal::TrkGdbAdapter - + Port specification missing. Es wurde kein Port angegeben. @@ -5308,7 +5282,7 @@ Möchten Sie den zu debuggenden Prozess anhalten und den gewählten Snapshot lad DebuggerPane - + Clear Contents Inhalt löschen @@ -5525,17 +5499,17 @@ Versuchen Sie, das Projekt neu zu erstellen. Qt-Designer-Formular - + Creates a Qt Designer form along with a matching class (C++ header and source file) for implementation purposes. You can add the form and class to an existing Qt C++ Project. Erstellt ein Qt-Designer-Formular mit zugehörigem Klassenrumpf (bestehend aus C++-Header- und -Quelldatei) für ein existierendes C++-Projekt. - + Creates a Qt Designer form that you can add to a Qt C++ project. This is useful if you already have an existing class for the UI business logic. Erstellt ein Qt-Designer-Formular für ein C++-Projekt. Verwenden Sie diese Vorlage, wenn bereits eine Klasse für den Programmablauf existiert. - + Qt Designer Form Class Qt-Designer-Formularklasse @@ -5543,25 +5517,25 @@ Versuchen Sie, das Projekt neu zu erstellen. Designer::Internal::FormEditorW - + Widget Box Widget-Box - - + + Object Inspector Objektanzeige - - + + Property Editor Eigenschaften - - + + Action Editor Aktionseditor @@ -5621,18 +5595,18 @@ Versuchen Sie, das Projekt neu zu erstellen. Ctrl+J - - + + Signals && Slots Editor Signale und Slots - + Widget box Widget-Box - + Edit Widgets Widgets bearbeiten @@ -5657,7 +5631,7 @@ Versuchen Sie, das Projekt neu zu erstellen. Ctrl+Alt+R - + About Qt Designer plugins.... Plugins... @@ -5667,12 +5641,12 @@ Versuchen Sie, das Projekt neu zu erstellen. Vorschau in - + Designer Designer - + The image could not be created: %1 Das Bild konnte nicht erstellt werden: %1 @@ -5698,7 +5672,7 @@ Versuchen Sie, das Projekt neu zu erstellen. Fehler beim Speichern von %1 - + Unable to open %1: %2 %1 kann nicht geöffnet werden: %2 @@ -5724,12 +5698,12 @@ Versuchen Sie, das Projekt neu zu erstellen. Designer::Internal::QtCreatorIntegration - + The class definition of '%1' could not be found in %2. Die Definition der Klasse '%1' konnte in %2 nicht gefunden werden. - + Error finding/adding a slot. Fehler beim Auffinden/Hinzufügen des Slot-Codes. @@ -5990,10 +5964,6 @@ Versuchen Sie, das Projekt neu zu erstellen. %1(%2) %1(%2) - - Cannot load plugin because dependencies are not resolved - Das Plugin kann nicht geladen werden, weil die Abhängigkeiten nicht bestimmt werden konnten - @@ -6015,26 +5985,16 @@ Grund: %3 Read .vimrc .vimrc lesen - - - FakeVim properties... - FakeVim-Einstellungen... - FakeVim::Internal::FakeVimHandler - + Not implemented in FakeVim In FakeVim nicht implementiert - - E20: Mark '%1' not set - E20: Die Marke '%1' ist nicht gesetzt - - - + %1%2% %1%2% @@ -6044,27 +6004,13 @@ Grund: %3 %1Alle - - File '%1' exists (add ! to override) - Die '%1' existiert bereits (Fügen Sie ! an, um sie zu überschreiben) - - - - Cannot open file '%1' for writing - Die Datei '%1' kann nicht zum Schreiben geöffnet werden - - - + + "%1" %2 %3L, %4C written "%1" %2 %3L, %4C geschrieben - - Cannot open file '%1' for reading - Die Datei '%1' kann nicht zum Lesen geöffnet werden - - - + "%1" %2L, %3C "%1" %2L, %3C @@ -6077,47 +6023,66 @@ Grund: %3 - - - %n lines >ed %1 time - What is that? - - Eine Zeile >ed %1-mal - %n Zeilen >ed %1-mal - - - + Can't open file %1 Die Datei '%1' kann nicht geöffnet werden - - E512: Unknown option: - E512: Unbekannte Option: + + Mark '%1' not set + Die Marke '%1' ist nicht gesetzt + + + + Unknown option: + Unbekannte Option: + File "%1" exists (add ! to override) + Die Datei '%1' existiert bereits (Fügen Sie ! an, um sie zu überschreiben) + + + + Cannot open file "%1" for writing + Die Datei '%1' kann nicht zum Schreiben geöffnet werden + + + + Cannot open file "%1" for reading + Die Datei '%1' kann nicht zum Lesen geöffnet werden + + + + %n lines %1ed %2 time + + %1 auf eine Zeile %2-mal angewandt + %1 auf %n Zeilen %2-mal angewandt + + + + Pattern not found: Suchmuster nicht gefunden: - + search hit BOTTOM, continuing at TOP Die Suche hat das Ende erreicht, setze am Anfang fort - + search hit TOP, continuing at BOTTOM Die Suche hat den Anfang erreicht, setze am Ende fort - + Already at oldest change Älteste Änderung erreicht - + Already at newest change Letzte Änderung erreicht @@ -6125,7 +6090,7 @@ Grund: %3 FakeVim::Internal::FakeVimOptionPage - + General Allgemein @@ -6138,7 +6103,7 @@ Grund: %3 FakeVim::Internal::FakeVimPluginPrivate - + Switch to next file Gehe zu nächster Datei @@ -6148,13 +6113,18 @@ Grund: %3 Gehe zur vorigen Datei - - + + Quit FakeVim FakeVim Beenden - + + File not saved + Datei nicht gespeichert + + + Saving succeeded Gespeichert @@ -6167,12 +6137,7 @@ Grund: %3 - - Not an editor command: %1 - Kein Editor-Kommando: %1 - - - + FakeVim Information Informationen zu FakeVim @@ -6274,6 +6239,11 @@ Grund: %3 Set Plain Style Einfachen Stil setzen + + + Show position of text marks + Position der Textmarken anzeigen + FilterNameDialogClass @@ -6940,10 +6910,6 @@ on slow machines. In this case, the value should be increased. Git::Internal::CloneWizard - - Clones a project from a Git repository and tries to load the contained project. - Holt ein Projekt aus einem Git-Repository und versucht, es zu laden. - Clones a Git repository and tries to load the contained project. @@ -6982,7 +6948,7 @@ on slow machines. In this case, the value should be increased. Warte auf Daten... - + Git Diff Git Diff @@ -7044,7 +7010,7 @@ on slow machines. In this case, the value should be increased. - + Unable to reset %1: %2 Das Repository %1 konnte nicht zurückgesetzt werden: %2 @@ -7131,7 +7097,7 @@ on slow machines. In this case, the value should be increased. Es ist kein Branch vorhanden. - + Git SVN Log Git SVN Log @@ -7166,7 +7132,7 @@ on slow machines. In this case, the value should be increased. Die verwendete git-Version konnte nicht bestimmt werden: %1 - + Unable stash in %1: %2 Die Operation 'stash' schlug in %1 fehl: %2 @@ -7197,7 +7163,7 @@ on slow machines. In this case, the value should be increased. Das Repository ist noch nicht initialisiert. - + Committed %n file(s). @@ -7782,10 +7748,6 @@ on slow machines. In this case, the value should be increased. Gitorious::Internal::GitoriousCloneWizard - - Clones a project from a Gitorious repository and tries to load the contained project. - Holt ein Projekt aus einem Gitorious-Repository und versucht, das darin enthaltene Projekt zu laden. - Clones a Gitorious repository and tries to load the contained project. @@ -7986,7 +7948,7 @@ on slow machines. In this case, the value should be increased. Help::Internal::CentralWidget - + Print Document Dokument drucken @@ -7994,7 +7956,7 @@ on slow machines. In this case, the value should be increased. Help::Internal::DocSettingsPage - + Documentation Dokumentation @@ -8012,7 +7974,7 @@ on slow machines. In this case, the value should be increased. Help::Internal::FilterSettingsPage - + Filters Filter @@ -8049,7 +8011,7 @@ on slow machines. In this case, the value should be increased. Help::Internal::HelpIndexFilter - + Help index Hilfe - Index @@ -8065,14 +8027,14 @@ on slow machines. In this case, the value should be increased. Help::Internal::HelpPlugin - - + + Contents Inhalt - - + + Index Index @@ -8082,12 +8044,12 @@ on slow machines. In this case, the value should be increased. Suche - + Bookmarks Lesezeichen - + Home Startseite @@ -8152,7 +8114,17 @@ on slow machines. In this case, the value should be increased. Ctrl+Shift+Tab - + + Activate Search in Help mode + Suche im Modus "Hilfe" aktivieren + + + + Activate Bookmarks in Help mode + Lesezeichen im Modus "Hilfe" aktivieren + + + Open Pages Offene Seiten @@ -8162,7 +8134,7 @@ on slow machines. In this case, the value should be increased. Offene Seiten im Hilfsmodus aktivieren - + Go to Help Mode Schalte in Hilfsmodus @@ -8172,17 +8144,17 @@ on slow machines. In this case, the value should be increased. Vorige - + Close current Page Diese Seite schließen - + Next Nächste - + Add Bookmark Lesezeichen hinzufügen @@ -8192,7 +8164,7 @@ on slow machines. In this case, the value should be increased. Kontexthilfe - + Activate Index in Help mode Index im Modus "Hilfe" zeigen @@ -8202,17 +8174,17 @@ on slow machines. In this case, the value should be increased. Inhalt im Modus "Hilfe" zeigen - + Unfiltered Kein - + <html><head><title>No Documentation</title></head><body><br/><center><b>%1</b><br/>No documentation available.</center></body></html> <html><head><title>Dokumentation fehlt</title></head><body><br/><center><b>%1</b><br/>Es ist keine Dokumentation verfügbar.</center></body></html> - + Filtered by: Filter: @@ -8220,7 +8192,7 @@ on slow machines. In this case, the value should be increased. Help::Internal::SearchWidget - + Indexing Indizierung @@ -8672,18 +8644,23 @@ on slow machines. In this case, the value should be increased. Qt Project include file Qt-Projekt-Include-Datei + + + Qt Project feature file + Qt-Projekt-Feature-Datei + message catalog Meldungsdatei - + Qt Script file Qt-Skript-Datei - + Qt Resource file Qt-Ressourcendatei @@ -9353,7 +9330,7 @@ on slow machines. In this case, the value should be increased. Der Prozess wurde beendet, Rückgabewert %1. - + p4 submit failed: %1 Fehler beim Abgeben: %1 @@ -9380,7 +9357,7 @@ on slow machines. In this case, the value should be increased. Perforce: Das Repository von konnte nicht bestimmt werden: %1 - + The process terminated abnormally. Der Prozess wurde in anormaler Weise beendet. @@ -9405,7 +9382,7 @@ on slow machines. In this case, the value should be increased. Perforce ist nicht richtig konfiguriert. - + p4 diff %1 p4 diff %1 @@ -9709,31 +9686,31 @@ on slow machines. In this case, the value should be increased. ProjectExplorer::AbstractProcessStep - - <font color="#0000ff">Starting: "%1" %2</font> + + Starting: "%1" %2 - <font color="#0000ff">Starte: "%1" %2</font> + Starte "%1" %2 - - <font color="#0000ff">The process "%1" exited normally.</font> - <font color="#0000ff">The Prozess "%1" wurde normal beendet.</font> + + The process "%1" exited normally. + Der Prozess "%1" wurde normal beendet. - - <font color="#ff0000"><b>The process "%1" exited with code %2.</b></font> - <font color="#0000ff">The Prozess "%1" wurde mit dem Rückgabewert %2 beendet.</font> + + The process "%1" exited with code %2. + Der Prozess "%1" wurde mit dem Rückgabewert %2 beendet. - - <font color="#ff0000"><b>The process "%1" crashed.</b></font> - <font color="#ff0000"><b>The Prozess "%1" ist abgestürzt.</b></font> + + The process "%1" crashed. + Der Prozess "%1" ist abgestürzt. - - <font color="#ff0000"><b>Could not start process "%1"</b></font> - <font color="#ff0000"><b>Der Prozess "%1"konnte nicht gestartet werden</b></font> + + Could not start process "%1" + Der Prozess :"%1" konnte nicht gestartet werden @@ -9771,43 +9748,39 @@ on slow machines. In this case, the value should be increased. Build System - - <font color="#ff0000">Canceled build.</font> - <font color="#ff0000">Erstellen abgebrochen.</font> + + Canceled build. + Erstellen abgebrochen. - + + + When executing build step '%1' + Bei der Ausführung von Build-Schritt '%1' + + + + Running build steps for project %1... + Führe Build-Schritte für Projekt %1 aus... + + + Build Erstellen - - - <font color="#ff0000">Error while building project %1 (target: %2)</font> - <font color="#ff0000">Fehler beim Erstellen des Projekts %1 (Ziel: %2)</font> - - - + + + Error while building project %1 (target: %2) Fehler beim Erstellen des Projekts %1(Ziel: %2) - + Compile Category for compiler isses listened under 'Build Issues' Compilierung - - - - <font color="#ff0000">When executing build step '%1'</font> - <font color="#ff0000">Beim Ausführen des Build-Schritts '%1'</font> - - - - <b>Running build steps for project %2...</b> - <b>Führe Build-Schritte für Projekt %2 aus...</b> - ProjectExplorer::CustomExecutableRunConfiguration @@ -9855,7 +9828,7 @@ on slow machines. In this case, the value should be increased. ProjectExplorer::DebuggingHelperLibrary - + The target directory %1 could not be created. Das Zielverzeichnis %1 konnte nicht erstellt werden. @@ -9880,7 +9853,7 @@ Reason: %2 Fehler: %2 - + Building debugging helper library in %1 Erstelle Ausgabe-Hilfsbibliothek in %1 @@ -10114,7 +10087,7 @@ Fehler: %2 ProjectExplorer::Internal::CompileOutputWindow - + Compile Output Kompilierung @@ -10243,7 +10216,7 @@ Fehler: %2 ProjectExplorer::Internal::FolderNavigationWidgetFactory - + File System Dateisystem @@ -10375,7 +10348,7 @@ Fehler: %2 ProjectExplorer::Internal::ProjectExplorerSettingsPage - + General Allgemein @@ -10392,11 +10365,6 @@ Fehler: %2 Use jom instead of nmake jom an Stelle von nmake verwenden - - - <i>jom</i> is a drop-in replacement for <i>nmake</i> which distributes the compilation process to multiple CPU cores. For more details, see the <a href="http://qt.gitorious.org/qt-labs/jom/">jom Homepage</a>. Disable it if you experience problems with your builds. - <i>jom</i> ist ein Ersatz für <i>nmake</i>, der den Kompilationsprozess auf mehrere Prozessorkerne verteilt. Mehr Informationen finden Sie auf der <a href="http://qt.gitorious.org/qt-labs/jom/">jom Homepage</a>. Deaktivieren Sie die Einstellungen, wenn Probleme beim Build auftreten. - Current directory @@ -10437,6 +10405,11 @@ Fehler: %2 Clear old application output on a new run Ausgabe vorangegangener Ausführungen löschen + + + <i>jom</i> is a drop-in replacement for <i>nmake</i> which distributes the compilation process to multiple CPU cores. The latest binary is available at <a href="ftp://ftp.qt.nokia.com/jom/">ftp://ftp.qt.nokia.com/jom/</a>. Disable it if you experience problems with your builds. + <i>jom</i> ist ein Ersatz für <i>nmake</i>, der den Kompilationsprozess auf mehrere Prozessorkerne verteilt. Eine aktuelle Version erhalten Sie von <a href="ftp://ftp.qt.nokia.com/jom/">ftp://ftp.qt.nokia.com/jom/</a>. Deaktivieren Sie die Einstellungen, wenn Probleme beim Build auftreten. + ProjectExplorer::Internal::ProjectFileFactory @@ -10532,7 +10505,7 @@ No project selected Sitzungen... - + %1 (last session) %1 (zuletzt benutzt) @@ -10646,11 +10619,6 @@ No project selected Session Manager Sitzungsverwaltung - - - <a href="qthelp://com.nokia.qtcreator/doc/creator-quick-tour.html#session-management-in-qt-creator">What is a Session?</a> - <a href="qthelp://com.nokia.qtcreator/doc/creator-quick-tour.html#session-management-in-qt-creator">Was ist eine Sitzung?</a> - &New @@ -10677,16 +10645,21 @@ No project selected &Gehe zu Sitzung - - + + New session name Name der neuen Sitzung - + Rename session Sitzung umbenennen + + + <a href="qthelp://com.nokia.qtcreator/doc/creator-project-managing-sessions.html">What is a Session?</a> + <a href="qthelp://com.nokia.qtcreator/doc/creator-project-managing-sessions.htm">Was ist eine Sitzung?</a> + ProjectExplorer::Internal::SessionFile @@ -10705,7 +10678,7 @@ No project selected ProjectExplorer::Internal::TaskDelegate - + File not found: %1 Datei nicht gefunden: %1 @@ -10762,7 +10735,7 @@ No project selected Projekte - + &Build &Erstellen @@ -10777,12 +10750,12 @@ No project selected &Debuggen - + Open With Öffnen mit - + Session Manager... Sitzungsverwaltung @@ -10933,7 +10906,17 @@ No project selected Neues Projekt - + + Projects (%1) + Projekte (%1) + + + + All Files (*) + Alle Dateien (*) + + + Close Project "%1" Projekt "%1" schließen @@ -10981,7 +10964,7 @@ No project selected Zielauswahl für Build/Auswahl öffnen... - + Always save files before build Alle Dateien vor Erstellen speichern @@ -10996,7 +10979,7 @@ No project selected Debuggen ohne Projekt nicht möglich. - + New File Title of dialog Neue Datei @@ -11213,7 +11196,7 @@ unter Versionsverwaltung (%2) gestellt werden? Warning - Warnung + Warnung @@ -11679,28 +11662,38 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Schon gewusst? - + The Qt Creator User Interface Die Benutzeroberfläche von Qt Creator + + + Building and Running an Example + Ein Beispiel erstellen und ausführen + Creating a Qt C++ Application Erstellen einer C++-Anwendung mit Qt + + + Creating a Mobile Application + Erstellen einer mobilen Anwendung + Creating a Qt Quick Application Erstellen einer Qt-Quick-Anwendung - + Choose an example... Beispiel wählen... - + Copy Project to writable Location? Soll das Projekt in ein schreibbares Verzeichnis kopiert werden? @@ -11735,7 +11728,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Das angegebene Verzeichnis existiert bereits. Bitte geben Sie ein gültiges Verzeichnis an. - + New Project Neues Projekt @@ -11759,12 +11752,22 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Strg - - You can switch between Qt Creator's modes using <tt>Ctrl+number</tt>:<ul><li>1 - Welcome</li><li>2 - Edit</li><li>3 - Debug</li><li>4 - Projects</li><li>5 - Help</li></ul> - Sie können mit <tt>Strg+Nummer</tt> zwischen den Modi von Qt Creator umschalten: <ul><li>1 - Willkommen</li><li>2 - Editieren</li><li>3 - Debuggen</li><li>4 - Projekte</li><li>5 - Hilfe</li><li></li><li>6 - Ausgabe</li></ul> + + If you add external libraries to your project, Qt Creator will automatically offer syntax highlighting and code completion. + Qt Creator bietet automatisch Syntax-Hervorhebung und Code-Vervollständigung an, wenn Sie externe Bibliotheken zu Ihrem Projekt hinzufügen. - + + You can add custom build steps in the <a href="qthelp://com.nokia.qtcreator/doc/creator-build-settings.html">build settings</a>. + Sie können eigene Erstellungsschritte in den <a href="qthelp://com.nokia.qtcreator/doc/creator-build-settings.html">'Build'-Einstellungen</a> hinzufügen. + + + + Within a session, you can add <a href="qthelp://com.nokia.qtcreator/doc/creator-build-dependencies.html">dependencies</a> between projects. + In einer Sitzung können Sie <a href="qthelp://com.nokia.qtcreator/doc/creator-build-dependencies.html">Abhängigkeiten</a> zwischen Projekten herstellen. + + + You can show and hide the side bar using <tt>%1+0<tt>. Sie können die Seitenleiste mit <tt>%1+0</tt> anzeigen oder zuklappen. @@ -11774,12 +11777,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Sie können die <tt>Finden</tt>-Funktion durch Auswahl von &quot;Ganze Wörter&quot; oder &quot;Groß/Kleinschreibung&quot; steuern. Klicken Sie einfach auf die Symbole rechts vom Eingabefeld. - - If you add <a href="qthelp://com.nokia.qtcreator/doc/creator-external-library-handling.html">external libraries</a>, Qt Creator will automatically offer syntax highlighting and code completion. - Wenn Sie eine <a href="qthelp://com.nokia.qtcreator/doc/creator-external-library-handling.html">externe Bibliothek</a> hinzufügen, bietet Qt Creator automatisch Syntax-Hervorhebung und Code-Vervollständigung. - - - + The code completion is CamelCase-aware. For example, to complete <tt>namespaceUri</tt> you can just type <tt>nU</tt> and hit <tt>Ctrl+Space</tt>. Die Code-Vervollständigung versteht CamelCase. Sie können zum Beipiel statt <tt>namespaceUri</tt> einfach <tt>nU</tt> schreiben und danach <tt>Strg+Leertaste</tt> drücken. @@ -11809,17 +11807,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Mit der <a href="qthelp://com.nokia.qtcreator/doc/creator-navigation.html">Locator-Leiste</a> (<tt>%1+K</tt>) können Sie schnell nach Methoden, Klassen, Hilfe und anderem suchen. - - You can add custom build steps in the <a href="qthelp://com.nokia.qtcreator/doc/creator-project-pane.html#build-settings">build settings</a>. - Sie können eigene Erstellungsschritte in den <a href="qthelp://com.nokia.qtcreator/doc/creator-project-pane.html#build-settingsl">'Build'-Einstellungen</a> hinzufügen. - - - - Within a session, you can add <a href="qthelp://com.nokia.qtcreator/doc/creator-project-pane.html#dependencies">dependencies</a> between projects. - In einer Sitzung können Sie <a href="qthelp://com.nokia.qtcreator/doc/creator-project-pane.html#dependencies">Abhängigkeiten</a> zwischen Projekten herstellen. - - - + You can set the preferred editor encoding for every project in <tt>Projects -> Editor Settings -> Default Encoding</tt>. Sie können ihre Encoding-Vorgabe für den Editor für jedes Projekt in <tt>Projekte -> Editoreinstellungen -> Encoding-Vorgabe</tt> einstellen. @@ -11943,7 +11931,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Qt4ProjectManager::Internal::MakeStepFactory - + Make Make @@ -11990,7 +11978,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Qt4ProjectManager::Internal::QMakeStepFactory - + qmake qmake @@ -12058,13 +12046,12 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Qt4ProjectManager::Internal::Qt4ProFileNode - - + Error while parsing file %1. Giving up. Fehler beim Auswerten von %1. Abbruch. - + Could not find .pro file for sub dir '%1' in '%2' Die .pro-Datei des Unterverzeichnisses '%1' konnte in '%2' nicht gefunden werden @@ -12082,7 +12069,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Shadow-Build-Verzeichnis - + using <font color="#ff0000">invalid</font> Qt Version: <b>%1</b><br>%2 verwende <font color="#ff0000">ungültige</font> Qt-Version: <b>%1</b><br>%2 @@ -12102,7 +12089,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Allgemein - + Building in subdirectories of the source directory is not supported by qmake. qmake unterstützt keine Build-Vorgänge in dem Quellverzeichnis untergeordneten Verzeichnissen. @@ -12167,7 +12154,7 @@ Wählt eine für Desktop-Entwicklung geeignete Qt-Version aus, sofern sie verfü Erstellen - + Run qmake in %1 qmake in %1 ausführen @@ -12520,7 +12507,7 @@ p, li { white-space: pre-wrap; } Installationspaket: - + Device on serial port: Gerät auf serieller Schnittstelle: @@ -12791,21 +12778,21 @@ Installiere Anwendung auf '%2'... Qt4ProjectManager::MakeStep - + Make Qt4 MakeStep display name. Make - - <font color="#ff0000">Could not find make command: %1 in the build environment</font> - <font color="#ff0000">Das make-Kommando %1 konnte in der Build-Umgebung nicht gefunden werden</font> + + Could not find make command: %1 in the build environment + Das 'make'-Kommando '%1' konnte in der Build-Umgebung nicht gefunden werden Qt4ProjectManager::MakeStepConfigWidget - + Override %1: Überschreibe %1: @@ -12823,20 +12810,20 @@ Installiere Anwendung auf '%2'... Qt4ProjectManager::QMakeStep - + qmake QMakeStep display name. - - <font color="#0000ff">Configuration is faulty, please check the Build Issues view for details.</font> - <font color="#0000ff">Die Konfiguration ist fehlerhaft. Details befinden sich in der Ansicht "Build-Probleme".</font> + + Configuration is faulty, please check the Build Issues view for details. + Die Konfiguration ist fehlerhaft. Details befinden sich in der Ansicht "Build-Probleme". - - <font color="#0000ff">Configuration unchanged, skipping qmake step.</font> - <font color="#0000ff">Unveränderte Konfiguration, qmake-Schritt wird übersprungen.</font> + + Configuration unchanged, skipping qmake step. + Unveränderte Konfiguration, qmake-Schritt wird übersprungen. @@ -12868,7 +12855,7 @@ Installiere Anwendung auf '%2'... Qt4ProjectManager::QtVersionManager - + <not found> <nicht gefunden> @@ -13370,7 +13357,7 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich ResourceEditor::Internal::ResourceEditorW - + untitled kein Titel @@ -13396,7 +13383,7 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich SharedTools::QrcEditor - + Add Files Dateien hinzufügen @@ -13621,10 +13608,6 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich Subversion::Internal::CheckoutWizard - - Checks out a project from a Subversion repository and tries to load the contained project. - Holt ein Projekt aus einem Subversion-Repository und versucht, das darin enthaltene Projekt zu laden. - Checks out a Subversion repository and tries to load the contained project. @@ -13997,13 +13980,13 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich - + No subversion executable specified! Es wurde keine ausführbaren Subversion-Datei angegeben! - + The process terminated with exit code %1. Der Prozess wurde beendet, Rückgabewert %1. @@ -14061,7 +14044,7 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich TextEditor::BaseTextDocument - + untitled kein Titel @@ -14092,7 +14075,7 @@ Um es abzurufen, tippen Sie das Kürzel im Locator, gefolgt von einem Leerzeich TextEditor::BaseTextEditorEditable - + Line: %1, Col: %2 Zeile: %1, Spalte: %2 @@ -14453,7 +14436,7 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: TextEditor::Internal::FindInFiles - + Files on File System Dateien aus dem Dateisystem @@ -14473,7 +14456,7 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: Such&muster für Dateinamen: - + Directory to search Verzeichnis @@ -15556,13 +15539,13 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: - The unsaved file %1 has been changed outside Qt Creator. Do you want to reload it and discard your changes? - Die noch nicht gespeicherte Datei %1 wurde außerhalb von Qt Creator geändert. Möchten Sie sie neu laden? + The unsaved file <i>%1</i> has been changed outside Qt Creator. Do you want to reload it and discard your changes? + Die noch nicht gespeicherte Datei <i>%1</i> wurde außerhalb von Qt Creator geändert. Möchten Sie sie neu laden? - The file %1 has changed outside Qt Creator. Do you want to reload it? - Die Datei %1 wurde außerhalb von Qt Creator geändert. Möchten Sie sie neu laden? + The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it? + Die Datei <i>%1</i> wurde außerhalb von Qt Creator geändert. Möchten Sie sie neu laden? @@ -15601,7 +15584,7 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: Es konnten keine dem Muster (%1) entsprechenden Projektdateien in '%2' gefunden werden. - + The Project Explorer is not available. Das ProjectExplorer-Plugin ist nicht verfügbar. @@ -15729,7 +15712,7 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: VCSBase::VCSBaseEditor - + Annotate "%1" Annotation für "%1" @@ -15739,7 +15722,7 @@ Die folgenden Encodings scheinen der Datei zu entsprechen: "%1" Kopieren - + Describe change %1 Details zur Änderung %1 anzeigen @@ -15923,8 +15906,8 @@ p, li { white-space: pre-wrap; } - <b>Qt LGPL Support</b><br /><font color='gray'>Buy professional Qt support</font> - <b>Qt LGPL Unterstützung</b><br /><font color='gray'>Erwerben Sie professionelle Unterstützung für Qt</font> + <b>Qt LGPL Support</b><br /><font color='gray'>Buy commercial Qt support</font> + <b>Qt LGPL Unterstützung</b><br/><font color='gray'>Erwerben Sie kommerzielle Unterstützung für Qt</font> @@ -15984,7 +15967,7 @@ p, li { white-space: pre-wrap; } Feedback - + Welcome Willkommen @@ -16621,7 +16604,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Bibliothek - + Items Title of library items view Elemente @@ -17417,10 +17400,20 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Rand - + Qt Quick Designer Qt-Quick-Designer + + + Text Editor Helper + Texteditor-Unterstützung + + + + enable + Aktivieren + Qt4ProjectManager::Internal::TestWizardPage @@ -17509,7 +17502,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. CMakeProjectManager::Internal::CMakeRunConfiguration - + Clean Environment Umgebung löschen @@ -17523,6 +17516,11 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Build Environment Build-Umgebung + + + (disabled) + (deaktiviert) + CMakeProjectManager::Internal::CMakeTarget @@ -17686,7 +17684,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Subversion Commit-Editor - + Subversion Command Log Editor Subversion Command-Log-Editor @@ -17837,18 +17835,18 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. FakeVim::Internal::FakeVimExCommandsPage - - + + Ex Command Mapping Zuordnung von Kommandos - + FakeVim FakeVim - + Ex Trigger Expression Kommando @@ -17874,7 +17872,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. GitClient - + Unable to determine the repository for %1. Das Repository von %1 konnte nicht bestimmt werden. @@ -17937,7 +17935,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. Mercurial::Internal::MercurialClient - + Unable to find parent revisions of %1 in %2: %3 Die übergeordnete Revision von %1 im Repository %2 konnte nicht bestimmt werden: %3 @@ -18288,7 +18286,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Der Prozess "%1" wurde beendet (Rückgabewert %2): %3 - + The client does not seem to contain any mapped files. Der Perforce-Client enthält offenbar keine Dateizuordnungen. @@ -18447,12 +18445,12 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Ausführungskonfiguration wählen - + Build: Erstellung: - + Run: Ausführung: @@ -18460,7 +18458,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. ProjectExplorer::Internal::MiniProjectTargetSelector - + Project Projekt @@ -18470,7 +18468,17 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Projekt auswählen - + + Build: + Erstellung: + + + + Run: + Ausführung: + + + <html><nobr><b>Project:</b> %1<br/>%2%3<b>Run:</b> %4%5</html> <html><nobr><b>Projekt:</b> %1<br/>%2%3<b>Ausführung:</b> %4%5</html> @@ -18519,7 +18527,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Es ist kein Ziel festgelegt. - + Qt Creator Qt Creator @@ -18533,8 +18541,8 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. ProjectExplorer::TaskWindow - - + + Build Issues Build-Probleme @@ -18616,7 +18624,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Qt Simulator - + <b>Device:</b> Not connected <b>Gerät:</b> Nicht angeschlossen @@ -18633,11 +18641,6 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. QmlProjectManager::QmlTarget - - QML Runtime - QML Runtime target display name - QML-Laufzeitumgebung - QML Viewer @@ -18986,7 +18989,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.&Rechte Seitenleiste umschalten - + Projects Projekte @@ -19004,12 +19007,12 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. QmlJSEditor::Internal::QmlJSTextEditor - + <Select Symbol> <Symbol auswählen> - + Rename... Umbenennen... @@ -19097,25 +19100,15 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. Qt4ProjectManager::Internal::MaemoRunConfiguration - + New Maemo Run Configuration Neue Maemo-Ausführungskonfiguration - - - '%1' does not contain a valid Maemo simulator image. - '%1' enthält kein gültiges Maemo-Simulator-Image. - - - - Simulator could not be found. Please check the Qt Version you are using and that a simulator image is already installed. - Der Simulator konnte nicht gefunden werden. Bitte überprüfen Sie die verwendete Qt-Version und die Installation des Simulator-Images. - Qt4ProjectManager::Internal::MaemoRunConfigurationFactory - + New Maemo Run Configuration Neue Maemo-Ausführungskonfiguration @@ -19123,7 +19116,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. Qt4ProjectManager::Internal::MaemoRunControlFactory - + Run on device Auf Gerät ausführen @@ -19160,26 +19153,21 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Arguments: Argumente: - - - Simulator: - Simulator: - Qt4ProjectManager::Internal::AbstractMaemoRunControl - + Files to deploy: %1. Dateien für Deployment: %1: - + Deploying Deployment - + No device configuration set for run configuration. Für Ausführungskonfiguration ist keine Gerätekonfiguration eingestellt. @@ -19204,7 +19192,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Löschen beendet. - + Starting remote application. Starte Anwendung. @@ -19234,12 +19222,12 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Prozess auf Gerät beendet. - + Remote Execution Failure Fehler bei Ausführung auf dem Gerät - + Deployment failed: %1 Deployment fehlgeschlagen: %1 @@ -19257,7 +19245,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Die öffentliche Schlüsseldatei '%1' konnte nicht gelesen werden. - + Key deployment failed: %1 Das Versenden des Schlüssels schlug fehl: %1 @@ -19267,13 +19255,13 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Öffentlichen Schlüssel senden... - - + + Deployment Failed Deployment fehlgeschlagen - + New Device Configuration %1 Standard Configuration name with number New Device Configuration %1 @@ -19284,7 +19272,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Datei mit öffentlichem Schlüssel - + Stop Deploying Deployement beenden @@ -19330,7 +19318,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. Qt4ProjectManager - + Qt4 Qt4 @@ -19466,7 +19454,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. trk::Launcher - + Cannot open remote file '%1': %2 Die Datei '%1' auf dem Gerät konnte nicht geöffnet werden: %2 @@ -19487,7 +19475,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. About Bauhaus AboutDialog - + Über Bauhaus @@ -19505,7 +19493,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. unknown value for enum - + Unbekannter Wert für Aufzählung @@ -19517,14 +19505,6 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.'%1' is not a member of '%2' '%1' gehört nicht zu '%2' - - easing-curve name is not a string - Der Name der Easing-Kurve ist keine Zeichenkette - - - unknown easing-curve name - Ungültiger Name der Easing-Kurve - value might be 'undefined' @@ -19533,7 +19513,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. enum value is not a string or number - + Wert der Aufzählung ist weder Zeichenkette noch Zahl @@ -19580,7 +19560,18 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen. BINEditor::BinEditor - + + Decimal unsigned value (little endian): %1 +Decimal unsigned value (big endian): %2 +Decimal signed value (little endian): %3 +Decimal signed value (big endian): %4 + Dezimaler, vorzeichenloser Wert (Little Endian): %1 +Dezimaler, vorzeichenloser Wert (Big Endian): %2 +Dezimaler, vorzeichenbehafteter Wert (Little Endian): %3 +Dezimaler, vorzeichenbehafteter Wert (Big Endian): %4 + + + Copying Failed Das Kopieren schlug fehl @@ -19600,7 +19591,7 @@ Sie können die Änderungen in einem Stash ablegen oder rücksetzen.Auswahl als hexadezimale Werte kopieren - + Jump to Address in This Window Gehe zu Adresse in diesem Fenster @@ -19870,14 +19861,6 @@ Please check your project settings. Ausgaben des QML-Inspektors, wie zum Beispiel Information über die Verbindung zum Server. - - QmlJSEditor::Internal::HoverHandler - - - Unfiltered - Ungefiltert - - QmlJSEditor::Internal::ModelManager @@ -20010,20 +19993,7 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben QmlProjectManager::QmlProjectRunConfiguration - QML Runtime - QMLRunConfiguration display name. - QML-Laufzeitumgebung - - - QML Runtime - QML-Laufzeitumgebung - - - QML Runtime arguments: - Kommandozeilenargumente für QML-Laufzeitumgebung - - - + QML Viewer QMLRunConfiguration display name. QML-Betrachter @@ -20065,7 +20035,7 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben Qt4ProjectManager::Internal::Qt4TargetFactory - + Debug Debug @@ -20099,44 +20069,15 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben Über Plugins - - Qt4ProjectManager::Internal::MaemoManager - - - - Start Maemo Emulator - Maemo-Emulator starten - - - - Qemu failed to start: %1 - Qemu konnte nicht gestartet werden: %1 - - - - Qemu crashed - Qemu ist abgestürzt - - - - Qemu error - Qemu-Fehler - - - - Stop Maemo Emulator - Maemo-Emulator stoppen - - QmlDesigner::Internal::BauhausPlugin - + Switch Text/Design Text/Design umschalten - + Save %1 As... Speichere '%1' unter... @@ -20460,12 +20401,12 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben - + Load on Startup Beim Start Laden - + Utilities Hilfsmittel @@ -20473,7 +20414,7 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben Utils::fileDeletedPrompt - + File has been removed Die Datei wurde gelöscht @@ -20545,14 +20486,6 @@ QML-Anwendungen werden durch die QML-Laufzeitumgebung direkt ausgeführt und ben Fehler: Zeitüberschreitung nach %1s. - - Help::HelpManager - - - Unfiltered - Kein - - ProjectExplorer::BuildConfiguration @@ -20941,7 +20874,7 @@ Haben Sie Qemu gestartet? Qt4ProjectManager::Qt4Project - + Evaluating Auswertung @@ -20969,7 +20902,7 @@ Haben Sie Qemu gestartet? <%1> hat kein gültiges Attribut %2 - + %1: %2 %1: %2 @@ -21000,7 +20933,7 @@ Haben Sie Qemu gestartet? QmlJS::Link - + could not find file or directory Datei oder Ordner konnte nicht gefunden werden @@ -21015,7 +20948,7 @@ Haben Sie Qemu gestartet? Package-Import erfordert eine Versionsnummer - + package not found Package nicht gefunden @@ -21520,13 +21453,13 @@ Haben Sie Qemu gestartet? Help::Internal::HelpViewer - + Open Link Verweis öffnen - + Open Link as New Page Verweis in neuer Seite öffnen @@ -21602,13 +21535,13 @@ Wählt Qt-Versionen für Simulator und mobile Ziele aus, sofern sie verfügbar s Status - + Qt Creator can set up the following targets for project <b>%1</b>: %1: Project name Qt Creator kann für das Projekt <b>%1</b> die folgenden Ziele anlegen: - + Choose a directory to scan for additional shadow builds Zusätzliche Shadow-Builds @@ -21624,7 +21557,7 @@ Wählt Qt-Versionen für Simulator und mobile Ziele aus, sofern sie verfügbar s Im Ordner "%2" konnten keine Builds des Projekts "%1" gefunden werden. - + <b>Error:</b> Severity is Task::Error <b>Fehler:</b> @@ -21636,7 +21569,7 @@ Wählt Qt-Versionen für Simulator und mobile Ziele aus, sofern sie verfügbar s <b>Warnung:</b> - + Import Is this an import of an existing build or a new one? Import @@ -21736,28 +21669,6 @@ Wählt Qt-Versionen für Simulator und mobile Ziele aus, sofern sie verfügbar s Default short title for custom wizard page to be shown in the progress pane of the wizard. Details - - - Creates a C++ plugin to extend the funtionality of the QML runtime. - Creates a plug-in for the QML runtime. - Erstellt ein C++-Plugin zur Erweiterung der Funktionalität der QML-Laufzeitumgebung. - - - - - QML Runtime Plug-in - Plugin für QML-Laufzeitumgebung - - - - QML Runtime Plug-in Parameters - Parameter des Plugins für die QML-Laufzeitumgebung - - - - Example Object Class-name: - Klassenname des Beispiel-Objektes: - Qt4ProjectManager::Internal::BaseQt4ProjectWizardDialog @@ -22105,7 +22016,7 @@ Namen <E-Mail> Alias <E-Mail? QApplication - + EditorManager Next Open Document in History Nächstes Dokument im Verlauf @@ -22136,7 +22047,7 @@ Namen <E-Mail> Alias <E-Mail? QmlDesigner::Internal::ModelPrivate - + invalid type ungültiger Typ @@ -22177,7 +22088,7 @@ Namen <E-Mail> Alias <E-Mail? Qt4ProjectManager::Internal::MaemoPackageCreationStep - + Creating package file ... Erzeuge Paketdatei... @@ -22187,7 +22098,7 @@ Namen <E-Mail> Alias <E-Mail? Die MADDE-Konfigurationsdatei '%1' kann nicht geöffnet werden. - + Packaging Error: Cannot open file '%1'. Fehler bei Paketerstellung: Die Datei '%1' kann nicht geöffnet werden. @@ -22197,7 +22108,7 @@ Namen <E-Mail> Alias <E-Mail? Fehler bei Paketerstellung: Die Datei '%1' kann nicht geschrieben werden. - + Packaging Error: Could not create directory '%1'. Fehler bei Paketerstellung: Der Ordner '%1' konnte nicht erstellt werden. @@ -22217,28 +22128,22 @@ Namen <E-Mail> Alias <E-Mail? Paketdatei erzeugt. - + Package Creation: Running command '%1'. Paketerstellung: Führe Kommando '%1' aus. - Packaging failed. Die Paketerstellung schlug fehl. - + Packaging error: Could not start command '%1'. Reason: %2 Fehler bei Paketerstellung: Das Kommando '%1' konnte nicht ausgeführt werden: %2 - Packaging Error: Command '%1' timed out. - Fehler bei Paketerstellung: Zeitüberschreitung bei Kommando '%1'. - - - Packaging Error: Command '%1' failed. Fehler bei Paketerstellung: Das Kommando '%1' schlug fehl. @@ -22256,7 +22161,7 @@ Namen <E-Mail> Alias <E-Mail? Qt4ProjectManager::Internal::MaemoPackageCreationWidget - + <b>Create Package:</b> <b>Erzeuge Paketdatei:</b> @@ -22266,7 +22171,7 @@ Namen <E-Mail> Alias <E-Mail? Lokale Datei - + File already in package Die Datei ist bereits im Paket enthalten @@ -22387,11 +22292,6 @@ Namen <E-Mail> Alias <E-Mail? MaemoPackageCreationWidget - Package contents: - Inhalt des Pakets: - - - Add File to Package Hinzuzufügende Datei @@ -22400,6 +22300,41 @@ Namen <E-Mail> Alias <E-Mail? Remove File from Package Datei aus Paket entfernen + + + Check this if you want the files below to be deployed directly. + Startet das Deployment der Dateien unmittelbar. + + + + Skip packaging step + Paketerstellung überspringen + + + + Version number: + Versionsnummer: + + + + Major: + Major: + + + + Minor: + Minor: + + + + Patch: + Patch: + + + + Files to deploy: + Dateien für Deployment: + Utils::FancyMainWindow @@ -22560,7 +22495,7 @@ Namen <E-Mail> Alias <E-Mail? ProjectExplorer::Internal::SessionNameInputDialog - + Enter the name of the session: Geben Sie den Namen der Sitzung an: @@ -22758,7 +22693,7 @@ Namen <E-Mail> Alias <E-Mail? QmlDesigner::PropertyEditor - + Invalid Id Ungültige Id @@ -22792,22 +22727,23 @@ Namen <E-Mail> Alias <E-Mail? InvalidIdException - - Ids have to be unique: - Ids müssen eindeutig sein: - - - - Invalid Id: - Ungültige Id: - - - - -Only alphanumeric characters and underscore allowed. + + Only alphanumeric characters and underscore allowed. Ids must begin with a lowercase letter. - -Ids müssen mit einem Kleinbuchstaben beginnen und dürfen nur alphanumerische Zeichen und Unterstriche enthalten. + Es sind nur alphanumerische Zeichen und Unterstriche zulässig. +Ids müssen außerdem mit einem Kleinbuchstaben beginnen. + + + + Ids have to be unique. + Ids müssen eindeutig sein. + + + + Invalid Id: %1 +%2 + Ungültige Id: %1 +%2 @@ -22821,7 +22757,7 @@ Ids müssen mit einem Kleinbuchstaben beginnen und dürfen nur alphanumerische Z QmlDesigner::QmlModelView - + Invalid Id Ungültige Id @@ -22897,4 +22833,100 @@ Ids müssen mit einem Kleinbuchstaben beginnen und dürfen nur alphanumerische Z QML-Betrachter + + ContextPaneTextWidget + + + Text + Text + + + + Style + Stil + + + + Normal + + + + + Outline + Umriss + + + + Raised + Hervorgehoben + + + + Sunken + Abgesenkt + + + + ... + ... + + + + Core::HelpManager + + + Unfiltered + Ungefiltert + + + + FakeVim::Internal::FakeVimHandler::Private + + + Not an editor command: %1 + Kein Editor-Kommando: %1 + + + + QmlDesigner::ContextPaneWidget + + + Disable permanently + Permanent deaktivieren + + + + Qt4ProjectManager::Internal::QemuRuntimeManager + + + + Start Maemo Emulator + Maemo-Emulator starten + + + + Qemu has been shut down, because you removed the corresponding Qt version. + + + + + Qemu failed to start: %1 + Qemu konnte nicht gestartet werden: %1 + + + + Qemu crashed + Qemu ist abgestürzt + + + + Qemu error + Qemu-Fehler + + + + Stop Maemo Emulator + Maemo-Emulator stoppen + + diff --git a/src/app/main.cpp b/src/app/main.cpp index 99714241d0b..c08049f4c96 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -306,6 +306,9 @@ int main(int argc, char **argv) // Do this after the event loop has started QTimer::singleShot(100, &pluginManager, SLOT(startTests())); - return app.exec(); + + int ret = app.exec(); + pluginManager.shutdown(); + return ret; } diff --git a/src/libs/3rdparty/3rdparty.pro b/src/libs/3rdparty/3rdparty.pro index 5c2dec27d03..c7babdde2c0 100644 --- a/src/libs/3rdparty/3rdparty.pro +++ b/src/libs/3rdparty/3rdparty.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += botan \ - net7ssh +SUBDIRS += botan diff --git a/src/libs/3rdparty/net7ssh/AUTHORS b/src/libs/3rdparty/net7ssh/AUTHORS deleted file mode 100644 index 18d0a6839d5..00000000000 --- a/src/libs/3rdparty/net7ssh/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Andrew Useckas -Keef Aragon \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/CHANGELOG b/src/libs/3rdparty/net7ssh/CHANGELOG deleted file mode 100644 index 2ae5ca241a9..00000000000 --- a/src/libs/3rdparty/net7ssh/CHANGELOG +++ /dev/null @@ -1,126 +0,0 @@ -1.3.2 -Random Number Generator is now thread safe. Thanks to Jack Llloyd of Radnombit. -Timeouts in waitFor() and sendCmd() now work as they are supposed to. -Fixed include issues. -Fixed handling of NULL packet. - - -1.3.1 -Channel ID managment rewriten and ID clashes that caused multiple issues are now fixed. -Fixed cleanup procedures after timed out login. -Fixed cleanup procedures after remote end goes away. -Fixed variable types for MSVS compatbility. -Fixed thred sleep issues under Windows. -Fixed couple of small memory leaks. - - -1.3.0 -Changes made to support new stable Botan 1.8.x crypto library. -Added macros for backward compatibility with Botan 1.6.x. -All strings returned by read() method are now NULL terminated. -All error message strings are now NULL terminated. -Fixed multiple race conditions related to late mutex locking. -Fixed multiple race conditions related to premature mutex unlocking. -Fixed segfault when using cryptographic algorithms with block size > 64bit. -Added aes192-cbc algorithm support. -Fixed cleanup of connections after authentication failure. -Fixed SFTP crash after changing to non existent remote directory. -Updated examples. -Updated api docs. - - -1.2.7 -Converted to cmake from auto* tools. -Moved thread functions into macros to avoid conflicts when linking to POSIX libraries in Windows. -Fixed a race condition in ne7ssh.cpp. -Fixed multiple memory leaks. - - -1.2.6 -Fixed includes to compile with GCC 4.3.0. -Fixed the cleanup of timed out connections. -Fixed a race condition within ne7ssh.cpp. -Fixes for mingw32 compiler. - - -1.2.5 -Fixed a typo preventing use of 3des-cbc (thanks to Henry Fann for the patch). -Fixed includes preventing compile in older versions of Linux. -Fixed memory relocation issue in ne7ssh destructor. - - -1.2.4 -Added support for SSH2_MSG_USERAUTH_BANNER. -Fixed infinate loop in select_thread(). -Other bug fixes. - - -1.2.3 -Fixed error logging issue seen during authentication. -Added more detailed authentication error messages. -Adjusted the error reporting interface for easier porting. -Addressed debugging issues in the Windows port. -Included new code examples reflecting the changes to the error reporting interface. - - -1.2.2 -Fixed premature communication thread termination. -Adjustments for MINGW compiler. -Other bugfixes. - - -1.2.1 -Fixed buffer overflow in SFTP put() and get(). -Mutex put in it's own class. -Code formatting fixed. -Other bugfixes. - - -1.2.0 -Implemented Secure FTP client functionality. -Fixed mutex locking issues. -Fixed race conditions when running with multiple threads. -Added support for RSA host keys. -Added diffie-hellman-group14-sha1 key exchange algorithm support. -Added timeout variable to connect methods. -Other bugfixes. - - -1.1.6 -Added support for Botan 1.5. Thanks to Jack Lloyd for the patch. -WIN32 related bugfixes. -Improved PEM file checking. -Other minor bugfixes. - - -1.1.5 - -Fixed DSA key generation. -Implemented single command execution. -Added Support for reading binary data. -Fixed getReceivedSize() method. -Error handling rewritten. -Fixed a few memory leaks. -Other bugfixes. - - -1.1 - -RSA and DSA public key authentication support added. -RSA and DSA key generation methods added. -All errors are handled through throwError() function. -Syslog functions removed. -Implemented getReceivedSize() method to support reading past /0 character in received stream. -Botan types changed to full types to avoid compatibility issues with WIN32. -WIN32 specific thread functions added. -Premature mutex unlocking in connection routines fixed. -Fixed prevLen variable initialization in waitFor method. -In Net7Sock class write() method, write() replaced with send(). -In Net7Sock class read() method, read() replaced with recv(). -Type definitions adjusted for WIN32 compatibility. -WIN32 socket functions implemented. - - -1.03 - -Initial stand alone release. diff --git a/src/libs/3rdparty/net7ssh/CMakeLists.txt b/src/libs/3rdparty/net7ssh/CMakeLists.txt deleted file mode 100644 index 9bd25d2d557..00000000000 --- a/src/libs/3rdparty/net7ssh/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -cmake_minimum_required(VERSION 2.0) -project(net7ssh CXX) -INCLUDE(CheckIncludeFileCXX) -check_include_file_cxx("botan/botan.h" HAVE_BOTAN) -if (NOT ${HAVE_BOTAN}) -MESSAGE(FATAL_ERROR "Could not find Botan library.") -endif() -set(CMAKE_INSTALL_PREFIX "/usr") -add_subdirectory ( src ) -include_directories ( src ) -if ( UNIX ) - SET(UNIX_STYLE_FLAGS 1) - SET(WIN32_STYLE_FLAGS 0) - EXECUTE_PROCESS( - COMMAND uname -a - OUTPUT_VARIABLE OS_ARCH - ) - - IF ( OS_ARCH MATCHES ".*SunOS.*" ) - MESSAGE ("Making Changes for SunOS!") - SET(CMAKE_C_COMPILER "cc") - SET(CMAKE_CXX_COMPILER "CC") - SET(CMAKE_LINKER "cc") - SET(CMAKE_AR "/usr/ccs/bin/ar") - SET(CMAKE_CXX_FLAGS "-I/usr/local/include") - SET(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/lib") - SET(CMAKE_MODULE_LINKER_FLAGS "-L/usr/local/lib") - ENDIF ( OS_ARCH MATCHES ".*SunOS.*" ) - -ENDIF ( UNIX ) -set(net7ssh_LIB_SRCS - src/crypt.cpp - src/crypt.h - src/ne7ssh.cpp - src/ne7ssh.h - src/ne7ssh_channel.cpp - src/ne7ssh_channel.h - src/ne7ssh_connection.cpp - src/ne7ssh_connection.h - src/ne7ssh_kex.cpp - src/ne7ssh_kex.h - src/ne7ssh_session.cpp - src/ne7ssh_session.h - src/ne7ssh_string.cpp - src/ne7ssh_string.h - src/ne7ssh_transport.cpp - src/ne7ssh_transport.h - src/ne7ssh_types.h - src/ne7ssh_keys.cpp - src/ne7ssh_keys.h - src/ne7ssh_error.cpp - src/ne7ssh_error.h - src/ne7ssh_sftp.cpp - src/ne7ssh_sftp.h - src/ne7ssh_sftp_packet.cpp - src/ne7ssh_sftp_packet.h - src/ne7ssh_mutex.cpp - src/ne7ssh_mutex.h) - -add_library(ne7ssh STATIC ${net7ssh_LIB_SRCS}) - -add_library(net7ssh SHARED ${net7ssh_LIB_SRCS}) -target_link_libraries(net7ssh botan) -set_target_properties(net7ssh PROPERTIES VERSION 0.3.1 SOVERSION 0) - - -########### install files ############### - -install(TARGETS net7ssh LIBRARY DESTINATION lib) -install(FILES src/ne7ssh.h src/ne7ssh_types.h src/ne7ssh_error.h src/ne7ssh_mutex.h DESTINATION include) -install(FILES LICENSE.QPL AUTHORS INSTALL COPYING CHANGELOG DESTINATION share/doc/ne7ssh) -install(DIRECTORY doc DESTINATION share/doc/ne7ssh) -install(DIRECTORY doc/html DESTINATION share/doc/ne7ssh) -install(DIRECTORY examples DESTINATION share/doc/ne7ssh) diff --git a/src/libs/3rdparty/net7ssh/COPYING b/src/libs/3rdparty/net7ssh/COPYING deleted file mode 100644 index 85bc6356f50..00000000000 --- a/src/libs/3rdparty/net7ssh/COPYING +++ /dev/null @@ -1,103 +0,0 @@ - THE Q PUBLIC LICENSE - version 1.0 - - Copyright (C) 1999-2000 Troll Tech AS, Norway. - Everyone is permitted to copy and - distribute this license document. - -The intent of this license is to establish freedom to share and change the -software regulated by this license under the open source model. - -This license applies to any software containing a notice placed by the -copyright holder saying that it may be distributed under the terms of -the Q Public License version 1.0. Such software is herein referred to as -the Software. This license covers modification and distribution of the -Software, use of third-party application programs based on the Software, -and development of free software which uses the Software. - - Granted Rights - -1. You are granted the non-exclusive rights set forth in this license - provided you agree to and comply with any and all conditions in this - license. Whole or partial distribution of the Software, or software - items that link with the Software, in any form signifies acceptance of - this license. - -2. You may copy and distribute the Software in unmodified form provided - that the entire package, including - but not restricted to - copyright, - trademark notices and disclaimers, as released by the initial developer - of the Software, is distributed. - -3. You may make modifications to the Software and distribute your - modifications, in a form that is separate from the Software, such as - patches. The following restrictions apply to modifications: - - a. Modifications must not alter or remove any copyright notices in - the Software. - - b. When modifications to the Software are released under this - license, a non-exclusive royalty-free right is granted to the - initial developer of the Software to distribute your modification - in future versions of the Software provided such versions remain - available under these terms in addition to any other license(s) of - the initial developer. - -4. You may distribute machine-executable forms of the Software or - machine-executable forms of modified versions of the Software, provided - that you meet these restrictions: - - a. You must include this license document in the distribution. - - b. You must ensure that all recipients of the machine-executable forms - are also able to receive the complete machine-readable source code - to the distributed Software, including all modifications, without - any charge beyond the costs of data transfer, and place prominent - notices in the distribution explaining this. - - c. You must ensure that all modifications included in the - machine-executable forms are available under the terms of this - license. - -5. You may use the original or modified versions of the Software to - compile, link and run application programs legally developed by you - or by others. - -6. You may develop application programs, reusable components and other - software items that link with the original or modified versions of the - Software. These items, when distributed, are subject to the following - requirements: - - a. You must ensure that all recipients of machine-executable forms of - these items are also able to receive and use the complete - machine-readable source code to the items without any charge - beyond the costs of data transfer. - - b. You must explicitly license all recipients of your items to use - and re-distribute original and modified versions of the items in - both machine-executable and source code forms. The recipients must - be able to do so without any charges whatsoever, and they must be - able to re-distribute to anyone they choose. - - - c. If the items are not available to the general public, and the - initial developer of the Software requests a copy of the items, - then you must supply one. - - Limitations of Liability - -In no event shall the initial developers or copyright holders be liable -for any damages whatsoever, including - but not restricted to - lost -revenue or profits or other direct, indirect, special, incidental or -consequential damages, even if they have been advised of the possibility -of such damages, except to the extent invariable law, if any, provides -otherwise. - - No Warranty - -The Software and this license document are provided AS IS with NO WARRANTY -OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE. - Choice of Law - -This license is governed by the Laws of Norway. Disputes shall be settled -by Oslo City Court. diff --git a/src/libs/3rdparty/net7ssh/INSTALL b/src/libs/3rdparty/net7ssh/INSTALL deleted file mode 100644 index fde2e814599..00000000000 --- a/src/libs/3rdparty/net7ssh/INSTALL +++ /dev/null @@ -1,26 +0,0 @@ -Basic Installation Instructions -=============================== - - These are generic installation instructions. - - NetSieben SSH Library requires Botan crypto library 1.4.9 or higher. - It can be found here: - - http://botan.randombit.net - - NetSieben SSH Library requires Cmake. Cmake software can be found here: - http://www.cmake.org - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `cmake .' to configure the package for your system. - - 2. Type `make all' to compile the package. - - 3. Type `make install' to install the programs and any data files and - documentation. - - 4. You can remove the program binaries and object files from the - source code directory by typing `make clean'. - diff --git a/src/libs/3rdparty/net7ssh/LICENSE.QPL b/src/libs/3rdparty/net7ssh/LICENSE.QPL deleted file mode 100644 index 85bc6356f50..00000000000 --- a/src/libs/3rdparty/net7ssh/LICENSE.QPL +++ /dev/null @@ -1,103 +0,0 @@ - THE Q PUBLIC LICENSE - version 1.0 - - Copyright (C) 1999-2000 Troll Tech AS, Norway. - Everyone is permitted to copy and - distribute this license document. - -The intent of this license is to establish freedom to share and change the -software regulated by this license under the open source model. - -This license applies to any software containing a notice placed by the -copyright holder saying that it may be distributed under the terms of -the Q Public License version 1.0. Such software is herein referred to as -the Software. This license covers modification and distribution of the -Software, use of third-party application programs based on the Software, -and development of free software which uses the Software. - - Granted Rights - -1. You are granted the non-exclusive rights set forth in this license - provided you agree to and comply with any and all conditions in this - license. Whole or partial distribution of the Software, or software - items that link with the Software, in any form signifies acceptance of - this license. - -2. You may copy and distribute the Software in unmodified form provided - that the entire package, including - but not restricted to - copyright, - trademark notices and disclaimers, as released by the initial developer - of the Software, is distributed. - -3. You may make modifications to the Software and distribute your - modifications, in a form that is separate from the Software, such as - patches. The following restrictions apply to modifications: - - a. Modifications must not alter or remove any copyright notices in - the Software. - - b. When modifications to the Software are released under this - license, a non-exclusive royalty-free right is granted to the - initial developer of the Software to distribute your modification - in future versions of the Software provided such versions remain - available under these terms in addition to any other license(s) of - the initial developer. - -4. You may distribute machine-executable forms of the Software or - machine-executable forms of modified versions of the Software, provided - that you meet these restrictions: - - a. You must include this license document in the distribution. - - b. You must ensure that all recipients of the machine-executable forms - are also able to receive the complete machine-readable source code - to the distributed Software, including all modifications, without - any charge beyond the costs of data transfer, and place prominent - notices in the distribution explaining this. - - c. You must ensure that all modifications included in the - machine-executable forms are available under the terms of this - license. - -5. You may use the original or modified versions of the Software to - compile, link and run application programs legally developed by you - or by others. - -6. You may develop application programs, reusable components and other - software items that link with the original or modified versions of the - Software. These items, when distributed, are subject to the following - requirements: - - a. You must ensure that all recipients of machine-executable forms of - these items are also able to receive and use the complete - machine-readable source code to the items without any charge - beyond the costs of data transfer. - - b. You must explicitly license all recipients of your items to use - and re-distribute original and modified versions of the items in - both machine-executable and source code forms. The recipients must - be able to do so without any charges whatsoever, and they must be - able to re-distribute to anyone they choose. - - - c. If the items are not available to the general public, and the - initial developer of the Software requests a copy of the items, - then you must supply one. - - Limitations of Liability - -In no event shall the initial developers or copyright holders be liable -for any damages whatsoever, including - but not restricted to - lost -revenue or profits or other direct, indirect, special, incidental or -consequential damages, even if they have been advised of the possibility -of such damages, except to the extent invariable law, if any, provides -otherwise. - - No Warranty - -The Software and this license document are provided AS IS with NO WARRANTY -OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE. - Choice of Law - -This license is governed by the Laws of Norway. Disputes shall be settled -by Oslo City Court. diff --git a/src/libs/3rdparty/net7ssh/README b/src/libs/3rdparty/net7ssh/README deleted file mode 100644 index d81761df4fa..00000000000 --- a/src/libs/3rdparty/net7ssh/README +++ /dev/null @@ -1,614 +0,0 @@ -NetSieben SSH Library (ne7ssh) v1.3.2 README - -LEGALESE - -NetSieben Technologies Pty Limited -http://www.netsieben.com - -Copyright (C) 2005-2009 NetSieben Technologies INC -ALL RIGHTS RESERVED - -This program may be distributed under the terms of the Q Public -License as defined by Trolltech AS of Norway and appearing in the -file LICENSE.QPL included in the packaging of this file. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - ----------------------------------------- - -Table of Contents - -1. Overview -1.1 Features -1.2 Dependencies -1.3 Installation - -2. Usage -2.1 Initializing the class -2.2 Setting the options -2.3 Connecting to a remote server -2.3.1 Key based authentication -2.3.1.1 Generating a key pair -2.3.2 Password based authentication - -2.4 Communications -2.4.1 Interactive mode -2.4.2 Single command - -2.5 Closing the connection -2.6 Error handling -2.6.1 Core context -2.6.2 Channel context -2.7 Secure FTP support -2.7.1 Initializing the subsystem -2.7.2 Setting a timeout for SFTP communications -2.7.3 Downloading a file -2.7.4 Uploading a file -2.7.5 Removing a file -2.7.6 Renaming or moving a file -2.7.7 Changing the current context -2.7.8 Creating a new directory -2.7.9 Removing a directory -2.7.10 Getting a directory listing -2.7.11 Changing permissions -2.7.12 Changing ownership - -3. Commercial License - ----------------------------------------- -1. Overview - -The Secure Shell (SSH) protocol is used by many, as a secure way of managing -servers, firewalls and other network appliances. Nowadays many custom built -applications require Secure Shell client functionality. Instead of spending -countless hours building SSH functionality into an application one can now use -NetSieben Technologies Inc. (NetSieben) SSH library to securely communicate -with a variety of SSH server implementations. - -The library was developed by NetSieben after researching the limited number of -options available. A lot of available solutions were either wrappers to openssh -application or libraries with very limited functionality, and at best, still in -alpha or beta stages of development. At this time version 1 of the SSH -protocol is outdated with well known security flaws inherently in its design. -Therefore NetSieben SSH library supports only with version 2 of the SSH -protocol. Currently NetSieben's library supports only the SSH client. - - -1.1 Features Feature Supported Algorithms - -Key exchange Diffie Hellman Group 1, SHA1 Signatures ssh-dss (1024) User -authentication public key, password Authentication keys DSA (512bit to -1024bit), RSA Encryption aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, -3des-cbc, aes128-cbc, cast128-cbc HMAC hmac-md5, hmac-sha1, none Compression -not supported Interoperability SSH Library should work with most SSH2 server -implementations. Tested with openssh on Linux. Solaris, FreeBSD and NetBSD. -Also tested with Juniper Netscreen ssh server implementation. - -Portability: The NetSieben SSH Library is based on the Botan crypto library, -making it highly portable. It has been tested on Linux x86, Linux x86_64Linux -PPC, Linux SPARC, Solaris, Windows 2000 and XP. - -1.2 Dependencies - -NetSiben SSH Library requires Botan crypto library 1.4.9 or higher. -Recommended version is 1.4.12. 1.5.x development versions are not supported at -this time. - -The Botan library can be found here: http://botan.randombit.net - -NetSieben SSH Library requires Cmake version 2.0 or higher. Cmake software can -be found here: http://www.cmake.org - - -1.3 Installation - -Public version of NetSieben SSH library is distributed in source code form. -The current version uses autoconf to handle generating of Makefile(s) for your -system. Generally you should be able to install NetSieben SSH Library by -executing the following commands after decompressing the tarball: - -cmake . -make -make install - -For more information please refer to INSTALL file included in the software -package. - - -2. Usage - -2.1 Initializing the class - -Before using library's functionality it needs to be initialized. The -initialization process will allocate the required memory resources and prepare -cryptographic methods for usage. It is recommended to do this first, when -starting the application. Only one instance of ne7ssh class can be used at a -time. Single instance of ne7ssh class is able to handle multiple connections -to multiple servers. It is recommended to initialize the class when starting, -use the same class for all of your SSH connections, and destroy it on the exit. -The class should be initialized with the following command: - -ne7ssh *ssh = new ne7ssh (); - -The constructor of the class requires no arguments. The applications will exit -when trying to initialize the class more than once within the same application. - - -2.2 Setting the options - -Before opening Secure connections, custom options can be configured for the use -in all future connections. Currently only desired cipher and integrity -checking algorithms can be configured. The following method can be used to -configure the options: - -setOptions (const char *prefCipher, const char *prefHmac) - -prefCipher your preferred cipher algorithm string representation. - Supported options are: aes256-cbc, twofish-cbc, twofish256-cbc, - blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc. - -prefHmac the preferred integrity checking algorithm string. - Supported optionss are: hmac-md5, hmac-sha1 and none. - - -This step is optional and if skipped the SSH library will use the default -settings. If desired algorithms are not supported by the server, the next one -from the list of supported algorithms will be used. - - -2.3 Connecting to a remote server - -After the options are set, connections to remote servers can be initiated. -NetSieben library supports Password and Public Key authentication methods. - - -2.3.1 Key based authentication - -NetSieben SSH library supports key based authentication. For this to work one -needs to generate a key pair either by using generateKeyPair method from ne7ssh -class or by using ssh-keygen program included in openssh distributions. Server -has to support key based authentication and newly generated public key needs to -be added to servers authorized keys. The process may differ depending on SSH -server vendor. Currently RSA and DSA keys are supported. The NetSieben -library keys are compatible with unencrypted OpenSSH keys. - -No password should be specified when creating a key pair with ssh-keygen. To -establish connection to a remote server using a private key use the following -method: - -int ssh->connectWithKey (const char* host, uint32 port, const char* username, -const char* privKeyFile); - -host Hostname or IP of the server. -port Port the SSH server binds to. - usually be 22 (standard SSH port). -username Username to be used in authentication. -PrivKeyFile Full path to a PEM encoded private key file. - -If the connection succeeds, the method will return the newly created channel -ID. This ID should be used in all further communications via newly created -connection. If the connection failed for any reason, "-1" will be returned by -the method. - -Generating a key pair - -NetSieben SSH library can be used to generate key pairs. Currently RSA and DSA -key algorithms are supported. DSA keys can only be between 512bits and -1024bits (restriction inherited from Botan library). The newly generate keys -are OpenSSH compatible and public keys can be pasted straight into -authorized_keys file. The following method generates a key pair: - -bool generateKeyPair (const char* type, const char* fqdn, const char* -privKeyFileName, const char* pubKeyFileName, uint16 keySize); - -type String specifying key type. Currently "dsa" and "rsa" are supported. -fqdn User id. Such as an Email address. -privKeyFileName Full path to a file where generated private key will be written. -pubKeyFileName Full path to a file where generated public key will be written. -keySize Desired key size in bits. If not specified will default to 2048. - The value has to be changed if generating a dsa keypair. -shell Should the shell be spawned on the remote end. True by defaut. - Should be set to false if using sendCmd method after authentication. - - -2.3.2 Password based authentication - -NetSieben SSH library supports password based authentication. The password -authentication should be enabled in the server configuration. If using this -method make sure its enabled as many distributions of OpenSSH disable this -method by default. The following method allows to establish a connection using -the password authentication: - -int connectWithPassword (const char *host, uint32 port, const char *username, -const char *password ) - -host Hostname or IP of the server. -port Port SSH server binds to, usually 22 (the standard SSH port). -username Username used in authentication. -password Password used in authentication. - -If the connection succeeds, the method will return the newly created channel -ID. This ID should be used in all further communications via newly established -connection. If the connection fails for any reason, "-1" will be returned by -the method. - - -2.4 Communications - -NetSieben SSH library supports two command modes. The first is interactive -mode used for sending text commands and waiting for text results. This works -much like perl "Expect" module. The second mode is a single command mode, -where library sends a single command to the remote end, waits for results and -disconnects. This method can be used to handle binary results. - - -2.4.1 Interactive mode - -Send command - -Before sending a command the waitFor method should be used to wait for shell -prompt, ensuing the remote end is ready for interactive commands. Sending a -command to the remote end can be accomplished using this method: - -bool send (const char *data, int channel ) - -data Command to send. This should be a string terminated with an EOL. - Most terminals will not process a command without end-line. - (character(s) (\n in Unix) to it). -channel Channel ID. - -The method will return "true" if the write to send buffer succeeded. Otherwise -false will be returned. Note: Keep in mind that each usage of send() method -will flush the receive buffer. - -Wait for results - -If the connection is established and a shell launched at the remote end one -needs to pause until a specific string is received. This could be used to wait -for shell prompt after connecting or after a command execution. The SSH -protocol is designed to send data in packets. If results are read from the -buffer right after sending a command, there is no guarantee that the entire -result has been received by the library. Thus it is necessary to wait for a -particular string to appear in the receive buffer. This ensures that all the -data has been received. - -If the specified string is not received, to avoid blocking condition, a timeout -value should be specified. If the desired result is not received in specified -timeframe, the function will return false. The following method is used for -interactive communications: - -bool waitFor (int channel, const char *str, uint32 timeout = 0) - -channel Channel ID received from the connection methods, specifying - the interactive channel. -str String containing text to wait for. -timeout Timeout in seconds. Timeout depends on the speed of your - connection to the remote side. 2 seconds should be enough for - most connections. If 0 is specified, the method will block - until the requested string arrives in the receive buffer. - -If an expected string is received the method will return "true". If the -timeout has been reached, the method will return "false". - - -Fetching the result - -After receiving the expected string or reaching the timeout threshold, the -received results can be accessed by using the following method: - -const char *read (int channel) - -channel Channel ID received from the connection methods, specifying - the interactive channel. - -The method will return pointer to the receive buffer. The memory for the -buffer doesn't need to be allocated nor freed by a programmer, its storage is -handled entirely by the ne7ssh class. This method should always be executed -after waitFor() method. - - -2.4.2 Single command - -Single command can be used when only one command needs to be executed before -disconnecting. Or when expected result is binary. - -Sending command - -This method will not work if the shell has been spawned at the remote end. One -needs to make sure that "shell" parameter of authentication method is set to -"false" before using this method: - -bool sendCmd (const char* cmd, int channel, int timeout); - -cmd Command to send. This should be a string terminated with an EOL. - Most terminals will not process a command without end-line. - (character(s) (\n in Unix) to it). -channel Channel ID. -timeout How long to wait for completion. This value will depend on the - speed of connection and size of results. Recommended value is 30 - seconds. - -The method will "true" if command executed successfully. If an error occurred -during execution "false" is returned. The last error can be obtained by using -errors()->pop() method. - -Result buffer size - -After sending a command followed by a successful execution, the result is -received by the SSH library and placed into the receive buffer. If the data -received is binary one needs to know the size of the buffer before reading it. -This can be obtain by the following method: - -int getReceivedSize (int channel) - -channel Channel ID. - -The method will return the size of the receive buffer, or zero if the buffer is -empty. - -Fetching the result - -If the expected result is a string one can use the above mentioned read() -method to fetch the data. However if the result is binary the following method -should be used: - -void *readBinary (int channel) - -channel Channel ID received from the connection methods. - -The method will return a pointer to the receive buffer. The memory for the -buffer doesn't need to be allocated nor freed by a programmer, its storage is -handled entirely by the ne7ssh class. Having a pointer to the receive buffer -and the size of the buffer, one can easily fetch the binary data stored. - - -2.5 Closing the connection - -When the desired communications are completed the connection needs to be close -using this method: - -bool close (int channel) - -channel Channel ID received from the connection methods. - -The method returns "true" if the sending of "close" command succeeds. "False" -is returned if the channel has already been closed. It is highly recommended -to use a shell command to close the interactive connection instead of this -method. - - -2.6 Error handling - -Starting with version 1.1.5 the SSH library integrates contextual error -reporting. Errors are bound to the channel they occur in. The core messages -are bound to the Core context. All errors are stored in a static instance of -Ne7sshError class and can be access via ne7ssh::errors() method. - - -2.6.1 Core context - -The errors that are not bound to a channel context are considered to be core -errors and can be retrieved using the following command: - -const char* Ne7sshError::pop() - -The command returns a pointer to the last error message within Core context, -removing it from the stack. Continued execution of this command will result in -returning of all Core error messages and at the same time removing them from -the stack. If there are no error message in the Core context zero is returned. - - -2.6.2 Channel context - -The errors that are bound to a channel context can be retrieved using the -following command: - -const char* Ne7sshError::pop(in channel) - -channel Channel ID. - -The command returns a pointer to the last error message within particular -channel context, also removing it from the stack. Continued execution of this -command will result in returning of all particular channel error messages at -the same time removing them from the stack. If there are no error message in a -channel context zero is returned. - - -2.7 Secure FTP support - -Secure FTP (SFTP) client is supported by the NetSieben library starting with -version 1.2.0. - -2.7.1 Initializing the subsystem - -In order to utilize the Secure FTP functionality sftp specific class instances -need to be icreated and sftp subsystem started on the server side. In order to -accomplish this task the following variable needs to be defined: - -Ne7SftpSubsystem _sftp - -The following method is used to initialize the subsystem. The method needs -channel ID, so has to be executed after one of the connect methods. Make sure -remote shell is not spawned. - -bool initSftp (class Ne7SftpSubsystem& _sftp, int channel) - -_sftp Reference to SFTP subsystem to be initialized. -channel Channel ID returned by one of the connect methods. - - -This command returns "true" if the new subsystem was successfully initialized. -And "false" is returned if any error occurs. - - -2.7.2 Setting a timeout for SFTP communications. - -The SFTP subsystem has a default timeout for all of the communications, set to -30 seconds. This should work well under most circumstances, however sometimes -it maybe desirable to modify this value. The following method accomplishes the -task: - -bool setTimeout (uint32 _timeout) - -timeout Timeout in seconds. - - -This command returns "true" upon successful setting of the timeout. Returns -"false" on any error. - - -2.7.3 Downloading a file - -The following method is used to download a file from a remote server. It -functions like sftp "get" command: - -bool get (const char* remoteFile, FILE* localFile) - -remoteFile Full or relative path to the file on the remote side. -LocalFile Pointer to FILE structure. If the file being retrieved - is binary, use "w+" attributes in fopen function. - -This command returns "true" if the file was successfully downloaded. Returns -"false" on any error. - - -2.7.4 Uploading a file - -The following method is used for uploading a file to a remote server. It -functions like SFTP "put" command: - -bool put (FILE* localFile, const char* remoteFile) - -localFile Pointer to FILE structure. If the file being retrieved - is binary, use "r+" attributes in fopen function. -remoteFile Full or relative path to the file on the remote side. - - -This command returns "true" if the file was successfully uploaded. Returns -"false" if any error is encountered. - - -2.7.5 Removing a file - -The following method is used to remove a file. It functions like sftp "rm" -command: - -bool rm (const char* remoteFile) - -remoteFile Full or relative path to the file on the remote side. - - -This command returns "true" if the file was successfully removed. Returns -"false" if any error is encountered. - - -2.7.6 Renaming or moving a file - -The following method is used to rename or move a file. It functions like sftp -"rename" command: - -bool mv (const char* oldFile, const char* newFile) - -oldFile Full or relative path to the file being moved or renamed. -newFIle Full or relative path to the new location/name of the file. - - -This command returns "true" if the file was successfully renamed or moved. -Returns "false" if any error is encountered. - - -2.7.7 Changing the current context - -The following method is used to change the current context. It functions like -sftp "cd" command: - -bool cd (const char* remoteDir) - -remoteDir Full or relative path to a new work path. - - -This command returns "true" if the context was successfully changed. Returns -"false" if any error is encountered. - - -2.7.8 Creating a new directory - -The following method is used to create a new directory. It functions like sftp -"mkdir" command: - -bool mkdir (const char* remoteDir) - -remoteDir Full or relative path to a new directory. - - -This command returns "true" if the new directory was successfully created. -Returns "false" if any error is encountered. - - -2.7.9 Removing a directory - -The following method if used to remove a directory. It functions like sftp -"rmdir" command: - -bool rmdir (const char* remoteDir) - -remoteDir Full or relative path to a directory. - -This command returns "true" if the directory was successfully removed. Returns -"false" if any error is encountered. - - -2.7.10 Getting a directory listing - -The following method is used to get a directory listing. It functions like -sftp "ls" command: - -const char* ls (const char* remoteDir, bool longNames=false) - -remoteDir Full or relative path to a directory. -LongNames If set to "true" the returned string in addition to - file strings will contain attributes for each file. - - -This command returns pointer to a buffer containing directory listing. Returns -NULL if any error is encountered. - - -2.7.11 Changing permissions - -The following method is used to change the permissions of a file or directory. -It functions like sftp "chmod" command: - -bool chmod (const char* remoteFile, const char* mode) - -remotFile Full or relative path to a file. -mode Mode string. It can be either a numerical mode - expression such as "755" or an expression showing the - modifications to be made, such as "ug+w". Mode string - is the same as used by *nix chmod command. - -This command returns "true" if the new permissions are successfully applied. -Returns "false" if any error is encountered. - - -2.7.12 Changing ownership - -The following method is used to change the ownership of a file or directory. -It functions like sftp "chown" command: - -bool chown (const char* remoteFile, uint32_t uid, uint32_t gid) - -remoteFile Full or relative path to a file. -uid Numerical user ID of the new owner. -gid Numerical group ID of the new owner. - -This command returns "true" if the new ownership is successfully applied. -Returns "false" if any error is encountered. - - -3. Commercial License - -For details about commercial license please fill out the form located at: -https://netsieben.com/sshlib_info.phtml diff --git a/src/libs/3rdparty/net7ssh/doc/html/annotated.html b/src/libs/3rdparty/net7ssh/doc/html/annotated.html deleted file mode 100644 index 6a2145ac6c5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/annotated.html +++ /dev/null @@ -1,52 +0,0 @@ - - -ne7ssh.kdevelop: Class List - - - - - - -
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html deleted file mode 100644 index 73bb9a14d95..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html +++ /dev/null @@ -1,62 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7SftpSubsystem Member List

This is the complete list of members for Ne7SftpSubsystem, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPEND enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
cd(const char *remoteDir)Ne7SftpSubsystem
chmod(const char *remoteFile, const char *mode)Ne7SftpSubsystem
chown(const char *remoteFile, uint32_t uid, uint32_t gid=0)Ne7SftpSubsystem
closeFile(uint32 fileID)Ne7SftpSubsystem
errorNotInited()Ne7SftpSubsystem [private]
get(const char *remoteFile, FILE *localFile)Ne7SftpSubsystem
getFileAttrs(fileAttrs &attrs, const char *filename, bool followSymLinks=true)Ne7SftpSubsystem
inited (defined in Ne7SftpSubsystem)Ne7SftpSubsystem [private]
isDir(const char *remoteFile)Ne7SftpSubsystem
isFile(const char *remoteFile)Ne7SftpSubsystem
ls(const char *remoteDir, bool longNames=false)Ne7SftpSubsystem
mkdir(const char *remoteDir)Ne7SftpSubsystem
mv(const char *oldFile, const char *newFile)Ne7SftpSubsystem
Ne7SftpSubsystem()Ne7SftpSubsystem
Ne7SftpSubsystem(class Ne7sshSftp *_sftp)Ne7SftpSubsystem
openDir(const char *dirname)Ne7SftpSubsystem
openFile(const char *filename, uint8 mode)Ne7SftpSubsystem
OVERWRITE enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
put(FILE *localFile, const char *remoteFile)Ne7SftpSubsystem
READ enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
readFile(uint32 fileID, uint64 offset=0)Ne7SftpSubsystem
rm(const char *remoteFile)Ne7SftpSubsystem
rmdir(const char *remoteDir)Ne7SftpSubsystem
setTimeout(uint32 _timeout)Ne7SftpSubsystem
sftp (defined in Ne7SftpSubsystem)Ne7SftpSubsystem [private]
writeFile(uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)Ne7SftpSubsystem
writeMode enum nameNe7SftpSubsystem
~Ne7SftpSubsystem()Ne7SftpSubsystem

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html deleted file mode 100644 index 09b06ed273b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html +++ /dev/null @@ -1,879 +0,0 @@ - - -ne7ssh.kdevelop: Ne7SftpSubsystem Class Reference - - - - - -
-

Ne7SftpSubsystem Class Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for Ne7SftpSubsystem:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  fileAttrs

Public Types

enum  writeMode { READ, -OVERWRITE, -APPEND - }

Public Member Functions

 Ne7SftpSubsystem ()
 Ne7SftpSubsystem (class Ne7sshSftp *_sftp)
 ~Ne7SftpSubsystem ()
bool setTimeout (uint32 _timeout)
uint32 openFile (const char *filename, uint8 mode)
uint32 openDir (const char *dirname)
bool readFile (uint32 fileID, uint64 offset=0)
bool writeFile (uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)
bool closeFile (uint32 fileID)
bool getFileAttrs (fileAttrs &attrs, const char *filename, bool followSymLinks=true)
bool get (const char *remoteFile, FILE *localFile)
bool put (FILE *localFile, const char *remoteFile)
bool rm (const char *remoteFile)
bool mv (const char *oldFile, const char *newFile)
bool mkdir (const char *remoteDir)
bool rmdir (const char *remoteDir)
const char * ls (const char *remoteDir, bool longNames=false)
bool cd (const char *remoteDir)
bool chmod (const char *remoteFile, const char *mode)
bool chown (const char *remoteFile, uint32_t uid, uint32_t gid=0)
bool isFile (const char *remoteFile)
bool isDir (const char *remoteFile)

Private Member Functions

bool errorNotInited ()

Private Attributes

-bool inited
-Ne7sshSftpsftp
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Member Enumeration Documentation

- -
-
- - - - -
enum Ne7SftpSubsystem::writeMode
-
-
- -

-Modes used when opening a remote file. -

-

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7SftpSubsystem::Ne7SftpSubsystem (  ) 
-
-
- -

-Default constructor. -

-

- -

-
- - - - - - - - - -
Ne7SftpSubsystem::Ne7SftpSubsystem (class Ne7sshSftp _sftp  ) 
-
-
- -

-Constructor used to initialize the subsystem with a new Ne7sshSftp class instance.

Parameters:
- - -
_sftp Ne7sshSftp class instance.
-
- -
-

- -

-
- - - - - - - - -
Ne7SftpSubsystem::~Ne7SftpSubsystem (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7SftpSubsystem::cd (const char *  remoteDir  ) 
-
-
- -

-This method is used to change the current working directory.

Parameters:
- - -
remoteDir Full or relative path to the new working directory on the remote server.
-
-
Returns:
True if change of directory succedded. False on any error.
- -

References Ne7sshSftp::cd(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::chmod (const char *  remoteFile,
const char *  mode 
)
-
-
- -

-This method is used for changing the permissions associated with a remote file.

Parameters:
- - - -
remoteFile Full or relative path to the remote file.
mode Mode string. It can be either a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command.
-
-
Returns:
True if the new permissions are succesfully applied to the remote file. False on any error.
- -

References Ne7sshSftp::chmod(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::chown (const char *  remoteFile,
uint32_t  uid,
uint32_t  gid = 0 
)
-
-
- -

-This method is used to change the owner of a remote file.

Parameters:
- - - - -
remoteFile Full or relative path to the remote file.
uid Numerical new owner user ID.
gid Numerical new owner group ID.
-
-
Returns:
True if the change of ownership succeeds. False on any error.
- -

References Ne7sshSftp::chown(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::closeFile (uint32  fileID  ) 
-
-
- -

-Low level method used to close a file opened by using openFile() method.

Parameters:
- - -
fileID File ID returned by openFile() method.
-
-
Returns:
True on success. False on any error.
- -

References Ne7sshSftp::closeFile(), and errorNotInited().

- -
-

- -

-
- - - - - - - - -
bool Ne7SftpSubsystem::errorNotInited (  )  [private]
-
-
- -

-Pushes and error to the error buffer, if this subsystem has not been initialized before usage.

Returns:
True if the push succeeds. Otherwise false.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by cd(), chmod(), chown(), closeFile(), get(), getFileAttrs(), isDir(), isFile(), ls(), mkdir(), mv(), openDir(), openFile(), put(), readFile(), rm(), rmdir(), setTimeout(), and writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::get (const char *  remoteFile,
FILE *  localFile 
)
-
-
- -

-This method is used to retrieve a remote file and dump it into local file.

Parameters:
- - - -
remoteFile Full or relative path to the file on the remote side.
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
-
-
Returns:
True if getting the file is succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::getFileAttrs (fileAttrs attrs,
const char *  filename,
bool  followSymLinks = true 
)
-
-
- -

-This method is used to retrieve remote file attributes and place them into fileAttrs structure.

Parameters:
- - - - -
attrs Reference to fileAttrs structure where retrieved attributes should be placed.
filename Name of the remote file.
followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false".
-
-
Returns:
True if the attributes successfully retrieved. Otherwise false is returned.
- -

References errorNotInited(), and Ne7sshSftp::getFileAttrs().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::isDir (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a directory.

Parameters:
- - -
remoteFile Full or relative path to the remote file.
-
-
Returns:
True if the remote inode is a directory. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::isDir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::isFile (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a regular file.

Parameters:
- - -
remoteFile Full or relative path to the remote inode.
-
-
Returns:
True if the remote inode is a regular file. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * Ne7SftpSubsystem::ls (const char *  remoteDir,
bool  longNames = false 
)
-
-
- -

-This methods is used retrieve a listing of a remote directory.

Parameters:
- - - -
remoteDir Full or relative path to a directory.
longNames If set to "true" the returned string in addition to file strings will contain attributes for each file.
-
-
Returns:
A pointer to a string containing the directory listing.
- -

References errorNotInited(), and Ne7sshSftp::ls().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::mkdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to create a new directory.

Parameters:
- - -
remoteDir Full or relative path to a new directory on the remote server.
-
-
Returns:
True if the directory successfully created. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::mkdir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::mv (const char *  oldFile,
const char *  newFile 
)
-
-
- -

-This method is used to rename/move files.

Parameters:
- - - -
oldFile Full or relative path to an old file on the remote server.
newFile Full or relative path to a new file on the remote side.
-
-
Returns:
True if renaming successfull. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::mv().

- -
-

- -

-
- - - - - - - - - -
uint32 Ne7SftpSubsystem::openDir (const char *  dirname  ) 
-
-
- -

-Low level method used to open an inode containing file entries a.k.a directory.

Parameters:
- - -
dirname Relative or full path to the inode.
-
-
Returns:
Newly opened file ID or 0 if the inode could not be opened.
- -

References errorNotInited(), and Ne7sshSftp::openDir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
uint32 Ne7SftpSubsystem::openFile (const char *  filename,
uint8  mode 
)
-
-
- -

-Low level method used to open a remote file.

Parameters:
- - - -
filename Relative or full path to the file.
mode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable.
-
-
Returns:
Newly opened file ID or 0 if file could not be opened.
- -

References errorNotInited(), and Ne7sshSftp::openFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::put (FILE *  localFile,
const char *  remoteFile 
)
-
-
- -

-This method is used to upload a file to a remote server.

Parameters:
- - - -
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "r+" attributes in fopen function.
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if putting the file succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::readFile (uint32  fileID,
uint64  offset = 0 
)
-
-
- -

-Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file.

Parameters:
- - - -
fileID File ID retruned by openFile() method.
offset Offset.
-
-
Returns:
True if file content successfully read and placed in the buffer. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::readFile().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::rm (const char *  remoteFile  ) 
-
-
- -

-This method is used to remove a file on a remote server.

Parameters:
- - -
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if remove succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::rm().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::rmdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to remove a remote directory.

Parameters:
- - -
remoteDir Full or relative path to a directory to be removed.
-
-
Returns:
True if the directory successfully removed. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::rmdir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::setTimeout (uint32  _timeout  ) 
-
-
- -

-This method is used to set a timeout for all SFTP subsystem communications.

Parameters:
- - -
_timeout Timeout in seconds.
-
-
Returns:
True if timeout set, otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::setTimeout().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::writeFile (uint32  fileID,
const uint8 *  data,
uint32  len,
uint64  offset = 0 
)
-
-
- -

-Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file.

Parameters:
- - - - - -
fileID File ID returned by openFile() method.
data Pointer to a buffer containing the data.
len Length of the block.
offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0.
-
-
Returns:
True if file contect successfully written. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::writeFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map deleted file mode 100644 index 7abd9ada75c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 deleted file mode 100644 index b417fbad956..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a3599377bc7d09bac1983e35132d609e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html deleted file mode 100644 index f7cafb0c76d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html +++ /dev/null @@ -1,47 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshError Member List

This is the complete list of members for Ne7sshError, including all inherited members.

- - - - - - - - - - - - - - -
deleteChannel(int32 channel)Ne7sshError
deleteCoreMsgs()Ne7sshError
deleteRecord(uint16 recID)Ne7sshError [private]
ErrorBufferNe7sshError [private]
lock()Ne7sshError [private, static]
memberCount (defined in Ne7sshError)Ne7sshError [private]
mut (defined in Ne7sshError)Ne7sshError [private, static]
Ne7sshError()Ne7sshError
pop()Ne7sshError
pop(int32 channel)Ne7sshError
popedErr (defined in Ne7sshError)Ne7sshError [private]
push(int32 channel, const char *format,...)Ne7sshError
unlock()Ne7sshError [private, static]
~Ne7sshError()Ne7sshError

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html deleted file mode 100644 index e8dcc654b44..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html +++ /dev/null @@ -1,375 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshError Class Reference - - - - - -
-

Ne7sshError Class Reference

#include <ne7ssh_error.h> -

-

-Collaboration diagram for Ne7sshError:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  Error

Public Member Functions

 Ne7sshError ()
 ~Ne7sshError ()
bool push (int32 channel, const char *format,...)
const char * pop ()
const char * pop (int32 channel)
bool deleteCoreMsgs ()
bool deleteChannel (int32 channel)

Private Member Functions

bool deleteRecord (uint16 recID)

Static Private Member Functions

static bool lock ()
static bool unlock ()

Private Attributes

-uint16 memberCount
-char popedErr [MAX_ERROR_LEN+1]
struct Ne7sshError::Error ** ErrorBuffer

Static Private Attributes

-static Ne7ssh_Mutex mut
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7sshError::Ne7sshError (  ) 
-
-
- -

-Ne7sshError constructor. -

-

- -

-
- - - - - - - - -
Ne7sshError::~Ne7sshError (  ) 
-
-
- -

-Ne7sshError destructor. -

References ErrorBuffer.

- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7sshError::deleteChannel (int32  channel  ) 
-
-
- -

-Removes all error messages within Channel context from the stack.

Parameters:
- - -
channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
-
-
Returns:
True on succes, false on failure.
- -

References ErrorBuffer, lock(), and unlock().

- -

Referenced by ne7ssh::close(), and deleteCoreMsgs().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::deleteCoreMsgs (  ) 
-
-
- -

-Removes all error messages within Core context from the stack.

Returns:
True on success, false on failure.
- -

References deleteChannel().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshError::deleteRecord (uint16  recID  )  [private]
-
-
- -

-Delete a single error message.

Parameters:
- - -
recID Position within the array.
-
-
Returns:
True on success, false on failure.
- -

References ErrorBuffer.

- -

Referenced by pop().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::lock (  )  [static, private]
-
-
- -

-Lock the mutex.

Returns:
True if lock aquired. Oterwise false.
- -

-FIXME possible infinite loop -

References ne7ssh::errors(), and push().

- -

Referenced by deleteChannel(), pop(), and push().

- -
-

- -

-
- - - - - - - - - -
const char * Ne7sshError::pop (int32  channel  ) 
-
-
- -

-Pops an error message from the Channel context.

Parameters:
- - -
channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
-
-
Returns:
The last error message in the Channel context. The message is removed from the stack. Returns null if no there are no erros in the Channel context.
- -

References deleteRecord(), ErrorBuffer, lock(), and unlock().

- -
-

- -

-
- - - - - - - - -
const char * Ne7sshError::pop (  ) 
-
-
- -

-Pops an error message from the Core context.

Returns:
The last error message in the Core context. The message is removed from the stack.
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshError::push (int32  channel,
const char *  format,
  ... 
)
-
-
- -

-Pushes a new error message into the stack.

Parameters:
- - - -
channel Specifies the channel to bind the error message to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
format Specifies the error message followed by argument in printf format. The following formatting characters are supported: s,d,i,l,x. Modifier u can be used together with decimal to specify an unsigned variable. Returns null if no there are no erros in the Core context.
-
-
Returns:
True on success, false on failure.
- -

References ErrorBuffer, lock(), and unlock().

- -

Referenced by ne7ssh_string::addFile(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), ne7ssh::close(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), Ne7SftpSubsystem::errorNotInited(), ne7ssh_transport::establish(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh::generateKeyPair(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::get(), ne7ssh::getChannelNo(), ne7ssh_crypt::getCryptAlgo(), ne7ssh_keys::getDSAKeys(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_crypt::getMacKeyLen(), ne7ssh_keys::getRSAKeys(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), ne7ssh::initSftp(), Ne7sshSftp::isType(), lock(), ne7ssh::lock(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh::ne7ssh(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), ne7ssh_transport::NoBlock(), ne7ssh_channel::open(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), ne7ssh::read(), ne7ssh::readBinary(), Ne7sshSftp::readFile(), ne7ssh_transport::receive(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh::selectThread(), ne7ssh_transport::send(), ne7ssh::send(), ne7ssh::sendCmd(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), ne7ssh_connection::startSftp(), unlock(), ne7ssh::unlock(), ne7ssh_crypt::verifySig(), ne7ssh::waitFor(), ne7ssh_transport::waitForPacket(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::unlock (  )  [static, private]
-
-
- -

-Unlock the mutext.

Returns:
True if the mutext successfully unlocked. Otherwise false.
- -

References ne7ssh::errors(), and push().

- -

Referenced by deleteChannel(), pop(), and push().

- -
-

-


Member Data Documentation

- -
-
- - - - -
struct Ne7sshError::Error ** Ne7sshError::ErrorBuffer [private]
-
-
- -

-Structure for storing error messages. -

Referenced by deleteChannel(), deleteRecord(), pop(), push(), and ~Ne7sshError().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map deleted file mode 100644 index f46ec445b1f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 deleted file mode 100644 index 1b4476ec8bf..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -59fecf6fac000bbe159906d2497191a5 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html deleted file mode 100644 index a5b7df92978..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html +++ /dev/null @@ -1,110 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp Member List

This is the complete list of members for Ne7sshSftp, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addOpenHandle(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
adjustRecvWindow(int bufferSize)ne7ssh_channel
APPEND enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
attrs (defined in Ne7sshSftp)Ne7sshSftp [private]
cd(const char *remoteDir)Ne7sshSftp
channelOpened (defined in ne7ssh_channel)ne7ssh_channel [protected]
chmod(const char *remoteFile, const char *mode)Ne7sshSftp
chown(const char *remoteFile, uint32 uid, uint32 gid=0)Ne7sshSftp
closeFile(uint32 fileID)Ne7sshSftp
commBuffer (defined in Ne7sshSftp)Ne7sshSftp [private]
currentPath (defined in Ne7sshSftp)Ne7sshSftp [private]
data2Send()ne7ssh_channel [inline]
execCmd(const char *cmd)ne7ssh_channel
fileBuffer (defined in Ne7sshSftp)Ne7sshSftp [private]
get(const char *remoteFile, FILE *localFile)Ne7sshSftp
getCmdComplete()ne7ssh_channel [inline]
getFileAttrs(sftpFileAttrs &attributes, Botan::SecureVector< Botan::byte > &remoteFile, bool followSymLinks=true)Ne7sshSftp [private]
getFileAttrs(Ne7SftpSubsystem::fileAttrs &attributes, const char *remoteFile, bool followSymLinks=true)Ne7sshSftp
getFileHandle(uint32 fileID)Ne7sshSftp [private]
getFileSize(uint32 fileID)Ne7sshSftp [private]
getFileStats(const char *remoteFile, bool followSymLinks=true)Ne7sshSftp [private]
getFStat(uint32 fileID)Ne7sshSftp [private]
getFullPath(const char *filename)Ne7sshSftp [private]
getReceived()ne7ssh_channel [inline]
getRecvWindow()ne7ssh_channel [inline]
getSendWindow()ne7ssh_channel [inline]
getShell()ne7ssh_channel
handleData(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private, virtual]
handleNames(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleReceived(Botan::SecureVector< Botan::byte > &_packet)ne7ssh_channel
handleSftpData(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleStatus(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleVersion(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
init()Ne7sshSftp
isDir(const char *remoteFile)Ne7sshSftp
isFile(const char *remoteFile)Ne7sshSftp
isOpen()ne7ssh_channel [inline]
isRemoteShell()ne7ssh_channel [inline]
isType(const char *remoteFile, uint32 type)Ne7sshSftp [private]
lastError (defined in Ne7sshSftp)Ne7sshSftp [private]
ls(const char *remoteDir, bool longNames=false)Ne7sshSftp
mkdir(const char *remoteDir)Ne7sshSftp
mv(const char *oldFile, const char *newFile)Ne7sshSftp
ne7ssh_channel(ne7ssh_session *_session)ne7ssh_channel
Ne7sshSftp(ne7ssh_session *_session, ne7ssh_channel *_channel)Ne7sshSftp
open(uint32 channelID)ne7ssh_channel
openDir(const char *dirname)Ne7sshSftp
openFile(const char *filename, uint8 shortMode)Ne7sshSftp
OVERWRITE enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
processAttrs(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
put(FILE *localFile, const char *remoteFile)Ne7sshSftp
READ enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
readFile(uint32 fileID, uint64 offset=0)Ne7sshSftp
receive()ne7ssh_channel
receiveUntil(short _cmd, uint32 timeSec=0)Ne7sshSftp [private]
receiveWhile(short _cmd, uint32 timeSec=0)Ne7sshSftp [private]
receiveWindowAdjust()Ne7sshSftp [private]
rm(const char *remoteFile)Ne7sshSftp
rmdir(const char *remoteDir)Ne7sshSftp
sendAdjustWindow()ne7ssh_channel [protected]
sendAll()ne7ssh_channel
sendClose()ne7ssh_channel
sendEof()ne7ssh_channel
seq (defined in Ne7sshSftp)Ne7sshSftp [private]
session (defined in Ne7sshSftp)Ne7sshSftp [private]
setTimeout(uint32 _timeout)Ne7sshSftp [inline]
sftpCmd (defined in Ne7sshSftp)Ne7sshSftp [private]
sftpFiles (defined in Ne7sshSftp)Ne7sshSftp [private]
sftpFilesCount (defined in Ne7sshSftp)Ne7sshSftp [private]
timeout (defined in Ne7sshSftp)Ne7sshSftp [private]
windowRecv (defined in ne7ssh_channel)ne7ssh_channel [protected]
windowSend (defined in ne7ssh_channel)ne7ssh_channel [protected]
write(Botan::SecureVector< Botan::byte > &data)ne7ssh_channel
writeFile(uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)Ne7sshSftp
writeMode enum name (defined in Ne7sshSftp)Ne7sshSftp [private]
~ne7ssh_channel()ne7ssh_channel [virtual]
~Ne7sshSftp()Ne7sshSftp

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html deleted file mode 100644 index dcb580358da..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html +++ /dev/null @@ -1,1516 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp Class Reference - - - - - -
-

Ne7sshSftp Class Reference

#include <ne7ssh_sftp.h> -

-

-Inheritance diagram for Ne7sshSftp:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for Ne7sshSftp:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  sftpFile
struct  sftpFileAttrs

Public Member Functions

 Ne7sshSftp (ne7ssh_session *_session, ne7ssh_channel *_channel)
 ~Ne7sshSftp ()
bool init ()
void setTimeout (uint32 _timeout)
uint32 openFile (const char *filename, uint8 shortMode)
uint32 openDir (const char *dirname)
bool readFile (uint32 fileID, uint64 offset=0)
bool writeFile (uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)
bool closeFile (uint32 fileID)
bool getFileAttrs (Ne7SftpSubsystem::fileAttrs &attributes, const char *remoteFile, bool followSymLinks=true)
bool isFile (const char *remoteFile)
bool isDir (const char *remoteFile)
bool get (const char *remoteFile, FILE *localFile)
bool put (FILE *localFile, const char *remoteFile)
bool rm (const char *remoteFile)
bool mv (const char *oldFile, const char *newFile)
bool mkdir (const char *remoteDir)
bool rmdir (const char *remoteDir)
const char * ls (const char *remoteDir, bool longNames=false)
bool cd (const char *remoteDir)
bool chmod (const char *remoteFile, const char *mode)
bool chown (const char *remoteFile, uint32 uid, uint32 gid=0)

Private Types

enum  writeMode { READ, -OVERWRITE, -APPEND - }

Private Member Functions

bool handleData (Botan::SecureVector< Botan::byte > &packet)
bool handleVersion (Botan::SecureVector< Botan::byte > &packet)
bool handleStatus (Botan::SecureVector< Botan::byte > &packet)
bool addOpenHandle (Botan::SecureVector< Botan::byte > &packet)
bool handleSftpData (Botan::SecureVector< Botan::byte > &packet)
bool handleNames (Botan::SecureVector< Botan::byte > &packet)
sftpFilegetFileHandle (uint32 fileID)
bool receiveUntil (short _cmd, uint32 timeSec=0)
bool receiveWhile (short _cmd, uint32 timeSec=0)
bool processAttrs (Botan::SecureVector< Botan::byte > &packet)
bool getFileStats (const char *remoteFile, bool followSymLinks=true)
bool getFileAttrs (sftpFileAttrs &attributes, Botan::SecureVector< Botan::byte > &remoteFile, bool followSymLinks=true)
bool getFStat (uint32 fileID)
uint64 getFileSize (uint32 fileID)
bool receiveWindowAdjust ()
ne7ssh_string getFullPath (const char *filename)
bool isType (const char *remoteFile, uint32 type)

Private Attributes

-ne7ssh_sessionsession
-uint32 timeout
-uint32 seq
-uint8 sftpCmd
-ne7ssh_string commBuffer
-Botan::SecureVector< Botan::byte > fileBuffer
-uint8 lastError
-char * currentPath
-sftpFileAttrs attrs
-sftpFile ** sftpFiles
-uint16 sftpFilesCount
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
Ne7sshSftp::Ne7sshSftp (ne7ssh_session _session,
ne7ssh_channel _channel 
)
-
-
- -

-Constructor.

Parameters:
- - - -
_session Pointer to connections session data.
_channel Pointer to the ne7ssh_channel instance, taken from the new ne7ssh_connection instance.
-
- -

References ne7ssh_channel::getRecvWindow(), and ne7ssh_channel::getSendWindow().

- -
-

- -

-
- - - - - - - - -
Ne7sshSftp::~Ne7sshSftp (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7sshSftp::addOpenHandle (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to add a new file to sftpFiles variable from the HANDLE packet.

Parameters:
- - -
packet HANDLE packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::getInt(), and ne7ssh_string::getString().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::cd (const char *  remoteDir  ) 
-
-
- -

-This method is used to change the current working directory.

Parameters:
- - -
remoteDir Full or relative path to the new working directory on the remote server.
-
-
Returns:
True if change of directory succedded. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::cd().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::chmod (const char *  remoteFile,
const char *  mode 
)
-
-
- -

-This method is used for changing the permissions associated with a remote file.

Parameters:
- - - -
remoteFile Full or relative path to the remote file.
mode Mode string. It can be wither a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command.
-
-
Returns:
True if the new permissions are succesfully applied to the remote file. False on any error.
- -

References ne7ssh::errors(), getFileAttrs(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::chmod().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::chown (const char *  remoteFile,
uint32  uid,
uint32  gid = 0 
)
-
-
- -

-This method is used to change the owner of a remote file.

Parameters:
- - - - -
remoteFile Full or relative path to the remote file.
uid Numerical new owner user ID.
gid Numerical new owner group ID.
-
-
Returns:
True if the change of ownership succeeds. False on any error.
- -

References ne7ssh::errors(), getFileAttrs(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::chown().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::closeFile (uint32  fileID  ) 
-
-
- -

-Low level method used to close a file opened using openFile() method.

Parameters:
- - -
fileID File ID returned by openFile() method.
-
-
Returns:
True on success. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveUntil().

- -

Referenced by Ne7SftpSubsystem::closeFile(), get(), ls(), and put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::get (const char *  remoteFile,
FILE *  localFile 
)
-
-
- -

-This method is used to retrieve a remote file and dump it into local file.

Parameters:
- - - -
remoteFile Full or relative path to the file on the remote side.
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
-
-
Returns:
True if getting the file is succeeds. False on any error.
- -

References closeFile(), ne7ssh::errors(), getFileSize(), ne7ssh_session::getSshChannel(), openFile(), Ne7sshError::push(), and readFile().

- -

Referenced by Ne7SftpSubsystem::get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileAttrs (Ne7SftpSubsystem::fileAttrs attributes,
const char *  remoteFile,
bool  followSymLinks = true 
)
-
-
- -

-This method is used to retrieve remote file attributes and place them into fileAttrs structure.

Parameters:
- - - - -
attributes Reference to fileAttrs structure where retrieved attributes should be placed.
remoteFile Name of the remote file.
followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false".
-
-
Returns:
True if the attributes successfully retrieved. Otherwise false is returned.
- -

References ne7ssh::errors(), getFileStats(), getFullPath(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileAttrs (sftpFileAttrs attributes,
Botan::SecureVector< Botan::byte > &  remoteFile,
bool  followSymLinks = true 
) [private]
-
-
- -

-Gets attributes of a remote file and dumps them into sfptFileAtts structure.

Parameters:
- - - - -
attributes reference to sftpFileAttrs structure where the result will be stored.
remoteFile Full or relative path to a remote file.
followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false".
-
-
Returns:
True if the attributes successfully received. False on any error.
- -

References ne7ssh::errors(), getFileStats(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by chmod(), chown(), and Ne7SftpSubsystem::getFileAttrs().

- -
-

- -

-
- - - - - - - - - -
Ne7sshSftp::sftpFile * Ne7sshSftp::getFileHandle (uint32  fileID  )  [private]
-
-
- -

-This method is used to get a pointer to currently open file stored in sftpFile structure.

Parameters:
- - -
fileID File ID, received from fileOpen() method.
-
-
Returns:
Returns a pointer to sftpFile structyure containing opened file or directory. If file specified by fileID has not been opened, NULL is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by closeFile(), getFStat(), ls(), readFile(), and writeFile().

- -
-

- -

-
- - - - - - - - - -
uint64 Ne7sshSftp::getFileSize (uint32  fileID  )  [private]
-
-
- -

-This methods returnes the size of an open file.

Parameters:
- - -
fileID File ID, returned by the openFile() method.
-
-
Returns:
The size of the remote file. False on any error.
- -

References ne7ssh::errors(), getFStat(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileStats (const char *  remoteFile,
bool  followSymLinks = true 
) [private]
-
-
- -

-Low level method to request file attributes.

Parameters:
- - - -
remoteFile Full or relative path to a remote file.
followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false".
-
-
Returns:
True if the request succeeds. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by getFileAttrs(), and isType().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::getFStat (uint32  fileID  )  [private]
-
-
- -

-Works like getFileStats() method, except that it operates on a handle of already opened file instead of path.

Parameters:
- - -
fileID File ID, returned by the openFile() method.
-
-
Returns:
True if the request succeeds. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveWhile().

- -

Referenced by getFileSize().

- -
-

- -

-
- - - - - - - - - -
ne7ssh_string Ne7sshSftp::getFullPath (const char *  filename  )  [private]
-
-
- -

-Returns full path to a file or directory.

Parameters:
- - -
filename Relative path to a remote file or directory.
-
-
Returns:
ne7ssh_string class containing full path to the remote file or directory. The class will contain an empty string on error.
- -

Referenced by cd(), chmod(), chown(), getFileAttrs(), getFileStats(), isType(), mkdir(), mv(), openDir(), openFile(), rm(), and rmdir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleData (Botan::SecureVector< Botan::byte > &  packet  )  [private, virtual]
-
-
- -

-Replacement for ne7ssh_channel handleData method. Processes SFTP specific packets.

Parameters:
- - -
packet Reference to the newly received packet.
-
-
Returns:
True if data successfully processed. False on any error.
- -

Reimplemented from ne7ssh_channel.

- -

References addOpenHandle(), ne7ssh_string::addVector(), ne7ssh_channel::adjustRecvWindow(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), handleNames(), handleSftpData(), handleStatus(), handleVersion(), ne7ssh_string::length(), processAttrs(), Ne7sshError::push(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleNames (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process NAME packets.

Parameters:
- - -
packet NAME packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::addInt(), ne7ssh_string::addVectorField(), ne7ssh_string::getInt(), Ne7sshSftpPacket::getInt64(), ne7ssh_string::getString(), and ne7ssh_string::value().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleSftpData (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process DATA packets.

Parameters:
- - -
packet DATA packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleStatus (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Processes the STATUS packet received from the server.

Parameters:
- - -
packet STATUS packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleVersion (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Processes the VERSION packet received from the server.

Parameters:
- - -
packet VERSION packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftp::init (  ) 
-
-
- -

-Initializes SFTP subsystem.

Returns:
True if the subsystem successfully initialized. False on any error.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh_session::getSendChannel(), receiveUntil(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::startSftp().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::isDir (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a directory.

Parameters:
- - -
remoteFile Full or relative path to the remote file.
-
-
Returns:
True if the remote inode is a directory. Otherwise false.
- -

References isType().

- -

Referenced by Ne7SftpSubsystem::isDir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::isFile (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a regular file.

Parameters:
- - -
remoteFile Full or relative path to the remote inode.
-
-
Returns:
True if the remote inode is a regular file. Otherwise false.
- -

References isType().

- -

Referenced by Ne7SftpSubsystem::isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::isType (const char *  remoteFile,
uint32  type 
) [private]
-
-
- -

-Determines the type of a remote file.

Parameters:
- - - -
remoteFile Relative or full path to the remote file.
type Type, taken from sys/stat.h.
-
-
Returns:
True if file is of specified type. Otherwise false.
- -

References ne7ssh::errors(), getFileStats(), getFullPath(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by isDir(), and isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * Ne7sshSftp::ls (const char *  remoteDir,
bool  longNames = false 
)
-
-
- -

-This methods is used retrieve a listing of a remote directory.

Parameters:
- - - -
remoteDir Full or relative path to a directory.
longNames If set to "true" the returned string in addition to file strings will contain attributes for each file.
-
-
Returns:
A pointer to a string containing the directory listing.
- -

References ne7ssh_string::addVector(), ne7ssh_string::clear(), closeFile(), ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), openDir(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::ls().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::mkdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to create a new directory.

Parameters:
- - -
remoteDir Full or relative path to a new directory on the remote server.
-
-
Returns:
True if the directory successfully created. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::mkdir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::mv (const char *  oldFile,
const char *  newFile 
)
-
-
- -

-This method is used to rename/move files.

Parameters:
- - - -
oldFile Full or relative path to an old file on the remote server.
newFile Full or relative path to a new file on the remote side.
-
-
Returns:
True if renaming successfull. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::mv().

- -
-

- -

-
- - - - - - - - - -
uint32 Ne7sshSftp::openDir (const char *  dirname  ) 
-
-
- -

-Low level method used to open an inode containing file entries a.k.a directory.

Parameters:
- - -
dirname Relative or full path to the inode.
-
-
Returns:
Newly opened file ID or 0 if the inode could not be opened.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveUntil(), and ne7ssh_string::value().

- -

Referenced by ls(), and Ne7SftpSubsystem::openDir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
uint32 Ne7sshSftp::openFile (const char *  filename,
uint8  shortMode 
)
-
-
- -

-Low level method used to open a remote file.

Parameters:
- - - -
filename Relative or full path to the file.
shortMode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable.
-
-
Returns:
Newly opened file ID or 0 if file could not be opened.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveUntil(), and ne7ssh_string::value().

- -

Referenced by get(), Ne7SftpSubsystem::openFile(), and put().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::processAttrs (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process ATTRS packet.

Parameters:
- - -
packet ATTRS packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::getInt(), and Ne7sshSftpPacket::getInt64().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::put (FILE *  localFile,
const char *  remoteFile 
)
-
-
- -

-This method is used to upload a file to a remote server.

Parameters:
- - - -
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if putting the file succeeds. False on any error.
- -

References closeFile(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), openFile(), Ne7sshError::push(), and writeFile().

- -

Referenced by Ne7SftpSubsystem::put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::readFile (uint32  fileID,
uint64  offset = 0 
)
-
-
- -

-Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file.

Parameters:
- - - -
fileID File ID retruned by openFile() method.
offset Offset. 0 by default.
-
-
Returns:
True if file content successfully read and placed in the buffer. Otherwise false.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveWhile().

- -

Referenced by get(), and Ne7SftpSubsystem::readFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::receiveUntil (short  _cmd,
uint32  timeSec = 0 
) [private]
-
-
- -

-Receive packets until specific SFTP subsystem command is received.

Parameters:
- - - -
_cmd SFTP command to wait for.
timeSec Timeout in seconds.
-
-
Returns:
True if the command specified has been received. Otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh_transport::getPacket(), ne7ssh_channel::handleReceived(), ne7ssh_string::length(), and ne7ssh_transport::waitForPacket().

- -

Referenced by closeFile(), init(), openDir(), openFile(), and writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::receiveWhile (short  _cmd,
uint32  timeSec = 0 
) [private]
-
-
- -

-Receive packets while SFTP subsystem commands received matches specified command.

Parameters:
- - - -
_cmd Command to receive.
timeSec Timeout in seconds.
-
-
Returns:
True if all expected data received. Otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh_transport::getPacket(), ne7ssh_channel::handleReceived(), ne7ssh_string::length(), and ne7ssh_transport::waitForPacket().

- -

Referenced by cd(), chmod(), chown(), getFileStats(), getFStat(), ls(), mkdir(), mv(), readFile(), rm(), and rmdir().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftp::receiveWindowAdjust (  )  [private]
-
-
- -

-This method is used to wait for an ADJUST_WINDOW packet, when the send window size is zero.

Returns:
True if the ADJUST_WINDOW packet has been received, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_transport::getPacket(), ne7ssh_session::getSshChannel(), ne7ssh_channel::handleReceived(), Ne7sshError::push(), and ne7ssh_transport::waitForPacket().

- -

Referenced by writeFile().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::rm (const char *  remoteFile  ) 
-
-
- -

-This method is used to remove a file on a remote server.

Parameters:
- - -
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if remove succeeds. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::rm().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::rmdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to remove a remote directory.

Parameters:
- - -
remoteDir Full or relative path to a directory to be removed.
-
-
Returns:
True if the directory successfully removed. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::rmdir().

- -
-

- -

-
- - - - - - - - - -
void Ne7sshSftp::setTimeout (uint32  _timeout  )  [inline]
-
-
- -

-This method is used to set a timeout for all SFTP subsystem communications.

Parameters:
- - -
_timeout Timeout in seconds.
-
- -

Referenced by Ne7SftpSubsystem::setTimeout().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::writeFile (uint32  fileID,
const uint8 *  data,
uint32  len,
uint64  offset = 0 
)
-
-
- -

-Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file.

Parameters:
- - - - - -
fileID File ID returned by openFile() method.
data Pointer to a buffer containing the data.
len Length of the block.
offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. Variable is set to 0 by default.
-
-
Returns:
True if file contect successfully written. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), receiveUntil(), and receiveWindowAdjust().

- -

Referenced by put(), and Ne7SftpSubsystem::writeFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html deleted file mode 100644 index d17712480ac..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html +++ /dev/null @@ -1,67 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftpPacket Member List

This is the complete list of members for Ne7sshSftpPacket, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addBigInt(const Botan::BigInt &bn)ne7ssh_string
addBytes(const Botan::byte *buff, uint32 len)ne7ssh_string
addChar(const char ch)ne7ssh_string
addFile(const char *filename)ne7ssh_string
addInt(const uint32 var)ne7ssh_string
addInt64(const uint64 var)Ne7sshSftpPacket
addString(const char *str)ne7ssh_string
addVector(Botan::SecureVector< Botan::byte > &secvec)ne7ssh_string
addVectorField(const Botan::SecureVector< Botan::byte > &vector)ne7ssh_string
bn2vector(Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)ne7ssh_string [static]
buffer (defined in ne7ssh_string)ne7ssh_string [protected]
channel (defined in Ne7sshSftpPacket)Ne7sshSftpPacket [private]
chop(uint32 nBytes)ne7ssh_string
clear()ne7ssh_string [inline]
getBigInt(Botan::BigInt &result)ne7ssh_string
getByte()ne7ssh_string
getInt()ne7ssh_string
getInt64()Ne7sshSftpPacket
getString(Botan::SecureVector< Botan::byte > &result)ne7ssh_string
isChannelSet()Ne7sshSftpPacket
length()ne7ssh_string [inline]
ne7ssh_string()ne7ssh_string
ne7ssh_string(Botan::SecureVector< Botan::byte > &var, uint32 position)ne7ssh_string
ne7ssh_string(const char *var, uint32 position)ne7ssh_string
Ne7sshSftpPacket()Ne7sshSftpPacket
Ne7sshSftpPacket(int channel)Ne7sshSftpPacket
Ne7sshSftpPacket(Botan::SecureVector< Botan::byte > &var, uint32 position)Ne7sshSftpPacket
nextPart()ne7ssh_string
resetParts()ne7ssh_string [inline]
split(const char token)ne7ssh_string
value()Ne7sshSftpPacket [virtual]
valueFragment(uint32 len=0)Ne7sshSftpPacket
~ne7ssh_string()ne7ssh_string [virtual]
~Ne7sshSftpPacket()Ne7sshSftpPacket

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html deleted file mode 100644 index 6d3f0e2e6a9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html +++ /dev/null @@ -1,302 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftpPacket Class Reference - - - - - -
-

Ne7sshSftpPacket Class Reference

#include <ne7ssh_sftp_packet.h> -

-

-Inheritance diagram for Ne7sshSftpPacket:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for Ne7sshSftpPacket:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 Ne7sshSftpPacket ()
 Ne7sshSftpPacket (int channel)
 Ne7sshSftpPacket (Botan::SecureVector< Botan::byte > &var, uint32 position)
 ~Ne7sshSftpPacket ()
Botan::SecureVector
-< Botan::byte > & 
value ()
Botan::SecureVector< Botan::byte > valueFragment (uint32 len=0)
void addInt64 (const uint64 var)
uint64 getInt64 ()
bool isChannelSet ()

Private Attributes

-int channel
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (  ) 
-
-
- -

-Default constructor. -

-

- -

-
- - - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (int  channel  ) 
-
-
- -

-Constructor.

Parameters:
- - -
channel Channel ID, returned by connect methods.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (Botan::SecureVector< Botan::byte > &  var,
uint32  position 
)
-
-
- -

-Constructor. Intializes the class with packet data.

Parameters:
- - - -
var Reference to packet data.
position Offset.
-
- -
-

- -

-
- - - - - - - - -
Ne7sshSftpPacket::~Ne7sshSftpPacket (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
void Ne7sshSftpPacket::addInt64 (const uint64  var  ) 
-
-
- -

-Appends 64 bit integer to the packet buffer.

Parameters:
- - -
var 64 bit integer.
-
- -

References ne7ssh_string::addBytes().

- -
-

- -

-
- - - - - - - - -
uint64 Ne7sshSftpPacket::getInt64 (  ) 
-
-
- -

-Retrieves a 64 bit integer from a packet buffer.

Returns:
Unsigned 64 bit integer.
- -

Referenced by Ne7sshSftp::handleNames(), and Ne7sshSftp::processAttrs().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftpPacket::isChannelSet (  ) 
-
-
- -

-Checks if the channel ID is set in the instance. Channel ID is needed to construct a SFTP packet.

Returns:
True if the channel ID is set. Otherwise false.
- -
-

- -

-
- - - - - - - - -
Botan::SecureVector< Botan::byte > & Ne7sshSftpPacket::value (  )  [virtual]
-
-
- -

-Returns buffer as a vector appending the SFTP subsystem specific packet headers.

Returns:
Reference to the buffer.
- -

Reimplemented from ne7ssh_string.

- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addVectorField(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
Botan::SecureVector< Botan::byte > Ne7sshSftpPacket::valueFragment (uint32  len = 0  ) 
-
-
- -

-Returns buffer as a vector appending the SFTP subsystem specific packet headers, including the length in the first packet transmitted. Used in transmissions when it's necessary to split the message into multiple packets.

Parameters:
- - -
len Length to append to the first packet in the message.
-
-
Returns:
Reference to SFTP packet or empty vector on error.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), and ne7ssh_string::value().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map deleted file mode 100644 index bd23dfcbe72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 deleted file mode 100644 index c5be6ab9d57..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c1347fb4ae29dfc3c6f77685b09bf3ae \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map deleted file mode 100644 index bd23dfcbe72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 deleted file mode 100644 index c5be6ab9d57..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c1347fb4ae29dfc3c6f77685b09bf3ae \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map deleted file mode 100644 index f6c6d47b42b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 deleted file mode 100644 index 0daef81959c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a33cd3840dcce8913b78a463d6b5024b \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map deleted file mode 100644 index 0988ea6f45c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 deleted file mode 100644 index 68a0a1079f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ead7f3358bb2dde804b9829bd96bab56 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classes.html b/src/libs/3rdparty/net7ssh/doc/html/classes.html deleted file mode 100644 index 94fc911372f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classes.html +++ /dev/null @@ -1,40 +0,0 @@ - - -ne7ssh.kdevelop: Alphabetical List - - - - - -
-

Class Index

C | E | F | N | S

- -
  C  
-
Ne7SftpSubsystem::fileAttrs   ne7ssh_connection   ne7ssh_string   Ne7sshSftpPacket   
connStruct   
  N  
-
ne7ssh_crypt   ne7ssh_transport   
  S  
-
  E  
-
Ne7SftpSubsystem   ne7ssh_kex   Ne7sshError   Ne7sshSftp::sftpFile   
Ne7sshError::Error   ne7ssh   ne7ssh_keys   Ne7sshSftp   Ne7sshSftp::sftpFileAttrs   
  F  
-
ne7ssh_channel   ne7ssh_session   

C | E | F | N | S

-

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html deleted file mode 100644 index b3de987c6f5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh Member List

This is the complete list of members for ne7ssh, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
allConns (defined in ne7ssh)ne7ssh [private]
CIPHER_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
close(int channel)ne7ssh
COMPRESSION_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
conCount (defined in ne7ssh)ne7ssh [private]
connected (defined in ne7ssh)ne7ssh [private]
connections (defined in ne7ssh)ne7ssh [private]
connectWithKey(const char *host, const int port, const char *username, const char *privKeyFileName, bool shell=true, const int timeout=0)ne7ssh
connectWithPassword(const char *host, const int port, const char *username, const char *password, bool shell=true, const int timeout=0)ne7ssh
errors()ne7ssh [static]
errs (defined in ne7ssh)ne7ssh [private, static]
generateKeyPair(const char *type, const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=0)ne7ssh
getChannelNo()ne7ssh [private]
getConnetions()ne7ssh [inline]
getReceivedSize(int channel, bool do_lock=true)ne7ssh
HOSTKEY_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
init (defined in ne7ssh)ne7ssh [private]
initSftp(Ne7SftpSubsystem &_sftp, int channel)ne7ssh
isSelectActive() (defined in ne7ssh)ne7ssh [inline, static]
KEX_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
lock()ne7ssh [private, static]
MAC_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
mut (defined in ne7ssh)ne7ssh [private, static]
ne7ssh()ne7ssh
PREFERED_CIPHER (defined in ne7ssh)ne7ssh [static]
PREFERED_MAC (defined in ne7ssh)ne7ssh [static]
read(int channel, bool do_lock=true)ne7ssh
readBinary(int channel)ne7ssh
running (defined in ne7ssh)ne7ssh [private, static]
select_thread (defined in ne7ssh)ne7ssh [private]
selectActive (defined in ne7ssh)ne7ssh [private, static]
selectDead() (defined in ne7ssh)ne7ssh [inline, static]
selectThread(void *)ne7ssh [private, static]
send(const char *data, int channel)ne7ssh
sendCmd(const char *cmd, int channel, int timeout)ne7ssh
setCount(uint32 count)ne7ssh [inline]
setOptions(const char *prefCipher, const char *prefHmac)ne7ssh
SSH_VERSION (defined in ne7ssh)ne7ssh [static]
unlock()ne7ssh [private, static]
waitFor(int channel, const char *str, uint32 timeout=0)ne7ssh
~ne7ssh()ne7ssh

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html deleted file mode 100644 index d4b28937445..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html +++ /dev/null @@ -1,906 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh Class Reference - - - - - -
-

ne7ssh Class Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for ne7ssh:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh ()
 ~ne7ssh ()
int connectWithPassword (const char *host, const int port, const char *username, const char *password, bool shell=true, const int timeout=0)
int connectWithKey (const char *host, const int port, const char *username, const char *privKeyFileName, bool shell=true, const int timeout=0)
connStructgetConnetions ()
bool send (const char *data, int channel)
bool sendCmd (const char *cmd, int channel, int timeout)
bool close (int channel)
void setCount (uint32 count)
const char * read (int channel, bool do_lock=true)
void * readBinary (int channel)
int getReceivedSize (int channel, bool do_lock=true)
bool waitFor (int channel, const char *str, uint32 timeout=0)
void setOptions (const char *prefCipher, const char *prefHmac)
bool generateKeyPair (const char *type, const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=0)
bool initSftp (Ne7SftpSubsystem &_sftp, int channel)

Static Public Member Functions

static Ne7sshErrorerrors ()
-static bool isSelectActive ()
-static void selectDead ()

Static Public Attributes

-static const char * SSH_VERSION = "SSH-2.0-NetSieben_1.3.1"
-static const char * KEX_ALGORITHMS = "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1"
-static const char * HOSTKEY_ALGORITHMS = "ssh-dss,ssh-rsa"
-static const char * MAC_ALGORITHMS = "hmac-md5,hmac-sha1,none"
-static const char * CIPHER_ALGORITHMS = "aes256-cbc,aes192-cbc,twofish-cbc,twofish256-cbc,blowfish-cbc,3des-cbc,aes128-cbc,cast128-cbc"
-static const char * COMPRESSION_ALGORITHMS = "none"
-static char * PREFERED_CIPHER = 0
-static char * PREFERED_MAC = 0

Private Member Functions

uint32 getChannelNo ()

Static Private Member Functions

static void * selectThread (void *)
static bool lock ()
static bool unlock ()

Private Attributes

-Botan::LibraryInitializer * init
-ne7ssh_connection ** connections
-uint32 conCount
-connStruct allConns
-ne7ssh_thread_t select_thread
-bool connected

Static Private Attributes

-static Ne7ssh_Mutex mut
-static bool running = false
-static bool selectActive = true
-static Ne7sshErrorerrs = NULL
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh::ne7ssh (  ) 
-
-
- -

-Default constructor. Used to allocate required memory, as well as initializing cryptographic routines. -

References connStruct::conns, connStruct::count, Ne7sshError::push(), and selectThread().

- -
-

- -

-
- - - - - - - - -
ne7ssh::~ne7ssh (  ) 
-
-
- -

-Destructor. -

References close(), lock(), and unlock().

- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool ne7ssh::close (int  channel  ) 
-
-
- -

-Closes specified channel.

Parameters:
- - -
channel Channel to close.
-
-
Returns:
Returns true if closing was successful, otherwise false is returned.
- -

References Ne7sshError::deleteChannel(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendClose(), and unlock().

- -

Referenced by ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh::connectWithKey (const char *  host,
const int  port,
const char *  username,
const char *  privKeyFileName,
bool  shell = true,
const int  timeout = 0 
)
-
-
- -

-Connect to remote host using SSH2 protocol, with publickey authentication.

-Reads private key from a file specified, and uses it to authenticate to remote host. Remote side must have public key from the key pair for authentication to succeed.

Parameters:
- - - - - - - -
host Hostname or IP to connect to.
port Port to connect to.
username Username to use in authentication.
privKeyFileName Full path to file containing private key used in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
Returns newly assigned channel ID, or -1 if connection failed.
- -

References ne7ssh_connection::connectWithKey(), connStruct::conns, connStruct::count, errors(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::setChannelNo(), and unlock().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh::connectWithPassword (const char *  host,
const int  port,
const char *  username,
const char *  password,
bool  shell = true,
const int  timeout = 0 
)
-
-
- -

-Connect to remote host using SSH2 protocol, with password authentication.

Parameters:
- - - - - - - -
host Hostname or IP to connect to.
port Port to connect to.
username Username to use in authentication.
password Password to use in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
Returns newly assigned channel ID, or -1 if connection failed.
- -

References ne7ssh_connection::connectWithPassword(), connStruct::conns, connStruct::count, errors(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::setChannelNo(), and unlock().

- -
-

- -

-
- - - - - - - - -
SSH_EXPORT Ne7sshError * ne7ssh::errors (  )  [static]
-
-
- -

-This method returns a pointer to the current Error collection.

Returns:
the Error collection
- -

Referenced by ne7ssh_string::addFile(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), connectWithKey(), connectWithPassword(), Ne7SftpSubsystem::errorNotInited(), ne7ssh_transport::establish(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::get(), ne7ssh_crypt::getCryptAlgo(), ne7ssh_keys::getDSAKeys(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_crypt::getMacKeyLen(), ne7ssh_keys::getRSAKeys(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), Ne7sshSftp::isType(), Ne7sshError::lock(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), ne7ssh_transport::NoBlock(), ne7ssh_channel::open(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), Ne7sshSftp::readFile(), ne7ssh_transport::receive(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_transport::send(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), ne7ssh_connection::startSftp(), Ne7sshError::unlock(), ne7ssh_crypt::verifySig(), ne7ssh_transport::waitForPacket(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::generateKeyPair (const char *  type,
const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 0 
)
-
-
- -

-Generate key pair.

Parameters:
- - - - - - -
type String specifying key type. Currently "dsa" and "rsa" are supported.
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
Return true if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateRSAKeys(), and Ne7sshError::push().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh::getChannelNo (  )  [private]
-
-
- -

-Returns the number of active channel.

Returns:
Active channel.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), send(), and sendCmd().

- -
-

- -

-
- - - - - - - - -
connStruct* ne7ssh::getConnetions (  )  [inline]
-
-
- -

-Retrieves a pointer to all current connections.

-For internal use only.

Returns:
Returns pointer to pointers to ne7ssh_connection class, or 0 if no connection exist.
- -

Referenced by selectThread().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
int ne7ssh::getReceivedSize (int  channel,
bool  do_lock = true 
)
-
-
- -

-Returns the size of all data read. Used to read buffer passed 0x0.

Parameters:
- - -
channel Channel number which buffer size to check.
-
-
Returns:
Return size of the buffer, or 0x0 if receive buffer empty.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), and unlock().

- -

Referenced by waitFor().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh::initSftp (Ne7SftpSubsystem _sftp,
int  channel 
)
-
-
- -

-This method is used to initialize a new SFTP subsystem.

Parameters:
- - - -
_sftp Reference to SFTP subsystem to be initialized.
channel Channel ID returned by one of the connect methods.
-
-
Returns:
True if the new subsystem successfully initialized. False on any error.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::startSftp(), and unlock().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh::lock (  )  [static, private]
-
-
- -

-Lock the mutex.

Returns:
True if lock aquired. Oterwise false.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), selectThread(), send(), sendCmd(), waitFor(), and ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * ne7ssh::read (int  channel,
bool  do_lock = true 
)
-
-
- -

-Reads all data from receiving buffer on specified channel.

Parameters:
- - -
channel Channel to read data on.
-
-
Returns:
Returns string read from receiver buffer or 0 if buffer is empty.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), Ne7sshError::push(), and unlock().

- -

Referenced by waitFor().

- -
-

- -

-
- - - - - - - - - -
void * ne7ssh::readBinary (int  channel  ) 
-
-
- -

-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.

Parameters:
- - -
channel Channel to read data on.
-
-
Returns:
Returns pointer to the start of binary data or 0 if nothing received.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), Ne7sshError::push(), and unlock().

- -
-

- -

-
- - - - - - - - - -
void * ne7ssh::selectThread (void *  initData  )  [static, private]
-
-
- -

-Send / Receive thread.

-For Internal use only

Returns:
Usually 0 when thread terminates
- -

References connStruct::conns, getConnetions(), ne7ssh_connection::handleData(), lock(), Ne7sshError::push(), ne7ssh_connection::sendData(), setCount(), and unlock().

- -

Referenced by ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh::send (const char *  data,
int  channel 
)
-
-
- -

-Retreives count of current connections

-For internal use only.

Returns:
Returns current count of connections. Sends a command string on specified channel, provided the specified channel has been previously opened through connectWithPassword() function.
-
Parameters:
- - - -
data Pointer to the command string to send to a channel.
channel Channel to send data on.
-
-
Returns:
Returns true if the send was successful, otherwise false returned.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendData(), and unlock().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::sendCmd (const char *  cmd,
int  channel,
int  timeout 
)
-
-
- -

-Can be used to send a single command and disconnect, similiar behavior to openssh when one appends a command to the end of ssh command.

Parameters:
- - - - -
cmd Remote command to execute. Can be used to read files on unix with 'cat [filename]'.
channel Channel to send the command.
timeout How long to wait before giving up.
-
-
Returns:
Returns true if the send was successful, otherwise false returned.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendCmd(), and unlock().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh::setCount (uint32  count  )  [inline]
-
-
- -

-Sets connection count.

-For internal use only.

Parameters:
- - -
count Integer to set connection count.
-
- -

Referenced by selectThread().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh::setOptions (const char *  prefCipher,
const char *  prefHmac 
)
-
-
- -

-Sets prefered cipher and hmac algorithms.

-This function as to be executed before connection functions, just after initialization of ne7ssh class.

Parameters:
- - - -
prefCipher prefered cipher algorithm string representation. Possible cipher algorithms are aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc.
prefHmac preferede hmac algorithm string representation. Possible hmac algorithms are hmac-md5, hmac-sha1, none.
-
- -
-

- -

-
- - - - - - - - -
bool ne7ssh::unlock (  )  [static, private]
-
-
- -

-Unlock the mutext.

Returns:
True if the mutext successfully unlocked. Otherwise false.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), selectThread(), send(), sendCmd(), waitFor(), and ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::waitFor (int  channel,
const char *  str,
uint32  timeout = 0 
)
-
-
- -

-Wait until receiving buffer contains a string passed in str, or until the function timeouts as specified in timeout.

Parameters:
- - - - -
channel Channel to wait on.
str String to wait for.
timeout Timeout in seconds.
-
-
Returns:
Returns true if string specified in str variable has been received, otherwise false returned.
- -

References getReceivedSize(), lock(), Ne7sshError::push(), read(), and unlock().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html deleted file mode 100644 index e6ea00c3865..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html +++ /dev/null @@ -1,72 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_channel Member List

This is the complete list of members for ne7ssh_channel, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
adjustRecvWindow(int bufferSize)ne7ssh_channel
adjustWindow(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
channelOpened (defined in ne7ssh_channel)ne7ssh_channel [protected]
closed (defined in ne7ssh_channel)ne7ssh_channel [private]
cmdComplete (defined in ne7ssh_channel)ne7ssh_channel [private]
data2Send()ne7ssh_channel [inline]
delayedBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
eof (defined in ne7ssh_channel)ne7ssh_channel [private]
execCmd(const char *cmd)ne7ssh_channel
getCmdComplete()ne7ssh_channel [inline]
getReceived()ne7ssh_channel [inline]
getRecvWindow()ne7ssh_channel [inline]
getSendWindow()ne7ssh_channel [inline]
getShell()ne7ssh_channel
handleChannelConfirm()ne7ssh_channel [private]
handleClose(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleData(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private, virtual]
handleDisconnect(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleEof(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleExtendedData(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleReceived(Botan::SecureVector< Botan::byte > &_packet)ne7ssh_channel
handleRequest(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
inBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
isOpen()ne7ssh_channel [inline]
isRemoteShell()ne7ssh_channel [inline]
ne7ssh_channel(ne7ssh_session *_session)ne7ssh_channel
open(uint32 channelID)ne7ssh_channel
outBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
receive()ne7ssh_channel
sendAdjustWindow()ne7ssh_channel [protected]
sendAll()ne7ssh_channel
sendClose()ne7ssh_channel
sendEof()ne7ssh_channel
session (defined in ne7ssh_channel)ne7ssh_channel [private]
shellSpawned (defined in ne7ssh_channel)ne7ssh_channel [private]
windowRecv (defined in ne7ssh_channel)ne7ssh_channel [protected]
windowSend (defined in ne7ssh_channel)ne7ssh_channel [protected]
write(Botan::SecureVector< Botan::byte > &data)ne7ssh_channel
~ne7ssh_channel()ne7ssh_channel [virtual]

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html deleted file mode 100644 index e96742383ca..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html +++ /dev/null @@ -1,882 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_channel Class Reference - - - - - -
-

ne7ssh_channel Class Reference

#include <ne7ssh_channel.h> -

-

-Inheritance diagram for ne7ssh_channel:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for ne7ssh_channel:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_channel (ne7ssh_session *_session)
virtual ~ne7ssh_channel ()
uint32 open (uint32 channelID)
void getShell ()
bool execCmd (const char *cmd)
void receive ()
bool handleReceived (Botan::SecureVector< Botan::byte > &_packet)
void write (Botan::SecureVector< Botan::byte > &data)
void sendAll ()
bool data2Send ()
bool isOpen ()
bool sendClose ()
bool sendEof ()
Botan::SecureVector
-< Botan::byte > & 
getReceived ()
bool getCmdComplete ()
bool isRemoteShell ()
bool adjustRecvWindow (int bufferSize)
uint32 getRecvWindow ()
uint32 getSendWindow ()

Protected Member Functions

void sendAdjustWindow ()

Protected Attributes

-uint32 windowRecv
-uint32 windowSend
-bool channelOpened

Private Member Functions

bool handleChannelConfirm ()
bool adjustWindow (Botan::SecureVector< Botan::byte > &packet)
virtual bool handleData (Botan::SecureVector< Botan::byte > &packet)
bool handleExtendedData (Botan::SecureVector< Botan::byte > &packet)
bool handleEof (Botan::SecureVector< Botan::byte > &packet)
void handleClose (Botan::SecureVector< Botan::byte > &packet)
void handleRequest (Botan::SecureVector< Botan::byte > &packet)
bool handleDisconnect (Botan::SecureVector< Botan::byte > &packet)

Private Attributes

-bool eof
-bool closed
-bool cmdComplete
-bool shellSpawned
-ne7ssh_sessionsession
-ne7ssh_string inBuffer
-ne7ssh_string outBuffer
-ne7ssh_string delayedBuffer
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_channel::ne7ssh_channel (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_channel class consturctor.

Parameters:
- - -
_session Pointer to ne7ssh_session.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_channel::~ne7ssh_channel (  )  [virtual]
-
-
- -

-ne7ssh_channel class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool ne7ssh_channel::adjustRecvWindow (int  bufferSize  ) 
-
-
- -

-Checks if receive window needs adjusting, if so send a window adjust request.

Parameters:
- - -
bufferSize Current buffer size.
-
-
Returns:
False on any error, otherwise true.
- -

References sendAdjustWindow().

- -

Referenced by Ne7sshSftp::handleData().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::adjustWindow (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'WINDOWS_ADJUST' packet.

-It's used to increase our sending window size.

Parameters:
- - -
packet Reference to vector containing WINDOW_ADJUST packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

References ne7ssh_string::getInt().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::data2Send (  )  [inline]
-
-
- -

-Checks if there is any data waiting to be sent. Most often called from selectThread via ne7ssh_connection class.

Returns:
True if there is data to send, otherwise false is returned.
- -

References ne7ssh_string::length().

- -

Referenced by ne7ssh_connection::data2Send().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::execCmd (const char *  cmd  ) 
-
-
- -

-Executes a single command on the remote end and terminates the connection.

Parameters:
- - -
cmd Remote command to execute.
-
-
Returns:
True if command if sening of a command succeded. False returned on failure.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::sendCmd().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::getCmdComplete (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the execution.

Returns:
True if execution of the command is complete. Otherwise false.
- -

Referenced by ne7ssh_connection::getCmdComplete().

- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_channel::getReceived (  )  [inline]
-
-
- -

-Gets last received packet.

Returns:
Reference to a vector containing the last received packet.
- -

References ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::getReceived().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_channel::getRecvWindow (  )  [inline]
-
-
- -

-Gets the current size of the receive window.

Returns:
Size of the revceive window.
- -

Referenced by Ne7sshSftp::Ne7sshSftp().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_channel::getSendWindow (  )  [inline]
-
-
- -

-Gets the current size of the send window.

Returns:
Size of the send window.
- -

Referenced by Ne7sshSftp::Ne7sshSftp().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::getShell (  ) 
-
-
- -

-Requests shell from remote side. Does not wait for or expect a reply. According to SSH specs that's an acceptable behavior. -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::handleChannelConfirm (  )  [private]
-
-
- -

-This function is used to handle the 'CHANNEL_OPEN_CONFIRMATION' packet.

-After parsing the payload, send channel ID is assigned, along with send windows size and maximum packer size.

Returns:
Always returns true.
- -

References ne7ssh_string::getInt(), ne7ssh_transport::getPacket(), ne7ssh_session::setMaxPacket(), and ne7ssh_session::setSendChannel().

- -

Referenced by open().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::handleClose (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'CLOSE' packet.

-If the close action wasn't initiated on this end, we also send a 'CLOSE' packet to the remote side, prompting the closing of remote side's receiving channel.

Parameters:
- - -
packet Reference to vector containing the 'CLOSE' packet.
-
- -

References sendClose().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleData (Botan::SecureVector< Botan::byte > &  packet  )  [private, virtual]
-
-
- -

-This function is used to handle the 'DATA' packet.

-It's used to parse the payload, and add received data to the buffer.

Parameters:
- - -
packet Reference to vector containing 'DATA' packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

Reimplemented in Ne7sshSftp.

- -

References ne7ssh_string::addChar(), ne7ssh_string::addVector(), ne7ssh_string::chop(), ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), ne7ssh_string::length(), Ne7sshError::push(), and sendAdjustWindow().

- -

Referenced by handleExtendedData(), and handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleDisconnect (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'DISCONNECT' packet.

-In normal operation we should not get this packet. Only if some serious error occurs, and makes remote side drop the connection, will this packet be received. And at that point we disconnect right away, and throw an error.

Parameters:
- - -
packet Reference to vector containing the 'DISCONNECT' packet.
-
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleEof (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'EOF' packet.

-It's used to close the receiving window and channel.

Parameters:
- - -
packet Reference to vector containing EOF packet.
-
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and sendClose().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleExtendedData (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle 'EXTENDED_DATA' packet. This packet is mostly used to transmit remote side errors.

Parameters:
- - -
packet Reference to vector containing 'EXTENDED_DATA' packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), handleData(), Ne7sshError::push(), and sendAdjustWindow().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleReceived (Botan::SecureVector< Botan::byte > &  _packet  ) 
-
-
- -

-Handle a packet received from remote side.

Parameters:
- - -
_packet Reference to a newly received packet.
-
-
Returns:
True if the packet successfully processed. False on any error.
- -

References ne7ssh_string::addVector(), adjustWindow(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_session::getSshChannel(), handleClose(), handleData(), handleDisconnect(), handleEof(), handleExtendedData(), handleRequest(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by receive(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), and Ne7sshSftp::receiveWindowAdjust().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::handleRequest (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'REQUEST' packet.

-At this point only two requests are supported, namely "exit-signal" and "exit-status". For the most part we ignore this packet, which is safe to do according to SSH specs.

Parameters:
- - -
packet Reference to vector containing the 'REQUEST' packet.
-
- -

References ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::isOpen (  )  [inline]
-
-
- -

-Checks if current channel is in an open state.

Returns:
True if channel is open, otherwise false is returned.
- -

Referenced by ne7ssh_connection::isOpen(), and ne7ssh_connection::sendClose().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::isRemoteShell (  )  [inline]
-
-
- -

-Determines if the shell has been spawned on the remote side.

Returns:
True if the shell has been spawned. Otherwise false.
- -

Referenced by ne7ssh_connection::isRemoteShell(), and ne7ssh_connection::startSftp().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_channel::open (uint32  channelID  ) 
-
-
- -

-Requests 'CHANNEL_OPEN' from the remote side.

Parameters:
- - -
channelID New receiving channel ID.
-
-
Returns:
Returns new channel ID, or 0 if open fails.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh::errors(), handleChannelConfirm(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::receive (  ) 
-
-
- -

-Receives new packet from remote side. This function is mostly used from selectThread. -

References ne7ssh_transport::getPacket(), handleReceived(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::handleData().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::sendAdjustWindow (  )  [protected]
-
-
- -

-Request adjustment of the send window size on the remote end, so we can receive more data. -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getMaxPacket(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by adjustRecvWindow(), handleData(), and handleExtendedData().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::sendAll (  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_channel::sendClose (  ) 
-
-
- -

-When closing a channel, initiates the closing procedure.

Returns:
False if sending fails. Otherwise true is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by handleClose(), handleEof(), and ne7ssh_connection::sendClose().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::sendEof (  ) 
-
-
- -

-Send EOF to the remote side.

Returns:
True if sending succeeds, otherwise false.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::write (Botan::SecureVector< Botan::byte > &  data  ) 
-
-
- -

-Pushes a new command to the buffer where the selectThread will catch and send it.

Parameters:
- - -
data Reference to vector containing a command to be added to the buffer.
-
- -

References ne7ssh_string::addVector(), ne7ssh_string::clear(), ne7ssh_session::getMaxPacket(), ne7ssh_string::length(), and ne7ssh_string::value().

- -

Referenced by sendAll(), and ne7ssh_connection::sendData().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map deleted file mode 100644 index 02c4c4d8a55..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 deleted file mode 100644 index d5ff61a0e44..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ec1101fe9893f883eb4ebdb2f49a2dc0 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map deleted file mode 100644 index 063936f72f4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 deleted file mode 100644 index 1feddb9d560..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -386e64f96857962ac64bfcfcd2ee191e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map deleted file mode 100644 index 98f2305886d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 deleted file mode 100644 index 27dbb60a0a5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -93c2b10c3b049ce2f2c5694a6507d90e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html deleted file mode 100644 index 42ca0ddd8e3..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html +++ /dev/null @@ -1,71 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_connection Member List

This is the complete list of members for ne7ssh_connection, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
authWithKey(const char *username, const char *privKeyFileName)ne7ssh_connection [private]
authWithPassword(const char *username, const char *password)ne7ssh_connection [private]
channel (defined in ne7ssh_connection)ne7ssh_connection [private]
checkRemoteVersion()ne7ssh_connection [private]
cmdClosed (defined in ne7ssh_connection)ne7ssh_connection [private]
cmdRunning (defined in ne7ssh_connection)ne7ssh_connection [private]
connected (defined in ne7ssh_connection)ne7ssh_connection [private]
connectWithKey(uint32 channelID, const char *host, uint32 port, const char *username, const char *privKeyFileName, bool shell=true, int timeout=0)ne7ssh_connection
connectWithPassword(uint32 channelID, const char *host, uint32 port, const char *username, const char *password, bool shell=true, int timeout=0)ne7ssh_connection
crypto (defined in ne7ssh_connection)ne7ssh_connection [private]
data2Send()ne7ssh_connection [inline]
getChannelNo()ne7ssh_connection [inline]
getCmdComplete()ne7ssh_connection [inline]
getReceived()ne7ssh_connection [inline]
getSocket()ne7ssh_connection [inline]
handleData()ne7ssh_connection
isCmdClosed()ne7ssh_connection [inline]
isCmdRunning()ne7ssh_connection [inline]
isConnected()ne7ssh_connection [inline]
isOpen()ne7ssh_connection [inline]
isRemoteShell()ne7ssh_connection [inline]
isSftpActive()ne7ssh_connection
mut (defined in ne7ssh_connection)ne7ssh_connection [private]
ne7ssh_connection()ne7ssh_connection
requestService(const char *service)ne7ssh_connection [private]
sendClose()ne7ssh_connection
sendCmd(const char *cmd)ne7ssh_connection
sendData(const char *data)ne7ssh_connection
sendData()ne7ssh_connection [inline]
sendLocalVersion()ne7ssh_connection [private]
session (defined in ne7ssh_connection)ne7ssh_connection [private]
setChannelNo(int channelID)ne7ssh_connection [inline]
sftp (defined in ne7ssh_connection)ne7ssh_connection [private]
sock (defined in ne7ssh_connection)ne7ssh_connection [private]
startSftp()ne7ssh_connection
thisChannel (defined in ne7ssh_connection)ne7ssh_connection [private]
transport (defined in ne7ssh_connection)ne7ssh_connection [private]
~ne7ssh_connection()ne7ssh_connection

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html deleted file mode 100644 index 6f252c42d8b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html +++ /dev/null @@ -1,900 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_connection Class Reference - - - - - -
-

ne7ssh_connection Class Reference

#include <ne7ssh_connection.h> -

-

-Collaboration diagram for ne7ssh_connection:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_connection ()
 ~ne7ssh_connection ()
int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char *username, const char *password, bool shell=true, int timeout=0)
int connectWithKey (uint32 channelID, const char *host, uint32 port, const char *username, const char *privKeyFileName, bool shell=true, int timeout=0)
SOCKET getSocket ()
void handleData ()
void sendData (const char *data)
void setChannelNo (int channelID)
int getChannelNo ()
bool data2Send ()
void sendData ()
bool sendCmd (const char *cmd)
bool sendClose ()
bool isOpen ()
bool isConnected ()
Botan::SecureVector
-< Botan::byte > & 
getReceived ()
bool getCmdComplete ()
bool isCmdClosed ()
bool isRemoteShell ()
bool isCmdRunning ()
Ne7sshSftpstartSftp ()
bool isSftpActive ()

Private Member Functions

bool checkRemoteVersion ()
bool sendLocalVersion ()
bool requestService (const char *service)
bool authWithPassword (const char *username, const char *password)
bool authWithKey (const char *username, const char *privKeyFileName)

Private Attributes

-SOCKET sock
-int thisChannel
-ne7ssh_cryptcrypto
-ne7ssh_transporttransport
-ne7ssh_sessionsession
-ne7ssh_channelchannel
-Ne7sshSftpsftp
-Ne7ssh_Mutex mut
-bool connected
-bool cmdRunning
-bool cmdClosed
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_connection::ne7ssh_connection (  ) 
-
-
- -

-ne7ssh_connection class constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_connection::~ne7ssh_connection (  ) 
-
-
- -

-ne7ssh_connection class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_connection::authWithKey (const char *  username,
const char *  privKeyFileName 
) [private]
-
-
- -

-Sends a test message to check if "publickey" authentication is allowed fo specified user. If succesfull proceeds wtih generating a signature and sending real authentication packet of "publickey" type.

Parameters:
- - - -
username Username used for authentication.
privKeyFileName Full path to file containing private key to be used in authentication.
-
-
Returns:
True if authentication was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_keys::generateSignature(), ne7ssh_string::getByte(), ne7ssh_keys::getKeyAlgo(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_transport::getPacket(), ne7ssh_keys::getPublicKeyBlob(), ne7ssh_session::getSessionID(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_connection::authWithPassword (const char *  username,
const char *  password 
) [private]
-
-
- -

-Sends an authentication request of "password" type. Waits for packet 'USERAUTH_SUCESS'.

Parameters:
- - - -
username Username used for authentication.
password Password used for authentication.
-
-
Returns:
True if authentication was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_transport::getPacket(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::checkRemoteVersion (  )  [private]
-
-
- -

-Checks if remote side is returning a correctly formated SSH version string, and makes sure that version 2 of SSH protocol is supported by the remote side.

Returns:
False if version string is malformed, or version 2 is not supported, otherwise true is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::receive(), and ne7ssh_session::setRemoteVersion().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh_connection::connectWithKey (uint32  channelID,
const char *  host,
uint32  port,
const char *  username,
const char *  privKeyFileName,
bool  shell = true,
int  timeout = 0 
)
-
-
- -

-Connects to a remote host using SSH protocol version 2, with publickey based authentication.

Parameters:
- - - - - - - - -
channelID ID assigned to the new channel.
host Hostname / IP of the remote host.
port Connection port.
username Username to use in the authentication.
privKeyFileName Full path to file containing private key to be used in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
A newly assigned channel ID, or -1 if connection failed.
- -

References authWithKey(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().

- -

Referenced by ne7ssh::connectWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh_connection::connectWithPassword (uint32  channelID,
const char *  host,
uint32  port,
const char *  username,
const char *  password,
bool  shell = true,
int  timeout = 0 
)
-
-
- -

-Connects to a remote host using SSH protocol version 2, with password based authentication.

Parameters:
- - - - - - - - -
channelID ID of the new channel.
host Hostname / IP of the remote host.
port Connection port.
username Username to use in the authentication.
password Password to use in the authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
A newly assigned channel ID, or -1 if connection failed.
- -

References authWithPassword(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().

- -

Referenced by ne7ssh::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::data2Send (  )  [inline]
-
-
- -

-Checks for the data in the send buffer.

Returns:
True is there is data to send, otherwise false.
- -

References ne7ssh_channel::data2Send().

- -
-

- -

-
- - - - - - - - -
int ne7ssh_connection::getChannelNo (  )  [inline]
-
-
- -

-Retrieves the current SSH channel.

Returns:
Returns SSH channel or -1 if not connected.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::getCmdComplete (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the xecution.

Returns:
True if execution of the command is complete. Otherwise false.
- -

References ne7ssh_channel::getCmdComplete().

- -

Referenced by sendClose().

- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_connection::getReceived (  )  [inline]
-
-
- -

-Retrieves the last received packet.

Returns:
A reference to a buffer containing the last received packet.
- -

References ne7ssh_channel::getReceived().

- -

Referenced by ne7ssh::getReceivedSize(), ne7ssh::read(), and ne7ssh::readBinary().

- -
-

- -

-
- - - - - - - - -
SOCKET ne7ssh_connection::getSocket (  )  [inline]
-
-
- -

-Retrieves the tcp socket number.

Returns:
Socket, or -1 if not connected.
- -
-

- -

-
- - - - - - - - -
void ne7ssh_connection::handleData (  ) 
-
-
- -

-When new data arrives, and is available for reading, this function is called from selectThread to handle it. -

References ne7ssh_channel::receive().

- -

Referenced by ne7ssh::selectThread().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isCmdClosed (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when the user requested a close() on the channel.

Returns:
True if the user requested to close the channel. Otherwise false.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isCmdRunning (  )  [inline]
-
-
- -

-Checks if current connection is executing a single command, without a shell.

Returns:
True if a single command is running. Otherwise false.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isConnected (  )  [inline]
-
-
- -

-Checks if process is connected and authenticated to the remote side.

Returns:
True if connected, otherwise false is returned.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isOpen (  )  [inline]
-
-
- -

-Checks if channel is open.

Returns:
True if channel is open, otherwise false is returned.
- -

References ne7ssh_channel::isOpen().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isRemoteShell (  )  [inline]
-
-
- -

-Determines if the shell has been spawned on the remote side.

Returns:
True if the shell has been spawned. Otherwise false.
- -

References ne7ssh_channel::isRemoteShell().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isSftpActive (  ) 
-
-
- -

-Checks if SFTP subsystem is active on the current connection.

Returns:
True if SFTP subsystem is active, otherwise false.
- -

Referenced by sendClose().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_connection::requestService (const char *  service  )  [private]
-
-
- -

-Sends an SSH service request, waits for 'SERVICE_ACCEPT' packet.

Parameters:
- - -
service pointer to a string containing the requested SSH service. For example "ssh-userauth".
-
-
Returns:
True If SERVICE_ACCEPT packet was received, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::sendClose (  ) 
-
-
- -

-This function is used to close the current connection.

-First closes the channel, and then the connection itself.

Returns:
True, if packet sent successfully, otherwise false is returned.
- -

References getCmdComplete(), ne7ssh_channel::isOpen(), isSftpActive(), and ne7ssh_channel::sendClose().

- -

Referenced by ne7ssh::close().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_connection::sendCmd (const char *  cmd  ) 
-
-
- -

-

Parameters:
- - -
cmd 
-
-
Returns:
- -

References ne7ssh_channel::execCmd().

- -

Referenced by ne7ssh::sendCmd().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_connection::sendData (  )  [inline]
-
-
- -

-Sends the content of the buffer.,

-Usually used after data2Send returns true, executed by selectThread. -

References ne7ssh_channel::sendAll().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_connection::sendData (const char *  data  ) 
-
-
- -

-This function is used to write commands to the buffer, later to be sent to the remote site for execution.

Parameters:
- - -
data Pointer to a string, containing command to be written to the buffer.
-
- -

References ne7ssh_channel::write().

- -

Referenced by ne7ssh::selectThread(), and ne7ssh::send().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::sendLocalVersion (  )  [private]
-
-
- -

-Sends local version string.

Returns:
Returns false is there any communication errors occur, otherwise true is returned.
- -

References ne7ssh_transport::send(), and ne7ssh_session::setLocalVersion().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_connection::setChannelNo (int  channelID  )  [inline]
-
-
- -

-Sets the current SSH channel number. -

Referenced by ne7ssh::connectWithKey(), and ne7ssh::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
Ne7sshSftp * ne7ssh_connection::startSftp (  ) 
-
-
- -

-Starts a new sftp subsystem.

Returns:
Returns a pointer to the newly started Ne7sshSftp instance.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshSftp::init(), ne7ssh_channel::isRemoteShell(), and Ne7sshError::push().

- -

Referenced by ne7ssh::initSftp().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map deleted file mode 100644 index 1f53e7b28cd..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 deleted file mode 100644 index b74f4f60914..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ce68b6591bcf910222da91a135d39054 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html deleted file mode 100644 index 581c5799723..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html +++ /dev/null @@ -1,112 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_crypt Member List

This is the complete list of members for ne7ssh_crypt, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AES128_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
AES192_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
AES256_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
agree(Botan::SecureVector< Botan::byte > &result, const char *local, Botan::SecureVector< Botan::byte > &remote)ne7ssh_crypt
BLOWFISH_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sCmprsMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sCryptoMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sMacMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
CAST128_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
cmprsMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
compress (defined in ne7ssh_crypt)ne7ssh_crypt [private]
compressData(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_crypt
compute_key(Botan::SecureVector< Botan::byte > &key, Botan::byte ID, uint32 nBytes)ne7ssh_crypt [private]
computeH(Botan::SecureVector< Botan::byte > &result, Botan::SecureVector< Botan::byte > &val)ne7ssh_crypt
computeMac(Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)ne7ssh_crypt
cryptoMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decompress (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decompressData(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_crypt
decrypt (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decryptBlock (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decryptPacket(Botan::SecureVector< Botan::byte > &decrypted, Botan::SecureVector< Botan::byte > &packet, uint32 len)ne7ssh_crypt
DH_GROUP14_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
DH_GROUP1_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encrypt (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encryptBlock (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encryptPacket(Botan::SecureVector< Botan::byte > &crypted, Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)ne7ssh_crypt
getCryptAlgo(uint32 crypto)ne7ssh_crypt [private]
getDecryptBlock()ne7ssh_crypt [inline]
getDHGroup14Sha1Public(Botan::BigInt &publicKey)ne7ssh_crypt [private]
getDHGroup1Sha1Public(Botan::BigInt &publicKey)ne7ssh_crypt [private]
getDSAKey(Botan::SecureVector< Botan::byte > &hostKey)ne7ssh_crypt [private]
getEncryptBlock()ne7ssh_crypt [inline]
getHashAlgo()ne7ssh_crypt [private]
getHmacAlgo(uint32 method)ne7ssh_crypt [private]
getKexPublic(Botan::BigInt &publicKey)ne7ssh_crypt
getMacDigestLen(uint32 method)ne7ssh_crypt [private]
getMacInLen()ne7ssh_crypt [inline]
getMacKeyLen(uint32 method)ne7ssh_crypt [private]
getMacOutLen()ne7ssh_crypt [inline]
getRSAKey(Botan::SecureVector< Botan::byte > &hostKey)ne7ssh_crypt [private]
H (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_MD5 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_NONE enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hmacIn (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hmacOut (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hostkeyMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hostkeyMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
inited (defined in ne7ssh_crypt)ne7ssh_crypt [private]
isCompressed()ne7ssh_crypt [inline]
isInited()ne7ssh_crypt [inline]
K (defined in ne7ssh_crypt)ne7ssh_crypt [private]
kexMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
kexMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
macMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
makeKexSecret(Botan::SecureVector< Botan::byte > &result, Botan::BigInt &f)ne7ssh_crypt
makeNewKeys()ne7ssh_crypt
ne7ssh_crypt(ne7ssh_session *_session)ne7ssh_crypt
negotiatedCmprsC2s(Botan::SecureVector< Botan::byte > &cmprsAlgo)ne7ssh_crypt
negotiatedCmprsS2c(Botan::SecureVector< Botan::byte > &cmprsAlgo)ne7ssh_crypt
negotiatedCryptoC2s(Botan::SecureVector< Botan::byte > &cryptoAlgo)ne7ssh_crypt
negotiatedCryptoS2c(Botan::SecureVector< Botan::byte > &cryptoAlgo)ne7ssh_crypt
negotiatedHostkey(Botan::SecureVector< Botan::byte > &hostKeyAlgo)ne7ssh_crypt
negotiatedKex(Botan::SecureVector< Botan::byte > &kexAlgo)ne7ssh_crypt
negotiatedMacC2s(Botan::SecureVector< Botan::byte > &macAlgo)ne7ssh_crypt
negotiatedMacS2c(Botan::SecureVector< Botan::byte > &macAlgo)ne7ssh_crypt
NONE enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
privKexKey (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cCmprsMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cCryptoMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cMacMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
session (defined in ne7ssh_crypt)ne7ssh_crypt [private]
SSH_DSS enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
SSH_RSA enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
TDES_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
TWOFISH_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
verifySig(Botan::SecureVector< Botan::byte > &hostKey, Botan::SecureVector< Botan::byte > &sig)ne7ssh_crypt
ZLIB enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
~ne7ssh_crypt()ne7ssh_crypt

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html deleted file mode 100644 index 7202d2d2192..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html +++ /dev/null @@ -1,1362 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_crypt Class Reference - - - - - -
-

ne7ssh_crypt Class Reference

#include <crypt.h> -

-

-Collaboration diagram for ne7ssh_crypt:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_crypt (ne7ssh_session *_session)
 ~ne7ssh_crypt ()
bool isInited ()
uint32 getEncryptBlock ()
uint32 getDecryptBlock ()
uint32 getMacOutLen ()
uint32 getMacInLen ()
bool agree (Botan::SecureVector< Botan::byte > &result, const char *local, Botan::SecureVector< Botan::byte > &remote)
bool negotiatedKex (Botan::SecureVector< Botan::byte > &kexAlgo)
bool negotiatedHostkey (Botan::SecureVector< Botan::byte > &hostKeyAlgo)
bool negotiatedCryptoC2s (Botan::SecureVector< Botan::byte > &cryptoAlgo)
bool negotiatedCryptoS2c (Botan::SecureVector< Botan::byte > &cryptoAlgo)
bool negotiatedMacC2s (Botan::SecureVector< Botan::byte > &macAlgo)
bool negotiatedMacS2c (Botan::SecureVector< Botan::byte > &macAlgo)
bool negotiatedCmprsC2s (Botan::SecureVector< Botan::byte > &cmprsAlgo)
bool negotiatedCmprsS2c (Botan::SecureVector< Botan::byte > &cmprsAlgo)
bool getKexPublic (Botan::BigInt &publicKey)
bool makeKexSecret (Botan::SecureVector< Botan::byte > &result, Botan::BigInt &f)
bool computeH (Botan::SecureVector< Botan::byte > &result, Botan::SecureVector< Botan::byte > &val)
bool verifySig (Botan::SecureVector< Botan::byte > &hostKey, Botan::SecureVector< Botan::byte > &sig)
bool makeNewKeys ()
bool encryptPacket (Botan::SecureVector< Botan::byte > &crypted, Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)
bool decryptPacket (Botan::SecureVector< Botan::byte > &decrypted, Botan::SecureVector< Botan::byte > &packet, uint32 len)
void computeMac (Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)
void compressData (Botan::SecureVector< Botan::byte > &buffer)
void decompressData (Botan::SecureVector< Botan::byte > &buffer)
bool isCompressed ()

Private Types

enum  kexMethods { DH_GROUP1_SHA1, -DH_GROUP14_SHA1 - }
enum  hostkeyMethods { SSH_DSS, -SSH_RSA - }
enum  cryptoMethods {
-  TDES_CBC, -AES128_CBC, -AES192_CBC, -AES256_CBC, -
-  BLOWFISH_CBC, -CAST128_CBC, -TWOFISH_CBC -
- }
enum  macMethods { HMAC_SHA1, -HMAC_MD5, -HMAC_NONE - }
enum  cmprsMethods { NONE, -ZLIB - }

Private Member Functions

bool getDHGroup1Sha1Public (Botan::BigInt &publicKey)
bool getDHGroup14Sha1Public (Botan::BigInt &publicKey)
Botan::DSA_PublicKey * getDSAKey (Botan::SecureVector< Botan::byte > &hostKey)
Botan::RSA_PublicKey * getRSAKey (Botan::SecureVector< Botan::byte > &hostKey)
const char * getHashAlgo ()
const char * getCryptAlgo (uint32 crypto)
const char * getHmacAlgo (uint32 method)
uint32 getMacKeyLen (uint32 method)
uint32 getMacDigestLen (uint32 method)
bool compute_key (Botan::SecureVector< Botan::byte > &key, Botan::byte ID, uint32 nBytes)

Private Attributes

-ne7ssh_sessionsession
-uint32 kexMethod
-uint32 hostkeyMethod
-uint32 c2sCryptoMethod
-uint32 s2cCryptoMethod
-uint32 c2sMacMethod
-uint32 s2cMacMethod
-uint32 c2sCmprsMethod
-uint32 s2cCmprsMethod
-bool inited
-Botan::SecureVector< Botan::byte > H
-Botan::SecureVector< Botan::byte > K
-Botan::Pipe * encrypt
-Botan::Pipe * decrypt
-Botan::Pipe * compress
-Botan::Pipe * decompress
-Botan::HMAC * hmacOut
-Botan::HMAC * hmacIn
-Botan::DH_PrivateKey * privKexKey
-uint32 encryptBlock
-uint32 decryptBlock
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_crypt::ne7ssh_crypt (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_crypt class constructor.

Parameters:
- - -
_session Pointer to ne7ssh_session class.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_crypt::~ne7ssh_crypt (  ) 
-
-
- -

-ne7ssh_crypt class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::agree (Botan::SecureVector< Botan::byte > &  result,
const char *  local,
Botan::SecureVector< Botan::byte > &  remote 
)
-
-
- -

-This function is used in negotiations of crypto, signing and HMAC algorithms.

Parameters:
- - - - -
result Reference to a vector where negotiated algorithm name will be dumped.
local String containing a list of localy supported algorithms, separated by commas.
remote Reference to vector containing a list of algorithms supported by remote side, separated by commas.
-
-
Returns:
True, if common algorithm was found, otherwise false is returned.
- -

References ne7ssh_string::nextPart(), ne7ssh_string::resetParts(), and ne7ssh_string::split().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_crypt::compressData (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Compresses the data.

Parameters:
- - -
buffer Reference to vector containing payload to be compress. Results will also be dumped into this var.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::compute_key (Botan::SecureVector< Botan::byte > &  key,
Botan::byte  ID,
uint32  nBytes 
) [private]
-
-
- -

-Function used to compute crypto and HMAC keys.

-Keys are computed using K, H, ID and sessionID values. All these are concated and hashed. If hash is not long enough K, H, and newly generated key is used over and over again, till keys are long enough.

Parameters:
- - - - -
key Resulting key will be dumped into this var.
ID Single character ID, as specified in SSH protocol specs.
nBytes Key length in bytes.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), getHashAlgo(), ne7ssh_session::getSessionID(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::computeH (Botan::SecureVector< Botan::byte > &  result,
Botan::SecureVector< Botan::byte > &  val 
)
-
-
- -

-Computes H value by checking what hash algorithm is used and hashing "val".

Parameters:
- - - -
result H value will be dumped into this var.
val Reference to vector containing material for H variable generation.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
void ne7ssh_crypt::computeMac (Botan::SecureVector< Botan::byte > &  hmac,
Botan::SecureVector< Botan::byte > &  packet,
uint32  seq 
)
-
-
- -

-Computes HMAC from specific packet.

Parameters:
- - - - -
hmac Generated HMAC value will be dumped into this var.
packet Reference to vector containing packet for HMAC generation.
seq receive sequence.
-
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_crypt::decompressData (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Decompresses the data.

Parameters:
- - -
buffer Reference to vector containing packet payload to decompress. Result will also be dumped into this var.
-
- -

Referenced by ne7ssh_transport::getPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::decryptPacket (Botan::SecureVector< Botan::byte > &  decrypted,
Botan::SecureVector< Botan::byte > &  packet,
uint32  len 
)
-
-
- -

-Decrypts a packet.

Parameters:
- - - - -
decrypted Decrypted payload will be dumped into this var.
packet Reference to vector containing encrypted packet.
len Specifies the length of chunk to be decrypted.
-
-
Returns:
True if decryption is successful, otherwise false returned.
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::encryptPacket (Botan::SecureVector< Botan::byte > &  crypted,
Botan::SecureVector< Botan::byte > &  hmac,
Botan::SecureVector< Botan::byte > &  packet,
uint32  seq 
)
-
-
- -

-Encrypts a packet and generates HMAC, if enabled during negotiation.

-The entire packet is encrypted, only HMAC stays in raw format.

Parameters:
- - - - - -
crypted Encrypted packet will be dumped into this var.
hmac HMAC will be dumped into this var.
packet Reference to vector containing unencrypted packet.
seq Transmited packet sequence.
-
-
Returns:
True if encryption successful, otherwise false is returned.
- -

Referenced by ne7ssh_transport::sendPacket().

- -
-

- -

-
- - - - - - - - - -
const char * ne7ssh_crypt::getCryptAlgo (uint32  crypto  )  [private]
-
-
- -

-Returns a string represenation of negotiated cipher algorithm.

Parameters:
- - -
crypto Integer represenating a cipher algorithm.
-
-
Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getDecryptBlock (  )  [inline]
-
-
- -

-Returns the size of decryption block

Returns:
Size of the block
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getDHGroup14Sha1Public (Botan::BigInt &  publicKey  )  [private]
-
-
- -

-Generates a new Public Key, based on Diffie Helman Group14, SHA1 standard.

Parameters:
- - -
publicKey Reference to publick Key. The result will be dumped into this var.
-
-
Returns:
If generation successful returns true, otherwise false is returned.
- -

Referenced by getKexPublic().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getDHGroup1Sha1Public (Botan::BigInt &  publicKey  )  [private]
-
-
- -

-Generates a new Public Key, based on Diffie Helman Group1, SHA1 standard.

Parameters:
- - -
publicKey Reference to publick Key. The result will be dumped into this var.
-
-
Returns:
If generation successful returns true, otherwise false is returned.
- -

Referenced by getKexPublic().

- -
-

- -

-
- - - - - - - - - -
DSA_PublicKey * ne7ssh_crypt::getDSAKey (Botan::SecureVector< Botan::byte > &  hostKey  )  [private]
-
-
- -

-Generates a new DSA public Key from p,q,g,y values extracted from the host key received from the server.

Parameters:
- - -
hostKey Reference to vector containing host key received from a server.
-
-
Returns:
Returns newly generated DSA public Key. If host key vector is trash, more likely application will be aborted within Botan library.
- -

References ne7ssh_string::addVector(), ne7ssh_string::getBigInt(), ne7ssh_string::getString(), and negotiatedHostkey().

- -

Referenced by verifySig().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getEncryptBlock (  )  [inline]
-
-
- -

-Returns the size of encryption block.

Returns:
Size of the block.
- -

Referenced by ne7ssh_transport::sendPacket().

- -
-

- -

-
- - - - - - - - -
const char * ne7ssh_crypt::getHashAlgo (  )  [private]
-
-
- -

-Returns a string represenation of negotiated one way hash algorithm. For DH1_GROUP1_SHA1, "SHA-1" will be returned.

Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by compute_key().

- -
-

- -

-
- - - - - - - - - -
const char * ne7ssh_crypt::getHmacAlgo (uint32  method  )  [private]
-
-
- -

-Returns a string represenation of negotiated HMAC algorithm.

Parameters:
- - -
method Integer represenating HMAC algorithm.
-
-
Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getKexPublic (Botan::BigInt &  publicKey  ) 
-
-
- -

-Generates KEX public key.

Parameters:
- - -
publicKey Public key will be dumped into this var.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh::errors(), getDHGroup14Sha1Public(), getDHGroup1Sha1Public(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_crypt::getMacDigestLen (uint32  method  )  [private]
-
-
- -

-Returns digest length of negotiated HMAC algorithm.

-If HMAC integrity checking is enabled, this value is used in the verification process. Digest length coded in accordance with SSH protocol specs.

Parameters:
- - -
method Integer represenation of HMAC algorithm.
-
-
Returns:
Key length.
- -

Referenced by getMacInLen(), and getMacOutLen().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getMacInLen (  )  [inline]
-
-
- -

-Returns digest length of HMAC algorithm used to verify integrity of data received.

Returns:
Digest length.
- -

References getMacDigestLen().

- -

Referenced by ne7ssh_transport::getPacket(), and ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_crypt::getMacKeyLen (uint32  method  )  [private]
-
-
- -

-Returns key length of the negotiated HMAC algorithm.

-Used in HMAC key generation. Key length coded in accordance with SSH protocol specs.

Parameters:
- - -
method Integer represenating HMAC algorithm.
-
-
Returns:
Key length.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getMacOutLen (  )  [inline]
-
-
- -

-Returns digest length of HMAC algorithm used to verify integrity of transmited data.

Returns:
Digest length.
- -

References getMacDigestLen().

- -
-

- -

-
- - - - - - - - - -
RSA_PublicKey * ne7ssh_crypt::getRSAKey (Botan::SecureVector< Botan::byte > &  hostKey  )  [private]
-
-
- -

-Generates a new RSA public Key from n and e values extracted from the host key received from the server.

Parameters:
- - -
hostKey Reference to a vector containing host key.
-
-
Returns:
Returns newly generated ESA public Key. If the hostkey is trash, more likely application will abort within Botan library.
- -

References ne7ssh_string::addVector(), ne7ssh_string::getBigInt(), ne7ssh_string::getString(), and negotiatedHostkey().

- -

Referenced by verifySig().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::isCompressed (  )  [inline]
-
-
- -

-Checks if compression is enabled.

Returns:
If compression is enabled returns true, otherwise false is returned.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::isInited (  )  [inline]
-
-
- -

-Checks if cryptographic engine has been initialized.

-The engine is initialized when all crypto and hmac keys are generated and the cryptographic Pipes are created.

Returns:
True if cryptographic engine is initialized, otherwise false is returned.
- -

Referenced by ne7ssh_transport::getPacket(), ne7ssh_kex::handleKexDHReply(), ne7ssh_transport::sendPacket(), and ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::makeKexSecret (Botan::SecureVector< Botan::byte > &  result,
Botan::BigInt &  f 
)
-
-
- -

-At the end of key exchange this function is used to generate a shared secret key from private KEX key, that one gets from getKexPublic() function and F value received from a server.

Parameters:
- - - -
result Secret key will be dumped into this var.
f Reference to F value.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh_string::bn2vector().

- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::makeNewKeys (  ) 
-
-
- -

-Generates new cipher and HMAC keys.

Returns:
True if key generation was successful, otherwise false is returned.
- -

References compute_key(), getCryptAlgo(), getHmacAlgo(), and getMacKeyLen().

- -

Referenced by ne7ssh_kex::sendKexNewKeys().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCmprsC2s (Botan::SecureVector< Botan::byte > &  cmprsAlgo  ) 
-
-
- -

-Parses negotiated client to server compression algorithm and registers it's integer representation with the class.

Parameters:
- - -
cmprsAlgo Reference to a vector containing the negotiated compression algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCmprsS2c (Botan::SecureVector< Botan::byte > &  cmprsAlgo  ) 
-
-
- -

-Parses negotiated server to client compression algorithm and registers it's integer representation with the class.

Parameters:
- - -
cmprsAlgo Reference to a vector containing the negotiated compression algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCryptoC2s (Botan::SecureVector< Botan::byte > &  cryptoAlgo  ) 
-
-
- -

-Parse negotiated client to server cipher algorithm and registers it's integer representation with the class.

Parameters:
- - -
cryptoAlgo Reference to a vector containing the negotiated cipher algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCryptoS2c (Botan::SecureVector< Botan::byte > &  cryptoAlgo  ) 
-
-
- -

-Parses negotiated server to client cipher algorithm and registers it's integer representation with the class.

Parameters:
- - -
cryptoAlgo Reference to a vector containing the negotiated cipher algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedHostkey (Botan::SecureVector< Botan::byte > &  hostKeyAlgo  ) 
-
-
- -

-Parses negotiated host key algorithm and registers it's integer representation with the class.

Parameters:
- - -
hostKeyAlgo Reference to a vector containing the negotiated host key algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by getDSAKey(), getRSAKey(), and ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedKex (Botan::SecureVector< Botan::byte > &  kexAlgo  ) 
-
-
- -

-Parses negotiated key exchange algorithm vector, and registers it's integer representation with the class.

Parameters:
- - -
kexAlgo Reference to a vector containing the negotiated KEX algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedMacC2s (Botan::SecureVector< Botan::byte > &  macAlgo  ) 
-
-
- -

-Parses negotiated client to server HMAC algorithm and registers it's integer representation with the class.

Parameters:
- - -
macAlgo Reference to a vector containing the negotiated HMAC algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedMacS2c (Botan::SecureVector< Botan::byte > &  macAlgo  ) 
-
-
- -

-Parses negotiated server to client HMAC algorithm vector and registers it's integer representation with the class.

Parameters:
- - -
macAlgo Reference to a vector containing the negotiated HMAC algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::verifySig (Botan::SecureVector< Botan::byte > &  hostKey,
Botan::SecureVector< Botan::byte > &  sig 
)
-
-
- -

-Verifies host signature.

Parameters:
- - - -
hostKey Reference to vector containing hostKey.
sig Regerence to vector containing the signature.
-
-
Returns:
True if signature verification was successful, otherwise false is returned.
- -

References ne7ssh::errors(), getDSAKey(), getRSAKey(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map deleted file mode 100644 index acb09cde818..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 deleted file mode 100644 index a0191a6c0a9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -72e4da21efe57283ea6ef8f98feb75eb \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html deleted file mode 100644 index b87d6c42236..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html +++ /dev/null @@ -1,51 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_kex Member List

This is the complete list of members for ne7ssh_kex, including all inherited members.

- - - - - - - - - - - - - - - - - - -
Ciphers (defined in ne7ssh_kex)ne7ssh_kex [private]
constructLocalKex()ne7ssh_kex [private]
e (defined in ne7ssh_kex)ne7ssh_kex [private]
f (defined in ne7ssh_kex)ne7ssh_kex [private]
handleInit()ne7ssh_kex
handleKexDHReply()ne7ssh_kex
Hmacs (defined in ne7ssh_kex)ne7ssh_kex [private]
hostKey (defined in ne7ssh_kex)ne7ssh_kex [private]
k (defined in ne7ssh_kex)ne7ssh_kex [private]
localKex (defined in ne7ssh_kex)ne7ssh_kex [private]
makeH(Botan::SecureVector< Botan::byte > &hVector)ne7ssh_kex [private]
ne7ssh_kex(ne7ssh_session *_session)ne7ssh_kex
remotKex (defined in ne7ssh_kex)ne7ssh_kex [private]
sendInit()ne7ssh_kex
sendKexDHInit()ne7ssh_kex
sendKexNewKeys()ne7ssh_kex
session (defined in ne7ssh_kex)ne7ssh_kex [private]
~ne7ssh_kex()ne7ssh_kex

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html deleted file mode 100644 index 64d7ba28820..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html +++ /dev/null @@ -1,319 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_kex Class Reference - - - - - -
-

ne7ssh_kex Class Reference

#include <ne7ssh_kex.h> -

-

-Collaboration diagram for ne7ssh_kex:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_kex (ne7ssh_session *_session)
 ~ne7ssh_kex ()
bool sendInit ()
bool handleInit ()
bool sendKexDHInit ()
bool handleKexDHReply ()
bool sendKexNewKeys ()

Private Member Functions

void constructLocalKex ()
void makeH (Botan::SecureVector< Botan::byte > &hVector)

Private Attributes

-ne7ssh_sessionsession
-ne7ssh_string localKex
-ne7ssh_string remotKex
-ne7ssh_string hostKey
-ne7ssh_string e
-ne7ssh_string f
-ne7ssh_string k
-Botan::SecureVector< Botan::byte > Ciphers
-Botan::SecureVector< Botan::byte > Hmacs
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_kex::ne7ssh_kex (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_kex class constructor.

Parameters:
- - -
_session Pointer to ne7ssh_session variable.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_kex::~ne7ssh_kex (  ) 
-
-
- -

-ne7ssh_kex class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - -
void ne7ssh_kex::constructLocalKex (  )  [private]
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_kex::handleInit (  ) 
-
-
- -

-After sendInit() function returnes true, this functions is used to parse the received 'KEX_INIT' packet.

-Used to agree on cipher, hmac, etc. algorithms used in communication between client and server.

Returns:
True if parsing was succesful and all algorithms agreed upon, otherwise false is returned.
- -

References ne7ssh_string::addBytes(), ne7ssh_crypt::agree(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_transport::getPacket(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), and Ne7sshError::push().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::handleKexDHReply (  ) 
-
-
- -

-After sendKexDHInit() returns true, this function is used to handle the received 'KEXDH_REPLY'.

-This is the function to create the shared secret K. It also extracts the host key and signature fields from the payload, generates DSA/RSA keys, and verifies the signature.

Returns:
True if all operations are completed successfully, otherwise false is returned.
- -

References ne7ssh_string::addVector(), ne7ssh_string::bn2vector(), ne7ssh_string::clear(), ne7ssh_string::getBigInt(), ne7ssh_transport::getPacket(), ne7ssh_string::getString(), ne7ssh_crypt::isInited(), makeH(), ne7ssh_crypt::makeKexSecret(), ne7ssh_session::setSessionID(), ne7ssh_string::value(), and ne7ssh_crypt::verifySig().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_kex::makeH (Botan::SecureVector< Botan::byte > &  hVector  )  [private]
-
-
- -

-Computes H hash, from concated values of the local SSH version string, remote SSH version string, local KEX_INIT payload, remote KEX_INIT payload, host key, e, f and k BigInt values.

Parameters:
- - -
hVector Reference to a vecor where H value will be stored.
-
- -

References ne7ssh_string::addVectorField(), ne7ssh_crypt::computeH(), ne7ssh_session::getLocalVersion(), ne7ssh_session::getRemoteVersion(), and ne7ssh_string::value().

- -

Referenced by handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendInit (  ) 
-
-
- -

-Sends 'KEX_INIT' packet and waits for 'KEX_INIT' reply.

Returns:
True if successful, otherwise false is returned.
- -

References constructLocalKex(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendKexDHInit (  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendKexNewKeys (  ) 
-
-
- -

-This function waits for 'NEWKEYS' packet from the remote host.

-Once the packet is received, local 'NEWKEYS' packet is sent, all encryption and hmac keys are generated and encrypted communication is established.

Returns:
True if all operations are successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), ne7ssh_crypt::makeNewKeys(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map deleted file mode 100644 index 892978342e2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 deleted file mode 100644 index 4685c290b84..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c6c626f9886b1a9d69d7e1660e94daa0 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html deleted file mode 100644 index a9fbbbdc0b3..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html +++ /dev/null @@ -1,53 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_keys Member List

This is the complete list of members for ne7ssh_keys, including all inherited members.

- - - - - - - - - - - - - - - - - - - - -
DSA enum value (defined in ne7ssh_keys)ne7ssh_keys
dsaPrivateKey (defined in ne7ssh_keys)ne7ssh_keys [private]
generateDSAKeys(const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)ne7ssh_keys
generateDSASignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
generateRSAKeys(const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)ne7ssh_keys
generateRSASignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
generateSignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
getDSAKeys(char *buffer, uint32 size)ne7ssh_keys [private]
getKeyAlgo()ne7ssh_keys [inline]
getKeyPairFromFile(const char *privKeyFileName)ne7ssh_keys
getPublicKeyBlob()ne7ssh_keys
getRSAKeys(char *buffer, uint32 size)ne7ssh_keys [private]
keyAlgo (defined in ne7ssh_keys)ne7ssh_keys [private]
keyAlgos enum name (defined in ne7ssh_keys)ne7ssh_keys
ne7ssh_keys()ne7ssh_keys
publicKeyBlob (defined in ne7ssh_keys)ne7ssh_keys [private]
RSA enum value (defined in ne7ssh_keys)ne7ssh_keys
rsaPrivateKey (defined in ne7ssh_keys)ne7ssh_keys [private]
signature (defined in ne7ssh_keys)ne7ssh_keys [private]
~ne7ssh_keys()ne7ssh_keys

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html deleted file mode 100644 index fe199c04891..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html +++ /dev/null @@ -1,526 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_keys Class Reference - - - - - -
-

ne7ssh_keys Class Reference

#include <ne7ssh_keys.h> -

-

-Collaboration diagram for ne7ssh_keys:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Types

enum  keyAlgos { DSA, -RSA - }

Public Member Functions

 ne7ssh_keys ()
 ~ne7ssh_keys ()
bool generateDSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)
bool generateRSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)
bool getKeyPairFromFile (const char *privKeyFileName)
Botan::SecureVector
-< Botan::byte > & 
generateSignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector< Botan::byte > generateDSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector< Botan::byte > generateRSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector
-< Botan::byte > & 
getPublicKeyBlob ()
uint8 getKeyAlgo ()

Private Member Functions

bool getDSAKeys (char *buffer, uint32 size)
bool getRSAKeys (char *buffer, uint32 size)

Private Attributes

-Botan::DSA_PrivateKey * dsaPrivateKey
-Botan::RSA_PrivateKey * rsaPrivateKey
-ne7ssh_string publicKeyBlob
-Botan::SecureVector< Botan::byte > signature
-uint8 keyAlgo
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_keys::ne7ssh_keys (  ) 
-
-
- -

-ne7ssh_keys constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_keys::~ne7ssh_keys (  ) 
-
-
- -

-ne7ssh_keys destructor.

Returns:
- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::generateDSAKeys (const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 2048 
)
-
-
- -

-Generates DSA Key pair and saves keys in specified files.

Parameters:
- - - - - -
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
True if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh::generateKeyPair().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > ne7ssh_keys::generateDSASignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by generateSignature().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::generateRSAKeys (const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 2048 
)
-
-
- -

-Generates RSA Key pair and saves keys in specified files.

Parameters:
- - - - - -
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
True if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh::generateKeyPair().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > ne7ssh_keys::generateRSASignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by generateSignature().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > & ne7ssh_keys::generateSignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided.

-Determines key type and passed the processing either to generateDSASignature() or generateRSAKeys() functions.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References generateDSASignature(), and generateRSASignature().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::getDSAKeys (char *  buffer,
uint32  size 
) [private]
-
-
- -

-Extracts DSA key pair from a PEM encoded stream.

Parameters:
- - - -
buffer PEM encoded string.
size Length of the stream.
-
-
Returns:
True if keys succesfully extracted. Otherwise False is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by getKeyPairFromFile().

- -
-

- -

-
- - - - - - - - -
uint8 ne7ssh_keys::getKeyAlgo (  )  [inline]
-
-
- -

-Returns type of initialized keys.

Returns:
Type of keys.
- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_keys::getKeyPairFromFile (const char *  privKeyFileName  ) 
-
-
- -

-Extracts key pair from a PEM encoded file.

-Reads the file and determines the type of key, then passes processing to either getDsaKeys() or getRSAKeys(*) functions.

Parameters:
- - -
privKeyFileName Full path to PEM encoded file.
-
-
Returns:
True if key succesfully extracted, otherwise False is returned.
- -

References ne7ssh_string::addFile(), ne7ssh::errors(), getDSAKeys(), getRSAKeys(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - -
SecureVector< Botan::byte > & ne7ssh_keys::getPublicKeyBlob (  ) 
-
-
- -

-After key pair has been initialized, this function returns public key blob, as specified by SSH2 specs.

Returns:
Public key blob or zero length vector, if there are initialized keys.
- -

References ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::getRSAKeys (char *  buffer,
uint32  size 
) [private]
-
-
- -

-Extracts RSA key pair from a PEM encoded stream.

Parameters:
- - - -
buffer PEM encoded string.
size Length of the stream.
-
-
Returns:
True if keys succesfully extracted. Otherwise False is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by getKeyPairFromFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map deleted file mode 100644 index 28bba305867..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 deleted file mode 100644 index 96a712790ec..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -b0e2e8f8f6e9dbf06d7b20a0e23b73c3 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html deleted file mode 100644 index 1c71879f867..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html +++ /dev/null @@ -1,58 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_session Member List

This is the complete list of members for ne7ssh_session, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - -
channelID (defined in ne7ssh_session)ne7ssh_session [private]
crypto (defined in ne7ssh_session)ne7ssh_session
getLocalVersion()ne7ssh_session [inline]
getMaxPacket()ne7ssh_session [inline]
getReceiveChannel()ne7ssh_session [inline]
getRemoteVersion()ne7ssh_session [inline]
getSendChannel() const ne7ssh_session [inline]
getSessionID()ne7ssh_session [inline]
getSshChannel()ne7ssh_session [inline]
localVersion (defined in ne7ssh_session)ne7ssh_session [private]
maxPacket (defined in ne7ssh_session)ne7ssh_session [private]
ne7ssh_session()ne7ssh_session
receiveChannel (defined in ne7ssh_session)ne7ssh_session [private]
remoteVersion (defined in ne7ssh_session)ne7ssh_session [private]
sendChannel (defined in ne7ssh_session)ne7ssh_session [private]
sessionID (defined in ne7ssh_session)ne7ssh_session [private]
setLocalVersion(Botan::SecureVector< Botan::byte > &version)ne7ssh_session [inline]
setMaxPacket(uint32 size)ne7ssh_session [inline]
setReceiveChannel(uint32 channel)ne7ssh_session [inline]
setRemoteVersion(Botan::SecureVector< Botan::byte > &version)ne7ssh_session [inline]
setSendChannel(uint32 channel)ne7ssh_session [inline]
setSessionID(Botan::SecureVector< Botan::byte > &session)ne7ssh_session [inline]
setSshChannel(int32 channel)ne7ssh_session [inline]
transport (defined in ne7ssh_session)ne7ssh_session
~ne7ssh_session()ne7ssh_session

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html deleted file mode 100644 index fec4e08805f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html +++ /dev/null @@ -1,494 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_session Class Reference - - - - - -
-

ne7ssh_session Class Reference

#include <ne7ssh_session.h> -

-

-Collaboration diagram for ne7ssh_session:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_session ()
 ~ne7ssh_session ()
void setLocalVersion (Botan::SecureVector< Botan::byte > &version)
Botan::SecureVector
-< Botan::byte > & 
getLocalVersion ()
void setRemoteVersion (Botan::SecureVector< Botan::byte > &version)
Botan::SecureVector
-< Botan::byte > & 
getRemoteVersion ()
void setSessionID (Botan::SecureVector< Botan::byte > &session)
Botan::SecureVector
-< Botan::byte > & 
getSessionID ()
void setSendChannel (uint32 channel)
uint32 getSendChannel () const
void setReceiveChannel (uint32 channel)
uint32 getReceiveChannel ()
void setMaxPacket (uint32 size)
uint32 getMaxPacket ()
void setSshChannel (int32 channel)
int32 getSshChannel ()

Public Attributes

-ne7ssh_transporttransport
-ne7ssh_cryptcrypto

Private Attributes

-Botan::SecureVector< Botan::byte > localVersion
-Botan::SecureVector< Botan::byte > remoteVersion
-Botan::SecureVector< Botan::byte > sessionID
-uint32 sendChannel
-uint32 receiveChannel
-uint32 maxPacket
-int32 channelID
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_session::ne7ssh_session (  ) 
-
-
- -

-ne7ssh_session class constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_session::~ne7ssh_session (  ) 
-
-
- -

-ne7ssh_session class desctructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getLocalVersion (  )  [inline]
-
-
- -

-Returns local SSH version.

Returns:
Reference to a vector containing the version string.
- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_session::getMaxPacket (  )  [inline]
-
-
- -

-Returns maximum send packet size.

Returns:
Maximum packet size.
- -

Referenced by ne7ssh_channel::sendAdjustWindow(), and ne7ssh_channel::write().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_session::getReceiveChannel (  )  [inline]
-
-
- -

-Returns the receive channel ID.

Returns:
Channel ID.
- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getRemoteVersion (  )  [inline]
-
-
- -

-Returns remote SSH version.

Returns:
Reference to a vector containing the version string.
- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getSessionID (  )  [inline]
-
-
- -

-Returns the current SSH session ID.

Returns:
Reference to a vector containing the session ID.
- -

Referenced by ne7ssh_connection::authWithKey(), and ne7ssh_crypt::compute_key().

- -
-

- -

-
- - - - - - - - -
int32 ne7ssh_session::getSshChannel (  )  [inline]
-
-
- -

-REtrieves current ne7ssh channel.

Returns:
ne7ssh channel or -1 if the session hasn't succesfully opened the channel yet.
- -

Referenced by ne7ssh_connection::authWithKey(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), ne7ssh_channel::execCmd(), Ne7sshSftp::get(), ne7ssh_crypt::getCryptAlgo(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_crypt::getMacKeyLen(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), Ne7sshSftp::isType(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), Ne7sshSftp::readFile(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_connection::startSftp(), ne7ssh_crypt::verifySig(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setLocalVersion (Botan::SecureVector< Botan::byte > &  version  )  [inline]
-
-
- -

-Sets the local SSH version string.

Parameters:
- - -
version Reference to a vector containing the version string.
-
- -

Referenced by ne7ssh_connection::sendLocalVersion().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setMaxPacket (uint32  size  )  [inline]
-
-
- -

-Sets maximum send packet size.

Parameters:
- - -
size Maximum packet size.
-
- -

Referenced by ne7ssh_channel::handleChannelConfirm().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setReceiveChannel (uint32  channel  )  [inline]
-
-
- -

-After the channel is open this function sets the receive channel ID.

Parameters:
- - -
channel Channel ID.
-
- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setRemoteVersion (Botan::SecureVector< Botan::byte > &  version  )  [inline]
-
-
- -

-Sets the remote SSH version string.

Parameters:
- - -
version Reference to a vector containing the version string.
-
- -

Referenced by ne7ssh_connection::checkRemoteVersion().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSendChannel (uint32  channel  )  [inline]
-
-
- -

-After the channel is open this function sets the send channel ID.

Parameters:
- - -
channel Channel ID.
-
- -

Referenced by ne7ssh_channel::handleChannelConfirm().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSessionID (Botan::SecureVector< Botan::byte > &  session  )  [inline]
-
-
- -

-Sets SSH session ID, a.k.a. H from the first KEX.

Parameters:
- - -
session Reference to a vector containing the session ID.
-
- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSshChannel (int32  channel  )  [inline]
-
-
- -

-Stores newly created ne7ssh channel.

Parameters:
- - -
channel ne7ssh channel.
-
- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map deleted file mode 100644 index 1d4d8540da5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 deleted file mode 100644 index eb206efc763..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -5a1d3b6712725f15bca94f2095e25ebe \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html deleted file mode 100644 index 33c19412b92..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html +++ /dev/null @@ -1,61 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_string Member List

This is the complete list of members for ne7ssh_string, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addBigInt(const Botan::BigInt &bn)ne7ssh_string
addBytes(const Botan::byte *buff, uint32 len)ne7ssh_string
addChar(const char ch)ne7ssh_string
addFile(const char *filename)ne7ssh_string
addInt(const uint32 var)ne7ssh_string
addString(const char *str)ne7ssh_string
addVector(Botan::SecureVector< Botan::byte > &secvec)ne7ssh_string
addVectorField(const Botan::SecureVector< Botan::byte > &vector)ne7ssh_string
bn2vector(Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)ne7ssh_string [static]
buffer (defined in ne7ssh_string)ne7ssh_string [protected]
chop(uint32 nBytes)ne7ssh_string
clear()ne7ssh_string [inline]
currentPart (defined in ne7ssh_string)ne7ssh_string [private]
getBigInt(Botan::BigInt &result)ne7ssh_string
getByte()ne7ssh_string
getInt()ne7ssh_string
getString(Botan::SecureVector< Botan::byte > &result)ne7ssh_string
length()ne7ssh_string [inline]
ne7ssh_string()ne7ssh_string
ne7ssh_string(Botan::SecureVector< Botan::byte > &var, uint32 position)ne7ssh_string
ne7ssh_string(const char *var, uint32 position)ne7ssh_string
nextPart()ne7ssh_string
parts (defined in ne7ssh_string)ne7ssh_string [private]
positions (defined in ne7ssh_string)ne7ssh_string [private]
resetParts()ne7ssh_string [inline]
split(const char token)ne7ssh_string
value()ne7ssh_string [inline, virtual]
~ne7ssh_string()ne7ssh_string [virtual]

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html deleted file mode 100644 index 01a716a2628..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html +++ /dev/null @@ -1,766 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_string Class Reference - - - - - -
-

ne7ssh_string Class Reference

#include <ne7ssh_string.h> -

-

-Inheritance diagram for ne7ssh_string:
-
-

Inheritance graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_string ()
 ne7ssh_string (Botan::SecureVector< Botan::byte > &var, uint32 position)
 ne7ssh_string (const char *var, uint32 position)
virtual ~ne7ssh_string ()
void clear ()
void addString (const char *str)
bool addFile (const char *filename)
void addBytes (const Botan::byte *buff, uint32 len)
void addVector (Botan::SecureVector< Botan::byte > &secvec)
void addVectorField (const Botan::SecureVector< Botan::byte > &vector)
void addChar (const char ch)
void addInt (const uint32 var)
void addBigInt (const Botan::BigInt &bn)
virtual Botan::SecureVector
-< Botan::byte > & 
value ()
uint32 length ()
bool getString (Botan::SecureVector< Botan::byte > &result)
bool getBigInt (Botan::BigInt &result)
uint32 getInt ()
Botan::byte getByte ()
void split (const char token)
void resetParts ()
char * nextPart ()
void chop (uint32 nBytes)

Static Public Member Functions

static void bn2vector (Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)

Protected Attributes

-Botan::SecureVector< Botan::byte > buffer

Private Attributes

-Botan::byte ** positions
-uint32 parts
-uint32 currentPart
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_string::ne7ssh_string (  ) 
-
-
- -

-ne7ssh_string class default consturctor.

-Zeros out 'positions' and 'parts'. -

-

- -

-
- - - - - - - - - - - - - - - - - - -
ne7ssh_string::ne7ssh_string (Botan::SecureVector< Botan::byte > &  var,
uint32  position 
)
-
-
- -

-ne7ssh_string class consturctor.

-Takes a vector as an argument and places the data into 'buffer'.

Parameters:
- - - -
var Reference to a vector containing a string.
position Position in the vector to start reading from. If '0', the entire vector is dumped into 'buffer'.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
ne7ssh_string::ne7ssh_string (const char *  var,
uint32  position 
)
-
-
- -

-Same as above costructor, but instead of vector it works with a string (const char*).

Parameters:
- - - -
var Pointer to a string terminated by '/0'.
position Read from this position onwards.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_string::~ne7ssh_string (  )  [virtual]
-
-
- -

-ne7ssh_string class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
void ne7ssh_string::addBigInt (const Botan::BigInt &  bn  ) 
-
-
- -

-Adds a BigInt variable to the buffer.

-BigInt is first converted to a vector, then the integer, representing length of the vector is converted to the network format. Converted ingeger is added to the buffer, followed by the vector.

Parameters:
- - -
bn Reference to BigInt variable.
-
- -

References bn2vector().

- -

Referenced by ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), and ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh_string::addBytes (const Botan::byte *  buff,
uint32  len 
)
-
-
- -

-Adds a byte stream to the buffer.

Parameters:
- - - -
buff Pointer to the byte stream.
len Length of the byte stream.
-
- -

Referenced by Ne7sshSftpPacket::addInt64(), ne7ssh_kex::constructLocalKex(), ne7ssh_kex::handleInit(), and ne7ssh_transport::sendPacket().

- -
-

- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::addFile (const char *  filename  ) 
-
-
- -

-Reads content of an ASCII file and appends it to the buffer.

Parameters:
- - -
filename Full path to ASCII file.
-
-
Returns:
True is file is successfully read. Otherwise False is returned.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by ne7ssh_keys::getKeyPairFromFile().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::addInt (const uint32  var  ) 
-
- -

- -

-
- - - - - - - - - -
void ne7ssh_string::addString (const char *  str  ) 
-
-
- -

-Adds a string to the buffer.

-Adds an integer representing the length of the string, converted to the network format, before the actual string data. Required by SSH protocol specifications.

Parameters:
- - -
str pointer to a string.
-
- -

References value().

- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), ne7ssh_channel::getShell(), Ne7sshSftp::init(), ne7ssh_channel::open(), and ne7ssh_connection::requestService().

- -
-

- -

- -

-
- - - - - - - - - -
void ne7ssh_string::addVectorField (const Botan::SecureVector< Botan::byte > &  vector  ) 
-
-
- -

-Adds a vector to the buffer.

-Adds an integer representing the length of the vector, converted to the network format, before the actual data. Required by SSH protocol specifications.

Parameters:
- - -
vector Reference to a vector.
-
- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::handleNames(), ne7ssh_kex::makeH(), ne7ssh_channel::sendAll(), Ne7sshSftpPacket::value(), and Ne7sshSftpPacket::valueFragment().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh_string::bn2vector (Botan::SecureVector< Botan::byte > &  result,
const Botan::BigInt &  bi 
) [static]
-
-
- -

-Converts BigInt into vector

-For internal use only

Parameters:
- - - -
result Reference to vector where the converted result will be dumped.
bi Reference to BigInt to convert.
-
- -

Referenced by addBigInt(), ne7ssh_kex::handleKexDHReply(), ne7ssh_crypt::makeKexSecret(), and ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::chop (uint32  nBytes  ) 
-
-
- -

-Chops bytes off of the end of the buffer.

Parameters:
- - -
nBytes How many bytes to chop off the end of the buffer.
-
- -

Referenced by ne7ssh_channel::handleData().

- -
-

- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::getBigInt (Botan::BigInt &  result  ) 
-
-
- -

-Extracts a single BigInt variable from the payload field of SSH packet.

Parameters:
- - -
result Reference to a BigInt variable where the result will be stored.
-
-
Returns:
True if BigInt field was found and successfully parsed, otherwise false is returned.
- -

Referenced by ne7ssh_crypt::getDSAKey(), ne7ssh_crypt::getRSAKey(), and ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
Botan::byte ne7ssh_string::getByte (  ) 
-
-
- -

-Extracts a single byte from tje payload field of SSH packet.

Returns:
A byte extracted from thenext byte of the payload.
- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::handleData(), ne7ssh_channel::handleReceived(), and ne7ssh_channel::handleRequest().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_string::getInt (  ) 
-
- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::getString (Botan::SecureVector< Botan::byte > &  result  ) 
-
- -

- -

- -

-
- - - - - - - - -
char * ne7ssh_string::nextPart (  ) 
-
-
- -

-Returns the next part.

Returns:
NULL terminated string, or 0 if this is the last part.
- -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_string::resetParts (  )  [inline]
-
-
- -

-Returns to the first part. -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::split (const char  token  ) 
-
-
- -

-Splits the buffer into strings separated by null character.

Parameters:
- - -
token Searches for this character in the buffer, replaces it with null and creates a part index.
-
- -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - -
virtual Botan::SecureVector<Botan::byte>& ne7ssh_string::value (  )  [inline, virtual]
-
- -

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map deleted file mode 100644 index b662f1b05f1..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 deleted file mode 100644 index 208ee6645fa..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -3edbca75c8429aa19fa0d66169573383 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html deleted file mode 100644 index 3f6e454a251..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html +++ /dev/null @@ -1,50 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_transport Member List

This is the complete list of members for ne7ssh_transport, including all inherited members.

- - - - - - - - - - - - - - - - - -
establish(const char *host, uint32 port, int timeout=0)ne7ssh_transport
getPacket(Botan::SecureVector< Botan::byte > &result)ne7ssh_transport
haveData()ne7ssh_transport
in (defined in ne7ssh_transport)ne7ssh_transport [private]
inBuffer (defined in ne7ssh_transport)ne7ssh_transport [private]
ne7ssh_transport(ne7ssh_session *_session)ne7ssh_transport
NoBlock(SOCKET socket, bool on)ne7ssh_transport [private]
receive(Botan::SecureVector< Botan::byte > &buffer, bool append=false)ne7ssh_transport
rSeq (defined in ne7ssh_transport)ne7ssh_transport [private]
send(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_transport
sendPacket(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_transport
seq (defined in ne7ssh_transport)ne7ssh_transport [private]
session (defined in ne7ssh_transport)ne7ssh_transport [private]
sock (defined in ne7ssh_transport)ne7ssh_transport [private]
wait(SOCKET socket, int rw, int timeout=-1)ne7ssh_transport [private]
waitForPacket(Botan::byte cmd, bool bufferOnly=false)ne7ssh_transport
~ne7ssh_transport()ne7ssh_transport

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html deleted file mode 100644 index a33eb0c00c4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html +++ /dev/null @@ -1,466 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_transport Class Reference - - - - - -
-

ne7ssh_transport Class Reference

#include <ne7ssh_transport.h> -

-

-Collaboration diagram for ne7ssh_transport:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_transport (ne7ssh_session *_session)
 ~ne7ssh_transport ()
SOCKET establish (const char *host, uint32 port, int timeout=0)
bool receive (Botan::SecureVector< Botan::byte > &buffer, bool append=false)
bool send (Botan::SecureVector< Botan::byte > &buffer)
bool sendPacket (Botan::SecureVector< Botan::byte > &buffer)
short waitForPacket (Botan::byte cmd, bool bufferOnly=false)
uint32 getPacket (Botan::SecureVector< Botan::byte > &result)
bool haveData ()

Private Member Functions

bool NoBlock (SOCKET socket, bool on)
bool wait (SOCKET socket, int rw, int timeout=-1)

Private Attributes

-uint32 seq
-uint32 rSeq
-const ne7ssh_sessionsession
-SOCKET sock
-Botan::SecureVector< Botan::byte > in
-Botan::SecureVector< Botan::byte > inBuffer
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_transport::ne7ssh_transport (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_transport class constructor.

-Transport class handles all socket communications for the ne7ssh library.

Parameters:
- - -
_session Pointer to ne7ssh_session instance.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_transport::~ne7ssh_transport (  ) 
-
-
- -

-ne7ssh_transport class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
SOCKET ne7ssh_transport::establish (const char *  host,
uint32  port,
int  timeout = 0 
)
-
-
- -

-Establishes connection to a remote host.

Parameters:
- - - - -
host Host name or IP.
port Port.
timeout Timeout for the establish procedure, in seconds.
-
-
Returns:
Socket number or -1 on failure.
- -

References ne7ssh::errors(), NoBlock(), and Ne7sshError::push().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_transport::getPacket (Botan::SecureVector< Botan::byte > &  result  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_transport::haveData (  ) 
-
-
- -

-Checks to see if there is more data to be read from the socket.

Returns:
True if there is data to be read, otherwise false is returned.
- -

References wait().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::NoBlock (SOCKET  socket,
bool  on 
) [private]
-
-
- -

-Switches socket's NonBlocking option on or off.

Parameters:
- - - -
socket Socket number.
on If set to true, NonBlocking option will be turned on, and vice versa.
-
-
Returns:
True if options have been successfuly set, otherwise false is returned.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by establish().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::receive (Botan::SecureVector< Botan::byte > &  buffer,
bool  append = false 
)
-
-
- -

-Reads data from the socket.

Parameters:
- - - -
buffer The data will be placed here.
append If set to true, received data will be appended to the buffer, instead of overwriting it.
-
-
Returns:
True if data successfuly read, otherwise false is returned.
- -

References ne7ssh::errors(), Ne7sshError::push(), and wait().

- -

Referenced by ne7ssh_connection::checkRemoteVersion(), and waitForPacket().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_transport::send (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Writes a buffer to the socket.

Parameters:
- - -
buffer Data to be written to the socket.
-
-
Returns:
True if data successful sent, otherwise false is returned.
- -

References ne7ssh::errors(), Ne7sshError::push(), and wait().

- -

Referenced by ne7ssh_connection::sendLocalVersion(), and sendPacket().

- -
-

- -

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::wait (SOCKET  socket,
int  rw,
int  timeout = -1 
) [private]
-
-
- -

-Waits for activity on a socket.

Parameters:
- - - - -
socket Socket number.
rw If set to true, checks if process can write to the socket, otherwise checks if there is data to be read from the socket.
timeout Desired timeout. By default the function will block until socket is ready for reading/writting. If set to '0', the function will return right away.
-
-
Returns:
True if socket is ready for reading/writting, otherwise false is returned.
- -

Referenced by haveData(), receive(), and send().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
short ne7ssh_transport::waitForPacket (Botan::byte  cmd,
bool  bufferOnly = false 
)
-
-
- -

-Waits until specified type of packet is received.

-If cmd is 0, waits for the first available packet of any kind.

-Once the desired packet is received, it is decrypted / decommpressed, the hMac is checked, and dropped into inBuffer class variable.

Parameters:
- - - -
cmd SSH2 packet to wait for. If 0, first available packet will be read into inBuffer class variable.
bufferOnly Does not wait to receive a new packet, only checks existing receive buffer for unprocessed packets.
-
-
Returns:
1 if desired packet is received, 0 if there another packet is received, or -1 if HMAC checking is enabled, and remote and local HMACs do not match.
- -

References ne7ssh_crypt::computeMac(), ne7ssh_crypt::decryptPacket(), ne7ssh::errors(), ne7ssh_crypt::getDecryptBlock(), ne7ssh_crypt::getMacInLen(), ne7ssh_crypt::isInited(), Ne7sshError::push(), and receive().

- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_channel::open(), ne7ssh_channel::receive(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), and ne7ssh_kex::sendKexNewKeys().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map deleted file mode 100644 index 0b572a73e88..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 deleted file mode 100644 index aa00e5ff508..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -7e399d8b6e7aaebcf329bfb9bf88132f \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html deleted file mode 100644 index d49b70beaeb..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html +++ /dev/null @@ -1,192 +0,0 @@ - - -ne7ssh.kdevelop: crypt.h Source File - - - - - -
-

crypt.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef CRYPT_H
-00018 #define CRYPT_H
-00019 
-00020 #include <botan/dl_group.h>
-00021 #include <botan/dh.h>
-00022 #include <botan/pubkey.h>
-00023 #include <botan/lookup.h>
-00024 #include <botan/dsa.h>
-00025 #include <botan/rsa.h>
-00026 #include <botan/look_pk.h>
-00027 #include <botan/pubkey.h>
-00028 
-00029 
-00030 // #if defined(BOTAN_EXT_COMPRESSOR_ZLIB)
-00031 //   #include <botan/zlib.h>
-00032 // #else
-00033 //   #error "Zlib support is not compiled into Botan"
-00034 // #endif
-00035 
-00036 #include <botan/cbc.h>
-00037 #include <botan/hmac.h>
-00038 
-00039 #include "ne7ssh_types.h"
-00040 #include "ne7ssh_string.h"
-00041 
-00042 class ne7ssh_session;
-00043 
-00047 class ne7ssh_crypt
-00048 {
-00049   private:
-00050     ne7ssh_session* session;
-00051 
-00052     enum kexMethods { DH_GROUP1_SHA1, DH_GROUP14_SHA1 };
-00053     uint32 kexMethod;
-00054 
-00055     enum hostkeyMethods { SSH_DSS, SSH_RSA };
-00056     uint32 hostkeyMethod;
-00057 
-00058     enum cryptoMethods { TDES_CBC, AES128_CBC, AES192_CBC, AES256_CBC, BLOWFISH_CBC, CAST128_CBC, TWOFISH_CBC };
-00059     uint32 c2sCryptoMethod;
-00060     uint32 s2cCryptoMethod;
-00061 
-00062     enum macMethods { HMAC_SHA1, HMAC_MD5, HMAC_NONE };
-00063     uint32 c2sMacMethod;
-00064     uint32 s2cMacMethod; 
-00065 
-00066     enum cmprsMethods { NONE, ZLIB };
-00067     uint32 c2sCmprsMethod;
-00068     uint32 s2cCmprsMethod; 
-00069 
-00070     bool inited;
-00071     Botan::SecureVector<Botan::byte> H;
-00072     Botan::SecureVector<Botan::byte> K;
-00073 
-00074     Botan::Pipe *encrypt;
-00075     Botan::Pipe *decrypt;
-00076     Botan::Pipe *compress;
-00077     Botan::Pipe *decompress;
-00078     Botan::HMAC *hmacOut, *hmacIn;
-00079 
-00080     Botan::DH_PrivateKey *privKexKey;
-00081 
-00082     uint32 encryptBlock;
-00083     uint32 decryptBlock;
-00084 
-00090     bool getDHGroup1Sha1Public (Botan::BigInt& publicKey);
-00091 
-00097     bool getDHGroup14Sha1Public (Botan::BigInt &publicKey);
-00098 
-00104     Botan::DSA_PublicKey* getDSAKey (Botan::SecureVector<Botan::byte>& hostKey);
-00105 
-00111     Botan::RSA_PublicKey* getRSAKey (Botan::SecureVector<Botan::byte> &hostKey);
-00112 
-00117     const char* getHashAlgo();
-00118 
-00124     const char* getCryptAlgo (uint32 crypto);
-00125 
-00131     const char* getHmacAlgo (uint32 method);
-00132 
-00139     uint32 getMacKeyLen (uint32 method);
-00140 
-00147     uint32 getMacDigestLen (uint32 method);
-00148 
-00157     bool compute_key (Botan::SecureVector<Botan::byte>& key, Botan::byte ID, uint32 nBytes);
-00158 
-00159 
-00160   public:
-00165     ne7ssh_crypt(ne7ssh_session* _session);
-00166 
-00170     ~ne7ssh_crypt();
-00171 
-00177     bool isInited () { return inited; }
-00178 
-00183     uint32 getEncryptBlock () { return encryptBlock; }
-00184 
-00189     uint32 getDecryptBlock () { return decryptBlock; }
-00190 
-00195     uint32 getMacOutLen () { return getMacDigestLen (c2sMacMethod); }
-00196 
-00201     uint32 getMacInLen () { return getMacDigestLen (s2cMacMethod); }
-00202 
-00210     bool agree (Botan::SecureVector<Botan::byte>& result, const char* local, Botan::SecureVector<Botan::byte>& remote);
-00211 
-00217     bool negotiatedKex (Botan::SecureVector<Botan::byte>& kexAlgo);
-00218 
-00224     bool negotiatedHostkey (Botan::SecureVector<Botan::byte>& hostKeyAlgo);
-00225 
-00231     bool negotiatedCryptoC2s (Botan::SecureVector<Botan::byte>& cryptoAlgo);
-00232 
-00238     bool negotiatedCryptoS2c (Botan::SecureVector<Botan::byte>& cryptoAlgo);
-00239 
-00245     bool negotiatedMacC2s (Botan::SecureVector<Botan::byte>& macAlgo);
-00246 
-00252     bool negotiatedMacS2c (Botan::SecureVector<Botan::byte>& macAlgo);
-00253 
-00259     bool negotiatedCmprsC2s (Botan::SecureVector<Botan::byte>& cmprsAlgo);
-00260 
-00266     bool negotiatedCmprsS2c (Botan::SecureVector<Botan::byte>& cmprsAlgo);
-00267 
-00273     bool getKexPublic (Botan::BigInt& publicKey);
-00274 
-00281     bool makeKexSecret (Botan::SecureVector<Botan::byte>& result, Botan::BigInt& f);
-00282 
-00289     bool computeH (Botan::SecureVector<Botan::byte>& result, Botan::SecureVector<Botan::byte>& val);
-00290 
-00297     bool verifySig (Botan::SecureVector<Botan::byte>& hostKey, Botan::SecureVector<Botan::byte>& sig);
-00298 
-00303     bool makeNewKeys ();
-00304 
-00314     bool encryptPacket (Botan::SecureVector<Botan::byte>& crypted, Botan::SecureVector<Botan::byte>& hmac, Botan::SecureVector<Botan::byte>& packet, uint32 seq);
-00315 
-00323     bool decryptPacket (Botan::SecureVector<Botan::byte>& decrypted, Botan::SecureVector<Botan::byte>& packet, uint32 len);
-00324 
-00331     void computeMac (Botan::SecureVector<Botan::byte>& hmac, Botan::SecureVector<Botan::byte>& packet, uint32 seq);
-00332 
-00337     void compressData (Botan::SecureVector<Botan::byte>& buffer);
-00338 
-00343     void decompressData (Botan::SecureVector<Botan::byte>& buffer);
-00344 
-00349     bool isCompressed () { if (decompress) return true; else return false; }
-00350 
-00355 };
-00356 
-00357 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html b/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html deleted file mode 100644 index b58281d98aa..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html +++ /dev/null @@ -1,42 +0,0 @@ - - -ne7ssh.kdevelop: projects/ne7ssh/ Directory Reference - - - - - -
-

ne7ssh Directory Reference

-

-

-
-
-

projects/ne7ssh/
- - -
- - - - - -

Directories

directory  src
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map deleted file mode 100644 index ba754eabf37..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html b/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html deleted file mode 100644 index a58bb3afbcf..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html +++ /dev/null @@ -1,42 +0,0 @@ - - -ne7ssh.kdevelop: projects/ Directory Reference - - - - - -
-

projects Directory Reference

-

-

-
-
-

projects/
- - -
- - - - - -

Directories

directory  ne7ssh
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map deleted file mode 100644 index c0ba7e87a72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html b/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html deleted file mode 100644 index 749b4ee316d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html +++ /dev/null @@ -1,94 +0,0 @@ - - -ne7ssh.kdevelop: projects/ne7ssh/src/ Directory Reference - - - - - -
-

src Directory Reference

-

-

-
-
-

projects/ne7ssh/src/
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Files

file  crypt.cpp
file  crypt.h [code]
file  ne7ssh.cpp
file  ne7ssh.h [code]
file  ne7ssh_channel.cpp
file  ne7ssh_channel.h [code]
file  ne7ssh_connection.cpp
file  ne7ssh_connection.h [code]
file  ne7ssh_error.cpp
file  ne7ssh_error.h [code]
file  ne7ssh_kex.cpp
file  ne7ssh_kex.h [code]
file  ne7ssh_keys.cpp
file  ne7ssh_keys.h [code]
file  ne7ssh_mutex.cpp
file  ne7ssh_mutex.h [code]
file  ne7ssh_session.cpp
file  ne7ssh_session.h [code]
file  ne7ssh_sftp.cpp
file  ne7ssh_sftp.h [code]
file  ne7ssh_sftp_packet.cpp
file  ne7ssh_sftp_packet.h [code]
file  ne7ssh_string.cpp
file  ne7ssh_string.h [code]
file  ne7ssh_transport.cpp
file  ne7ssh_transport.h [code]
file  ne7ssh_types.h [code]
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map deleted file mode 100644 index ed6c1032bca..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dirs.html b/src/libs/3rdparty/net7ssh/doc/html/dirs.html deleted file mode 100644 index df0a6dc0f96..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dirs.html +++ /dev/null @@ -1,34 +0,0 @@ - - -ne7ssh.kdevelop: Directory Hierarchy - - - - - -
-

Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically: -
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/doxygen.css b/src/libs/3rdparty/net7ssh/doc/html/doxygen.css deleted file mode 100644 index 3767dc957b0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/doxygen.css +++ /dev/null @@ -1,441 +0,0 @@ -body, table, div, p, dl { - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 12px; -} - -/* @group Heading Levels */ - -h1 { - text-align: center; - font-size: 150%; -} - -h2 { - font-size: 120%; -} - -h3 { - font-size: 100%; -} - -/* @end */ - -caption { - font-weight: bold; -} - -div.qindex, div.navtab{ - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #153788; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #1b77c5; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code { -} - -a.codeRef { -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - padding: 4px 6px; - margin: 4px 8px 4px 2px; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} - -td.indexkey { - background-color: #e8eef2; - font-weight: bold; - border: 1px solid #CCCCCC; - margin: 2px 0px 2px 0; - padding: 2px 10px; -} - -td.indexvalue { - background-color: #e8eef2; - border: 1px solid #CCCCCC; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #f0f0f0; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -/* @end */ - -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} - -th.dirtab { - background: #e8eef2; - font-weight: bold; -} - -hr { - height: 0; - border: none; - border-top: 1px solid #666; -} - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memTemplParams { - color: #606060; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; -} - -.memname { - white-space: nowrap; - font-weight: bold; -} - -.memproto, .memdoc { - border: 1px solid #84b0c7; -} - -.memproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; -} - -.memdoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0.5em; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -address { - font-style: normal; - color: #333; -} diff --git a/src/libs/3rdparty/net7ssh/doc/html/files.html b/src/libs/3rdparty/net7ssh/doc/html/files.html deleted file mode 100644 index 338df597d24..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/files.html +++ /dev/null @@ -1,46 +0,0 @@ - - -ne7ssh.kdevelop: File Index - - - - - -
-

File List

Here is a list of all documented files with brief descriptions: - - - - - - - - - - - - - - -
crypt.h [code]
ne7ssh.h [code]
ne7ssh_channel.h [code]
ne7ssh_connection.h [code]
ne7ssh_error.h [code]
ne7ssh_kex.h [code]
ne7ssh_keys.h [code]
ne7ssh_mutex.h [code]
ne7ssh_session.h [code]
ne7ssh_sftp.h [code]
ne7ssh_sftp_packet.h [code]
ne7ssh_string.h [code]
ne7ssh_transport.h [code]
ne7ssh_types.h [code]
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions.html b/src/libs/3rdparty/net7ssh/doc/html/functions.html deleted file mode 100644 index 2c0e0ae69f4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions.html +++ /dev/null @@ -1,97 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- a -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html deleted file mode 100644 index c49ba01c070..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html +++ /dev/null @@ -1,69 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- b -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html deleted file mode 100644 index b0beb9cf0d9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html +++ /dev/null @@ -1,107 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- c -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html deleted file mode 100644 index 46bd7dfd63a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- d -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html deleted file mode 100644 index 95871ef4e30..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- e -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html deleted file mode 100644 index 3d4ca3d7cbc..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html +++ /dev/null @@ -1,180 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- g -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html deleted file mode 100644 index bd0e22a478e..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- h -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html deleted file mode 100644 index 3b1959e33ee..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- i -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html deleted file mode 100644 index 0dc8af8a486..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- l -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html deleted file mode 100644 index f29e031dc16..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- m -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html deleted file mode 100644 index b6e426508c7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html +++ /dev/null @@ -1,113 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- n -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html deleted file mode 100644 index 5381ac7afc7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- o -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html deleted file mode 100644 index 17aa639c291..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html +++ /dev/null @@ -1,76 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- p -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html deleted file mode 100644 index 906a41136ef..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- r -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html deleted file mode 100644 index 402d9d48213..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html +++ /dev/null @@ -1,123 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- s -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html deleted file mode 100644 index 168a83a13c0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html +++ /dev/null @@ -1,70 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- u -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html deleted file mode 100644 index fa0714a7e62..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- v -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html deleted file mode 100644 index 5db1eed7af5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- w -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html deleted file mode 100644 index 40cd4ce5fd5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- ~ -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html b/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html deleted file mode 100644 index e8ea3b1da79..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html +++ /dev/null @@ -1,46 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Enumerations - - - - - -
-  -

-

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func.html deleted file mode 100644 index faa8c4818ff..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func.html +++ /dev/null @@ -1,97 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- a -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html deleted file mode 100644 index 9151f353652..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html +++ /dev/null @@ -1,69 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- b -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html deleted file mode 100644 index 0746f081a7b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html +++ /dev/null @@ -1,103 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- c -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html deleted file mode 100644 index 68c5bf05516..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- d -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html deleted file mode 100644 index 889de4d8ed6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html +++ /dev/null @@ -1,77 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- e -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html deleted file mode 100644 index ed7e15ae460..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html +++ /dev/null @@ -1,180 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- g -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html deleted file mode 100644 index 5d4474d3fb5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- h -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html deleted file mode 100644 index abaa6f5d958..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- i -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html deleted file mode 100644 index ecd17a0022c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- l -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html deleted file mode 100644 index 00c5331565c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- m -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html deleted file mode 100644 index f48e7975b6a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html +++ /dev/null @@ -1,113 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- n -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html deleted file mode 100644 index c6d4da4eef4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- o -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html deleted file mode 100644 index 5724154bc43..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html +++ /dev/null @@ -1,76 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- p -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html deleted file mode 100644 index 2cdf7c35fa0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- r -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html deleted file mode 100644 index 8e8e3571c78..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html +++ /dev/null @@ -1,123 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- s -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html deleted file mode 100644 index 0548b8639ba..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html +++ /dev/null @@ -1,70 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- u -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html deleted file mode 100644 index 69c4883da15..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- v -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html deleted file mode 100644 index 4cd1330ec9a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html +++ /dev/null @@ -1,78 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- w -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html deleted file mode 100644 index 6320d9440f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- ~ -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html b/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html deleted file mode 100644 index 6e33fd3f414..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html +++ /dev/null @@ -1,50 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Variables - - - - - -
-  -

-

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot b/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot deleted file mode 100644 index 9a09018a423..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot +++ /dev/null @@ -1,22 +0,0 @@ -digraph G -{ - edge [fontname="FreeSans",fontsize="10",labelfontname="FreeSans",labelfontsize="10"]; - node [fontname="FreeSans",fontsize="10",shape=record]; - Node9 [shape="box",label="Inherited",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",fillcolor="grey75",style="filled" fontcolor="black"]; - Node10 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node10 [shape="box",label="PublicBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classPublicBase.html"]; - Node11 -> Node10 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node11 [shape="box",label="Truncated",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="red",URL="$classTruncated.html"]; - Node13 -> Node9 [dir=back,color="darkgreen",fontsize="10",style="solid",fontname="FreeSans"]; - Node13 [shape="box",label="ProtectedBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classProtectedBase.html"]; - Node14 -> Node9 [dir=back,color="firebrick4",fontsize="10",style="solid",fontname="FreeSans"]; - Node14 [shape="box",label="PrivateBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classPrivateBase.html"]; - Node15 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node15 [shape="box",label="Undocumented",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="grey75"]; - Node16 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node16 [shape="box",label="Templ< int >",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classTempl.html"]; - Node17 -> Node16 [dir=back,color="orange",fontsize="10",style="dashed",label="< int >",fontname="FreeSans"]; - Node17 [shape="box",label="Templ< T >",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classTempl.html"]; - Node18 -> Node9 [dir=back,color="darkorchid3",fontsize="10",style="dashed",label="m_usedClass",fontname="FreeSans"]; - Node18 [shape="box",label="Used",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classUsed.html"]; -} diff --git a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html b/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html deleted file mode 100644 index d64d84e84f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html +++ /dev/null @@ -1,87 +0,0 @@ - - -ne7ssh.kdevelop: Graph Legend - - - - - -
-

Graph Legend

This page explains how to interpret the graphs that are generated by doxygen.

-Consider the following example:

/*! Invisible class because of truncation */
-class Invisible { };
-
-/*! Truncated class, inheritance relation is hidden */
-class Truncated : public Invisible { };
-
-/* Class not documented with doxygen comments */
-class Undocumented { };
-
-/*! Class that is inherited using public inheritance */
-class PublicBase : public Truncated { };
-
-/*! A template class */
-template<class T> class Templ { };
-
-/*! Class that is inherited using protected inheritance */
-class ProtectedBase { };
-
-/*! Class that is inherited using private inheritance */
-class PrivateBase { };
-
-/*! Class that is used by the Inherited class */
-class Used { };
-
-/*! Super class that inherits a number of other classes */
-class Inherited : public PublicBase,
-                  protected ProtectedBase,
-                  private PrivateBase,
-                  public Undocumented,
-                  public Templ<int>
-{
-  private:
-    Used *m_usedClass;
-};
-
This will result in the following graph:

-

-graph_legend.png -
-

-The boxes in the above graph have the following meaning:

    -
  • -A filled gray box represents the struct or class for which the graph is generated.
  • -
  • -A box with a black border denotes a documented struct or class.
  • -
  • -A box with a grey border denotes an undocumented struct or class.
  • -
  • -A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.
  • -
-The arrows have the following meaning:
    -
  • -A dark blue arrow is used to visualize a public inheritance relation between two classes.
  • -
  • -A dark green arrow is used for protected inheritance.
  • -
  • -A dark red arrow is used for private inheritance.
  • -
  • -A purple dashed arrow is used if a class is contained or used by another class. The arrow is labeled with the variable(s) through which the pointed class or struct is accessible.
  • -
  • -A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labeled with the template parameters of the instance.
  • -
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html b/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html deleted file mode 100644 index 4ec6552d01b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html +++ /dev/null @@ -1,58 +0,0 @@ - - -ne7ssh.kdevelop: Hierarchical Index - - - - - - -
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/index.html b/src/libs/3rdparty/net7ssh/doc/html/index.html deleted file mode 100644 index 82c22ca9f62..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - -ne7ssh.kdevelop: Main Page - - - - - -
-

ne7ssh.kdevelop Documentation

-

-

1.3.1

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map deleted file mode 100644 index 3009aad4f2f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 deleted file mode 100644 index 13b09c8fef9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 +++ /dev/null @@ -1 +0,0 @@ -32272a437d808ca54d1aa16d1fdcf2eb \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map deleted file mode 100644 index c42e0733bf4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 deleted file mode 100644 index 5624ec9074f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 +++ /dev/null @@ -1 +0,0 @@ -f86864cff4e18963b72fbace1c5228c2 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map deleted file mode 100644 index 10a671a8c85..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 deleted file mode 100644 index 069830d3364..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 +++ /dev/null @@ -1 +0,0 @@ -08221d327d3eba0b917aace18b9b8cc1 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map deleted file mode 100644 index 356017e409e..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 deleted file mode 100644 index 461f240a934..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 +++ /dev/null @@ -1 +0,0 @@ -198aa1e42d164855c29f7e3b8f0e32c8 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map deleted file mode 100644 index b7f1bc27b3f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 deleted file mode 100644 index 5630abcd40a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 +++ /dev/null @@ -1 +0,0 @@ -ff94628ec786c1149c0474d9992fbafa \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map deleted file mode 100644 index 9838396ca7a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 deleted file mode 100644 index a7b91b54653..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 +++ /dev/null @@ -1 +0,0 @@ -e205f807b675488e62401f919f733ac4 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map deleted file mode 100644 index 40a31429987..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 deleted file mode 100644 index 3be6621b6be..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 +++ /dev/null @@ -1 +0,0 @@ -4bcff168797e6c21ba1eede52dba50b9 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map deleted file mode 100644 index 6e989154fe4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 deleted file mode 100644 index 99eb483df07..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 +++ /dev/null @@ -1 +0,0 @@ -46e6503b52f860bd459c69e721707e2e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map deleted file mode 100644 index b8206e21457..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 deleted file mode 100644 index f3de628eb24..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 +++ /dev/null @@ -1 +0,0 @@ -d5b5d6ab3ef640c569f85650ea9f8480 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map deleted file mode 100644 index 3f55ba7def7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 deleted file mode 100644 index e8569efaf4f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 +++ /dev/null @@ -1 +0,0 @@ -7ee0313d1503b3cf75d48b435961182d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map deleted file mode 100644 index 78fc1253bae..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 deleted file mode 100644 index ddc4477d615..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 +++ /dev/null @@ -1 +0,0 @@ -78da7c9248f34e1119fb20cd3e56033d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map deleted file mode 100644 index deb643e1bb6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 deleted file mode 100644 index 92cc25bce0c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 +++ /dev/null @@ -1 +0,0 @@ -64416016196c678d33fadc16862bfd57 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map deleted file mode 100644 index e87f24acb08..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 deleted file mode 100644 index 4303f149612..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 +++ /dev/null @@ -1 +0,0 @@ -a2a52726162489889e63cafffb233f06 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map deleted file mode 100644 index 2dd4869225f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 deleted file mode 100644 index ee9cae3c5c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 +++ /dev/null @@ -1 +0,0 @@ -4d1c9d846e00a922cc47fd379b350562 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map deleted file mode 100644 index 26da6c643c8..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 deleted file mode 100644 index dc4a68efc75..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 +++ /dev/null @@ -1 +0,0 @@ -ed97562dd0a16449e3f78567ede9cb34 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map deleted file mode 100644 index b93da65e751..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 deleted file mode 100644 index 4bb114bf879..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 +++ /dev/null @@ -1 +0,0 @@ -1a000d5ea63c4b0adb98721e2737f886 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherits.html b/src/libs/3rdparty/net7ssh/doc/html/inherits.html deleted file mode 100644 index 25cacc052ef..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherits.html +++ /dev/null @@ -1,84 +0,0 @@ - - -ne7ssh.kdevelop: Graphical Class Hierarchy - - - - - -
-

Graphical Class Hierarchy

Go to the textual class hierarchy -

- - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-

-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html b/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html deleted file mode 100644 index 06ed3780a90..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html +++ /dev/null @@ -1,36 +0,0 @@ - - -ne7ssh.kdevelop: Botan Namespace Reference - - - - - -
-

Botan Namespace Reference

- -
-

Detailed Description

-definitions for Botan -

-

-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/namespaces.html b/src/libs/3rdparty/net7ssh/doc/html/namespaces.html deleted file mode 100644 index 38675124f64..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/namespaces.html +++ /dev/null @@ -1,33 +0,0 @@ - - -ne7ssh.kdevelop: Namespace Index - - - - - -
-

Namespace List

Here is a list of all documented namespaces with brief descriptions: - -
Botan
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html deleted file mode 100644 index c2d21f74683..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html +++ /dev/null @@ -1,277 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh.h Source File - - - - - -
-

ne7ssh.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_H
-00018 #define NE7SSH_H
-00019 
-00020 #include <botan/build.h>
-00021 
-00022 //#include <botan/zlib.h>
-00023 //#include "error.h"
-00024 
-00025 #if BOTAN_VERSION_MAJOR > 1
-00026 #   error Unsupported Botan Version
-00027 #endif
-00028 
-00029 #define BOTAN_PRE_15 (BOTAN_VERSION_MINOR < 5)
-00030 #define BOTAN_PRE_18 (BOTAN_VERSION_MINOR < 8)
-00031 
-00032 #if !BOTAN_PRE_18 && !BOTAN_PRE_15
-00033 # include <botan/auto_rng.h>
-00034 #endif
-00035 
-00036 #include <stdlib.h>
-00037 #include <string>
-00038 #include <fcntl.h>
-00039 #if !defined(WIN32) && !defined(__MINGW32__)
-00040 #   include <pthread.h>
-00041 #   include <sys/select.h>
-00042 #   include <unistd.h>
-00043 typedef pthread_t ne7ssh_thread_t;
-00044 #else
-00045 #include <windows.h>
-00046 typedef HANDLE ne7ssh_thread_t;
-00047 #endif
-00048 
-00049 #include "ne7ssh_types.h"
-00050 #include "ne7ssh_error.h"
-00051 #include "ne7ssh_mutex.h"
-00052 
-00053 #define SSH2_MSG_DISCONNECT 1
-00054 #define SSH2_MSG_IGNORE 2
-00055 
-00056 #define SSH2_MSG_KEXINIT  20
-00057 #define SSH2_MSG_NEWKEYS  21
-00058 
-00059 #define SSH2_MSG_KEXDH_INIT 30
-00060 #define SSH2_MSG_KEXDH_REPLY  31
-00061 
-00062 #define SSH2_MSG_SERVICE_REQUEST 5
-00063 #define SSH2_MSG_SERVICE_ACCEPT 6
-00064 
-00065 #define SSH2_MSG_USERAUTH_REQUEST 50
-00066 #define SSH2_MSG_USERAUTH_FAILURE 51
-00067 #define SSH2_MSG_USERAUTH_SUCCESS 52
-00068 #define SSH2_MSG_USERAUTH_BANNER 53
-00069 #define SSH2_MSG_USERAUTH_PK_OK 60
-00070 
-00071 #define SSH2_MSG_CHANNEL_OPEN                           90
-00072 #define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION              91
-00073 #define SSH2_MSG_CHANNEL_OPEN_FAILURE                   92
-00074 #define SSH2_MSG_CHANNEL_WINDOW_ADJUST                  93
-00075 #define SSH2_MSG_CHANNEL_DATA                           94
-00076 #define SSH2_MSG_CHANNEL_EXTENDED_DATA                  95
-00077 #define SSH2_MSG_CHANNEL_EOF                            96
-00078 #define SSH2_MSG_CHANNEL_CLOSE                          97
-00079 #define SSH2_MSG_CHANNEL_REQUEST                        98
-00080 #define SSH2_MSG_CHANNEL_SUCCESS                        99
-00081 #define SSH2_MSG_CHANNEL_FAILURE                        100
-00082 
-00083 class ne7ssh_connection;
-00084 
-00086 typedef struct {
-00088   ne7ssh_connection **conns;
-00090   uint32 count;
-00091 } connStruct;
-00092 
-00094 namespace Botan
-00095 {
-00096     class LibraryInitializer;
-00097 }
-00098 
-00099 class Ne7SftpSubsystem;
-00100 
-00104 class SSH_EXPORT ne7ssh
-00105 {
-00106   private:
-00107 
-00108     static Ne7ssh_Mutex mut;
-00109     Botan::LibraryInitializer *init;
-00110     ne7ssh_connection **connections;
-00111     uint32 conCount;
-00112     static bool running;
-00113     static bool selectActive;
-00114     connStruct allConns;
-00115 
-00116 
-00122     static void *selectThread (void*);
-00123 
-00128     uint32 getChannelNo ();
-00129     ne7ssh_thread_t select_thread;
-00130     bool connected;
-00131 
-00136     static bool lock ();
-00137 
-00142     static bool unlock ();
-00143     static Ne7sshError* errs;
-00144 
-00145   public:
-00146 #if !BOTAN_PRE_18 && !BOTAN_PRE_15
-00147     static Botan::AutoSeeded_RNG *rng;
-00148 #endif
-00149     static const char* SSH_VERSION;
-00150     static const char* KEX_ALGORITHMS;
-00151     static const char* HOSTKEY_ALGORITHMS;
-00152     static const char* MAC_ALGORITHMS;
-00153     static const char* CIPHER_ALGORITHMS;
-00154     static const char* COMPRESSION_ALGORITHMS;
-00155     static char* PREFERED_CIPHER;
-00156     static char* PREFERED_MAC;
-00157 
-00161     ne7ssh();
-00165     ~ne7ssh();
-00166 
-00177     int connectWithPassword (const char* host, const int port, const char* username, const char* password, bool shell = true, const int timeout = 0);
-00178 
-00191     int connectWithKey (const char* host, const int port, const char* username, const char* privKeyFileName, bool shell = true, const int timeout = 0);
-00192 
-00198 //    ne7ssh_connection** getConnections () { return connections; }
-00199 
-00200     connStruct* getConnetions () { return &allConns; }
-00201 
-00207 //    uint32 getConCount () { return conCount; }
-00208 
-00215     bool send (const char* data, int channel);
-00216 
-00224     bool sendCmd (const char* cmd, int channel, int timeout);
-00225 
-00231     bool close (int channel);
-00232 
-00238     void setCount (uint32 count) { conCount = count; }
-00239 
-00245     const char* read (int channel, bool do_lock=true);
-00246 
-00252     void* readBinary (int channel);
-00253 
-00259     int getReceivedSize (int channel, bool do_lock=true);
-00260 
-00268     bool waitFor (int channel, const char* str, uint32 timeout=0);
-00269 
-00276     void setOptions (const char* prefCipher, const char* prefHmac);
-00277 
-00278 
-00288     bool generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 0);
-00289 
-00296     bool initSftp (Ne7SftpSubsystem& _sftp, int channel);
-00297 
-00302     static Ne7sshError* errors();
-00303 
-00304     static bool isSelectActive() { return selectActive; }
-00305     static void selectDead() { selectActive = false; }
-00306 };
-00307 
-00308 class Ne7sshSftp;
-00309 
-00313 class SSH_EXPORT Ne7SftpSubsystem
-00314 {
-00315   private:
-00316     bool inited;
-00317     Ne7sshSftp* sftp;
-00318 
-00323 bool errorNotInited ();
-00324 
-00325   public:
-00327     typedef struct
-00328     {
-00329       uint64_t  size;
-00330       uint32_t  owner;
-00331       uint32_t  group;
-00332       uint32_t  permissions;
-00333       uint32_t  atime;
-00334       uint32_t  mtime;
-00335     } fileAttrs;
-00336 
-00338     enum writeMode { READ, OVERWRITE, APPEND };
-00339 
-00343     Ne7SftpSubsystem ();
-00344 
-00349     Ne7SftpSubsystem (class Ne7sshSftp* _sftp);
-00350 
-00354     ~Ne7SftpSubsystem();
-00355 
-00361     bool setTimeout (uint32 _timeout);
-00362 
-00369     uint32 openFile (const char* filename, uint8 mode);
-00370 
-00376     uint32 openDir (const char* dirname);
-00377 
-00384     bool readFile (uint32 fileID, uint64 offset = 0);
-00385 
-00394     bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0);
-00395 
-00401     bool closeFile (uint32 fileID);
-00402 
-00410     bool getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks = true);
-00411 
-00412 
-00419     bool get (const char* remoteFile, FILE* localFile);
-00420 
-00427     bool put (FILE* localFile, const char* remoteFile);
-00428 
-00434     bool rm (const char* remoteFile);
-00435 
-00442     bool mv (const char* oldFile, const char* newFile);
-00443 
-00449     bool mkdir (const char* remoteDir);
-00450 
-00456     bool rmdir (const char* remoteDir);
-00457 
-00464     const char* ls (const char* remoteDir, bool longNames=false);
-00465 
-00471     bool cd (const char* remoteDir);
-00472 
-00479     bool chmod (const char* remoteFile, const char* mode);
-00480 
-00488     bool chown (const char* remoteFile, uint32_t uid, uint32_t gid = 0);
-00489 
-00495     bool isFile (const char* remoteFile);
-00496 
-00502     bool isDir (const char* remoteFile);
-00503 };
-00504 
-00505 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html deleted file mode 100644 index d10fd791297..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html +++ /dev/null @@ -1,133 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_channel.h Source File - - - - - -
-

ne7ssh_channel.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_CHANNEL_H
-00018 #define NE7SSH_CHANNEL_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_string.h"
-00022 
-00023 class ne7ssh_session;
-00024 
-00028 class ne7ssh_channel
-00029 {
-00030   private:
-00031     bool eof, closed;
-00032     bool cmdComplete;
-00033     bool shellSpawned;
-00034 
-00035 //    static uint32 channelCount;
-00036     ne7ssh_session *session;
-00037     ne7ssh_string inBuffer;
-00038     ne7ssh_string outBuffer;
-00039     ne7ssh_string delayedBuffer;
-00040 
-00046     bool handleChannelConfirm ();
-00047 
-00054     bool adjustWindow (Botan::SecureVector<Botan::byte>& packet);
-00055 
-00062     virtual bool handleData (Botan::SecureVector<Botan::byte>& packet);
-00063 
-00069     bool handleExtendedData (Botan::SecureVector<Botan::byte>& packet);
-00070 
-00076     bool handleEof (Botan::SecureVector<Botan::byte>& packet);
-00077 
-00083     void handleClose (Botan::SecureVector<Botan::byte>& packet);
-00084 
-00090     void handleRequest (Botan::SecureVector<Botan::byte>& packet);
-00091 
-00097     bool handleDisconnect (Botan::SecureVector<Botan::byte>& packet);
-00098 
-00099   protected:
-00100     uint32 windowRecv, windowSend;
-00101 
-00102     bool channelOpened;
-00103 
-00107     void sendAdjustWindow ();
-00108 
-00109   public:
-00114     ne7ssh_channel(ne7ssh_session* _session);
-00115 
-00119     virtual ~ne7ssh_channel();
-00120 
-00126     uint32 open (uint32 channelID);
-00127 
-00131     void getShell ();
-00132 
-00138     bool execCmd (const char* cmd);
-00139 
-00143     void receive ();
-00144 
-00150     bool handleReceived (Botan::SecureVector<Botan::byte>& _packet);
-00151 
-00156     void write (Botan::SecureVector<Botan::byte>& data);
-00157 
-00161     void sendAll ();
-00162 
-00167     bool data2Send () { if (outBuffer.length() || delayedBuffer.length()) return true; else return false; }
-00168 
-00173     bool isOpen () { return channelOpened; } 
-00174 
-00179     bool sendClose ();
-00180 
-00185     bool sendEof ();
-00186 
-00191     Botan::SecureVector<Botan::byte>& getReceived () { return inBuffer.value(); }
-00192 
-00197     bool getCmdComplete () { return cmdComplete; }
-00198 
-00203     bool isRemoteShell () { return shellSpawned; }
-00204 
-00210     bool adjustRecvWindow (int bufferSize);
-00211 
-00216     uint32 getRecvWindow () { return windowRecv; }
-00217 
-00222     uint32 getSendWindow () { return windowSend; }
-00223 };
-00224 
-00225 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html deleted file mode 100644 index 09a66035769..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html +++ /dev/null @@ -1,135 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_connection.h Source File - - - - - -
-

ne7ssh_connection.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_CONNECTION_H
-00018 #define NE7SSH_CONNECTION_H
-00019 
-00020 #include "ne7ssh_transport.h"
-00021 #include "ne7ssh_session.h"
-00022 #include "ne7ssh_channel.h"
-00023 #include "ne7ssh_keys.h"
-00024 #include "crypt.h"
-00025 #include "ne7ssh_types.h"
-00026 #include "ne7ssh_string.h"
-00027 #include "ne7ssh_sftp.h"
-00028 
-00029 
-00033 class ne7ssh_connection
-00034 {
-00035   private:
-00036     SOCKET sock;
-00037     int thisChannel;
-00038     ne7ssh_crypt *crypto;
-00039     ne7ssh_transport *transport;
-00040     ne7ssh_session *session;
-00041     ne7ssh_channel *channel;
-00042     Ne7sshSftp* sftp;
-00043 
-00044     Ne7ssh_Mutex mut;
-00045     bool connected;
-00046     bool cmdRunning;
-00047     bool cmdClosed;
-00048 
-00049 
-00054     bool checkRemoteVersion ();
-00055 
-00060     bool sendLocalVersion ();
-00061 
-00067     bool requestService (const char* service);
-00068 
-00075     bool authWithPassword (const char* username, const char* password);
-00076 
-00085     bool authWithKey (const char* username, const char* privKeyFileName);
-00086 
-00087   public:
-00091     ne7ssh_connection();
-00092 
-00096     ~ne7ssh_connection();
-00097 
-00109     int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell = true, int timeout = 0);
-00110 
-00122     int connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell = true, int timeout = 0);
-00123 
-00128     SOCKET getSocket () { return sock; }
-00129 
-00133     void handleData ();
-00134 
-00139     void sendData (const char* data);
-00140 
-00144     void setChannelNo (int channelID) { thisChannel = channelID; }
-00145 
-00150     int getChannelNo () { return thisChannel; }
-00151 
-00156     bool data2Send () { return channel->data2Send(); }
-00157 
-00162     void sendData () { channel->sendAll (); }
-00163 
-00169     bool sendCmd (const char* cmd);
-00170 
-00176     bool sendClose ();
-00177 
-00182     bool isOpen () { return channel->isOpen(); }
-00183 
-00188     bool isConnected () { return connected; }
-00189 
-00194     Botan::SecureVector<Botan::byte>& getReceived () { return channel->getReceived(); }
-00195                 
-00200     bool getCmdComplete() { return channel->getCmdComplete(); }
-00201 
-00206     bool isCmdClosed() { return cmdClosed; }
-00207 
-00212     bool isRemoteShell () { return channel->isRemoteShell(); }
-00213 
-00218     bool isCmdRunning () { return cmdRunning; }
-00219 
-00224     Ne7sshSftp* startSftp ();
-00225 
-00230     bool isSftpActive ();
-00231 };
-00232 
-00233 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html deleted file mode 100644 index bb8ab8f01dd..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html +++ /dev/null @@ -1,96 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_error.h Source File - - - - - -
-

ne7ssh_error.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                           *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   This program may be distributed under the terms of the Q Public       *
-00007  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00008  *   file LICENSE.QPL included in the packaging of this file.              *
-00009  *                                                                         *
-00010  *   This program is distributed in the hope that it will be useful,       *
-00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00013  ***************************************************************************/
-00014 
-00015 #ifndef NE7SSH_ERROR_H
-00016 #define NE7SSH_ERROR_H
-00017 
-00018 #include <stdlib.h>
-00019 #if !defined(WIN32) && !defined(__MINGW32__)
-00020 #   include <sys/select.h>
-00021 #endif
-00022 
-00023 #define MAX_ERROR_LEN 500
-00024 
-00025 #include "ne7ssh_types.h"
-00026 #include "ne7ssh_mutex.h"
-00027 
-00031 class SSH_EXPORT Ne7sshError
-00032 {
-00033   private:
-00034     uint16 memberCount;
-00035     char popedErr[MAX_ERROR_LEN + 1];
-00036     static Ne7ssh_Mutex mut;
-00037 
-00041     struct Error
-00042     {
-00043       int32 channel;
-00044       char* errorStr;
-00045     } **ErrorBuffer;
-00046 
-00052     bool deleteRecord (uint16 recID);
-00053 
-00058     static bool lock ();
-00059 
-00064     static bool unlock ();
-00065 
-00066   public:
-00070     Ne7sshError();
-00071 
-00075     ~Ne7sshError();
-00076 
-00083     bool push (int32 channel, const char* format, ...);
-00084 
-00089     const char* pop ();
-00090 
-00096     const char* pop (int32 channel);
-00097 
-00102     bool deleteCoreMsgs ();
-00103 
-00109     bool deleteChannel (int32 channel);
-00110 
-00111 };
-00112 
-00113 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html deleted file mode 100644 index 87e22f488a2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html +++ /dev/null @@ -1,91 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_kex.h Source File - - - - - -
-

ne7ssh_kex.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_KEX_H
-00018 #define NE7SSH_KEX_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_session.h"
-00022 #include "ne7ssh_string.h"
-00023 #include "ne7ssh_transport.h"
-00024 #include "crypt.h"
-00025 
-00029 class ne7ssh_kex
-00030 {
-00031   private:
-00032     ne7ssh_session* session;
-00033     ne7ssh_string localKex;
-00034     ne7ssh_string remotKex;
-00035     ne7ssh_string hostKey;
-00036     ne7ssh_string e;
-00037     ne7ssh_string f;
-00038     ne7ssh_string k;
-00039     Botan::SecureVector<Botan::byte> Ciphers, Hmacs;
-00040 
-00044     void constructLocalKex();
-00045 
-00050     void makeH (Botan::SecureVector<Botan::byte>& hVector);
-00051 
-00052   public:
-00057     ne7ssh_kex(ne7ssh_session* _session);
-00058 
-00062     ~ne7ssh_kex();
-00063 
-00068     bool sendInit();
-00069 
-00075     bool handleInit();
-00076 
-00081     bool sendKexDHInit();
-00082 
-00088     bool handleKexDHReply();
-00089 
-00095     bool sendKexNewKeys();
-00096 
-00097 };
-00098 
-00099 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html deleted file mode 100644 index 3f9460076fc..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html +++ /dev/null @@ -1,104 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_keys.h Source File - - - - - -
-

ne7ssh_keys.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_KEYS_H
-00018 #define NE7SSH_KEYS_H
-00019 #include <botan/pubkey.h>
-00020 #include <botan/pem.h>
-00021 #include <botan/dsa.h>
-00022 #include <botan/rsa.h>
-00023 #include <botan/numthry.h>
-00024 #include <botan/der_enc.h>
-00025 #include <botan/ber_dec.h>
-00026 
-00027 #include "ne7ssh_types.h"
-00028 #include "ne7ssh_string.h"
-00029 
-00030 #define MAX_KEYSIZE 8192
-00031 
-00032 
-00036 class ne7ssh_keys
-00037 {
-00038   private:
-00039     Botan::DSA_PrivateKey *dsaPrivateKey;
-00040     Botan::RSA_PrivateKey *rsaPrivateKey;
-00041     ne7ssh_string publicKeyBlob;
-00042     Botan::SecureVector<Botan::byte> signature;
-00043 
-00044     uint8 keyAlgo;
-00045 
-00052     bool getDSAKeys (char* buffer, uint32 size);
-00053 
-00060     bool getRSAKeys (char* buffer, uint32 size);
-00061 
-00062   public:
-00063     enum keyAlgos { DSA, RSA };
-00064 
-00068     ne7ssh_keys();
-00069 
-00074     ~ne7ssh_keys();
-00075 
-00084     bool generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048);
-00085 
-00094     bool generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048);
-00095 
-00102     bool getKeyPairFromFile (const char* privKeyFileName);
-00103 
-00111     Botan::SecureVector<Botan::byte>& generateSignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00112 
-00119     Botan::SecureVector<Botan::byte> generateDSASignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00120 
-00127     Botan::SecureVector<Botan::byte> generateRSASignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00128 
-00133     Botan::SecureVector<Botan::byte>& getPublicKeyBlob ();
-00134 
-00139     uint8 getKeyAlgo () { return keyAlgo; }
-00140 
-00141 };
-00142 
-00143 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html deleted file mode 100644 index 4e079b7e3c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html +++ /dev/null @@ -1,77 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_mutex.h Source File - - - - - -
-

ne7ssh_mutex.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2006 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 
-00018 #ifndef NE7SSH_MUTEX_H
-00019 #define NE7SSH_MUTEX_H
-00020 
-00021 #if defined(WIN32) || defined(__MINGW32__)
-00022 #   include <windows.h>
-00023 #else
-00024 #   include <pthread.h>
-00025 #endif
-00026 
-00027 class Ne7ssh_Mutex
-00028 {
-00029 public:
-00030     Ne7ssh_Mutex();
-00031 
-00032     int lock();
-00033 
-00034     int unlock();
-00035 
-00036     ~Ne7ssh_Mutex();
-00037 private:
-00038 #if defined(WIN32) || defined(__MINGW32__)
-00039     CRITICAL_SECTION mutint;
-00040 #else
-00041     pthread_mutex_t mutint;
-00042 #endif
-00043 };
-00044 
-00045 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html deleted file mode 100644 index a1472bd16c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html +++ /dev/null @@ -1,106 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_session.h Source File - - - - - -
-

ne7ssh_session.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_SESSION_H
-00018 #define NE7SSH_SESSION_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_transport.h"
-00022 #include "crypt.h"
-00023 
-00027 class ne7ssh_session
-00028 {
-00029   private:
-00030     Botan::SecureVector<Botan::byte> localVersion;
-00031     Botan::SecureVector<Botan::byte> remoteVersion;
-00032     Botan::SecureVector<Botan::byte> sessionID;
-00033     uint32 sendChannel;
-00034     uint32 receiveChannel;
-00035     uint32 maxPacket;
-00036     int32 channelID;
-00037 
-00038   public:
-00039     ne7ssh_transport *transport;
-00040     ne7ssh_crypt *crypto;
-00041 
-00045     ne7ssh_session();
-00046 
-00050     ~ne7ssh_session();
-00051 
-00056     void setLocalVersion (Botan::SecureVector<Botan::byte>& version) { localVersion = version; }
-00057 
-00062     Botan::SecureVector<Botan::byte> &getLocalVersion () { return localVersion; }
-00063 
-00068     void setRemoteVersion (Botan::SecureVector<Botan::byte>& version) { remoteVersion = version; }
-00069 
-00074     Botan::SecureVector<Botan::byte> &getRemoteVersion () { return remoteVersion; }    
-00075 
-00080     void setSessionID (Botan::SecureVector<Botan::byte>& session) { sessionID = session; }
-00081 
-00086     Botan::SecureVector<Botan::byte> &getSessionID () { return sessionID; }
-00087 
-00092     void setSendChannel (uint32 channel) { sendChannel = channel; }
-00093 
-00098     uint32 getSendChannel () const { return sendChannel; }
-00099 
-00104     void setReceiveChannel (uint32 channel) { receiveChannel = channel; }
-00105 
-00110     uint32 getReceiveChannel () { return receiveChannel; }
-00111 
-00116     void setMaxPacket (uint32 size) { maxPacket = size; }
-00117 
-00122     uint32 getMaxPacket () { return maxPacket; }
-00123 
-00128     void setSshChannel (int32 channel) { channelID = channel; }
-00129 
-00134     int32 getSshChannel () { return channelID; }
-00135 
-00136 
-00137 };
-00138 
-00139 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html deleted file mode 100644 index b681100ecbe..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html +++ /dev/null @@ -1,251 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_sftp.h Source File - - - - - -
-

ne7ssh_sftp.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 
-00018 #ifndef NE7SSHSFTP_H
-00019 #define NE7SSHSFTP_H
-00020 
-00021 #include "ne7ssh_channel.h"
-00022 #include "ne7ssh.h"
-00023 
-00024 #ifdef WIN32
-00025 // 777 = 0x1ff
-00026 #ifndef __MINGW32__
-00027 #define S_IRUSR 0x100
-00028 #endif
-00029 #define S_IRGRP 0x020
-00030 #define S_IROTH 0x004
-00031 #ifndef __MINGW32__
-00032 #define S_IWUSR 0x080
-00033 #endif
-00034 #define S_IWGRP 0x010
-00035 #define S_IWOTH 0x002
-00036 #ifndef __MINGW32__
-00037 #define S_IXUSR 0x040
-00038 #endif
-00039 #define S_IXGRP 0x008
-00040 #define S_IXOTH 0x001
-00041 #define S_ISUID 0x800
-00042 #define S_ISGID 0x400
-00043 #define S_ISVTX 0x200
-00044 #ifndef __MINGW32__
-00045 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-00046 #endif
-00047 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-00048 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-00049 #endif
-00050 
-00051 #define SSH2_FXP_INIT                1
-00052 #define SSH2_FXP_VERSION             2
-00053 #define SSH2_FXP_OPEN                3
-00054 #define SSH2_FXP_CLOSE               4
-00055 #define SSH2_FXP_READ                5
-00056 #define SSH2_FXP_WRITE               6
-00057 #define SSH2_FXP_LSTAT               7
-00058 #define SSH2_FXP_FSTAT               8
-00059 #define SSH2_FXP_SETSTAT             9
-00060 #define SSH2_FXP_FSETSTAT           10
-00061 #define SSH2_FXP_OPENDIR            11
-00062 #define SSH2_FXP_READDIR            12
-00063 #define SSH2_FXP_REMOVE             13
-00064 #define SSH2_FXP_MKDIR              14
-00065 #define SSH2_FXP_RMDIR              15
-00066 #define SSH2_FXP_REALPATH           16
-00067 #define SSH2_FXP_STAT               17
-00068 #define SSH2_FXP_RENAME             18
-00069 #define SSH2_FXP_READLINK           19
-00070 #define SSH2_FXP_LINK               21
-00071 #define SSH2_FXP_BLOCK              22
-00072 #define SSH2_FXP_UNBLOCK            23
-00073 
-00074 #define SSH2_FXP_STATUS            101
-00075 #define SSH2_FXP_HANDLE            102
-00076 #define SSH2_FXP_DATA              103
-00077 #define SSH2_FXP_NAME              104
-00078 #define SSH2_FXP_ATTRS             105
-00079 
-00080 #define SSH2_FXP_EXTENDED          200
-00081 #define SSH2_FXP_EXTENDED_REPLY    201
-00082 
-00083 #define SFTP_VERSION 3
-00084 #define SFTP_MAX_SEQUENCE 4294967295U
-00085 #define SFTP_MAX_PACKET_SIZE (32 * 1024)
-00086 #define SFTP_MAX_MSG_SIZE (256 * 1024)
-00087 
-00088 #define SSH2_FXF_READ           0x00000001
-00089 #define SSH2_FXF_WRITE          0x00000002
-00090 #define SSH2_FXF_APPEND         0x00000004
-00091 #define SSH2_FXF_CREAT          0x00000008
-00092 #define SSH2_FXF_TRUNC          0x00000010
-00093 #define SSH2_FXF_EXCL           0x00000020
-00094 
-00095 #define SSH2_FILEXFER_ATTR_SIZE         0x00000001
-00096 #define SSH2_FILEXFER_ATTR_UIDGID       0x00000002
-00097 #define SSH2_FILEXFER_ATTR_ACMODTIME    0x00000008
-00098 #define SSH2_FILEXFER_ATTR_PERMISSIONS  0x00000004
-00099 
-00100 class ne7ssh_session;
-00101 class ne7ssh_transport;
-00102 
-00106 class Ne7sshSftp : public ne7ssh_channel
-00107 {
-00108   private:
-00109     ne7ssh_session* session;
-00110     uint32 timeout;
-00111     uint32 seq;
-00112     uint8 sftpCmd;
-00113     ne7ssh_string commBuffer;
-00114     Botan::SecureVector<Botan::byte> fileBuffer;
-00115     enum writeMode { READ, OVERWRITE, APPEND };
-00116     uint8 lastError;
-00117     char* currentPath;
-00118 
-00122     typedef struct
-00123     {
-00124       uint32 flags;
-00125       uint64 size;
-00126       uint32 owner;
-00127       uint32 group;
-00128       uint32 permissions;
-00129       uint32 atime;
-00130       uint32 mtime;
-00131     } sftpFileAttrs;
-00132 
-00133     sftpFileAttrs attrs;
-00134 
-00138     typedef struct 
-00139     {
-00140       uint32 fileID;
-00141       uint16 handleLen;
-00142       char handle[256];
-00143     } sftpFile;
-00144     sftpFile **sftpFiles;
-00145     uint16 sftpFilesCount;
-00146 
-00152     bool handleData (Botan::SecureVector<Botan::byte>& packet);
-00153 
-00159     bool handleVersion (Botan::SecureVector<Botan::byte>& packet);
-00160 
-00166     bool handleStatus (Botan::SecureVector<Botan::byte>& packet);
-00167 
-00173     bool addOpenHandle (Botan::SecureVector<Botan::byte>& packet);
-00174 
-00180     bool handleSftpData (Botan::SecureVector<Botan::byte>& packet);
-00181 
-00187     bool handleNames (Botan::SecureVector<Botan::byte>& packet);
-00188 
-00194     sftpFile* getFileHandle (uint32 fileID);
-00195 
-00202     bool receiveUntil (short _cmd, uint32 timeSec = 0);
-00203 
-00210     bool receiveWhile (short _cmd, uint32 timeSec = 0);
-00211 
-00217     bool processAttrs (Botan::SecureVector<Botan::byte>& packet);
-00218 
-00225     bool getFileStats (const char* remoteFile, bool followSymLinks = true);
-00226 
-00234     bool getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector<Botan::byte>& remoteFile,  bool followSymLinks = true);
-00235 
-00241     bool getFStat (uint32 fileID);
-00242 
-00248     uint64 getFileSize (uint32 fileID);
-00249 
-00254     bool receiveWindowAdjust ();
-00255 
-00261     ne7ssh_string getFullPath (const char* filename);
-00262 
-00269     bool isType (const char* remoteFile, uint32 type);
-00270 
-00271   public:
-00277     Ne7sshSftp(ne7ssh_session* _session, ne7ssh_channel* _channel);
-00278 
-00282     ~Ne7sshSftp();
-00283 
-00288     bool init();
-00289 
-00294     void setTimeout (uint32 _timeout) { timeout = _timeout; }
-00295 
-00302     uint32 openFile (const char* filename, uint8 shortMode);
-00303 
-00309     uint32 openDir (const char* dirname);
-00310 
-00317     bool readFile (uint32 fileID, uint64 offset = 0);
-00318 
-00327     bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0);
-00328 
-00334     bool closeFile (uint32 fileID);
-00335 
-00343     bool getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile,  bool followSymLinks = true);
-00344 
-00350     bool isFile (const char* remoteFile);
-00351 
-00357     bool isDir (const char* remoteFile);
-00358 
-00359 
-00366     bool get (const char* remoteFile, FILE* localFile);
-00367 
-00374     bool put (FILE* localFile, const char* remoteFile);
-00375 
-00381     bool rm (const char* remoteFile);
-00382 
-00389     bool mv (const char* oldFile, const char* newFile);
-00390 
-00396     bool mkdir (const char* remoteDir);
-00397 
-00403     bool rmdir (const char* remoteDir);
-00404 
-00411     const char* ls (const char* remoteDir, bool longNames=false);
-00412 
-00418     bool cd (const char* remoteDir);
-00419 
-00426     bool chmod (const char* remoteFile, const char* mode);
-00427 
-00435     bool chown (const char* remoteFile, uint32 uid, uint32 gid = 0);
-00436 };
-00437 
-00438 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html deleted file mode 100644 index 179fd9bbcd1..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_sftp_packet.h Source File - - - - - -
-

ne7ssh_sftp_packet.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSHSFTPPACKET_H
-00018 #define NE7SSHSFTPPACKET_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_string.h"
-00022 
-00026 class Ne7sshSftpPacket : public ne7ssh_string
-00027 {
-00028   private:
-00029     int channel;
-00030 
-00031   public:
-00036     Ne7sshSftpPacket();
-00041     Ne7sshSftpPacket(int channel);
-00042 
-00048     Ne7sshSftpPacket(Botan::SecureVector<Botan::byte>& var, uint32 position);
-00049     
-00053     ~Ne7sshSftpPacket();
-00054 
-00059     Botan::SecureVector<Botan::byte> &value ();
-00060 
-00066     Botan::SecureVector<Botan::byte> valueFragment (uint32 len = 0);
-00067 
-00072     void addInt64 (const uint64 var);
-00073 
-00078     uint64 getInt64 ();
-00079 
-00084     bool isChannelSet ();
-00085 
-00086 };
-00087 
-00088 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html deleted file mode 100644 index 8139ed96380..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html +++ /dev/null @@ -1,116 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_string.h Source File - - - - - -
-

ne7ssh_string.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_STRING_H
-00018 #define NE7SSH_STRING_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include <botan/bigint.h>
-00022  
-00026 class ne7ssh_string
-00027 {
-00028 private:
-00029   Botan::byte **positions;
-00030   uint32 parts;
-00031   uint32 currentPart;
-00032 
-00033 protected:
-00034   Botan::SecureVector<Botan::byte> buffer;
-00035 
-00036 public:
-00041     ne7ssh_string();
-00042 
-00049     ne7ssh_string(Botan::SecureVector<Botan::byte>& var, uint32 position);
-00050 
-00056     ne7ssh_string(const char* var, uint32 position);
-00057 
-00061     virtual ~ne7ssh_string();
-00062 
-00066     void clear() { buffer.destroy(); }
-00067 
-00074     void addString (const char* str);
-00075 
-00081     bool addFile (const char* filename);
-00082 
-00088     void addBytes (const Botan::byte* buff, uint32 len);
-00089 
-00094     void addVector (Botan::SecureVector<Botan::byte>& secvec);
-00095 
-00102     void addVectorField (const Botan::SecureVector<Botan::byte>& vector);
-00103 
-00108     void addChar (const char ch);
-00109 
-00115     void addInt (const uint32 var);
-00116 
-00123     void addBigInt (const Botan::BigInt& bn);
-00124 
-00129     virtual Botan::SecureVector<Botan::byte> &value () { return buffer; }
-00130 
-00135     uint32 length () { return buffer.size(); }
-00136 
-00142     bool getString (Botan::SecureVector<Botan::byte>& result);
-00143 
-00149     bool getBigInt (Botan::BigInt& result);
-00150 
-00155     uint32 getInt ();
-00156 
-00161     Botan::byte getByte ();
-00162 
-00167     void split (const char token);
-00168 
-00172     void resetParts () { currentPart = 0; }
-00173 
-00178     char* nextPart ();
-00179 
-00184     void chop (uint32 nBytes);
-00185 
-00192     static void bn2vector (Botan::SecureVector<Botan::byte>& result, const Botan::BigInt& bi);
-00193 
-00194 };
-00195 
-00196 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html deleted file mode 100644 index 130df3e5e84..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html +++ /dev/null @@ -1,104 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_transport.h Source File - - - - - -
-

ne7ssh_transport.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_TRANSPORT_H
-00018 #define NE7SSH_TRANSPORT_H
-00019 
-00020 #include "crypt.h"
-00021 #include "ne7ssh_types.h"
-00022 #include "ne7ssh_string.h"
-00023 
-00024 #if defined(WIN32) || defined(__MINGW32__)
-00025 #   include <winsock.h>
-00026 #endif
-00027 #include <sys/types.h>
-00028 
-00029 //#define MAX_PACKET_LEN 35000
-00030 #define MAX_PACKET_LEN 34816
-00031 #define MAX_SEQUENCE 4294967295U
-00032 
-00033 #if !defined(WIN32) && !defined(__MINGW32__)
-00034 #  define SOCKET int
-00035 #endif
-00036 
-00037 class ne7ssh_session;
-00038 
-00042 class ne7ssh_transport
-00043 {
-00044   private:
-00045     uint32 seq, rSeq;
-00046     const ne7ssh_session* session;
-00047     SOCKET sock;
-00048     Botan::SecureVector<Botan::byte> in;
-00049     Botan::SecureVector<Botan::byte> inBuffer;
-00050 
-00057     bool NoBlock (SOCKET socket, bool on);
-00058 
-00066     bool wait (SOCKET socket, int rw, int timeout = -1);
-00067 
-00068   public:
-00074     ne7ssh_transport(ne7ssh_session* _session);
-00075 
-00079     ~ne7ssh_transport();
-00080 
-00088     SOCKET establish (const char *host, uint32 port, int timeout = 0);
-00089 
-00096     bool receive (Botan::SecureVector<Botan::byte>& buffer, bool append = false);
-00097 
-00103     bool send (Botan::SecureVector<Botan::byte>& buffer);
-00104 
-00110     bool sendPacket (Botan::SecureVector<Botan::byte>& buffer);
-00111 
-00120     short waitForPacket (Botan::byte cmd, bool bufferOnly = false);
-00121 
-00127     uint32 getPacket (Botan::SecureVector<Botan::byte>& result);
-00128 
-00133     bool haveData ();
-00134 };
-00135 
-00136 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html deleted file mode 100644 index 91c005d093a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html +++ /dev/null @@ -1,127 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_types.h Source File - - - - - -
-

ne7ssh_types.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_TYPES_H
-00018 #define NE7SSH_TYPES_H
-00019 
-00020 #if defined(WIN32) || defined(__MINGW32)
-00021   typedef int int32_t;
-00022   typedef long long      int64_t;
-00023   typedef short        int16_t;
-00024   typedef signed char  int8_t;
-00025 
-00026   typedef unsigned int uint32_t;
-00027   typedef unsigned long long uint64_t;
-00028   typedef unsigned short uint16_t;
-00029   typedef unsigned char  uint8_t;
-00030 
-00031 #   if defined(_WINDLL) || defined(_USRDLL) || defined(_CONSOLE) || defined(_WINDOWS)
-00032 #       ifdef NE7SSH_EXPORTS
-00033 #        define SSH_EXPORT __declspec(dllexport)
-00034 #      else
-00035 #        define SSH_EXPORT __declspec(dllimport)
-00036 #      endif
-00037 #   else
-00038 #       define SSH_EXPORT
-00039 #   endif
-00040 #else
-00041 #  include <inttypes.h>
-00042 #  define SSH_EXPORT
-00043 #endif
-00044 
-00045 #ifndef int64_defined
-00046 #define int64_defined
-00047 typedef int64_t int64;
-00048 #endif
-00049 
-00050 #ifndef uint64_defined
-00051 #define uint64_defined
-00052 typedef uint64_t uint64;
-00053 #endif
-00054 
-00055 #ifndef int32_defined
-00056 #define int32_defined
-00057 typedef int32_t int32;
-00058 #endif
-00059 
-00060 #ifndef uint32_defined
-00061 #define uint32_defined
-00062 typedef uint32_t uint32;
-00063 #endif
-00064 
-00065 #ifndef int16_defined
-00066 #define int16_defined
-00067 typedef int16_t int16;
-00068 #endif
-00069 
-00070 #ifndef uint16_defined
-00071 #define uint16_defined
-00072 typedef uint16_t uint16;
-00073 #endif
-00074 
-00075 #ifndef int8_defined
-00076 #define int8_defined
-00077 typedef int8_t int8;
-00078 #endif
-00079 
-00080 #ifndef uint8_defined
-00081 #define uint8_defined
-00082 typedef uint8_t uint8;
-00083 #endif
-00084 
-00085 #ifndef Byte_defined
-00086 #define Byte_defined
-00087 typedef uint8_t Byte;
-00088 #endif
-00089 
-00090 #if defined(WIN32) || defined(__MINGW32__)
-00091 #  define usleep(time) Sleep(time)
-00092 #endif
-00093 
-00094 #endif
-00095 
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html deleted file mode 100644 index e25204015a5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html +++ /dev/null @@ -1,39 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7SftpSubsystem::fileAttrs Member List

This is the complete list of members for Ne7SftpSubsystem::fileAttrs, including all inherited members.

- - - - - - -
atime (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
group (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
mtime (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
owner (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
permissions (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
size (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html deleted file mode 100644 index a7c5b78971b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html +++ /dev/null @@ -1,63 +0,0 @@ - - -ne7ssh.kdevelop: Ne7SftpSubsystem::fileAttrs Struct Reference - - - - - -
-

Ne7SftpSubsystem::fileAttrs Struct Reference

#include <ne7ssh.h> -

- -

-List of all members. - - - - - - - - - - - - - - -

Public Attributes

-uint64_t size
-uint32_t owner
-uint32_t group
-uint32_t permissions
-uint32_t atime
-uint32_t mtime
-


Detailed Description

-Structure used to store rmote file attributes.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html deleted file mode 100644 index 3559d955169..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html +++ /dev/null @@ -1,35 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshError::Error Member List

This is the complete list of members for Ne7sshError::Error, including all inherited members.

- - -
channel (defined in Ne7sshError::Error)Ne7sshError::Error
errorStr (defined in Ne7sshError::Error)Ne7sshError::Error

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html deleted file mode 100644 index 68d10d26fc2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html +++ /dev/null @@ -1,49 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshError::Error Struct Reference - - - - - -
-

Ne7sshError::Error Struct Reference

-

-List of all members. - - - - - - -

Public Attributes

-int32 channel
-char * errorStr
-


Detailed Description

-Structure for storing error messages.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html deleted file mode 100644 index 20e6d888085..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html +++ /dev/null @@ -1,36 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp::sftpFile Member List

This is the complete list of members for Ne7sshSftp::sftpFile, including all inherited members.

- - - -
fileID (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile
handle (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile
handleLen (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html deleted file mode 100644 index 56bf1b2af5f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html +++ /dev/null @@ -1,52 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp::sftpFile Struct Reference - - - - - -
-

Ne7sshSftp::sftpFile Struct Reference

-

-List of all members. - - - - - - - - -

Public Attributes

-uint32 fileID
-uint16 handleLen
-char handle [256]
-


Detailed Description

-Structure used to store open rmote file.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html deleted file mode 100644 index d3c995b9ee5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html +++ /dev/null @@ -1,40 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp::sftpFileAttrs Member List

This is the complete list of members for Ne7sshSftp::sftpFileAttrs, including all inherited members.

- - - - - - - -
atime (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
flags (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
group (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
mtime (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
owner (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
permissions (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
size (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html deleted file mode 100644 index 53311c50173..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html +++ /dev/null @@ -1,64 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp::sftpFileAttrs Struct Reference - - - - - -
-

Ne7sshSftp::sftpFileAttrs Struct Reference

-

-List of all members. - - - - - - - - - - - - - - - - -

Public Attributes

-uint32 flags
-uint64 size
-uint32 owner
-uint32 group
-uint32 permissions
-uint32 atime
-uint32 mtime
-


Detailed Description

-Structure used to store rmote file attributes.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html deleted file mode 100644 index 2e63c113e16..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html +++ /dev/null @@ -1,35 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

connStruct Member List

This is the complete list of members for connStruct, including all inherited members.

- - -
connsconnStruct
countconnStruct

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html deleted file mode 100644 index 9f9cdd92109..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html +++ /dev/null @@ -1,89 +0,0 @@ - - -ne7ssh.kdevelop: connStruct Struct Reference - - - - - -
-

connStruct Struct Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for connStruct:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - -

Public Attributes

ne7ssh_connection ** conns
uint32 count
-


Detailed Description

-Structure used to store connections. Used to better sync with selectThread.

Member Data Documentation

- -
- -
- -

-Pointer to all active connections. -

Referenced by ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), ne7ssh::ne7ssh(), and ne7ssh::selectThread().

- -
-

- -

-
- - - - -
uint32 connStruct::count
-
-
- -

-Active connection count. -

Referenced by ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), and ne7ssh::ne7ssh().

- -
-

-


The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map deleted file mode 100644 index 62000438186..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 deleted file mode 100644 index f812527dcfe..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a70c5341fda0905a1c68e9544e7ad27d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/tabs.css b/src/libs/3rdparty/net7ssh/doc/html/tabs.css deleted file mode 100644 index ab02c624aff..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/tabs.css +++ /dev/null @@ -1,105 +0,0 @@ -/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ - -DIV.tabs -{ - float : left; - width : 100%; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; -} - -DIV.tabs UL -{ - margin : 0px; - padding-left : 10px; - list-style : none; -} - -DIV.tabs LI, DIV.tabs FORM -{ - display : inline; - margin : 0px; - padding : 0px; -} - -DIV.tabs FORM -{ - float : right; -} - -DIV.tabs A -{ - float : left; - background : url("tab_r.gif") no-repeat right top; - border-bottom : 1px solid #84B0C7; - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - -DIV.tabs A:hover -{ - background-position: 100% -150px; -} - -DIV.tabs A:link, DIV.tabs A:visited, -DIV.tabs A:active, DIV.tabs A:hover -{ - color: #1A419D; -} - -DIV.tabs SPAN -{ - float : left; - display : block; - background : url("tab_l.gif") no-repeat left top; - padding : 5px 9px; - white-space : nowrap; -} - -DIV.tabs INPUT -{ - float : right; - display : inline; - font-size : 1em; -} - -DIV.tabs TD -{ - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - - - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -DIV.tabs SPAN {float : none;} -/* End IE5-Mac hack */ - -DIV.tabs A:hover SPAN -{ - background-position: 0% -150px; -} - -DIV.tabs LI.current A -{ - background-position: 100% -150px; - border-width : 0px; -} - -DIV.tabs LI.current SPAN -{ - background-position: 0% -150px; - padding-bottom : 6px; -} - -DIV.navpath -{ - background : none; - border : none; - border-bottom : 1px solid #84B0C7; - text-align : center; - margin : 2px; - padding : 2px; -} diff --git a/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp b/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp deleted file mode 100644 index c5c0d70cbc0..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* An example of ne7ssh library usage. This code will generate a DSA key pair - and store private key in ./privKeyFile and public key in ./pubKeyFile. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - ne7ssh *_ssh = new ne7ssh(); - - // Generating DSA keys - if (!_ssh->generateKeyPair ("rsa", "test@test.com", "./privKeyFile", "./pubKeyFile", 2048)) - { - const char *errmsg = _ssh->errors()->pop(); - - if (errmsg == NULL) - errmsg = ""; - printf ("Key gneration failed with last error: %s.\n\n", errmsg); - } - - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/getFile.cpp b/src/libs/3rdparty/net7ssh/examples/getFile.cpp deleted file mode 100644 index 926e31ca2cf..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/getFile.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword -function before compiling. - -This will work with on a unix/linux server with cat utility. - -If you are testing this with later openssh versions, make sure to add this -option to your server's configuration file to enable password authentication: - -PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - int filesize = 0; - FILE *testFi; - - // Set SSH connection options. - _ssh->setOptions ("aes256-cbc", "hmac-md5"); - - // Initiate connection without starting a remote shell. - channel1 = _ssh->connectWithPassword ("remote-server", 22, "remoteUser", "password", 0); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // cat the remote file, works only on Unix systems. You may need to sepcifiy full path to cat. - // Timeout after 100 seconds. - - if (!_ssh->sendCmd ("cat ~/test.bin", channel1, 100)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Command failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Determine the size of received file. - filesize = _ssh->getReceivedSize(channel1); - - // Open a local file. - testFi = fopen ("./test.bin", "wb"); - - // Write binary data from the receive buffer to the opened file. - if (!fwrite (_ssh->readBinary(channel1), (size_t) filesize, 1, testFi)) - { - printf ("Error Writting to file\n\n"); - return EXIT_FAILURE; - } - - // Close the files. - fclose (testFi); - - // Destroy the instance. - delete _ssh; - - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp b/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp deleted file mode 100644 index e12fc120697..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWitKeys - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - - // Set SSH connection options. - _ssh->setOptions ("aes128-cbc", "hmac-sha1"); - - // Initiate connection. - channel1 = _ssh->connectWithKey ("remoteHost", 22, "remoteUsr", "/local/path/to/privKeyFile"); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, "$", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, "$", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - - // Terminate connection by sending "exit" command. - _ssh->send ("exit\n", channel1); - - // Destroy the instance. - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp b/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp deleted file mode 100644 index 5cb68649eca..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ -#include -#include - -#if defined(WIN32) || defined (__MINGW32__) -# include -typedef HANDLE pthread_t; -#endif - -void* thread1_proc (void* initData); -void* thread2_proc (void* initData); -void* thread3_proc (void* initData); -void* thread4_proc (void* initData); -pthread_t thread1, thread2, thread3, thread4; - -struct ssh_thrarg_t -{ - ne7ssh *ssh; - int thrid; -}; - -int main(int argc,char *argv[]) -{ - ne7ssh *_ssh = new ne7ssh(); - int status; - - // Set SSH connection options. - _ssh->setOptions ("aes128-cbc", "hmac-md5"); - - ssh_thrarg_t args[4]; - args[0].ssh = _ssh; - args[1].ssh = _ssh; - args[2].ssh = _ssh; - args[3].ssh = _ssh; - - args[0].thrid = 1; - args[1].thrid = 2; - args[2].thrid = 3; - args[3].thrid = 4; - -#if !defined(WIN32) && !defined(__MINGW32__) - status = pthread_create (&thread1, NULL, thread1_proc, (void*)&args[0]); - status = pthread_create (&thread2, NULL, thread2_proc, (void*)&args[1]); - status = pthread_create (&thread3, NULL, thread3_proc, (void*)&args[2]); - status = pthread_create (&thread4, NULL, thread4_proc, (void*)&args[3]); - pthread_join (thread1, NULL); - pthread_join (thread2, NULL); - pthread_join (thread3, NULL); - pthread_join (thread4, NULL); - -#else - HANDLE h[3]; - if ((thread1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread1_proc, (LPVOID)&args[0], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread2 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread2_proc, (LPVOID)&args[1], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread3 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread3_proc, (LPVOID)&args[2], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread4 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread4_proc, (LPVOID)&args[3], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - h[0] = thread1; - h[1] = thread2; - h[2] = thread3; - h[3] = thread4; - WaitForMultipleObjects(4, h, TRUE, INFINITE); -#endif - - delete _ssh; - return EXIT_SUCCESS; -} - - -void* thread1_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread1. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls -al\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread2_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread2. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - result = _ssh->read (channel1); - - printf ("Data Count: %i, Thread %i: %s\n\n", i, thrid, result); - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Count: %i, Thread %i: %s\n\n", i, thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread3_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread3. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread4_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread4. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} diff --git a/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp b/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp deleted file mode 100644 index d45e8a472d0..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - - // Set SSH connection options. - _ssh->setOptions ("aes192-cbc", "hmac-md5"); - - // Initiate connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remtoeUsr", "password"); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell with last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Send "ps ax" command. - if (!_ssh->send ("ps ax\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s.\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - - // Send "netstat -na" command. - if (!_ssh->send ("netstat -na\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s.\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - // Terminate connection by sending "exit" command. - _ssh->send ("exit\n", channel1); - - // Destroy the instance. - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp b/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp deleted file mode 100644 index c73a9920806..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - int filesize = 0; - FILE *testFi; - Ne7SftpSubsystem _sftp; - const char* dirList; - - // Set SSH connection options. - _ssh->setOptions ("aes256-cbc", "hmac-md5"); - - // Initiate connection without starting a remote shell. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", 0, 20); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Initiate SFTP subsystem. - if (!_ssh->initSftp (_sftp, channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Command failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Set a timeout for all SFTP communications. - _sftp.setTimeout (30); - - // Check remote file permissions. - Ne7SftpSubsystem::fileAttrs attrs; - if (_sftp.getFileAttrs (attrs, "test.bin", true)) - printf ("Permissions: %o\n", (attrs.permissions & 0777)); - - // Create a local file. - testFi = fopen ("test.bin", "wb+"); - if (!testFi) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not open local file: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Download a file. - if (!_sftp.get ("test.bin", testFi)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not get File: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Change directory. - if (!_sftp.cd ("testing")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not change Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Upload the file. - if (!_sftp.put (testFi, "test2.bin")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not put File: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Create a new directory. - if (!_sftp.mkdir ("testing3")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not create Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Get listing. - dirList = _sftp.ls (".", true); - if (!dirList) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not list Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - else - printf ("Directory Listing:\n\n %s\n", dirList); - - // Change permisions on newly uploaded file. - if (!_sftp.chmod ("test2.bin", "755")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not chmod: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Destroy the instance. - delete _ssh; - - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/net7ssh.pri b/src/libs/3rdparty/net7ssh/net7ssh.pri deleted file mode 100644 index 6389d249ad4..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh.pri +++ /dev/null @@ -1,3 +0,0 @@ -include(net7ssh_dependencies.pri) -INCLUDEPATH *= $$PWD/src -LIBS *= -l$$qtLibraryTarget(Net7ssh) diff --git a/src/libs/3rdparty/net7ssh/net7ssh.pro b/src/libs/3rdparty/net7ssh/net7ssh.pro deleted file mode 100644 index 862d64135dd..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS += src diff --git a/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri b/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri deleted file mode 100644 index d83ea3954d2..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri +++ /dev/null @@ -1 +0,0 @@ -include(../botan/botan.pri) diff --git a/src/libs/3rdparty/net7ssh/src/crypt.cpp b/src/libs/3rdparty/net7ssh/src/crypt.cpp deleted file mode 100644 index b7f4e151f54..00000000000 --- a/src/libs/3rdparty/net7ssh/src/crypt.cpp +++ /dev/null @@ -1,786 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#if !defined WIN32 && !defined(__MINGW32__) -# include -#endif - -#include -#include "crypt.h" -#include "ne7ssh_session.h" -#include "ne7ssh.h" - -using namespace Botan; - -ne7ssh_crypt::ne7ssh_crypt(ne7ssh_session* _session) : session(_session), kexMethod(DH_GROUP1_SHA1), c2sCryptoMethod(AES128_CBC), s2cCryptoMethod(AES128_CBC), c2sMacMethod(HMAC_MD5), s2cMacMethod(HMAC_MD5), inited(false), encrypt(0), decrypt(0), compress(0), decompress(0), hmacOut(0), hmacIn(0), privKexKey(0), encryptBlock(0), decryptBlock(0) -{ -} - - -ne7ssh_crypt::~ne7ssh_crypt() -{ - if (encrypt) delete encrypt; - if (decrypt) delete decrypt; - - if (compress) delete compress; - if (decompress) delete decompress; - - if (hmacOut) delete hmacOut; - if (hmacIn) delete hmacIn; - - if (privKexKey) delete privKexKey; -} - - -bool ne7ssh_crypt::agree (Botan::SecureVector &result, const char* local, Botan::SecureVector &remote) -{ - ne7ssh_string localAlgos (local, 0); - ne7ssh_string remoteAlgos (remote, 0); - char* localAlgo, *remoteAlgo; - bool match; - size_t len; - - localAlgos.split (','); - localAlgos.resetParts(); - remoteAlgos.split (','); - remoteAlgos.resetParts(); - - match = false; - while ((localAlgo = localAlgos.nextPart())) - { - len = strlen(localAlgo); - while ((remoteAlgo = remoteAlgos.nextPart())) - { - if (!memcmp (localAlgo, remoteAlgo, len)) - { - match = true; - break; - } - } - if (match) break; - remoteAlgos.resetParts(); - } - if (match) - { - result.set ((Botan::byte*)localAlgo, (uint32_t) len); - return true; - } - else - { - result.clear(); - return false; - } -} - -bool ne7ssh_crypt::negotiatedKex (Botan::SecureVector &kexAlgo) -{ - if (!memcmp (kexAlgo.begin(), "diffie-hellman-group1-sha1", kexAlgo.size())) - { - kexMethod = DH_GROUP1_SHA1; - return true; - } - else if (!memcmp (kexAlgo.begin(), "diffie-hellman-group14-sha1", kexAlgo.size())) - { - kexMethod = DH_GROUP14_SHA1; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "KEX algorithm: '%B' not defined.", &kexAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedHostkey (Botan::SecureVector &hostkeyAlgo) -{ - if (!memcmp (hostkeyAlgo.begin(), "ssh-dss", hostkeyAlgo.size())) - { - hostkeyMethod = SSH_DSS; - return true; - } - else if (!memcmp (hostkeyAlgo.begin(), "ssh-rsa", hostkeyAlgo.size())) - { - hostkeyMethod = SSH_RSA; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Hostkey algorithm: '%B' not defined.", &hostkeyAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCryptoC2s (Botan::SecureVector &cryptoAlgo) -{ - if (!memcmp (cryptoAlgo.begin(), "3des-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = TDES_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes128-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes192-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES192_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes256-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES256_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "blowfish-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = BLOWFISH_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "cast128-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = CAST128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "twofish-cbc", cryptoAlgo.size()) || !memcmp (cryptoAlgo.begin(), "twofish256-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = TWOFISH_CBC; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic algorithm: '%B' not defined.", &cryptoAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCryptoS2c (Botan::SecureVector &cryptoAlgo) -{ - if (!memcmp (cryptoAlgo.begin(), "3des-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = TDES_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes128-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes192-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES192_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes256-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES256_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "blowfish-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = BLOWFISH_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "cast128-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = CAST128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "twofish-cbc", cryptoAlgo.size()) || !memcmp (cryptoAlgo.begin(), "twofish256-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = TWOFISH_CBC; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic method: '%B' not defined.", &cryptoAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedMacC2s (Botan::SecureVector &macAlgo) -{ - if (!memcmp (macAlgo.begin(), "hmac-sha1", macAlgo.size())) - { - c2sMacMethod = HMAC_SHA1; - return true; - } - else if (!memcmp (macAlgo.begin(), "hmac-md5", macAlgo.size())) - { - c2sMacMethod = HMAC_MD5; - return true; - } - else if (!memcmp (macAlgo.begin(), "none", macAlgo.size())) - { - c2sMacMethod = HMAC_NONE; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: '%B' not defined.", &macAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedMacS2c (Botan::SecureVector &macAlgo) -{ - if (!memcmp (macAlgo.begin(), "hmac-sha1", macAlgo.size())) - { - s2cMacMethod = HMAC_SHA1; - return true; - } - else if (!memcmp (macAlgo.begin(), "hmac-md5", macAlgo.size())) - { - s2cMacMethod = HMAC_MD5; - return true; - } - else if (!memcmp (macAlgo.begin(), "none", macAlgo.size())) - { - s2cMacMethod = HMAC_NONE; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: '%B' not defined.", &macAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCmprsC2s (Botan::SecureVector &cmprsAlgo) -{ - if (!memcmp (cmprsAlgo.begin(), "none", cmprsAlgo.size())) - { - c2sCmprsMethod = NONE; - return true; - } - else if (!memcmp (cmprsAlgo.begin(), "zlib", cmprsAlgo.size())) - { - c2sCmprsMethod = ZLIB; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Compression algorithm: '%B' not defined.", &cmprsAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCmprsS2c (Botan::SecureVector &cmprsAlgo) -{ - if (!memcmp (cmprsAlgo.begin(), "none", cmprsAlgo.size())) - { - s2cCmprsMethod = NONE; - return true; - } - else if (!memcmp (cmprsAlgo.begin(), "zlib", cmprsAlgo.size())) - { - s2cCmprsMethod = ZLIB; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Compression algorithm: '%B' not defined.", &cmprsAlgo); - return false; -} - -bool ne7ssh_crypt::getKexPublic (Botan::BigInt &publicKey) -{ - switch (kexMethod) - { - case DH_GROUP1_SHA1: - return getDHGroup1Sha1Public (publicKey); - - case DH_GROUP14_SHA1: - return getDHGroup14Sha1Public (publicKey); - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Undefined DH Group: '%s'.", kexMethod); - return false; - } -} - -bool ne7ssh_crypt::computeH (Botan::SecureVector &result, Botan::SecureVector &val) -{ - HashFunction* hashIt; - - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - hashIt = get_hash ("SHA-1"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Undefined DH Group: '%s' while computing H.", kexMethod); - return false; - } - - if (!hashIt) return false; - H = hashIt->process (val); - result.set (H); - delete (hashIt); - return true; -} - -bool ne7ssh_crypt::verifySig (Botan::SecureVector &hostKey, Botan::SecureVector &sig) -{ - DSA_PublicKey *dsaKey = 0; - RSA_PublicKey *rsaKey = 0; - PK_Verifier *verifier; - ne7ssh_string signature (sig, 0); - SecureVector sigType, sigData; - bool result; - - if (H.is_empty()) - { - ne7ssh::errors()->push (session->getSshChannel(), "H was not initialzed."); - return false; - } - - if (!signature.getString (sigType)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Signature without type."); - return false; - } - if (!signature.getString (sigData)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Signature without data."); - return false; - } - - switch (hostkeyMethod) - { - case SSH_DSS: - dsaKey = getDSAKey (hostKey); - if (!dsaKey) - { - ne7ssh::errors()->push (session->getSshChannel(), "DSA key not generated."); - return false; - } - break; - - case SSH_RSA: - rsaKey = getRSAKey (hostKey); - if (!rsaKey) - { - ne7ssh::errors()->push (session->getSshChannel(), "RSA key not generated."); - return false; - } - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Hostkey algorithm: %i not supported.", hostkeyMethod); - return false; - } - - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - if (dsaKey) verifier = get_pk_verifier (*dsaKey, "EMSA1(SHA-1)"); - else if (rsaKey) verifier = get_pk_verifier (*rsaKey, "EMSA3(SHA-1)"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Key Exchange algorithm: %i not supported.", kexMethod); - return false; - } - - result = verifier->verify_message (H, sigData); - delete verifier; - if (dsaKey) delete dsaKey; - if (rsaKey) delete rsaKey; - - if (!result) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure to verify host signature."); - return false; - } - else return true; -} - -DSA_PublicKey* ne7ssh_crypt::getDSAKey (Botan::SecureVector &hostKey) -{ - ne7ssh_string hKey; - SecureVector field; - BigInt p, q, g, y; - DSA_PublicKey *pubKey; - - hKey.addVector (hostKey); - - if (!hKey.getString (field)) return 0; - if (!negotiatedHostkey (field)) return 0; - - if (!hKey.getBigInt (p)) return 0; - if (!hKey.getBigInt (q)) return 0; - if (!hKey.getBigInt (g)) return 0; - if (!hKey.getBigInt (y)) return 0; - - DL_Group keyDL (p, q, g); - pubKey = new DSA_PublicKey (keyDL, y); - return pubKey; -} - -RSA_PublicKey* ne7ssh_crypt::getRSAKey (Botan::SecureVector &hostKey) -{ - ne7ssh_string hKey; - SecureVector field; - BigInt e, n; - - hKey.addVector (hostKey); - - if (!hKey.getString (field)) return 0; - if (!negotiatedHostkey (field)) return 0; - - if (!hKey.getBigInt (e)) return 0; - if (!hKey.getBigInt (n)) return 0; - - return (new RSA_PublicKey (n, e)); -} - - - -bool ne7ssh_crypt::makeKexSecret (Botan::SecureVector &result, Botan::BigInt &f) -{ - SymmetricKey negotiated = privKexKey->derive_key (f); - if (!negotiated.length()) return false; - - BigInt Kint (negotiated.begin(), negotiated.length()); - ne7ssh_string::bn2vector(result, Kint); - K.set (result); - delete privKexKey; - privKexKey = 0; - return true; -} - -bool ne7ssh_crypt::getDHGroup1Sha1Public (Botan::BigInt &publicKey) -{ -#if BOTAN_PRE_15 - privKexKey = new DH_PrivateKey (get_dl_group("IETF-1024")); -#elif BOTAN_PRE_18 - privKexKey = new DH_PrivateKey (DL_Group("modp/ietf/1024")); -#else - privKexKey = new DH_PrivateKey (*ne7ssh::rng, DL_Group("modp/ietf/1024")); -#endif - DH_PublicKey pubKexKey = *privKexKey; - - publicKey = pubKexKey.get_y(); - if (publicKey.is_zero()) return false; - else return true; -} - -bool ne7ssh_crypt::getDHGroup14Sha1Public (Botan::BigInt &publicKey) -{ -#if BOTAN_PRE_15 - privKexKey = new DH_PrivateKey (get_dl_group("IETF-2048")); -#elif BOTAN_PRE_18 - privKexKey = new DH_PrivateKey (DL_Group("modp/ietf/2048")); -#else - privKexKey = new DH_PrivateKey (*ne7ssh::rng, DL_Group("modp/ietf/2048")); -#endif - DH_PublicKey pubKexKey = *privKexKey; - - publicKey = pubKexKey.get_y(); - if (publicKey.is_zero()) return false; - else return true; -} - -const char* ne7ssh_crypt::getHashAlgo () -{ - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - return "SHA-1"; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "DH Group: %i was not defined.", kexMethod); - return 0; - } -} - -const char* ne7ssh_crypt::getCryptAlgo (uint32 crypto) -{ - switch (crypto) - { - case TDES_CBC: - return "TripleDES"; - - case AES128_CBC: - return "AES-128"; - - case AES192_CBC: - return "AES-192"; - - case AES256_CBC: - return "AES-256"; - - case BLOWFISH_CBC: - return "Blowfish"; - - case CAST128_CBC: - return "CAST-128"; - - case TWOFISH_CBC: - return "Twofish"; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic algorithm: %i was not defined.", crypto); - return 0; - } -} - -const char* ne7ssh_crypt::getHmacAlgo (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return "SHA-1"; - - case HMAC_MD5: - return "MD5"; - - case HMAC_NONE: - return 0; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: %i was not defined.", method); - return 0; - } -} - -uint32 ne7ssh_crypt::getMacKeyLen (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return 20; - - case HMAC_MD5: - return 16; - - case HMAC_NONE: - return 0; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: %i was not defined.", method); - return 0; - } -} - -uint32 ne7ssh_crypt::getMacDigestLen (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return 20; - - case HMAC_MD5: - return 16; - - case HMAC_NONE: - return 0; - - default: - return 0; - } -} - -bool ne7ssh_crypt::makeNewKeys () -{ - const char* algo; - uint32 key_len, iv_len, macLen; - SecureVector key; -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - const Botan::BlockCipher *cipher; - const Botan::HashFunction *hash_algo; -#endif - - algo = getCryptAlgo (c2sCryptoMethod); - key_len = max_keylength_of (algo); - if (c2sCryptoMethod == BLOWFISH_CBC) key_len = 16; - else if (c2sCryptoMethod == TWOFISH_CBC) key_len = 32; - encryptBlock = iv_len = block_size_of (algo); - macLen = getMacKeyLen (c2sMacMethod); - if (!algo) return false; - - if (!compute_key(key, 'A', iv_len)) return false; - InitializationVector c2s_iv (key); - - if (!compute_key(key, 'C', key_len)) return false; - SymmetricKey c2s_key (key); - - if (!compute_key(key, 'E', macLen)) return false; - SymmetricKey c2s_mac (key); - -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - encrypt = new Pipe (new CBC_Encryption (algo, "NoPadding", c2s_key, c2s_iv)); -#else - Algorithm_Factory &af = global_state().algorithm_factory(); - cipher = af.prototype_block_cipher (algo); - encrypt = new Pipe (new CBC_Encryption (cipher->clone(), new Null_Padding, c2s_key, c2s_iv)); -#endif - - if (macLen) - { -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - hmacOut = new HMAC (getHmacAlgo(c2sMacMethod)); -#else - hash_algo = af.prototype_hash_function (getHmacAlgo (c2sMacMethod)); - hmacOut = new HMAC (hash_algo->clone()); -#endif - hmacOut->set_key (c2s_mac); - } -// if (c2sCmprsMethod == ZLIB) compress = new Pipe (new Zlib_Compression(9)); - - - algo = getCryptAlgo (s2cCryptoMethod); - key_len = max_keylength_of (algo); - if (s2cCryptoMethod == BLOWFISH_CBC) key_len = 16; - else if (s2cCryptoMethod == TWOFISH_CBC) key_len = 32; - decryptBlock = iv_len = block_size_of (algo); - macLen = getMacKeyLen (c2sMacMethod); - if (!algo) return false; - - if (!compute_key(key, 'B', iv_len)) return false; - InitializationVector s2c_iv (key); - - if (!compute_key(key, 'D', key_len)) return false; - SymmetricKey s2c_key (key); - - if (!compute_key(key, 'F', macLen)) return false; - SymmetricKey s2c_mac (key); - -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - decrypt = new Pipe (new CBC_Decryption (algo, "NoPadding", s2c_key, s2c_iv)); -#else - cipher = af.prototype_block_cipher (algo); - decrypt = new Pipe (new CBC_Decryption (cipher->clone(), new Null_Padding, s2c_key, s2c_iv)); -#endif - - if (macLen) - { -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - hmacIn = new HMAC (getHmacAlgo(s2cMacMethod)); -#else - hash_algo = af.prototype_hash_function (getHmacAlgo (s2cMacMethod)); - hmacIn = new HMAC (hash_algo->clone()); -#endif - hmacIn->set_key (s2c_mac); - } -// if (s2cCmprsMethod == ZLIB) decompress = new Pipe (new Zlib_Decompression); - - inited = true; - return true; -} - -bool ne7ssh_crypt::compute_key (Botan::SecureVector& key, Botan::byte ID, uint32 nBytes) -{ - SecureVector hash, newKey; - ne7ssh_string hashBytes; - HashFunction* hashIt; - const char* algo = getHashAlgo(); - uint32 len; - - if (!algo) return false; - hashIt = get_hash (algo); - if (!hashIt) - { - ne7ssh::errors()->push (session->getSshChannel(), "Undefined HASH algorithm encountered while computing the key."); - return false; - } - - hashBytes.addVectorField (K); - hashBytes.addVector (H); - hashBytes.addChar (ID); - hashBytes.addVector (session->getSessionID()); - - hash = hashIt->process (hashBytes.value()); - newKey.set (hash); - len = newKey.size(); - - while (len < nBytes) - { - hashBytes.clear(); - hashBytes.addVectorField (K); - hashBytes.addVector (H); - hashBytes.addVector (newKey); - hash = hashIt->process (hashBytes.value()); - newKey.append (hash); - len = newKey.size(); - } - - key.set (newKey.begin(), nBytes); - delete (hashIt); - return true; -} - -bool ne7ssh_crypt::encryptPacket (Botan::SecureVector &crypted, Botan::SecureVector &hmac, Botan::SecureVector &packet, uint32 seq) -{ - SecureVector macStr; - uint32 nSeq = (uint32)htonl (seq); - - encrypt->start_msg(); - encrypt->write (packet.begin(), packet.size()); - encrypt->end_msg(); -// encrypt->process_msg (packet); - crypted = encrypt->read_all (encrypt->message_count() - 1); - - if (hmacOut) - { - macStr.set ((Botan::byte*)&nSeq, 4); - macStr.append (packet); - hmac = hmacOut->process (macStr); - } - - return true; -} - -bool ne7ssh_crypt::decryptPacket (Botan::SecureVector &decrypted, Botan::SecureVector &packet, uint32 len) -{ - uint32 pLen = packet.size(); - - if (len % decryptBlock) len = len + (len % decryptBlock); - - if (len > pLen) len = pLen; - - decrypt->process_msg (packet.begin(), len); - decrypted = decrypt->read_all (decrypt->message_count() - 1); - - return true; -} - -void ne7ssh_crypt::compressData (Botan::SecureVector &buffer) -{ - SecureVector tmpVar; - if (!compress) return; - - tmpVar.swap (buffer); - compress->process_msg (tmpVar); - tmpVar = compress->read_all (compress->message_count() - 1); - buffer.set (tmpVar); -} - -void ne7ssh_crypt::decompressData (Botan::SecureVector &buffer) -{ - SecureVector tmpVar; - if (!decompress) return; - - tmpVar.swap (buffer); - decompress->process_msg (tmpVar); - tmpVar = decompress->read_all (compress->message_count() - 1); - buffer.set (tmpVar); -} - -void ne7ssh_crypt::computeMac (Botan::SecureVector &hmac, Botan::SecureVector &packet, uint32 seq) -{ - SecureVector macStr; - uint32 nSeq = htonl (seq); - - if (hmacIn) - { - macStr.set ((Botan::byte*)&nSeq, 4); - macStr.append (packet); - hmac = hmacIn->process (macStr); - } - else hmac.destroy(); -} - diff --git a/src/libs/3rdparty/net7ssh/src/crypt.h b/src/libs/3rdparty/net7ssh/src/crypt.h deleted file mode 100644 index 003dcb520d6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/crypt.h +++ /dev/null @@ -1,357 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef CRYPT_H -#define CRYPT_H - -#include -#include -#include -#include -#include -#include -#include -#include - - -// #if defined(BOTAN_EXT_COMPRESSOR_ZLIB) -// #include -// #else -// #error "Zlib support is not compiled into Botan" -// #endif - -#include -#include - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_crypt -{ - private: - ne7ssh_session* session; - - enum kexMethods { DH_GROUP1_SHA1, DH_GROUP14_SHA1 }; - uint32 kexMethod; - - enum hostkeyMethods { SSH_DSS, SSH_RSA }; - uint32 hostkeyMethod; - - enum cryptoMethods { TDES_CBC, AES128_CBC, AES192_CBC, AES256_CBC, BLOWFISH_CBC, CAST128_CBC, TWOFISH_CBC }; - uint32 c2sCryptoMethod; - uint32 s2cCryptoMethod; - - enum macMethods { HMAC_SHA1, HMAC_MD5, HMAC_NONE }; - uint32 c2sMacMethod; - uint32 s2cMacMethod; - - enum cmprsMethods { NONE, ZLIB }; - uint32 c2sCmprsMethod; - uint32 s2cCmprsMethod; - - bool inited; - Botan::SecureVector H; - Botan::SecureVector K; - - Botan::Pipe *encrypt; - Botan::Pipe *decrypt; - Botan::Pipe *compress; - Botan::Pipe *decompress; - Botan::HMAC *hmacOut, *hmacIn; - - Botan::DH_PrivateKey *privKexKey; - - uint32 encryptBlock; - uint32 decryptBlock; - - /** - * Generates a new Public Key, based on Diffie Helman Group1, SHA1 standard. - * @param publicKey Reference to publick Key. The result will be dumped into this var. - * @return If generation successful returns true, otherwise false is returned. - */ - bool getDHGroup1Sha1Public (Botan::BigInt& publicKey); - - /** - * Generates a new Public Key, based on Diffie Helman Group14, SHA1 standard. - * @param publicKey Reference to publick Key. The result will be dumped into this var. - * @return If generation successful returns true, otherwise false is returned. - */ - bool getDHGroup14Sha1Public (Botan::BigInt &publicKey); - - /** - * Generates a new DSA public Key from p,q,g,y values extracted from the host key received from the server. - * @param hostKey Reference to vector containing host key received from a server. - * @return Returns newly generated DSA public Key. If host key vector is trash, more likely application will be aborted within Botan library. - */ - Botan::DSA_PublicKey* getDSAKey (Botan::SecureVector& hostKey); - - /** - * Generates a new RSA public Key from n and e values extracted from the host key received from the server. - * @param hostKey Reference to a vector containing host key. - * @return Returns newly generated ESA public Key. If the hostkey is trash, more likely application will abort within Botan library. - */ - Botan::RSA_PublicKey* getRSAKey (Botan::SecureVector &hostKey); - - /** - * Returns a string represenation of negotiated one way hash algorithm. For DH1_GROUP1_SHA1, "SHA-1" will be returned. - * @return A string containing algorithm name. - */ - const char* getHashAlgo(); - - /** - * Returns a string represenation of negotiated cipher algorithm. - * @param crypto Integer represenating a cipher algorithm. - * @return A string containing algorithm name. - */ - const char* getCryptAlgo (uint32 crypto); - - /** - * Returns a string represenation of negotiated HMAC algorithm. - * @param method Integer represenating HMAC algorithm. - * @return A string containing algorithm name. - */ - const char* getHmacAlgo (uint32 method); - - /** - * Returns key length of the negotiated HMAC algorithm. - *

Used in HMAC key generation. Key length coded in accordance with SSH protocol specs. - * @param method Integer represenating HMAC algorithm. - * @return Key length. - */ - uint32 getMacKeyLen (uint32 method); - - /** - * Returns digest length of negotiated HMAC algorithm. - *

If HMAC integrity checking is enabled, this value is used in the verification process. Digest length coded in accordance with SSH protocol specs. - * @param method Integer represenation of HMAC algorithm. - * @return Key length. - */ - uint32 getMacDigestLen (uint32 method); - - /** - * Function used to compute crypto and HMAC keys. - *

Keys are computed using K, H, ID and sessionID values. All these are concated and hashed. If hash is not long enough K, H, and newly generated key is used over and over again, till keys are long enough. - * @param key Resulting key will be dumped into this var. - * @param ID Single character ID, as specified in SSH protocol specs. - * @param nBytes Key length in bytes. - * @return True if key generation was successful, otherwise false is returned. - */ - bool compute_key (Botan::SecureVector& key, Botan::byte ID, uint32 nBytes); - - - public: - /** - * ne7ssh_crypt class constructor. - * @param _session Pointer to ne7ssh_session class. - */ - ne7ssh_crypt(ne7ssh_session* _session); - - /** - * ne7ssh_crypt class destructor. - */ - ~ne7ssh_crypt(); - - /** - * Checks if cryptographic engine has been initialized. - *

The engine is initialized when all crypto and hmac keys are generated and the cryptographic Pipes are created. - * @return True if cryptographic engine is initialized, otherwise false is returned. - */ - bool isInited () { return inited; } - - /** - * Returns the size of encryption block. - * @return Size of the block. - */ - uint32 getEncryptBlock () { return encryptBlock; } - - /** - * Returns the size of decryption block - * @return Size of the block - */ - uint32 getDecryptBlock () { return decryptBlock; } - - /** - * Returns digest length of HMAC algorithm used to verify integrity of transmited data. - * @return Digest length. - */ - uint32 getMacOutLen () { return getMacDigestLen (c2sMacMethod); } - - /** - * Returns digest length of HMAC algorithm used to verify integrity of data received. - * @return Digest length. - */ - uint32 getMacInLen () { return getMacDigestLen (s2cMacMethod); } - - /** - * This function is used in negotiations of crypto, signing and HMAC algorithms. - * @param result Reference to a vector where negotiated algorithm name will be dumped. - * @param local String containing a list of localy supported algorithms, separated by commas. - * @param remote Reference to vector containing a list of algorithms supported by remote side, separated by commas. - * @return True, if common algorithm was found, otherwise false is returned. - */ - bool agree (Botan::SecureVector& result, const char* local, Botan::SecureVector& remote); - - /** - * Parses negotiated key exchange algorithm vector, and registers it's integer representation with the class. - * @param kexAlgo Reference to a vector containing the negotiated KEX algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedKex (Botan::SecureVector& kexAlgo); - - /** - * Parses negotiated host key algorithm and registers it's integer representation with the class. - * @param hostKeyAlgo Reference to a vector containing the negotiated host key algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedHostkey (Botan::SecureVector& hostKeyAlgo); - - /** - * Parse negotiated client to server cipher algorithm and registers it's integer representation with the class. - * @param cryptoAlgo Reference to a vector containing the negotiated cipher algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCryptoC2s (Botan::SecureVector& cryptoAlgo); - - /** - * Parses negotiated server to client cipher algorithm and registers it's integer representation with the class. - * @param cryptoAlgo Reference to a vector containing the negotiated cipher algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCryptoS2c (Botan::SecureVector& cryptoAlgo); - - /** - * Parses negotiated client to server HMAC algorithm and registers it's integer representation with the class. - * @param macAlgo Reference to a vector containing the negotiated HMAC algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedMacC2s (Botan::SecureVector& macAlgo); - - /** - * Parses negotiated server to client HMAC algorithm vector and registers it's integer representation with the class. - * @param macAlgo Reference to a vector containing the negotiated HMAC algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedMacS2c (Botan::SecureVector& macAlgo); - - /** - * Parses negotiated client to server compression algorithm and registers it's integer representation with the class. - * @param cmprsAlgo Reference to a vector containing the negotiated compression algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCmprsC2s (Botan::SecureVector& cmprsAlgo); - - /** - * Parses negotiated server to client compression algorithm and registers it's integer representation with the class. - * @param cmprsAlgo Reference to a vector containing the negotiated compression algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCmprsS2c (Botan::SecureVector& cmprsAlgo); - - /** - * Generates KEX public key. - * @param publicKey Public key will be dumped into this var. - * @return True if key generation was successful, otherwise false is returned. - */ - bool getKexPublic (Botan::BigInt& publicKey); - - /** - * At the end of key exchange this function is used to generate a shared secret key from private KEX key, that one gets from getKexPublic() function and F value received from a server. - * @param result Secret key will be dumped into this var. - * @param f Reference to F value. - * @return True if key generation was successful, otherwise false is returned. - */ - bool makeKexSecret (Botan::SecureVector& result, Botan::BigInt& f); - - /** - * Computes H value by checking what hash algorithm is used and hashing "val". - * @param result H value will be dumped into this var. - * @param val Reference to vector containing material for H variable generation. - * @return True if key generation was successful, otherwise false is returned. - */ - bool computeH (Botan::SecureVector& result, Botan::SecureVector& val); - - /** - * Verifies host signature. - * @param hostKey Reference to vector containing hostKey. - * @param sig Regerence to vector containing the signature. - * @return True if signature verification was successful, otherwise false is returned. - */ - bool verifySig (Botan::SecureVector& hostKey, Botan::SecureVector& sig); - - /** - * Generates new cipher and HMAC keys. - * @return True if key generation was successful, otherwise false is returned. - */ - bool makeNewKeys (); - - /** - * Encrypts a packet and generates HMAC, if enabled during negotiation. - *

The entire packet is encrypted, only HMAC stays in raw format. - * @param crypted Encrypted packet will be dumped into this var. - * @param hmac HMAC will be dumped into this var. - * @param packet Reference to vector containing unencrypted packet. - * @param seq Transmited packet sequence. - * @return True if encryption successful, otherwise false is returned. - */ - bool encryptPacket (Botan::SecureVector& crypted, Botan::SecureVector& hmac, Botan::SecureVector& packet, uint32 seq); - - /** - * Decrypts a packet. - * @param decrypted Decrypted payload will be dumped into this var. - * @param packet Reference to vector containing encrypted packet. - * @param len Specifies the length of chunk to be decrypted. - * @return True if decryption is successful, otherwise false returned. - */ - bool decryptPacket (Botan::SecureVector& decrypted, Botan::SecureVector& packet, uint32 len); - - /** - * Computes HMAC from specific packet. - * @param hmac Generated HMAC value will be dumped into this var. - * @param packet Reference to vector containing packet for HMAC generation. - * @param seq receive sequence. - */ - void computeMac (Botan::SecureVector& hmac, Botan::SecureVector& packet, uint32 seq); - - /** - * Compresses the data. - * @param buffer Reference to vector containing payload to be compress. Results will also be dumped into this var. - */ - void compressData (Botan::SecureVector& buffer); - - /** - * Decompresses the data. - * @param buffer Reference to vector containing packet payload to decompress. Result will also be dumped into this var. - */ - void decompressData (Botan::SecureVector& buffer); - - /** - * Checks if compression is enabled. - * @return If compression is enabled returns true, otherwise false is returned. - */ - bool isCompressed () { if (decompress) return true; else return false; } - - /** - * Returns private AutoSeededRNG object. - * @return Point to AutoSeededRNG object. - */ -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp deleted file mode 100644 index bb1d268582e..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp +++ /dev/null @@ -1,983 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include "ne7ssh_string.h" -#include "ne7ssh_connection.h" -#include "ne7ssh.h" -#include "ne7ssh_keys.h" -#include "ne7ssh_mutex.h" - -#if defined(WIN32) || defined(__MINGW32__) -# define kill(pid,signo) raise(signo) -# define ne7ssh_thread_join(hndl,ign) WaitForSingleObject(hndl, INFINITE) -# define ne7ssh_thread_exit(sig) ExitThread(sig) -#else -# define ne7ssh_thread_create pthread_create -# define ne7ssh_thread_join pthread_join -# define ne7ssh_thread_exit pthread_exit -#endif - -using namespace Botan; -using namespace std; - -const char* ne7ssh::SSH_VERSION = "SSH-2.0-NetSieben_1.3.2"; -Ne7sshError* ne7ssh::errs = NULL; - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 -RandomNumberGenerator* ne7ssh::rng = NULL; -#endif - -#ifdef _DEMO_BUILD -const char* ne7ssh::MAC_ALGORITHMS = "none"; -const char* ne7ssh::CIPHER_ALGORITHMS = "3des-cbc"; -const char* ne7ssh::KEX_ALGORITHMS = "diffie-hellman-group1-sha1"; -const char* ne7ssh::HOSTKEY_ALGORITHMS = "ssh-dss"; -#else -const char* ne7ssh::MAC_ALGORITHMS = "hmac-md5,hmac-sha1,none"; -const char* ne7ssh::CIPHER_ALGORITHMS = "aes256-cbc,aes192-cbc,twofish-cbc,twofish256-cbc,blowfish-cbc,3des-cbc,aes128-cbc,cast128-cbc"; -const char* ne7ssh::KEX_ALGORITHMS = "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1"; -const char* ne7ssh::HOSTKEY_ALGORITHMS = "ssh-dss,ssh-rsa"; -#endif - -const char* ne7ssh::COMPRESSION_ALGORITHMS = "none"; -char *ne7ssh::PREFERED_CIPHER = 0; -char *ne7ssh::PREFERED_MAC = 0; -Ne7ssh_Mutex ne7ssh::mut; -bool ne7ssh::running = false; -bool ne7ssh::selectActive = true; - -class Locking_AutoSeeded_RNG : public Botan::RandomNumberGenerator -{ - public: - Locking_AutoSeeded_RNG() { rng = new Botan::AutoSeeded_RNG(); } - ~Locking_AutoSeeded_RNG() { delete rng; } - - void randomize(Botan::byte output[], u32bit length) - { - mutex.lock(); - rng->randomize(output, length); - mutex.unlock(); - } - - void clear() throw() - { - mutex.lock(); - rng->clear(); - mutex.unlock(); - } - - std::string name() const { return rng->name(); } - - void reseed(u32bit bits_to_collect) - { - mutex.lock(); - rng->reseed(bits_to_collect); - mutex.unlock(); - } - - void add_entropy_source(EntropySource* source) - { - mutex.lock(); - rng->add_entropy_source(source); - mutex.unlock(); - } - - void add_entropy(const Botan::byte in[], u32bit length) - { - mutex.lock(); - rng->add_entropy(in, length); - mutex.unlock(); - } - - private: - Ne7ssh_Mutex mutex; - Botan::RandomNumberGenerator* rng; -}; - - - -ne7ssh::ne7ssh() : connections(0), conCount(0) -{ - errs = new Ne7sshError(); - if (ne7ssh::running) - { - errs->push (-1, "Cannot initialize more than more instance of ne7ssh class within the same application. Aborting."); - kill (0, SIGABRT); - return; - } - init = new LibraryInitializer("thread_safe"); - ne7ssh::running = true; - allConns.conns = 0; - allConns.count = 0; - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - ne7ssh::rng = new Locking_AutoSeeded_RNG(); -#endif - -#if !defined(WIN32) && !defined(__MINGW32__) - int status = ne7ssh_thread_create (&select_thread, NULL, selectThread, (void*)this); - if (status) - { - errs->push (-1, "Failure creating a new thread."); - return; - } -#else - if ((select_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) selectThread, (LPVOID)this, 0, NULL)) == NULL) - { - errs->push (-1, "Failure creating new thread."); - return; - } -#endif - -} - -ne7ssh::~ne7ssh() -{ - uint32 i; - long ign; - - ne7ssh::running = false; - lock(); - for (i = 0; i < conCount; i++) - close(i); - unlock(); - - ne7ssh_thread_join (select_thread, (void**)&ign); - - if (conCount) - { - for (i = 0; i < conCount; i++) - delete connections[i]; - free (connections); - } - else if (connections) free (connections); - - if (ne7ssh::PREFERED_CIPHER) - { - free (ne7ssh::PREFERED_CIPHER); - ne7ssh::PREFERED_CIPHER = 0; - } - if (ne7ssh::PREFERED_MAC) - { - free (ne7ssh::PREFERED_MAC); - ne7ssh::PREFERED_MAC = 0; - } - if (errs) - { - delete (errs); - errs = 0; - } -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - if (ne7ssh::rng) - { - delete (rng); - rng = 0; - } -#endif - - delete init; - -} - -void *ne7ssh::selectThread (void *initData) -{ - ne7ssh *_ssh = (ne7ssh*) initData; - uint32 i, z; - int status = 0; - fd_set rd; - SOCKET rfds; - struct timeval waitTime; - connStruct* allConns; - bool cmdOrShell = false; - bool fdIsSet; - - while (running) - { - if (!lock()) - { - _ssh->selectDead(); - return 0; - } - allConns = _ssh->getConnetions (); - for (i = 0; i < allConns->count; i++) - { - if (allConns->conns[i]->isOpen() && allConns->conns[i]->data2Send() && !allConns->conns[i]->isSftpActive()) - allConns->conns[i]->sendData(); - } - - waitTime.tv_sec = 0; - waitTime.tv_usec = 10000; - - rfds = 0; - - FD_ZERO (&rd); - fdIsSet = false; - - for (i = 0; i < allConns->count; i++) - { - cmdOrShell = (allConns->conns[i]->isRemoteShell() || allConns->conns[i]->isCmdRunning()) ? true : false; - if (allConns->conns[i]->isOpen() && cmdOrShell) - { - rfds = rfds > allConns->conns[i]->getSocket() ? rfds : allConns->conns[i]->getSocket(); - FD_SET (allConns->conns[i]->getSocket(), &rd); - if (!fdIsSet) fdIsSet = true; - } - else if ((allConns->conns[i]->isConnected() && allConns->conns[i]->isRemoteShell()) || allConns->conns[i]->isCmdClosed()) - { - delete (allConns->conns[i]); - allConns->conns[i] = 0; - allConns->count--; - for (z = i; z < allConns->count; z++) - { - allConns->conns[z] = allConns->conns[z + 1]; - allConns->conns[z + 1] = 0; - } - _ssh->setCount (allConns->count); - i--; - } - } - if (!unlock()) - { - _ssh->selectDead(); - return 0; - } - - if (fdIsSet) - { - if (rfds) status = select(rfds + 1, &rd, NULL, NULL, &waitTime); - else status = select(rfds + 1, NULL, &rd, NULL, &waitTime); - } - else usleep (1000); - if (status == -1) - { - errs->push (-1, "Error within select thread."); - usleep (1000); - } - - if (!lock()) - { - _ssh->selectDead(); - return 0; - } - - allConns = _ssh->getConnetions (); - for (i = 0; i < allConns->count; i++) - { - if (allConns->conns[i]->isOpen() && FD_ISSET (allConns->conns[i]->getSocket(), &rd)) - allConns->conns[i]->handleData(); - } - if (!unlock()) - { - _ssh->selectDead(); - return 0; - } - } - return 0; -} - -int ne7ssh::connectWithPassword (const char *host, const int port, - const char* username, const char* password, bool shell, const int timeout, - void (*callbackFunc)(void *), void *callbackArg) -{ - int channel; - uint32 currentRecord, z; - uint32 channelID; - - - if (!lock()) return -1; - ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg); - if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*)); - else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); - connections[conCount++] = con; - allConns.count = conCount; - allConns.conns = connections; - channelID = getChannelNo(); - con->setChannelNo (channelID); - - if (!unlock()) return -1; - channel = con->connectWithPassword (channelID, host, port, username, password, shell, timeout); - - if (channel == -1) - { - if (!lock()) return -1; - for (z = 0; z < allConns.count; z++) - { - if (allConns.conns[z] == con) - { - currentRecord = z; - break; - } - } - if (z == allConns.count) - { - ne7ssh::errors()->push (-1, "Unexpected behaviour!"); - return -1; - } - - delete con; - allConns.conns[currentRecord] = 0; - allConns.count--; - for (z = currentRecord; z < allConns.count; z++) - { - allConns.conns[z] = allConns.conns[z + 1]; - allConns.conns[z + 1] = 0; - } - conCount = allConns.count; - if (!unlock()) return -1; - } - return channel; -} - -int ne7ssh::connectWithKey (const char* host, const int port, - const char* username, const char* privKeyFileName, bool shell, - const int timeout, void (*callbackFunc)(void *), void *callbackArg) -{ - int channel; - uint32 currentRecord, z; - uint32 channelID; - - if (!lock()) return -1; - ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg); - if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*) * (conCount + 1)); - else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); - connections[conCount++] = con; - allConns.count = conCount; - allConns.conns = connections; - channelID = getChannelNo(); - con->setChannelNo (channelID); - - if (!unlock()) return -1; - - channel = con->connectWithKey (channelID, host, port, username, privKeyFileName, shell, timeout); - - if (channel == -1) - { - if (!lock()) return -1; - for (z = 0; z < allConns.count; z++) - { - if (allConns.conns[z] == con) - { - currentRecord = z; - break; - } - } - if (z == allConns.count) - { - ne7ssh::errors()->push (-1, "Unexpected behaviour!"); - return -1; - } - - delete con; - allConns.conns[currentRecord] = 0; - allConns.count--; - for (z = currentRecord; z < allConns.count; z++) - { - allConns.conns[z] = allConns.conns[z + 1]; - allConns.conns[z + 1] = 0; - } - conCount = allConns.count; - if (!unlock()) return -1; - } - return channel; -} - - -bool ne7ssh::send (const char* data, int channel) -{ - uint32 i; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - connections[i]->sendData (data); - if (!unlock()) return false; - else return true; - } - } - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; -} - -bool ne7ssh::initSftp (Ne7SftpSubsystem& _sftp, int channel) -{ - uint32 i; - Ne7sshSftp *__sftp; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - __sftp = connections[i]->startSftp (); - if (!__sftp) - { - if (!unlock()) return false; - return false; - } - else - { - Ne7SftpSubsystem sftpSubsystem (__sftp); - _sftp = sftpSubsystem; - if (!unlock()) return false; - return true; - } - } - } - if (!unlock()) return false; - errs->push (-1, "Bad channel: %i specified. Cannot initialize SFTP subsystem.", channel); - return false; -} - - -bool ne7ssh::sendCmd (const char* cmd, int channel, int timeout) -{ - uint32 i; - time_t cutoff = 0; - bool status; - - if (timeout) cutoff = time(NULL) + timeout; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - status = connections[i]->sendCmd (cmd); - if (!status) - { - if (!unlock()) return false; - return false; - } - - if (!timeout) - { - while (!connections[i]->getCmdComplete()) - { - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - break; - } - if (i == conCount) - { - errs->push (-1, "Bad channel: %i specified for sending.", channel); - unlock(); - return false; - } - if (!connections[i]->getCmdComplete()) - { - if (!unlock()) return false; - usleep (10000); - if (!lock()) return false; - } - } - } - else if (timeout > 0) - { - while (!connections[i]->getCmdComplete()) - { - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - break; - } - if (i == conCount) - { - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; - } - if (!connections[i]->getCmdComplete()) - { - if (!unlock()) return false; - usleep (10000); - if (!lock()) return false; - if (!cutoff) continue; - if (time(NULL) >= cutoff) break; - } - } - } - if (!unlock()) return false; - return true; - } - } - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; -} - - -bool ne7ssh::close (int channel) -{ - uint32 i; - bool status = false; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for closing.", channel); - return false; - } - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - status = connections[i]->sendClose(); - } - errs->deleteChannel (channel); - - if (!unlock()) return false; - - return status; -} - -bool ne7ssh::waitFor (int channel, const char* str, uint32 timeSec) -{ - Botan::byte one; - const Botan::byte *carret; - const char* buffer; - size_t len = 0, carretLen = 0, str_len = 0, prevLen = 0; - time_t cutoff = 0; - bool dataChange; - - if (timeSec) cutoff = time(NULL) + timeSec; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for waiting.", channel); - return false; - } - - str_len = strlen (str); - - while (1) - { - if (!lock()) return false; - buffer = read (channel, false); - if (buffer) - { - len = getReceivedSize(channel, false); - if (cutoff && prevLen && len == prevLen) dataChange = false; - else - { - dataChange = true; - prevLen = len; - } - carret = (const Botan::byte*) buffer + len - 1; - one = *str; - carretLen = 1; - - while (carretLen <= len) - { - if ((*carret == one) && (str_len <= carretLen)) - { - if (!memcmp (carret, str, str_len)) - { - if (!unlock()) return false; - return true; - } - } - carretLen++; - carret--; - } - } - else (dataChange = false); - if (!unlock()) return false; - usleep (10000); - if (!cutoff) continue; - if (time(NULL) >= cutoff) break; - } - return false; -} - - -const char* ne7ssh::read (int channel, bool do_lock) -{ - uint32 i; - SecureVector data; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for reading.", channel); - return false; - } - if (do_lock && !lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - if (do_lock && !unlock()) return false; - return ((const char*)connections[i]->getReceived().begin()); - } - } - } - if (do_lock && !unlock()) return false; - 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 data; - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - Botan::SecureVector& received=connections[i]->getReceived(); - buffer = alloc(received.size()); - strncpy(buffer, reinterpret_cast(received.begin()), received.size()); - connections[i]->resetReceiveBuffer(); - } - break; - } - } - if (!unlock()) return false; - return buffer; -} - - -void* ne7ssh::readBinary (int channel) -{ - uint32 i; - SecureVector data; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for reading.", channel); - return false; - } - - if (!lock()) return 0; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - if (!unlock()) return 0; - return ((void*)connections[i]->getReceived().begin()); - } - } - } - if (!unlock()) return 0; - return 0; -} - - -int ne7ssh::getReceivedSize (int channel, bool do_lock) -{ - uint32 i; - int size; - - if (do_lock && !lock()) return 0; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - if (!connections[i]->getReceived().size()) - { - if (do_lock && !unlock()) return 0; - return 0; - } - else - { - size = connections[i]->getReceived().size(); - if (do_lock && !unlock()) return 0; - return (size); - } - } - } - if (do_lock && !unlock()) return 0; - return 0; -} - -uint32 ne7ssh::getChannelNo () -{ - uint32 i; - int32 channelID = 1; - - if (!conCount) - { - return channelID; - } - - for (channelID = 1; channelID != 0x7FFFFFFF; channelID++) - { - for (i = 0; i < conCount; i++) - { - if (connections[i] && (connections[i]->getChannelNo() == channelID)) - break; - } - if (i == conCount) break; - } - - if (channelID == 0x7FFFFFFF) - { - errs->push (-1, "Maximum theoretical channel count reached!"); - return 0; - } - else return channelID; -} - -void ne7ssh::setOptions (const char* prefCipher, const char* prefHmac) -{ - size_t len = 0; - - if (prefCipher) len = strlen (prefCipher); - if (!ne7ssh::PREFERED_CIPHER && len) ne7ssh::PREFERED_CIPHER = (char*) malloc (len); - else if (len) ne7ssh::PREFERED_CIPHER = (char*) realloc (ne7ssh::PREFERED_CIPHER, len); - memcpy (ne7ssh::PREFERED_CIPHER, prefCipher, len); - - len = 0; - if (prefHmac) len = strlen (prefHmac); - if (!ne7ssh::PREFERED_MAC && len) ne7ssh::PREFERED_MAC = (char*) malloc (len); - else if (len) ne7ssh::PREFERED_MAC = (char*) realloc (ne7ssh::PREFERED_MAC, len); - memcpy (ne7ssh::PREFERED_MAC, prefHmac, len); -} - -bool ne7ssh::lock () -{ - int status; - status = ne7ssh::mut.lock(); - - if (!isSelectActive()) - { - errs->push (-1, "Select thread appears to be dead."); - return false; - } - - if (status) - { - errs->push (-1, "Could not aquire a mutex lock. Error: %i.", status); - return false; - } - return true; -} - -bool ne7ssh::unlock () -{ - int status; - status = ne7ssh::mut.unlock(); - - if (!isSelectActive()) - { - errs->push (-1, "Select thread appears to be dead."); - return false; - } - - if (status) - { - errs->push (-1, "Error while releasing a mutex lock. Error: %i.", status); - return false; - } - return true; -} - -SSH_EXPORT Ne7sshError* ne7ssh::errors() -{ - return errs; -} - -bool ne7ssh::generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - ne7ssh_keys keyPair; - enum keyAlgos { DSA, RSA }; - uint8 keyAlgo; - - if (!memcmp (type, "dsa", 3)) - keyAlgo = DSA; - else if (!memcmp (type, "rsa", 3)) - keyAlgo = RSA; - - switch (keyAlgo) - { - case DSA: - if (!keySize) - return keyPair.generateDSAKeys (fqdn, privKeyFileName, pubKeyFileName); - else - return keyPair.generateDSAKeys (fqdn, privKeyFileName, pubKeyFileName, keySize); - - case RSA: - if (!keySize) - return keyPair.generateRSAKeys (fqdn, privKeyFileName, pubKeyFileName); - else - return keyPair.generateRSAKeys (fqdn, privKeyFileName, pubKeyFileName, keySize); - - default: - errs->push (-1, "The specfied key algorithm: %i not supported", keyAlgo); - return false; - } - return false; -} - -Ne7SftpSubsystem::Ne7SftpSubsystem () : inited(false), sftp(0) -{ -} - -Ne7SftpSubsystem::Ne7SftpSubsystem (Ne7sshSftp* _sftp) : inited(true), sftp((Ne7sshSftp*)_sftp) -{ -} - -Ne7SftpSubsystem::~Ne7SftpSubsystem () -{ -} - -bool Ne7SftpSubsystem::setTimeout (uint32 _timeout) -{ - if (!inited) return errorNotInited(); - sftp->setTimeout (_timeout); - return true; -} - -uint32 Ne7SftpSubsystem::openFile (const char* filename, uint8 mode) -{ - if (!inited) return errorNotInited(); - return sftp->openFile (filename, mode); -} - -uint32 Ne7SftpSubsystem::openDir (const char* dirname) -{ - if (!inited) return errorNotInited(); - return sftp->openDir (dirname); -} - -bool Ne7SftpSubsystem::readFile (uint32 fileID, uint64 offset) -{ - if (!inited) return errorNotInited(); - return sftp->readFile (fileID, offset); -} - -bool Ne7SftpSubsystem::writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 /* offset */) -{ - if (!inited) return errorNotInited(); - return sftp->writeFile (fileID, data, len); -} - -bool Ne7SftpSubsystem::closeFile (uint32 fileID) -{ - if (!inited) return errorNotInited(); - return sftp->closeFile (fileID); -} - -bool Ne7SftpSubsystem::errorNotInited () -{ - ne7ssh::errors()->push (-1, "This SFTP system has not been initialized."); - return false; -} - -bool Ne7SftpSubsystem::getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks) -{ - if (!inited) return errorNotInited(); - return sftp->getFileAttrs (attrs, filename, followSymLinks); -} - -bool Ne7SftpSubsystem::get (const char* remoteFile, FILE* localFile) -{ - if (!inited) return errorNotInited(); - return sftp->get (remoteFile, localFile); -} - -bool Ne7SftpSubsystem::put (FILE* localFile, const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->put (localFile, remoteFile); -} - -bool Ne7SftpSubsystem::rm (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->rm (remoteFile); -} - -bool Ne7SftpSubsystem::mv (const char* oldFile, const char* newFile) -{ - if (!inited) return errorNotInited(); - return sftp->mv (oldFile, newFile); -} - -bool Ne7SftpSubsystem::mkdir (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->mkdir (remoteDir); -} - -bool Ne7SftpSubsystem::rmdir (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->rmdir (remoteDir); -} - -const char* Ne7SftpSubsystem::ls (const char* remoteDir, bool longNames) -{ - if (!inited) - { - errorNotInited(); - return 0; - } - return sftp->ls (remoteDir, longNames); -} - -bool Ne7SftpSubsystem::cd (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->cd (remoteDir); -} - -bool Ne7SftpSubsystem::chmod (const char* remoteFile, const char* mode) -{ - if (!inited) return errorNotInited(); - return sftp->chmod (remoteFile, mode); -} - -bool Ne7SftpSubsystem::chown (const char* remoteFile, uint32_t uid, uint32_t gid) -{ - if (!inited) return errorNotInited(); - return sftp->chown (remoteFile, uid, gid); -} - -bool Ne7SftpSubsystem::isFile (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->isFile (remoteFile); -} - -bool Ne7SftpSubsystem::isDir (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->isDir (remoteFile); -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh.h b/src/libs/3rdparty/net7ssh/src/ne7ssh.h deleted file mode 100644 index 57cc281b902..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh.h +++ /dev/null @@ -1,521 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_H -#define NE7SSH_H - -#include - -//#include -//#include "error.h" - -#if BOTAN_VERSION_MAJOR > 1 -# error Unsupported Botan Version -#endif - -#define BOTAN_PRE_15 (BOTAN_VERSION_MINOR < 5) -#define BOTAN_PRE_18 (BOTAN_VERSION_MINOR < 8) - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 -# include -# include -#endif - -#include -#include -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -# include -# include -typedef pthread_t ne7ssh_thread_t; -#else -#include -typedef HANDLE ne7ssh_thread_t; -#endif - -#include "ne7ssh_types.h" -#include "ne7ssh_error.h" -#include "ne7ssh_mutex.h" - -#define SSH2_MSG_DISCONNECT 1 -#define SSH2_MSG_IGNORE 2 - -#define SSH2_MSG_KEXINIT 20 -#define SSH2_MSG_NEWKEYS 21 - -#define SSH2_MSG_KEXDH_INIT 30 -#define SSH2_MSG_KEXDH_REPLY 31 - -#define SSH2_MSG_SERVICE_REQUEST 5 -#define SSH2_MSG_SERVICE_ACCEPT 6 - -#define SSH2_MSG_USERAUTH_REQUEST 50 -#define SSH2_MSG_USERAUTH_FAILURE 51 -#define SSH2_MSG_USERAUTH_SUCCESS 52 -#define SSH2_MSG_USERAUTH_BANNER 53 -#define SSH2_MSG_USERAUTH_PK_OK 60 - -#define SSH2_MSG_CHANNEL_OPEN 90 -#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91 -#define SSH2_MSG_CHANNEL_OPEN_FAILURE 92 -#define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93 -#define SSH2_MSG_CHANNEL_DATA 94 -#define SSH2_MSG_CHANNEL_EXTENDED_DATA 95 -#define SSH2_MSG_CHANNEL_EOF 96 -#define SSH2_MSG_CHANNEL_CLOSE 97 -#define SSH2_MSG_CHANNEL_REQUEST 98 -#define SSH2_MSG_CHANNEL_SUCCESS 99 -#define SSH2_MSG_CHANNEL_FAILURE 100 - -class ne7ssh_connection; - -/** Structure used to store connections. Used to better sync with selectThread. */ -typedef struct { - /** Pointer to all active connections.*/ - ne7ssh_connection **conns; - /** Active connection count. */ - uint32 count; -} connStruct; - -/** definitions for Botan */ -namespace Botan -{ - class LibraryInitializer; -} - -class Ne7SftpSubsystem; - -/** -@author Andrew Useckas -*/ -class SSH_EXPORT ne7ssh -{ - private: - - static Ne7ssh_Mutex mut; - Botan::LibraryInitializer *init; - ne7ssh_connection **connections; - uint32 conCount; - static bool running; - static bool selectActive; - connStruct allConns; - - - /** - * Send / Receive thread. - *

For Internal use only - * @return Usually 0 when thread terminates - */ - static void *selectThread (void*); - - /** - * Returns the number of active channel. - * @return Active channel. - */ - uint32 getChannelNo (); - ne7ssh_thread_t select_thread; - bool connected; - - /** - * Lock the mutex. - * @return True if lock aquired. Oterwise false. - */ - static bool lock (); - - /** - * Unlock the mutext. - * @return True if the mutext successfully unlocked. Otherwise false. - */ - static bool unlock (); - static Ne7sshError* errs; - - public: -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - static Botan::RandomNumberGenerator *rng; -#endif - static const char* SSH_VERSION; - static const char* KEX_ALGORITHMS; - static const char* HOSTKEY_ALGORITHMS; - static const char* MAC_ALGORITHMS; - static const char* CIPHER_ALGORITHMS; - static const char* COMPRESSION_ALGORITHMS; - static char* PREFERED_CIPHER; - static char* PREFERED_MAC; - - /** - * Default constructor. Used to allocate required memory, as well as initializing cryptographic routines. - */ - ne7ssh(); - /** - * Destructor. - */ - ~ne7ssh(); - - /** - * Connect to remote host using SSH2 protocol, with password authentication. - * @param host Hostname or IP to connect to. - * @param port Port to connect to. - * @param username Username to use in authentication. - * @param password Password to use in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return Returns newly assigned channel ID, or -1 if connection failed. - */ - int connectWithPassword (const char* host, const int port, const char* username, - const char* password, bool shell = true, const int timeout = 0, - void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * Connect to remote host using SSH2 protocol, with publickey authentication. - *

Reads private key from a file specified, and uses it to authenticate to remote host. - * Remote side must have public key from the key pair for authentication to succeed. - * @param host Hostname or IP to connect to. - * @param port Port to connect to. - * @param username Username to use in authentication. - * @param privKeyFileName Full path to file containing private key used in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return Returns newly assigned channel ID, or -1 if connection failed. - */ - int connectWithKey (const char* host, const int port, const char* username, - const char* privKeyFileName, bool shell = true, const int timeout = 0, - void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * Retrieves a pointer to all current connections. - *

For internal use only. - * @return Returns pointer to pointers to ne7ssh_connection class, or 0 if no connection exist. - */ -// ne7ssh_connection** getConnections () { return connections; } - - connStruct* getConnetions () { return &allConns; } - - /** - * Retreives count of current connections - *

For internal use only. - * @return Returns current count of connections. - */ -// uint32 getConCount () { return conCount; } - - /** - * Sends a command string on specified channel, provided the specified channel has been previously opened through connectWithPassword() function. - * @param data Pointer to the command string to send to a channel. - * @param channel Channel to send data on. - * @return Returns true if the send was successful, otherwise false returned. - */ - bool send (const char* data, int channel); - - /** - * Can be used to send a single command and disconnect, similiar behavior to openssh when one appends a command to the end of ssh command. - * @param cmd Remote command to execute. Can be used to read files on unix with 'cat [filename]'. - * @param channel Channel to send the command. - * @param timeout How long to wait before giving up. - * @return Returns true if the send was successful, otherwise false returned. - */ - bool sendCmd (const char* cmd, int channel, int timeout); - - /** - * Closes specified channel. - * @param channel Channel to close. - * @return Returns true if closing was successful, otherwise false is returned. - */ - bool close (int channel); - - /** - * Sets connection count. - *

For internal use only. - * @param count Integer to set connection count. - */ - void setCount (uint32 count) { conCount = count; } - - /** - * Reads all data from receiving buffer on specified channel. - * @param channel Channel to read data on. - * @return Returns string read from receiver buffer or 0 if buffer is empty. - */ - 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. - * @return Returns pointer to the start of binary data or 0 if nothing received. - */ - void* readBinary (int channel); - - /** - * Returns the size of all data read. Used to read buffer passed 0x0. - * @param channel Channel number which buffer size to check. - * @return Return size of the buffer, or 0x0 if receive buffer empty. - */ - int getReceivedSize (int channel, bool do_lock=true); - - /** - * Wait until receiving buffer contains a string passed in str, or until the function timeouts as specified in timeout. - * @param channel Channel to wait on. - * @param str String to wait for. - * @param timeout Timeout in seconds. - * @return Returns true if string specified in str variable has been received, otherwise false returned. - */ - bool waitFor (int channel, const char* str, uint32 timeout=0); - - /** - * Sets prefered cipher and hmac algorithms. - *

This function as to be executed before connection functions, just after initialization of ne7ssh class. - * @param prefCipher prefered cipher algorithm string representation. Possible cipher algorithms are aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc. - * @param prefHmac preferede hmac algorithm string representation. Possible hmac algorithms are hmac-md5, hmac-sha1, none. - */ - void setOptions (const char* prefCipher, const char* prefHmac); - - - /** - * Generate key pair. - * @param type String specifying key type. Currently "dsa" and "rsa" are supported. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return Return true if keys generated and written to the files. Otherwise false is returned. - */ - bool generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 0); - - /** - * This method is used to initialize a new SFTP subsystem. - * @param _sftp Reference to SFTP subsystem to be initialized. - * @param channel Channel ID returned by one of the connect methods. - * @return True if the new subsystem successfully initialized. False on any error. - */ - bool initSftp (Ne7SftpSubsystem& _sftp, int channel); - - /** - * This method returns a pointer to the current Error collection. - * @return the Error collection - */ - static Ne7sshError* errors(); - - static bool isSelectActive() { return selectActive; } - static void selectDead() { selectActive = false; } -}; - -class Ne7sshSftp; - -/** - @author Andrew Useckas -*/ -class SSH_EXPORT Ne7SftpSubsystem -{ - private: - bool inited; - Ne7sshSftp* sftp; - -/** - * Pushes and error to the error buffer, if this subsystem has not been initialized before usage. - * @return True if the push succeeds. Otherwise false. - */ -bool errorNotInited (); - - public: - /** Structure used to store rmote file attributes. */ - typedef struct - { - uint64_t size; - uint32_t owner; - uint32_t group; - uint32_t permissions; - uint32_t atime; - uint32_t mtime; - } fileAttrs; - - /** Modes used when opening a remote file. */ - enum writeMode { READ, OVERWRITE, APPEND }; - - /** - * Default constructor. - */ - Ne7SftpSubsystem (); - - /** - * Constructor used to initialize the subsystem with a new Ne7sshSftp class instance. - * @param _sftp Ne7sshSftp class instance. - */ - Ne7SftpSubsystem (class Ne7sshSftp* _sftp); - - /** - * Default destructor. - */ - ~Ne7SftpSubsystem(); - - /** - * This method is used to set a timeout for all SFTP subsystem communications. - * @param _timeout Timeout in seconds. - * @return True if timeout set, otherwise false. - */ - bool setTimeout (uint32 _timeout); - - /** - * Low level method used to open a remote file. - * @param filename Relative or full path to the file. - * @param mode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable. - * @return Newly opened file ID or 0 if file could not be opened. - */ - uint32 openFile (const char* filename, uint8 mode); - - /** - * Low level method used to open an inode containing file entries a.k.a directory. - * @param dirname Relative or full path to the inode. - * @return Newly opened file ID or 0 if the inode could not be opened. - */ - uint32 openDir (const char* dirname); - - /** - * Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file. - * @param fileID File ID retruned by openFile() method. - * @param offset Offset. - * @return True if file content successfully read and placed in the buffer. Otherwise false. - */ - bool readFile (uint32 fileID, uint64 offset = 0); - - /** - * Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file. - * @param fileID File ID returned by openFile() method. - * @param data Pointer to a buffer containing the data. - * @param len Length of the block. - * @param offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. - * @return True if file contect successfully written. False on any error. - */ - bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0); - - /** - * Low level method used to close a file opened by using openFile() method. - * @param fileID File ID returned by openFile() method. - * @return True on success. False on any error. - */ - bool closeFile (uint32 fileID); - - /** - * This method is used to retrieve remote file attributes and place them into fileAttrs structure. - * @param attrs Reference to fileAttrs structure where retrieved attributes should be placed. - * @param filename Name of the remote file. - * @param followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false". - * @return True if the attributes successfully retrieved. Otherwise false is returned. - */ - bool getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks = true); - - - /** - * This method is used to retrieve a remote file and dump it into local file. - * @param remoteFile Full or relative path to the file on the remote side. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @return True if getting the file is succeeds. False on any error. - */ - bool get (const char* remoteFile, FILE* localFile); - - /** - * This method is used to upload a file to a remote server. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "r+" attributes in fopen function. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if putting the file succeeds. False on any error. - */ - bool put (FILE* localFile, const char* remoteFile); - - /** - * This method is used to remove a file on a remote server. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if remove succeeds. False on any error. - */ - bool rm (const char* remoteFile); - - /** - * This method is used to rename/move files. - * @param oldFile Full or relative path to an old file on the remote server. - * @param newFile Full or relative path to a new file on the remote side. - * @return True if renaming successfull. False on any error. - */ - bool mv (const char* oldFile, const char* newFile); - - /** - * This method is used to create a new directory. - * @param remoteDir Full or relative path to a new directory on the remote server. - * @return True if the directory successfully created. False on any error. - */ - bool mkdir (const char* remoteDir); - - /** - * This method is used to remove a remote directory. - * @param remoteDir Full or relative path to a directory to be removed. - * @return True if the directory successfully removed. False on any error. - */ - bool rmdir (const char* remoteDir); - - /** - * This methods is used retrieve a listing of a remote directory. - * @param remoteDir Full or relative path to a directory. - * @param longNames If set to "true" the returned string in addition to file strings will contain attributes for each file. - * @return A pointer to a string containing the directory listing. - */ - const char* ls (const char* remoteDir, bool longNames=false); - - /** - * This method is used to change the current working directory. - * @param remoteDir Full or relative path to the new working directory on the remote server. - * @return True if change of directory succedded. False on any error. - */ - bool cd (const char* remoteDir); - - /** - * This method is used for changing the permissions associated with a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param mode Mode string. It can be either a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command. - * @return True if the new permissions are succesfully applied to the remote file. False on any error. - */ - bool chmod (const char* remoteFile, const char* mode); - - /** - * This method is used to change the owner of a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param uid Numerical new owner user ID. - * @param gid Numerical new owner group ID. - * @return True if the change of ownership succeeds. False on any error. - */ - bool chown (const char* remoteFile, uint32_t uid, uint32_t gid = 0); - - /** - * This method is used to determine if a remote inode is a regular file. - * @param remoteFile Full or relative path to the remote inode. - * @return True if the remote inode is a regular file. Otherwise false. - */ - bool isFile (const char* remoteFile); - - /** - * This method is used to determine if a remote inode is a directory. - * @param remoteFile Full or relative path to the remote file. - * @return True if the remote inode is a directory. Otherwise false. - */ - bool isDir (const char* remoteFile); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp deleted file mode 100644 index 2f31e19a6d6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_transport.h" -#include "ne7ssh_channel.h" -#include "ne7ssh_session.h" -#include "ne7ssh.h" - -using namespace Botan; - -//uint32 ne7ssh_channel::channelCount = 0; - -ne7ssh_channel::ne7ssh_channel(ne7ssh_session *_session) : eof(false), closed(false), cmdComplete(false), shellSpawned(false), session(_session), channelOpened(false) -{ -} - -ne7ssh_channel::~ne7ssh_channel() -{ -} - -uint32 ne7ssh_channel::open (uint32 channelID) -{ - ne7ssh_string packet; - ne7ssh_transport *_transport = session->transport; - - packet.addChar (SSH2_MSG_CHANNEL_OPEN); - packet.addString ("session"); - packet.addInt (channelID); -// ne7ssh_channel::channelCount++; - windowSend = 0; - windowRecv = MAX_PACKET_LEN - 2400; - packet.addInt (windowRecv); - packet.addInt (MAX_PACKET_LEN); - - if (!_transport->sendPacket (packet.value())) return 0; - if (!_transport->waitForPacket (SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) - { - ne7ssh::errors()->push (-1, "New channel: %i could not be open.", channelID); - return 0; - } - if (handleChannelConfirm ()) - { - channelOpened = true; - return channelID; -// return (ne7ssh_channel::channelCount - 1); - } - else return 0; -} - -bool ne7ssh_channel::handleChannelConfirm () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - _transport->getPacket (packet); - ne7ssh_string channelConfirm (packet, 1); - uint32 field; - - // Receive Channel - field = channelConfirm.getInt(); - // Send Channel - field = channelConfirm.getInt(); - session->setSendChannel (field); - - // Window Size - field = channelConfirm.getInt(); - windowSend = field; - - // Max Packet - field = channelConfirm.getInt(); - session->setMaxPacket (field); - return true; -} - -bool ne7ssh_channel::adjustWindow (Botan::SecureVector& packet) -{ - ne7ssh_string adjustWindow (packet, 0); - ne7ssh_string newPacket; - uint32 field; - - // channel number - field = adjustWindow.getInt(); - - // add bytes to the window - field = adjustWindow.getInt(); - windowSend += field; - return true; -} - -bool ne7ssh_channel::handleEof (Botan::SecureVector& /* packet */) -{ - this->cmdComplete = true; - windowRecv = 0; - eof = true; - if (!closed) sendClose(); - closed = true; - channelOpened = false; - ne7ssh::errors()->push (session->getSshChannel(), "Remote side responded with EOF."); - return false; -} - -void ne7ssh_channel::handleClose (Botan::SecureVector& /* newPacket */) -{ - //ne7ssh_string packet; - - if (!closed) sendClose (); - windowRecv = 0; - closed = true; - channelOpened = false; -} - -bool ne7ssh_channel::handleDisconnect (Botan::SecureVector& packet) -{ - ne7ssh_string message (packet, 0); -// uint32 reasonCode = message.getInt (); - SecureVector description; - - message.getString (description); - windowSend = windowRecv = 0; - closed = true; - channelOpened = false; - - ne7ssh::errors()->push (session->getSshChannel(), "Remote Site disconnected with Error: %B.", &description); - return false; -} - -bool ne7ssh_channel::sendClose () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (closed) return false; - packet.addChar (SSH2_MSG_CHANNEL_CLOSE); - packet.addInt (session->getSendChannel()); - - if (!_transport->sendPacket (packet.value())) return false; - windowSend = 0; - windowRecv = 0; - closed = true; - return true; -} - -bool ne7ssh_channel::sendEof () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (closed) return false; - packet.addChar (SSH2_MSG_CHANNEL_EOF); - packet.addInt (session->getSendChannel()); - - if (!_transport->sendPacket (packet.value())) return false; - windowSend = 0; - windowRecv = 0; - closed = true; - return true; -} - -void ne7ssh_channel::sendAdjustWindow () -{ - uint32 len = session->getMaxPacket () - windowRecv - 2400; - ne7ssh_string packet; - ne7ssh_transport *_transport = session->transport; - - packet.addChar (SSH2_MSG_CHANNEL_WINDOW_ADJUST); - packet.addInt (session->getSendChannel()); - packet.addInt (len); - windowRecv = len; - - _transport->sendPacket (packet.value()); -} - -bool ne7ssh_channel::handleData (Botan::SecureVector& packet) -{ - ne7ssh_string handleData (packet, 0); - uint32 channelID; - SecureVector data; - - channelID = handleData.getInt(); - - if (!handleData.getString (data)) return false; - if (!data.size()) - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected."); - if (inBuffer.length()) inBuffer.chop(1); - inBuffer.addVector (data); - if (inBuffer.length()) inBuffer.addChar(0x00); - windowRecv -= data.size(); - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -bool ne7ssh_channel::handleExtendedData (Botan::SecureVector& packet) -{ - ne7ssh_string handleData (packet, 0); - uint32 channelID, dataType; - SecureVector data; - - channelID = handleData.getInt(); - dataType = handleData.getInt(); - if (dataType != 1) - { - ne7ssh::errors()->push (session->getSshChannel(), "Unable to handle received request."); - return false; - } - - if (handleData.getString (data)) - ne7ssh::errors()->push (session->getSshChannel(), "Remote side returned the following error: %B", &data); - else return false; - - windowRecv -= data.size(); - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -void ne7ssh_channel::handleRequest (Botan::SecureVector& packet) -{ - ne7ssh_string handleRequest (packet, 0); - uint32 channelID; - SecureVector field; - uint32 signal; - - channelID = handleRequest.getInt(); - handleRequest.getString (field); - if (!memcmp((char*)field.begin(), "exit-signal", 11)) - ne7ssh::errors()->push (session->getSshChannel(), "exit-signal ignored."); - else if (!memcmp((char*)field.begin(), "exit-status", 11)) - { - handleRequest.getByte(); - signal = handleRequest.getInt(); - ne7ssh::errors()->push (session->getSshChannel(), "Remote side exited with status: %i.", signal); - } - -// handleRequest.getByte(); -// handleRequest.getString (field); -} - -bool ne7ssh_channel::execCmd (const char* cmd) -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (this->shellSpawned) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote shell is running. This command cannot be executed."); - return false; - } - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("exec"); - packet.addChar (0); - packet.addString (cmd); - - if (!_transport->sendPacket (packet.value())) - return false; - - cmdComplete = false; - return true; -} - -void ne7ssh_channel::getShell () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("pty-req"); - packet.addChar (0); - packet.addString ("dumb"); - packet.addInt (80); - packet.addInt (24); - packet.addInt (0); - packet.addInt (0); - packet.addString (""); - if (!_transport->sendPacket (packet.value())) return; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("shell"); - packet.addChar (0); - if (!_transport->sendPacket (packet.value())) return; - this->shellSpawned = true; -} - -void ne7ssh_channel::receive () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 padLen; - bool notFirst = false; - short status; - - if (eof) - { - return; - } - - while ((status = _transport->waitForPacket (0, notFirst))) - { - if (status == -1) - { - eof = true; - closed = true; - channelOpened = false; - return; - } - if (!notFirst) notFirst = true; - padLen = _transport->getPacket (packet); - handleReceived (packet); - } -} - -bool ne7ssh_channel::handleReceived (Botan::SecureVector& _packet) -{ - ne7ssh_string newPacket; - Botan::byte cmd; - - newPacket.addVector (_packet); - cmd = newPacket.getByte(); - switch (cmd) - { - case SSH2_MSG_CHANNEL_WINDOW_ADJUST: - adjustWindow(newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_DATA: - return handleData (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_EXTENDED_DATA: - handleExtendedData(newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_EOF: - return handleEof (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_CLOSE: - handleClose (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_REQUEST: - handleRequest (newPacket.value()); - break; - - case SSH2_MSG_IGNORE: - break; - - case SSH2_MSG_DISCONNECT: - return handleDisconnect(newPacket.value()); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unhandled command encountered: %i.", cmd); - return false; - } - return true; -} - -void ne7ssh_channel::write (Botan::SecureVector& data) -{ - SecureVector dataBuff, outBuff, delayedBuff; - uint32 len, maxBytes, i, dataStart; - - if (delayedBuffer.length()) - { - dataBuff.set (delayedBuffer.value()); - delayedBuffer.clear(); - } - dataBuff.append (data); - - if (!windowSend) delayedBuff.set (dataBuff); - else if (windowSend < dataBuff.size()) - { - outBuff.append (dataBuff.begin(), windowSend); - delayedBuff.set (dataBuff.begin() + windowSend, dataBuff.size() - windowSend); - } - else outBuff.append (dataBuff); - - if (delayedBuff.size()) delayedBuffer.addVector (delayedBuff); - if (!outBuff.size()) return; - - len = outBuff.size(); - windowSend -= len; - - maxBytes = session->getMaxPacket(); - for (i = 0; len > maxBytes - 64; i++) - { - dataStart = maxBytes * i; - if (i) dataStart -= 64; - dataBuff.set (outBuff.begin() + dataStart, maxBytes - 64); - outBuffer.addVector (dataBuff); - len -= maxBytes - 64; - } - if (len) - { - dataStart = maxBytes * i; - if (i) dataStart -= 64; - dataBuff.set (outBuff.begin() + dataStart, len); - outBuffer.addVector (dataBuff); - inBuffer.clear(); - } -} - -void ne7ssh_channel::sendAll () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector tmpVar; - ne7ssh_string packet; - - if (!outBuffer.length() && delayedBuffer.length()) - { - tmpVar.swap(delayedBuffer.value()); - delayedBuffer.clear(); - write (tmpVar); - } - if (!outBuffer.length()) return; - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_DATA); - packet.addInt (session->getSendChannel()); - packet.addVectorField (outBuffer.value()); - - windowSend -= outBuffer.length(); - inBuffer.clear(); - if (!_transport->sendPacket (packet.value())) return; - else outBuffer.clear(); - -} - -bool ne7ssh_channel::adjustRecvWindow (int bufferSize) -{ - windowRecv -= bufferSize; - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -void ne7ssh_channel::resetReceiveBuffer() -{ - inBuffer.clear(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h deleted file mode 100644 index 6b9d0526c8b..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_CHANNEL_H -#define NE7SSH_CHANNEL_H - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_channel -{ - private: - bool eof, closed; - bool cmdComplete; - bool shellSpawned; - -// static uint32 channelCount; - ne7ssh_session *session; - ne7ssh_string inBuffer; - ne7ssh_string outBuffer; - ne7ssh_string delayedBuffer; - - /** - * This function is used to handle the 'CHANNEL_OPEN_CONFIRMATION' packet. - *

After parsing the payload, send channel ID is assigned, along with send windows size and maximum packer size. - * @return Always returns true. - */ - bool handleChannelConfirm (); - - /** - * This function is used to handle the 'WINDOWS_ADJUST' packet. - *

It's used to increase our sending window size. - * @param packet Reference to vector containing WINDOW_ADJUST packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - bool adjustWindow (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'DATA' packet. - *

It's used to parse the payload, and add received data to the buffer. - * @param packet Reference to vector containing 'DATA' packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - virtual bool handleData (Botan::SecureVector& packet); - - /** - * This function is used to handle 'EXTENDED_DATA' packet. This packet is mostly used to transmit remote side errors. - * @param packet Reference to vector containing 'EXTENDED_DATA' packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - bool handleExtendedData (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'EOF' packet. - *

It's used to close the receiving window and channel. - * @param packet Reference to vector containing EOF packet. - */ - bool handleEof (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'CLOSE' packet. - *

If the close action wasn't initiated on this end, we also send a 'CLOSE' packet to the remote side, prompting the closing of remote side's receiving channel. - * @param packet Reference to vector containing the 'CLOSE' packet. - */ - void handleClose (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'REQUEST' packet. - *

At this point only two requests are supported, namely "exit-signal" and "exit-status". For the most part we ignore this packet, which is safe to do according to SSH specs. - * @param packet Reference to vector containing the 'REQUEST' packet. - */ - void handleRequest (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'DISCONNECT' packet. - *

In normal operation we should not get this packet. Only if some serious error occurs, and makes remote side drop the connection, will this packet be received. And at that point we disconnect right away, and throw an error. - * @param packet Reference to vector containing the 'DISCONNECT' packet. - */ - bool handleDisconnect (Botan::SecureVector& packet); - - protected: - uint32 windowRecv, windowSend; - - bool channelOpened; - - /** - * Request adjustment of the send window size on the remote end, so we can receive more data. - */ - void sendAdjustWindow (); - - public: - /** - * ne7ssh_channel class consturctor. - * @param _session Pointer to ne7ssh_session. - */ - ne7ssh_channel(ne7ssh_session* _session); - - /** - * ne7ssh_channel class destructor. - */ - virtual ~ne7ssh_channel(); - - /** - * Requests 'CHANNEL_OPEN' from the remote side. - * @param channelID New receiving channel ID. - * @return Returns new channel ID, or 0 if open fails. - */ - uint32 open (uint32 channelID); - - /** - * Requests shell from remote side. Does not wait for or expect a reply. According to SSH specs that's an acceptable behavior. - */ - void getShell (); - - /** - * Executes a single command on the remote end and terminates the connection. - * @param cmd Remote command to execute. - * @return True if command if sening of a command succeded. False returned on failure. - */ - bool execCmd (const char* cmd); - - /** - * Receives new packet from remote side. This function is mostly used from selectThread. - */ - void receive (); - - /** - * Handle a packet received from remote side. - * @param _packet Reference to a newly received packet. - * @return True if the packet successfully processed. False on any error. - */ - bool handleReceived (Botan::SecureVector& _packet); - - /** - * Pushes a new command to the buffer where the selectThread will catch and send it. - * @param data Reference to vector containing a command to be added to the buffer. - */ - void write (Botan::SecureVector& data); - - /** - * Sends the entire buffer. Most often called from selectThread via ne7ssh_connection class. - */ - void sendAll (); - - /** - * Checks if there is any data waiting to be sent. Most often called from selectThread via ne7ssh_connection class. - * @return True if there is data to send, otherwise false is returned. - */ - bool data2Send () { if (outBuffer.length() || delayedBuffer.length()) return true; else return false; } - - /** - * Checks if current channel is in an open state. - * @return True if channel is open, otherwise false is returned. - */ - bool isOpen () { return channelOpened; } - - /** - * When closing a channel, initiates the closing procedure. - * @return False if sending fails. Otherwise true is returned. - */ - bool sendClose (); - - /** - * Send EOF to the remote side. - * @return True if sending succeeds, otherwise false. - */ - bool sendEof (); - - /** - * Gets last received packet. - * @return Reference to a vector containing the last received packet. - */ - Botan::SecureVector& getReceived () { return inBuffer.value(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the execution. - * @return True if execution of the command is complete. Otherwise false. - */ - bool getCmdComplete () { return cmdComplete; } - - /** - * Determines if the shell has been spawned on the remote side. - * @return True if the shell has been spawned. Otherwise false. - */ - bool isRemoteShell () { return shellSpawned; } - - /** - * Checks if receive window needs adjusting, if so send a window adjust request. - * @param bufferSize Current buffer size. - * @return False on any error, otherwise true. - */ - bool adjustRecvWindow (int bufferSize); - - /** - * Gets the current size of the receive window. - * @return Size of the revceive window. - */ - uint32 getRecvWindow () { return windowRecv; } - - /** - * Gets the current size of the send window. - * @return Size of the send window. - */ - uint32 getSendWindow () { return windowSend; } - - /** Empties the receive buffer. */ - void resetReceiveBuffer(); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp deleted file mode 100644 index 7361dba4d80..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_connection.h" -#include "ne7ssh_kex.h" -#include "ne7ssh.h" - -using namespace Botan; - -ne7ssh_connection::ne7ssh_connection(void (*callbackFunc)(void *), - void *callbackArg) - : sock (-1), thisChannel(0), sftp(0), connected(false), cmdRunning(false), - cmdClosed(false), callbackFunc(callbackFunc), callbackArg(callbackArg) -{ - session = new ne7ssh_session(); - crypto = new ne7ssh_crypt(session); - transport = new ne7ssh_transport(session); - channel = new ne7ssh_channel(session); - session->transport = transport; - session->crypto = crypto; -} - - -ne7ssh_connection::~ne7ssh_connection() -{ - delete channel; - delete transport; - delete crypto; - delete session; - - if (sftp) delete sftp; -} - -int ne7ssh_connection::connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell, int timeout) -{ - sock = transport->establish (host, port, timeout); - if (sock == -1) return -1; - - if (!checkRemoteVersion()) return -1; - if (!sendLocalVersion()) return -1; - - ne7ssh_kex kex (session); - if (!kex.sendInit()) return -1; - if (!kex.handleInit ()) return -1; - - if (!kex.sendKexDHInit()) return -1; - if (!kex.handleKexDHReply()) return -1; - - if (!kex.sendKexNewKeys()) return -1; - - if (!requestService("ssh-userauth")) return -1; - if (!authWithPassword (username, password)) return -1; - - thisChannel = channel->open(channelID); - if (!thisChannel) return -1; - - if (shell) - channel->getShell (); - - connected = true; - this->session->setSshChannel (thisChannel); - return thisChannel; -} - -int ne7ssh_connection::connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell, int timeout) -{ - sock = transport->establish (host, port, timeout); - if (sock == -1) return -1; - - if (!checkRemoteVersion()) return -1; - if (!sendLocalVersion()) return -1; - - ne7ssh_kex kex (session); - if (!kex.sendInit()) return -1; - if (!kex.handleInit ()) return -1; - - if (!kex.sendKexDHInit()) return -1; - if (!kex.handleKexDHReply()) return -1; - - if (!kex.sendKexNewKeys()) return -1; - - if (!requestService("ssh-userauth")) return -1; - if (!authWithKey (username, privKeyFileName)) return -1; - - thisChannel = channel->open(channelID); - if (!thisChannel) return -1; - - if (shell) - channel->getShell (); - - connected = true; - - this->session->setSshChannel (thisChannel); - return thisChannel; -} - - -bool ne7ssh_connection::requestService (const char* service) -{ - - ne7ssh_string packet; - packet.addChar (SSH2_MSG_SERVICE_REQUEST); - packet.addString (service); - - if (!transport->sendPacket (packet.value())) return false; - if (!transport->waitForPacket (SSH2_MSG_SERVICE_ACCEPT)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Service request failed."); - return false; - } - return true; -} - -bool ne7ssh_connection::authWithPassword (const char* username, const char* password) -{ - short _cmd; - ne7ssh_string packet; - SecureVector response; - Botan::byte canContinue; - SecureVector methods; - - - packet.addChar (SSH2_MSG_USERAUTH_REQUEST); - packet.addString (username); - packet.addString ("ssh-connection"); - packet.addString ("password"); - packet.addChar ('\0'); - packet.addString (password); - - if (!transport->sendPacket (packet.value())) return false; - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) - { - return true; - } - else if (_cmd == SSH2_MSG_USERAUTH_BANNER) - { - packet.clear(); - packet.addString (password); - if (!transport->sendPacket (packet.value())) return false; - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) return true; - } - - if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported authentication methods: %B", &methods); - return false; - } - else return false; -} - -bool ne7ssh_connection::authWithKey (const char* username, const char* privKeyFileName) -{ - ne7ssh_keys keyPair; - ne7ssh_string packet, packetBegin, packetEnd; - SecureVector pubKeyBlob, sigBlob; - if (!keyPair.getKeyPairFromFile (privKeyFileName)) - return false; - short _cmd; - SecureVector response; - Botan::byte canContinue; - SecureVector methods; - - packetBegin.addChar (SSH2_MSG_USERAUTH_REQUEST); - packetBegin.addString (username); - packetBegin.addString ("ssh-connection"); - packetBegin.addString ("publickey"); - - switch (keyPair.getKeyAlgo()) - { - case ne7ssh_keys::DSA: - packetEnd.addString ("ssh-dss"); - break; - - case ne7ssh_keys::RSA: - packetEnd.addString ("ssh-rsa"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "The key algorithm: %i is not supported.", keyPair.getKeyAlgo()); - return false; - } - pubKeyBlob = keyPair.getPublicKeyBlob(); - if (!pubKeyBlob.size()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invallid public key."); - return false; - } - packetEnd.addVectorField (pubKeyBlob); - - packet.addVector (packetBegin.value()); - packet.addChar (0x0); - packet.addVector (packetEnd.value()); - - if (!transport->sendPacket (packet.value())) return false; - - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported methods are: %B", &methods); - return false; - } - else if (_cmd != SSH2_MSG_USERAUTH_PK_OK) return false; - - packet.clear(); - packet.addVector (packetBegin.value()); - packet.addChar (0x1); - packet.addVector (packetEnd.value()); - - sigBlob = keyPair.generateSignature (session->getSessionID(), packet.value()); - if (!sigBlob.size()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure while generating the signature."); - return false; - } - - packet.addVectorField (sigBlob); - if (!transport->sendPacket (packet.value())) return false; - - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) return true; - else if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported methods are: %B", &methods); - return false; - } - else return false; -} - -bool ne7ssh_connection::checkRemoteVersion () -{ - SecureVector remoteVer, tmpVar; - Botan::byte* _pos; - if (!transport->receive (remoteVer)) return false; - - if (remoteVer.size() < 4 || \ - (memcmp (remoteVer.begin(), "SSH-1.99", 8) && memcmp (remoteVer.begin(), "SSH-2", 5))) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote SSH version is not supported. Remote version: %B.", &remoteVer); - return false; - } - else - { - _pos = remoteVer.end() - 1; - while (*_pos == '\r' || *_pos == '\n') _pos--; - tmpVar.set (remoteVer.begin(), _pos - remoteVer.begin() + 1); - session->setRemoteVersion (tmpVar); - return true; - } -} - -bool ne7ssh_connection::sendLocalVersion () -{ - SecureVector localVer ((const Botan::byte*)ne7ssh::SSH_VERSION, (uint32_t) strlen(ne7ssh::SSH_VERSION)); - session->setLocalVersion (localVer); - localVer.append ((const Botan::byte*)"\r\n", 2); - - if (!transport->send (localVer)) return false; - else return true; -} - -void ne7ssh_connection::handleData () -{ - channel->receive(); - if (callbackFunc && getReceived().size() > 0) - callbackFunc(callbackArg); -} - -void ne7ssh_connection::sendData (const char* data) -{ - SecureVector _cmd ((const Botan::byte *) data, (uint32_t) strlen(data)); - channel->write (_cmd); -} - -bool ne7ssh_connection::sendCmd (const char* cmd) -{ - cmdRunning = true; - return channel->execCmd(cmd); -} - -Ne7sshSftp* ne7ssh_connection::startSftp () -{ - if (channel->isRemoteShell()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote shell is running. SFTP subsystem cannot be started."); - return 0; - } - sftp = new Ne7sshSftp (session, channel); - - if (sftp->init()) return sftp; - else - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure to launch remote sftp subsystem."); - return 0; - } - - return 0; -} - -bool ne7ssh_connection::sendClose () -{ - bool status; - if (channel->isOpen() && !isSftpActive()) return (channel->sendClose ()); - else if (getCmdComplete()) cmdClosed=true; - if (isSftpActive()) - { - delete sftp; - sftp = 0; - status = channel->sendClose (); - return status; - } - else return false; -} - -bool ne7ssh_connection::isSftpActive () -{ - if (sftp) return true; - else return false; -} - -void ne7ssh_connection::resetReceiveBuffer() -{ - channel->resetReceiveBuffer(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h deleted file mode 100644 index 182b48294fc..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h +++ /dev/null @@ -1,238 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_CONNECTION_H -#define NE7SSH_CONNECTION_H - -#include "ne7ssh_transport.h" -#include "ne7ssh_session.h" -#include "ne7ssh_channel.h" -#include "ne7ssh_keys.h" -#include "crypt.h" -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" -#include "ne7ssh_sftp.h" - - -/** -@author Andrew Useckas -*/ -class ne7ssh_connection -{ - private: - SOCKET sock; - int thisChannel; - ne7ssh_crypt *crypto; - ne7ssh_transport *transport; - ne7ssh_session *session; - ne7ssh_channel *channel; - Ne7sshSftp* sftp; - - Ne7ssh_Mutex mut; - bool connected; - bool cmdRunning; - bool cmdClosed; - - void (*callbackFunc)(void *); - void *callbackArg; - - /** - * Checks if remote side is returning a correctly formated SSH version string, and makes sure that version 2 of SSH protocol is supported by the remote side. - * @return False if version string is malformed, or version 2 is not supported, otherwise true is returned. - */ - bool checkRemoteVersion (); - - /** - * Sends local version string. - * @return Returns false is there any communication errors occur, otherwise true is returned. - */ - bool sendLocalVersion (); - - /** - * Sends an SSH service request, waits for 'SERVICE_ACCEPT' packet. - * @param service pointer to a string containing the requested SSH service. For example "ssh-userauth". - * @return True If SERVICE_ACCEPT packet was received, otherwise false is returned. - */ - bool requestService (const char* service); - - /** - * Sends an authentication request of "password" type. Waits for packet 'USERAUTH_SUCESS'. - * @param username Username used for authentication. - * @param password Password used for authentication. - * @return True if authentication was successful, otherwise false is returned. - */ - bool authWithPassword (const char* username, const char* password); - - /** - * Sends a test message to check if "publickey" authentication is allowed fo specified user. - * If succesfull proceeds wtih generating a signature and sending real authentication packet - * of "publickey" type. - * @param username Username used for authentication. - * @param privKeyFileName Full path to file containing private key to be used in authentication. - * @return True if authentication was successful, otherwise false is returned. - */ - bool authWithKey (const char* username, const char* privKeyFileName); - - public: - /** - * ne7ssh_connection class constructor. - */ - ne7ssh_connection(void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * ne7ssh_connection class destructor. - */ - ~ne7ssh_connection(); - - /** - * Connects to a remote host using SSH protocol version 2, with password based authentication. - * @param channelID ID of the new channel. - * @param host Hostname / IP of the remote host. - * @param port Connection port. - * @param username Username to use in the authentication. - * @param password Password to use in the authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return A newly assigned channel ID, or -1 if connection failed. - */ - int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell = true, int timeout = 0); - - /** - * Connects to a remote host using SSH protocol version 2, with publickey based authentication. - * @param channelID ID assigned to the new channel. - * @param host Hostname / IP of the remote host. - * @param port Connection port. - * @param username Username to use in the authentication. - * @param privKeyFileName Full path to file containing private key to be used in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return A newly assigned channel ID, or -1 if connection failed. - */ - int connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell = true, int timeout = 0); - - /** - * Retrieves the tcp socket number. - * @return Socket, or -1 if not connected. - */ - SOCKET getSocket () { return sock; } - - /** - * When new data arrives, and is available for reading, this function is called from selectThread to handle it. - */ - void handleData (); - - /** - * This function is used to write commands to the buffer, later to be sent to the remote site for execution. - * @param data Pointer to a string, containing command to be written to the buffer. - */ - void sendData (const char* data); - - /** - * Sets the current SSH channel number. - */ - void setChannelNo (int channelID) { thisChannel = channelID; } - - /** - * Retrieves the current SSH channel. - * @return Returns SSH channel or -1 if not connected. - */ - int getChannelNo () { return thisChannel; } - - /** - * Checks for the data in the send buffer. - * @return True is there is data to send, otherwise false. - */ - bool data2Send () { return channel->data2Send(); } - - /** - * Sends the content of the buffer., - *

Usually used after data2Send returns true, executed by selectThread. - */ - void sendData () { channel->sendAll (); } - - /** - * - * @param cmd - * @return - */ - bool sendCmd (const char* cmd); - - /** - * This function is used to close the current connection. - *

First closes the channel, and then the connection itself. - * @return True, if packet sent successfully, otherwise false is returned. - */ - bool sendClose (); - - /** - * Checks if channel is open. - * @return True if channel is open, otherwise false is returned. - */ - bool isOpen () { return channel->isOpen(); } - - /** - * Checks if process is connected and authenticated to the remote side. - * @return True if connected, otherwise false is returned. - */ - bool isConnected () { return connected; } - - /** - * Retrieves the last received packet. - * @return A reference to a buffer containing the last received packet. - */ - Botan::SecureVector& getReceived () { return channel->getReceived(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the xecution. - * @return True if execution of the command is complete. Otherwise false. - */ - bool getCmdComplete() { return channel->getCmdComplete(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when the user requested a close() on the channel. - * @return True if the user requested to close the channel. Otherwise false. - */ - bool isCmdClosed() { return cmdClosed; } - - /** - * Determines if the shell has been spawned on the remote side. - * @return True if the shell has been spawned. Otherwise false. - */ - bool isRemoteShell () { return channel->isRemoteShell(); } - - /** - * Checks if current connection is executing a single command, without a shell. - * @return True if a single command is running. Otherwise false. - */ - bool isCmdRunning () { return cmdRunning; } - - /** - * Starts a new sftp subsystem. - * @return Returns a pointer to the newly started Ne7sshSftp instance. - */ - Ne7sshSftp* startSftp (); - - /** - * Checks if SFTP subsystem is active on the current connection. - * @return True if SFTP subsystem is active, otherwise false. - */ - bool isSftpActive (); - - /** Empties this connection's receive buffer. */ - void resetReceiveBuffer(); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp deleted file mode 100644 index acf848bfbe0..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_error.h" -#include -#include -#include -#include "stdarg.h" -#include "ne7ssh.h" - -using namespace Botan; -Ne7ssh_Mutex Ne7sshError::mut; - -Ne7sshError::Ne7sshError() : memberCount(0), ErrorBuffer(0) -{ - -} - -Ne7sshError::~Ne7sshError() -{ - uint16 i; - - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->errorStr) free (ErrorBuffer[i]->errorStr); - free (ErrorBuffer[i]); - } - free (ErrorBuffer); -} - - -bool Ne7sshError::push (int32 channel, const char* format, ...) -{ - va_list args; - char *s; - char* errStr = 0; - uint32 len = 0, msgLen = 0, _pos = 0; - bool isArg = false; - bool isUnsigned = false; - char converter[21]; - SecureVector *secVec; - int32 i; - - if (channel < -1 || !format) - return false; - - converter[0] = 0x00; - len = strlen (format); - - va_start (args, format); - errStr = (char*) malloc (len + 1); - - do - { - if (*format == '%' || isArg) - { - switch (*format) - { - case '%': - isArg = true; - break; - - case 'u': - isUnsigned = true; - break; - - case 's': - s = va_arg (args, char*); - msgLen = strlen (s); - if (msgLen > MAX_ERROR_LEN) msgLen = MAX_ERROR_LEN; - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), s, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'B': - secVec = va_arg (args, SecureVector*); - msgLen = secVec->size(); - if (msgLen > MAX_ERROR_LEN) msgLen = MAX_ERROR_LEN; - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), secVec->begin(), msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'l': - case 'd': - case 'i': - i = va_arg (args, int32); - if (isUnsigned) sprintf (converter, "%u", i); - else sprintf (converter, "%d", i); - msgLen = strlen (converter); - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), converter, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'x': - i = va_arg (args, int32); - sprintf (converter, "%x", i); - msgLen = strlen (converter); - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), converter, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - } - } - else errStr[_pos++] = *format; - - } while (*format++); - - va_end (args); - - if (!lock()) - { - free(errStr); - return false; - } - if (!memberCount) - { - ErrorBuffer = (Error**) malloc (sizeof(Error*)); - ErrorBuffer[0] = (Error*) malloc (sizeof(Error)); - } - else - { - ErrorBuffer = (Error**) realloc (ErrorBuffer, sizeof(Error*) * (memberCount + 1)); - ErrorBuffer[memberCount] = (Error*) malloc (sizeof(Error)); - } - - ErrorBuffer[memberCount]->channel = channel; - ErrorBuffer[memberCount]->errorStr = errStr; - memberCount++; - if (!unlock()) return false; - return true; -} - -const char* Ne7sshError::pop () -{ - return pop(-1); -} - -const char* Ne7sshError::pop (int32 channel) -{ - uint16 i; - int32 recID = -1; - const char* result = 0; - uint32 len; - - if (!memberCount) return 0; - if (!lock()) return false; - - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->channel == channel) - { - recID = i; - result = ErrorBuffer[i]->errorStr; - } - } - if (recID < 0) - { - unlock(); - return 0; - } - - if (result) - { - len = strlen (result) < MAX_ERROR_LEN ? strlen (result) : MAX_ERROR_LEN; - memcpy (popedErr, result, len + 1); - deleteRecord (recID); - } - else - { - unlock(); - return 0; - } - if (!unlock()) return false; - - return popedErr; -} - -bool Ne7sshError::deleteRecord (uint16 recID) -{ - uint16 i; - - if (ErrorBuffer[recID] && ErrorBuffer[recID]->errorStr) free (ErrorBuffer[recID]->errorStr); - else return false; - free (ErrorBuffer[recID]); - ErrorBuffer[recID] = 0; - for (i = recID + 1; i < memberCount; i++) - { - ErrorBuffer[i - 1] = ErrorBuffer[i]; - } - memberCount--; - return true; -} - - -bool Ne7sshError::deleteCoreMsgs () -{ - return deleteChannel(-1); -} - -bool Ne7sshError::deleteChannel (int32 channel) -{ - uint16 i, offset=0; - - if (!lock()) return false; - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->channel == channel) - { - if (ErrorBuffer[i]->errorStr) free (ErrorBuffer[i]->errorStr); - free (ErrorBuffer[i]); - offset++; - } - else if (offset) ErrorBuffer[i - offset] = ErrorBuffer[i]; - } - memberCount -= offset; - if (!unlock()) return false; - return true; -} - -bool Ne7sshError::lock () -{ - int status; - status = Ne7sshError::mut.lock(); - if (status) - { - /// FIXME possible infinite loop - ne7ssh::errors()->push (-1, "Could not aquire a mutex lock. Error: %i.", status); - usleep (1000); - return false; - } - return true; -} - -bool Ne7sshError::unlock () -{ - int status; - status = Ne7sshError::mut.unlock(); - if (status) - { - ne7ssh::errors()->push (-1, "Error while releasing a mutex lock. Error: %i.", status); - return false; - } - return true; -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h deleted file mode 100644 index 6ed167ea945..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_ERROR_H -#define NE7SSH_ERROR_H - -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -#endif - -#define MAX_ERROR_LEN 500 - -#include "ne7ssh_types.h" -#include "ne7ssh_mutex.h" - -/** - @author Andrew Useckas -*/ -class SSH_EXPORT Ne7sshError -{ - private: - uint16 memberCount; - char popedErr[MAX_ERROR_LEN + 1]; - static Ne7ssh_Mutex mut; - - /** - * Structure for storing error messages. - */ - struct Error - { - int32 channel; - char* errorStr; - } **ErrorBuffer; - - /** - * Delete a single error message. - * @param recID Position within the array. - * @return True on success, false on failure. - */ - bool deleteRecord (uint16 recID); - - /** - * Lock the mutex. - * @return True if lock aquired. Oterwise false. - */ - static bool lock (); - - /** - * Unlock the mutext. - * @return True if the mutext successfully unlocked. Otherwise false. - */ - static bool unlock (); - - public: - /** - * Ne7sshError constructor. - */ - Ne7sshError(); - - /** - * Ne7sshError destructor. - */ - ~Ne7sshError(); - - /** - * Pushes a new error message into the stack. - * @param channel Specifies the channel to bind the error message to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @param format Specifies the error message followed by argument in printf format. The following formatting characters are supported: %s,%d,%i,%l,%x. Modifier %u can be used together with decimal to specify an unsigned variable. Returns null if no there are no erros in the Core context. - * @return True on success, false on failure. - */ - bool push (int32 channel, const char* format, ...); - - /** - * Pops an error message from the Core context. - * @return The last error message in the Core context. The message is removed from the stack. - */ - const char* pop (); - - /** - * Pops an error message from the Channel context. - * @param channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @return The last error message in the Channel context. The message is removed from the stack. Returns null if no there are no erros in the Channel context. - */ - const char* pop (int32 channel); - - /** - * Removes all error messages within Core context from the stack. - * @return True on success, false on failure. - */ - bool deleteCoreMsgs (); - - /** - * Removes all error messages within Channel context from the stack. - * @param channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @return True on succes, false on failure. - */ - bool deleteChannel (int32 channel); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp deleted file mode 100644 index c0bfc413caa..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_kex.h" -#include "ne7ssh.h" -#include - -using namespace Botan; - -ne7ssh_kex::ne7ssh_kex(ne7ssh_session* _session) : session(_session) -{ -} - -ne7ssh_kex::~ne7ssh_kex() -{ -} - -void ne7ssh_kex::constructLocalKex() -{ - Botan::byte random[16]; - ne7ssh_string myCiphers (ne7ssh::CIPHER_ALGORITHMS, 0); - ne7ssh_string myMacs (ne7ssh::MAC_ALGORITHMS, 0); - SecureVector tmpCiphers, tmpMacs; - char* cipher, *hmac; - size_t len; - - localKex.clear(); - localKex.addChar (SSH2_MSG_KEXINIT); - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - Botan::Global_RNG::randomize (random, 16); -#else - ne7ssh::rng->randomize (random, 16); -#endif - - localKex.addBytes (random, 16); - localKex.addString (ne7ssh::KEX_ALGORITHMS); - localKex.addString (ne7ssh::HOSTKEY_ALGORITHMS); - - if (ne7ssh::PREFERED_CIPHER) - { - myCiphers.split (','); - myCiphers.resetParts(); - - while ((cipher = myCiphers.nextPart())) - { - len = strlen (cipher); - if (!memcmp (cipher, ne7ssh::PREFERED_CIPHER, len)) Ciphers.append ((Botan::byte*)cipher, (uint32_t) len); - else - { - tmpCiphers.append (','); - tmpCiphers.append ((Botan::byte*)cipher, (uint32_t) len); - } - } - } - if (Ciphers.size()) Ciphers.append (tmpCiphers); - else Ciphers.set (myCiphers.value()); -// Ciphers.append (&null_byte, 1); - - if (ne7ssh::PREFERED_MAC) - { - myMacs.split (','); - myMacs.resetParts(); - - while ((hmac = myMacs.nextPart())) - { - len = strlen (hmac); - if (!memcmp (hmac, ne7ssh::PREFERED_MAC, len)) Hmacs.append ((Botan::byte*)hmac, (uint32_t) len); - else - { - tmpMacs.append (','); - tmpMacs.append ((Botan::byte*)hmac, (uint32_t) len); - } - } - } - if (Hmacs.size()) Hmacs.append (tmpMacs); - else Hmacs.set (myMacs.value()); -// Hmacs.append (&null_byte, 1); - - localKex.addVectorField (Ciphers); - localKex.addVectorField (Ciphers); - localKex.addVectorField (Hmacs); - localKex.addVectorField (Hmacs); - localKex.addString (ne7ssh::COMPRESSION_ALGORITHMS); - localKex.addString (ne7ssh::COMPRESSION_ALGORITHMS); - localKex.addInt (0); - localKex.addInt (0); - localKex.addChar ('\0'); - localKex.addInt (0); -} - - -bool ne7ssh_kex::sendInit () -{ - ne7ssh_transport *_transport; - - if (!session->transport) - { - ne7ssh::errors()->push (session->getSshChannel(), "No transport. Cannot initialize key exchange."); - return false; - } - _transport = session->transport; - - constructLocalKex(); - - if (!_transport->sendPacket (localKex.value())) return false; - if (!_transport->waitForPacket (SSH2_MSG_KEXINIT)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange init reply"); - return false; - } - - return true; -} - -bool ne7ssh_kex::handleInit () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - SecureVector packet; - uint32 padLen = _transport->getPacket (packet); - ne7ssh_string remoteKex (packet, 17); - SecureVector algos; - SecureVector agreed; - - if (!_transport || !_crypto) return false; - remotKex.clear(); - remotKex.addBytes (packet.begin(), packet.size() - padLen - 1); - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::KEX_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible key exchange algorithms."); - return false; - } - if (!_crypto->negotiatedKex (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::HOSTKEY_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible Hostkey algorithms."); - return false; - } - if (!_crypto->negotiatedHostkey (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Ciphers.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible cryptographic algorithms."); - return false; - } - if (!_crypto->negotiatedCryptoC2s (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Ciphers.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible cryptographic algorithms."); - return false; - } - if (!_crypto->negotiatedCryptoS2c (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Hmacs.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible HMAC algorithms."); - return false; - } - if (!_crypto->negotiatedMacC2s (agreed)) return false; - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Hmacs.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible HMAC algorithms."); - return false; - } - if (!_crypto->negotiatedMacS2c (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::COMPRESSION_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible compression algorithms."); - return false; - } - if (!_crypto->negotiatedCmprsC2s (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::COMPRESSION_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible compression algorithms."); - return false; - } - if (!_crypto->negotiatedCmprsS2c (agreed)) return false; - - return true; -} - -bool ne7ssh_kex::sendKexDHInit () -{ - ne7ssh_string dhInit; - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - BigInt publicKey; - SecureVector eVector; - - if (!_crypto->getKexPublic (publicKey)) return false; - - dhInit.addChar (SSH2_MSG_KEXDH_INIT); - dhInit.addBigInt (publicKey); - ne7ssh_string::bn2vector (eVector, publicKey); - e.clear(); - e.addVector (eVector); - - if (!_transport->sendPacket (dhInit.value())) return false; - if (!_transport->waitForPacket (SSH2_MSG_KEXDH_REPLY)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange dh reply."); - return false; - } - return true; -} - -bool ne7ssh_kex::handleKexDHReply () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - SecureVector packet; - _transport->getPacket (packet); - ne7ssh_string remoteKexDH (packet, 1); - SecureVector field, fVector, hSig, kVector, hVector; - BigInt publicKey; - - if (!remoteKexDH.getString (field)) return false; - hostKey.clear(); - hostKey.addVector (field); - - if (!remoteKexDH.getBigInt (publicKey)) return false; - ne7ssh_string::bn2vector (fVector, publicKey); - f.clear(); - f.addVector (fVector); - - if (!remoteKexDH.getString (hSig)) return false; - - if (!_crypto->makeKexSecret (kVector, publicKey)) return false; - k.clear(); - k.addVector (kVector); - - makeH (hVector); - if (hVector.is_empty()) return false; - if (!_crypto->isInited()) session->setSessionID (hVector); - - if (!_crypto->verifySig (hostKey.value(), hSig)) return false; - - return true; -} - -bool ne7ssh_kex::sendKexNewKeys () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string newKeys; - - if (!_transport->waitForPacket (SSH2_MSG_NEWKEYS)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange newkeys reply."); - return false; - } - - newKeys.addChar (SSH2_MSG_NEWKEYS); - if (!_transport->sendPacket (newKeys.value())) return false; - - if (!_crypto->makeNewKeys()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not make keys."); - return false; - } - - return true; -} - - -void ne7ssh_kex::makeH (Botan::SecureVector &hVector) -{ - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string hashBytes; - - hashBytes.addVectorField (session->getLocalVersion()); - hashBytes.addVectorField (session->getRemoteVersion()); - hashBytes.addVectorField (localKex.value()); - hashBytes.addVectorField (remotKex.value()); - hashBytes.addVectorField (hostKey.value()); - hashBytes.addVectorField (e.value()); - hashBytes.addVectorField (f.value()); - hashBytes.addVectorField (k.value()); - - _crypto->computeH (hVector, hashBytes.value()); -} - - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h deleted file mode 100644 index cd9167dd4b2..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_KEX_H -#define NE7SSH_KEX_H - -#include "ne7ssh_types.h" -#include "ne7ssh_session.h" -#include "ne7ssh_string.h" -#include "ne7ssh_transport.h" -#include "crypt.h" - -/** -@author Andrew Useckas -*/ -class ne7ssh_kex -{ - private: - ne7ssh_session* session; - ne7ssh_string localKex; - ne7ssh_string remotKex; - ne7ssh_string hostKey; - ne7ssh_string e; - ne7ssh_string f; - ne7ssh_string k; - Botan::SecureVector Ciphers, Hmacs; - - /** - * Constructs local 'KEX_INIT' payload - */ - void constructLocalKex(); - - /** - * Computes H hash, from concated values of the local SSH version string, remote SSH version string, local KEX_INIT payload, remote KEX_INIT payload, host key, e, f and k BigInt values. - * @param hVector Reference to a vecor where H value will be stored. - */ - void makeH (Botan::SecureVector& hVector); - - public: - /** - * ne7ssh_kex class constructor. - * @param _session Pointer to ne7ssh_session variable. - */ - ne7ssh_kex(ne7ssh_session* _session); - - /** - * ne7ssh_kex class destructor. - */ - ~ne7ssh_kex(); - - /** - * Sends 'KEX_INIT' packet and waits for 'KEX_INIT' reply. - * @return True if successful, otherwise false is returned. - */ - bool sendInit(); - - /** - * After sendInit() function returnes true, this functions is used to parse the received 'KEX_INIT' packet. - *

Used to agree on cipher, hmac, etc. algorithms used in communication between client and server. - * @return True if parsing was succesful and all algorithms agreed upon, otherwise false is returned. - */ - bool handleInit(); - - /** - * Sends 'KEXDH_INIT' packet and waits for 'KEXDH_REPLY'. - * @return True if reply is received, otherwise false is returned. - */ - bool sendKexDHInit(); - - /** - * After sendKexDHInit() returns true, this function is used to handle the received 'KEXDH_REPLY'. - *

This is the function to create the shared secret K. It also extracts the host key and signature fields from the payload, generates DSA/RSA keys, and verifies the signature. - * @return True if all operations are completed successfully, otherwise false is returned. - */ - bool handleKexDHReply(); - - /** - * This function waits for 'NEWKEYS' packet from the remote host. - *

Once the packet is received, local 'NEWKEYS' packet is sent, all encryption and hmac keys are generated and encrypted communication is established. - * @return True if all operations are successful, otherwise false is returned. - */ - bool sendKexNewKeys(); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp deleted file mode 100644 index 2e20fe57b98..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_keys.h" -#include "ne7ssh.h" -#include -#include -#include -#include - -using namespace std; -using namespace Botan; - -const u32bit PIPE_DEFAULT_MESSAGE = -1; - -ne7ssh_keys::ne7ssh_keys() : dsaPrivateKey(0), rsaPrivateKey(0), keyAlgo(0) -{ -} - - -ne7ssh_keys::~ne7ssh_keys() -{ - if (dsaPrivateKey) delete dsaPrivateKey; - if (rsaPrivateKey) delete rsaPrivateKey; -} - -bool ne7ssh_keys::generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - RSA_PrivateKey *rsaPrivKey; - BigInt e, n, d, p, q; - BigInt dmp1, dmq1, iqmp; - ne7ssh_string pubKeyBlob; - FILE *privKeyFile, *pubKeyFile; - std::string privKeyEncoded; - DER_Encoder encoder; - - if (keySize > MAX_KEYSIZE) - { - ne7ssh::errors()->push (-1, "Specified key size: '%i' is larger than allowed maximum.", keySize); - return false; - } - - if (keySize < 1024) - { - ne7ssh::errors()->push (-1, "Key Size: '%i' is too small. Use at least 1024 key size for RSA keys.", keySize); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - rsaPrivKey = new RSA_PrivateKey (keySize); -#else - rsaPrivKey = new RSA_PrivateKey (*ne7ssh::rng, keySize); -#endif - privKeyFile = fopen (privKeyFileName, "w"); - - e = rsaPrivKey->get_e(); - n = rsaPrivKey->get_n(); - - d = rsaPrivKey->get_d(); - p = rsaPrivKey->get_p(); - q = rsaPrivKey->get_q(); - - dmp1 = d % (p - 1); - dmq1 = d % (q - 1); - iqmp = inverse_mod (q, p); - - pubKeyBlob.addString ("ssh-rsa"); - pubKeyBlob.addBigInt (e); - pubKeyBlob.addBigInt (n); - - Pipe base64it (new Base64_Encoder); - base64it.process_msg(pubKeyBlob.value()); - - SecureVector pubKeyBase64 = base64it.read_all (PIPE_DEFAULT_MESSAGE); - - pubKeyFile = fopen (pubKeyFileName, "w"); - - if (!pubKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where public key is stored. Filename: %s", pubKeyFileName); - delete rsaPrivKey; - return false; - } - - if ((!fwrite ("ssh-rsa ", 8, 1, pubKeyFile)) || - (!fwrite (pubKeyBase64.begin(), (size_t) pubKeyBase64.size(), 1, pubKeyFile)) || - (!fwrite (" ", 1, 1, pubKeyFile)) || - (!fwrite (fqdn, strlen(fqdn), 1, pubKeyFile)) || - (!fwrite ("\n", 1, 1, pubKeyFile))) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", pubKeyFileName); - delete rsaPrivKey; - return false; - } - - fclose (pubKeyFile); - -#if (BOTAN_PRE_15) - encoder.start_sequence(); - DER::encode (encoder, 0U); - DER::encode (encoder, n); - DER::encode (encoder, e); - DER::encode (encoder, d); - DER::encode (encoder, p); - DER::encode (encoder, q); - DER::encode (encoder, dmp1); - DER::encode (encoder, dmq1); - DER::encode (encoder, iqmp); - encoder.end_sequence(); - - privKeyEncoded = PEM_Code::encode (encoder.get_contents(), "RSA PRIVATE KEY"); -#else - privKeyEncoded = PEM_Code::encode ( - DER_Encoder().start_cons (SEQUENCE) - .encode(0U) - .encode(n) - .encode(e) - .encode(d) - .encode(p) - .encode(q) - .encode(dmp1) - .encode(dmq1) - .encode(iqmp) - .end_cons() - .get_contents(), "RSA PRIVATE KEY"); -#endif - - if (!privKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where the private key is stored. Filename: %s.", privKeyFileName); - delete rsaPrivKey; - return false; - } - - if (!fwrite (privKeyEncoded.c_str(), privKeyEncoded.length(), 1, privKeyFile)) - { - ne7ssh::errors()->push (-1, "IO error while writting to file: %s.", privKeyFileName); - delete rsaPrivKey; - return false; - } - fclose (privKeyFile); - - delete rsaPrivKey; - return true; -} - -bool ne7ssh_keys::generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - DER_Encoder encoder; - BigInt p, q, g, y, x; - ne7ssh_string pubKeyBlob; - FILE *privKeyFile, *pubKeyFile; - std::string privKeyEncoded; - - if (keySize != 1024) - { - ne7ssh::errors()->push (-1, "DSA keys must be 1024 bits."); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - DL_Group dsaGroup (keySize, DL_Group::DSA_Kosherizer); - DSA_PrivateKey privDsaKey (dsaGroup); -#else - DL_Group dsaGroup (*ne7ssh::rng, Botan::DL_Group::DSA_Kosherizer, keySize); - DSA_PrivateKey privDsaKey (*ne7ssh::rng, dsaGroup); -#endif - - DSA_PublicKey pubDsaKey = privDsaKey; - - p = dsaGroup.get_p(); - q = dsaGroup.get_q(); - g = dsaGroup.get_g(); - y = pubDsaKey.get_y(); - x = privDsaKey.get_x(); - - pubKeyBlob.addString ("ssh-dss"); - pubKeyBlob.addBigInt (p); - pubKeyBlob.addBigInt (q); - pubKeyBlob.addBigInt (g); - pubKeyBlob.addBigInt (y); - - Pipe base64it (new Base64_Encoder); - base64it.process_msg(pubKeyBlob.value()); - - SecureVector pubKeyBase64 = base64it.read_all (PIPE_DEFAULT_MESSAGE); - - pubKeyFile = fopen (pubKeyFileName, "w"); - - if (!pubKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where public key is stored. Filename: %s", pubKeyFileName); - return false; - } - - if ((!fwrite ("ssh-dss ", 8, 1, pubKeyFile)) || - (!fwrite (pubKeyBase64.begin(), (size_t) pubKeyBase64.size(), 1, pubKeyFile)) || - (!fwrite (" ", 1, 1, pubKeyFile)) || - (!fwrite (fqdn, strlen(fqdn), 1, pubKeyFile)) || - (!fwrite ("\n", 1, 1, pubKeyFile))) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", pubKeyFileName); - return false; - } - fclose (pubKeyFile); - -#if BOTAN_PRE_15 - encoder.start_sequence(); - DER::encode (encoder, 0U); - DER::encode (encoder, p); - DER::encode (encoder, q); - DER::encode (encoder, g); - DER::encode (encoder, y); - DER::encode (encoder, x); - encoder.end_sequence(); -#else - encoder.start_cons(SEQUENCE) - .encode (0U) - .encode (p) - .encode (q) - .encode (g) - .encode (y) - .encode (x) - .end_cons(); -#endif - privKeyEncoded = PEM_Code::encode (encoder.get_contents(), "DSA PRIVATE KEY"); - - privKeyFile = fopen (privKeyFileName, "w"); - - if (!privKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where private key is stored. Filename: %s", privKeyFileName); - return false; - } - - if (!fwrite (privKeyEncoded.c_str(), (size_t) privKeyEncoded.length(), 1, privKeyFile)) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", privKeyFileName); - return false; - } - fclose (privKeyFile); - -// delete dsaGroup; - - return true; -} - - -SecureVector& ne7ssh_keys::generateSignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - this->signature.destroy(); - switch (this->keyAlgo) - { - case DSA: - this->signature = generateDSASignature (sessionID, signingData); - return (signature); - - case RSA: - this->signature = generateRSASignature (sessionID, signingData); - return (signature); - - default: - this->signature.clear(); - return (signature); - } - -} - -SecureVector ne7ssh_keys::generateDSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - SecureVector sigRaw; - ne7ssh_string sigData, sig; - - sigData.addVectorField (sessionID); - sigData.addVector (signingData); - if (!dsaPrivateKey) - { - ne7ssh::errors()->push (-1, "Private DSA key not initialized."); - return sig.value(); - } - - PK_Signer *DSASigner = get_pk_signer (*dsaPrivateKey, "EMSA1(SHA-1)"); -#if BOTAN_PRE_18 || BOTAN_PRE_15 - sigRaw = DSASigner->sign_message(sigData.value()); -#else - sigRaw = DSASigner->sign_message(sigData.value(), *ne7ssh::rng); -#endif - - if (!sigRaw.size()) - { - ne7ssh::errors()->push (-1, "Failure to generate DSA signature."); - delete DSASigner; - return sig.value(); - } - - if (sigRaw.size() != 40) - { - ne7ssh::errors()->push (-1, "DSS signature block <> 320 bits. Make sure you are using 1024 bit keys for authentication!"); - sig.clear(); - return sig.value(); - } - - delete DSASigner; - sig.addString ("ssh-dss"); - sig.addVectorField (sigRaw); - return (sig.value()); -} - -SecureVector ne7ssh_keys::generateRSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - SecureVector sigRaw; - ne7ssh_string sigData, sig; - - sigData.addVectorField (sessionID); - sigData.addVector (signingData); - if (!rsaPrivateKey) - { - ne7ssh::errors()->push (-1, "Private RSA key not initialized."); - return sig.value(); - } - - PK_Signer *RSASigner = get_pk_signer (*rsaPrivateKey, "EMSA3(SHA-1)"); -#if BOTAN_PRE_18 || BOTAN_PRE_15 - sigRaw = RSASigner->sign_message(sigData.value()); -#else - sigRaw = RSASigner->sign_message(sigData.value(), *ne7ssh::rng); -#endif - if (!sigRaw.size()) - { - ne7ssh::errors()->push (-1, "Failure while generating RSA signature."); - delete RSASigner; - return sig.value(); - } - - delete RSASigner; - sig.addString ("ssh-rsa"); - sig.addVectorField (sigRaw); - return (sig.value()); -} - -bool ne7ssh_keys::getKeyPairFromFile (const char* privKeyFileName) -{ - ne7ssh_string privKeyStr; - char* buffer; - uint32 pos, i, length; - - if (!privKeyStr.addFile (privKeyFileName)) - { - ne7ssh::errors()->push (-1, "Cannot read PEM file: '%s'. Permission issues?", privKeyFileName); - return false; - } - - buffer = (char*) malloc (privKeyStr.length() + 1); - memcpy (buffer, (const char*)privKeyStr.value().begin(), privKeyStr.length()); - buffer[privKeyStr.length()] = 0x0; - - length = privKeyStr.length(); - - for (i = pos = 0; i < privKeyStr.length(); i++) - { - if (isspace(buffer[i])) - { - while (i < privKeyStr.length() && isspace (buffer[i])) - { - if (buffer[pos] != '\n') - buffer[pos] = buffer[i]; - if (++i >= privKeyStr.length()) break; - } - i--; - pos++; - continue; - } - buffer[pos] = buffer[i]; - pos++; - } - buffer[pos] = 0x00; - length = pos; - - if ((memcmp (buffer, "-----BEGIN", 10)) || - (memcmp (buffer + length - 17, "PRIVATE KEY-----", 16))) - { - ne7ssh::errors()->push (-1, "Encountered unknown PEM file format. Perhaps not an SSH private key file: '%s'.", privKeyFileName); - free (buffer); - return false; - } - - if (!memcmp (buffer, "-----BEGIN RSA PRIVATE KEY-----", 31)) - this->keyAlgo = ne7ssh_keys::RSA; - else if (!memcmp (buffer, "-----BEGIN DSA PRIVATE KEY-----", 31)) - this->keyAlgo = ne7ssh_keys::DSA; - else - { - ne7ssh::errors()->push (-1, "Encountered unknown PEM file format. Perhaps not an SSH private key file: '%s'.", privKeyFileName); - free (buffer); - return false; - } - - SecureVector keyVector ((Botan::byte*)buffer, length); - free (buffer); - switch (this->keyAlgo) - { - case DSA: - if (!getDSAKeys ((char*)keyVector.begin(), keyVector.size())) - return false; - break; - - case RSA: - if (!getRSAKeys ((char*)keyVector.begin(), keyVector.size())) - return false; - break; - } - - return true; - -} - -bool ne7ssh_keys::getDSAKeys (char* buffer, uint32 size) -{ -// DataSource_Memory privKeyPEMSrc (privKeyPEMStr); - const char* headerDSA = "-----BEGIN DSA PRIVATE KEY-----\n"; - const char* footerDSA = "-----END DSA PRIVATE KEY-----\n"; - SecureVector keyDataRaw; - BigInt p, q, g, y, x; - char *start; - uint32 version; - - start = buffer + strlen(headerDSA); - Pipe base64dec (new Base64_Decoder); - base64dec.process_msg ((Botan::byte*)start, size - strlen(footerDSA) - strlen(headerDSA)); - keyDataRaw = base64dec.read_all (PIPE_DEFAULT_MESSAGE); - - BER_Decoder decoder (keyDataRaw); - -#if BOTAN_PRE_15 - BER_Decoder sequence = BER::get_subsequence(decoder); - BER::decode (sequence, version); -#else - BER_Decoder sequence = decoder.start_cons (SEQUENCE); - sequence.decode (version); -#endif - - if (version) - { - ne7ssh::errors()->push (-1, "Encountered unknown DSA key version."); - return false; - } - -#if BOTAN_PRE_15 - BER::decode (sequence, p); - BER::decode (sequence, q); - BER::decode (sequence, g); - BER::decode (sequence, y); - BER::decode (sequence, x); -#else - sequence.decode (p); - sequence.decode (q); - sequence.decode (g); - sequence.decode (y); - sequence.decode (x); -#endif - - - sequence.discard_remaining(); - sequence.verify_end(); - - if (p.is_zero() || q.is_zero() || g.is_zero() || y.is_zero() || x.is_zero()) - { - ne7ssh::errors()->push (-1, "Could not decode the supplied DSA key."); - return false; - } - - DL_Group dsaGroup (p, q, g); - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - dsaPrivateKey = new DSA_PrivateKey (dsaGroup, x); -#else - dsaPrivateKey = new DSA_PrivateKey (*ne7ssh::rng, dsaGroup, x); -#endif - publicKeyBlob.clear(); - publicKeyBlob.addString ("ssh-dss"); - publicKeyBlob.addBigInt (p); - publicKeyBlob.addBigInt (q); - publicKeyBlob.addBigInt (g); - publicKeyBlob.addBigInt (y); - - return true; - -} - -bool ne7ssh_keys::getRSAKeys (char* buffer, uint32 size) -{ - const char* headerRSA = "-----BEGIN RSA PRIVATE KEY-----\n"; - const char* footerRSA = "-----END RSA PRIVATE KEY-----\n"; - SecureVector keyDataRaw; - BigInt p, q, e, d, n; - char *start; - uint32 version; - - start = buffer + strlen(headerRSA); - Pipe base64dec (new Base64_Decoder); - base64dec.process_msg ((Botan::byte*)start, size - strlen(footerRSA) - strlen(headerRSA)); - keyDataRaw = base64dec.read_all (PIPE_DEFAULT_MESSAGE); - - BER_Decoder decoder (keyDataRaw); - -#if BOTAN_PRE_15 - BER_Decoder sequence = BER::get_subsequence(decoder); - BER::decode (sequence, version); -#else - BER_Decoder sequence = decoder.start_cons(SEQUENCE); - sequence.decode (version); -#endif - - if (version) - { - ne7ssh::errors()->push (-1, "Encountered unknown RSA key version."); - return false; - } - -#if BOTAN_PRE_15 - BER::decode (sequence, n); - BER::decode (sequence, e); - BER::decode (sequence, d); - BER::decode (sequence, p); - BER::decode (sequence, q); -#else - sequence.decode (n); - sequence.decode (e); - sequence.decode (d); - sequence.decode (p); - sequence.decode (q); -#endif - - sequence.discard_remaining(); - sequence.verify_end(); - - if (n.is_zero() || e.is_zero() || d.is_zero() || p.is_zero() || q.is_zero()) - { - ne7ssh::errors()->push (-1, "Could not decode the supplied RSA key."); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - rsaPrivateKey = new RSA_PrivateKey (p, q, e, d, n); -#else - rsaPrivateKey = new RSA_PrivateKey (*ne7ssh::rng, p, q, e, d, n); -#endif - - publicKeyBlob.clear(); - publicKeyBlob.addString ("ssh-rsa"); - publicKeyBlob.addBigInt (e); - publicKeyBlob.addBigInt (n); - - return true; -} - -SecureVector& ne7ssh_keys::getPublicKeyBlob () -{ - return publicKeyBlob.value(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h deleted file mode 100644 index f62c66f26a1..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h +++ /dev/null @@ -1,143 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_KEYS_H -#define NE7SSH_KEYS_H -#include -#include -#include -#include -#include -#include -#include - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -#define MAX_KEYSIZE 8192 - - -/** - @author Andrew Useckas -*/ -class ne7ssh_keys -{ - private: - Botan::DSA_PrivateKey *dsaPrivateKey; - Botan::RSA_PrivateKey *rsaPrivateKey; - ne7ssh_string publicKeyBlob; - Botan::SecureVector signature; - - uint8 keyAlgo; - - /** - * Extracts DSA key pair from a PEM encoded stream. - * @param buffer PEM encoded string. - * @param size Length of the stream. - * @return True if keys succesfully extracted. Otherwise False is returned. - */ - bool getDSAKeys (char* buffer, uint32 size); - - /** - * Extracts RSA key pair from a PEM encoded stream. - * @param buffer PEM encoded string. - * @param size Length of the stream. - * @return True if keys succesfully extracted. Otherwise False is returned. - */ - bool getRSAKeys (char* buffer, uint32 size); - - public: - enum keyAlgos { DSA, RSA }; - - /** - * ne7ssh_keys constructor. - */ - ne7ssh_keys(); - - /** - * ne7ssh_keys destructor. - * @return - */ - ~ne7ssh_keys(); - - /** - * Generates DSA Key pair and saves keys in specified files. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return True if keys generated and written to the files. Otherwise false is returned. - */ - bool generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048); - - /** - * Generates RSA Key pair and saves keys in specified files. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return True if keys generated and written to the files. Otherwise false is returned. - */ - bool generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048); - - /** - * Extracts key pair from a PEM encoded file. - *

Reads the file and determines the type of key, then passes processing to either getDsaKeys() or getRSAKeys(*) functions. - * @param privKeyFileName Full path to PEM encoded file. - * @return True if key succesfully extracted, otherwise False is returned. - */ - bool getKeyPairFromFile (const char* privKeyFileName); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided. - *

Determines key type and passed the processing either to generateDSASignature() or generateRSAKeys() functions. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector& generateSignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector generateDSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector generateRSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * After key pair has been initialized, this function returns public key blob, as specified by SSH2 specs. - * @return Public key blob or zero length vector, if there are initialized keys. - */ - Botan::SecureVector& getPublicKeyBlob (); - - /** - * Returns type of initialized keys. - * @return Type of keys. - */ - uint8 getKeyAlgo () { return keyAlgo; } - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp deleted file mode 100644 index 1b8f4255156..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_mutex.h" - -Ne7ssh_Mutex::Ne7ssh_Mutex() -{ -#if defined(WIN32) || defined(__MINGW32__) - InitializeCriticalSection(&mutint); -#else - pthread_mutexattr_t mattr; - - pthread_mutexattr_init (&mattr); - pthread_mutexattr_settype (&mattr, PTHREAD_MUTEX_ERRORCHECK); - pthread_mutex_init (&mutint, &mattr); - pthread_mutexattr_destroy (&mattr); -#endif -} - -int Ne7ssh_Mutex::lock() -{ -#if defined(WIN32) || defined(__MINGW32__) - try - { - EnterCriticalSection(&mutint); - return 0; - } - catch (...) - { - return -1; - } -#else - return pthread_mutex_lock(&mutint); -#endif -} - -int Ne7ssh_Mutex::unlock() -{ -#if defined(WIN32) || defined(__MINGW32__) - LeaveCriticalSection(&mutint); - return 0; -#else - return pthread_mutex_unlock(&mutint); -#endif -} - -Ne7ssh_Mutex::~Ne7ssh_Mutex() -{ -#if defined(WIN32) || defined(__MINGW32__) - DeleteCriticalSection(&mutint); -#else - pthread_mutex_destroy(&mutint); -#endif -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h deleted file mode 100644 index d48d7414f20..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2006 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#ifndef NE7SSH_MUTEX_H -#define NE7SSH_MUTEX_H - -#if defined(WIN32) || defined(__MINGW32__) -# include -#else -# include -#endif - -class Ne7ssh_Mutex -{ -public: - Ne7ssh_Mutex(); - - int lock(); - - int unlock(); - - ~Ne7ssh_Mutex(); -private: -#if defined(WIN32) || defined(__MINGW32__) - CRITICAL_SECTION mutint; -#else - pthread_mutex_t mutint; -#endif -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp deleted file mode 100644 index 57176695941..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_session.h" - -ne7ssh_session::ne7ssh_session() : sendChannel(0), receiveChannel(0), channelID(-1), transport(0) -{ -} - - -ne7ssh_session::~ne7ssh_session() -{ -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h deleted file mode 100644 index ae312c3acfa..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_SESSION_H -#define NE7SSH_SESSION_H - -#include "ne7ssh_types.h" -#include "ne7ssh_transport.h" -#include "crypt.h" - -/** -@author Andrew Useckas -*/ -class ne7ssh_session -{ - private: - Botan::SecureVector localVersion; - Botan::SecureVector remoteVersion; - Botan::SecureVector sessionID; - uint32 sendChannel; - uint32 receiveChannel; - uint32 maxPacket; - int32 channelID; - - public: - ne7ssh_transport *transport; - ne7ssh_crypt *crypto; - - /** - * ne7ssh_session class constructor. - */ - ne7ssh_session(); - - /** - * ne7ssh_session class desctructor. - */ - ~ne7ssh_session(); - - /** - * Sets the local SSH version string. - * @param version Reference to a vector containing the version string. - */ - void setLocalVersion (Botan::SecureVector& version) { localVersion = version; } - - /** - * Returns local SSH version. - * @return Reference to a vector containing the version string. - */ - Botan::SecureVector &getLocalVersion () { return localVersion; } - - /** - * Sets the remote SSH version string. - * @param version Reference to a vector containing the version string. - */ - void setRemoteVersion (Botan::SecureVector& version) { remoteVersion = version; } - - /** - * Returns remote SSH version. - * @return Reference to a vector containing the version string. - */ - Botan::SecureVector &getRemoteVersion () { return remoteVersion; } - - /** - * Sets SSH session ID, a.k.a. H from the first KEX. - * @param session Reference to a vector containing the session ID. - */ - void setSessionID (Botan::SecureVector& session) { sessionID = session; } - - /** - * Returns the current SSH session ID. - * @return Reference to a vector containing the session ID. - */ - Botan::SecureVector &getSessionID () { return sessionID; } - - /** - * After the channel is open this function sets the send channel ID. - * @param channel Channel ID. - */ - void setSendChannel (uint32 channel) { sendChannel = channel; } - - /** - * Returns the send channel ID. - * @return Channel ID. - */ - uint32 getSendChannel () const { return sendChannel; } - - /** - * After the channel is open this function sets the receive channel ID. - * @param channel Channel ID. - */ - void setReceiveChannel (uint32 channel) { receiveChannel = channel; } - - /** - * Returns the receive channel ID. - * @return Channel ID. - */ - uint32 getReceiveChannel () { return receiveChannel; } - - /** - * Sets maximum send packet size. - * @param size Maximum packet size. - */ - void setMaxPacket (uint32 size) { maxPacket = size; } - - /** - * Returns maximum send packet size. - * @return Maximum packet size. - */ - uint32 getMaxPacket () { return maxPacket; } - - /** - * Stores newly created ne7ssh channel. - * @param channel ne7ssh channel. - */ - void setSshChannel (int32 channel) { channelID = channel; } - - /** - * REtrieves current ne7ssh channel. - * @return ne7ssh channel or -1 if the session hasn't succesfully opened the channel yet. - */ - int32 getSshChannel () { return channelID; } - - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp deleted file mode 100644 index 61d325634eb..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp +++ /dev/null @@ -1,1366 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#include -#include -#include "ne7ssh_transport.h" -#include "ne7ssh_sftp.h" -#include "ne7ssh_sftp_packet.h" -#include "ne7ssh.h" -#include "ne7ssh_session.h" -#include "ne7ssh_channel.h" - -using namespace Botan; - -Ne7sshSftp::Ne7sshSftp (ne7ssh_session* _session, ne7ssh_channel* _channel) : ne7ssh_channel (_session), session(_session), timeout(30), seq(1), sftpCmd(0), lastError(0), currentPath(0), sftpFiles(0), sftpFilesCount(0) -{ - windowRecv = _channel->getRecvWindow(); - windowSend = _channel->getSendWindow(); -} - -Ne7sshSftp::~Ne7sshSftp() -{ - uint16 i; - for (i = 0; i < sftpFilesCount; i++) - { - free (sftpFiles[i]); - } - if (sftpFiles) free (sftpFiles); - if (currentPath) free (currentPath); -} - -bool Ne7sshSftp::init () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - bool status; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("subsystem"); - packet.addChar (0); - packet.addString ("sftp"); - - if (!_transport->sendPacket (packet.value())) - { - return false; - } - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_DATA); - packet.addInt (session->getSendChannel()); - packet.addInt (sizeof(uint32) * 2 + sizeof(char)); - packet.addInt (sizeof(uint32) + sizeof(char)); - packet.addChar (SSH2_FXP_INIT); - packet.addInt (SFTP_VERSION); - - windowSend -= 9; - - if (!_transport->sendPacket (packet.value())) - return false; - - channelOpened = true; - status = receiveUntil (SSH2_FXP_VERSION, this->timeout); - - return status; - -} - -bool Ne7sshSftp::handleData (Botan::SecureVector& packet) -{ - ne7ssh_string mainBuffer (packet, 0); - uint32 channelID; - SecureVector sftpBuffer; - uint32 len = 0; - Botan::byte _cmd; - - channelID = mainBuffer.getInt(); - - if (!mainBuffer.getString (sftpBuffer)) return false; - if (!sftpBuffer.size()) - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected in SFTP subsystem."); - - adjustRecvWindow (sftpBuffer.size()); - - if (seq >= SFTP_MAX_SEQUENCE) seq = 0; - - mainBuffer.clear(); - - len = commBuffer.length(); - - if (len) mainBuffer.addVector (commBuffer.value()); - - commBuffer.addVector (sftpBuffer); - mainBuffer.addVector (sftpBuffer); - - if (mainBuffer.length() < sizeof(uint32) - || mainBuffer.getInt() > mainBuffer.length()) - return true; - - commBuffer.clear(); - - _cmd = mainBuffer.getByte(); - - this->sftpCmd = _cmd; - switch (_cmd) - { - case SSH2_FXP_VERSION: - return handleVersion (mainBuffer.value()); - break; - - case SSH2_FXP_HANDLE: - return addOpenHandle (mainBuffer.value()); - - case SSH2_FXP_STATUS: - return handleStatus (mainBuffer.value()); - - case SSH2_FXP_DATA: - return handleSftpData (mainBuffer.value()); - - case SSH2_FXP_NAME: - return handleNames (mainBuffer.value()); - - case SSH2_FXP_ATTRS: - return processAttrs (mainBuffer.value()); - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unhandled SFTP subsystem command: %i.", _cmd); - return false; - } - - return true; -} - -bool Ne7sshSftp::receiveWindowAdjust () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - - if (!_transport->waitForPacket (SSH2_MSG_CHANNEL_WINDOW_ADJUST)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote side could not adjust the Window."); - return false; - } - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - return true; -} - -bool Ne7sshSftp::receiveUntil (short _cmd, uint32 timeSec) -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 cutoff = timeSec * 1000000, timeout = 0; - uint32 prevSize = 0; - - this->sftpCmd = 0; - commBuffer.clear(); - - while (true) - { - const short status = _transport->waitForPacket (0, false); - if (status > 0) - { - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - } - - if (commBuffer.length() > prevSize) timeout = 0; - - prevSize = commBuffer.length(); - - usleep (10000); - - if (sftpCmd == _cmd) return true; - if (!cutoff) continue; - if (timeout >= cutoff) break; - else timeout += 10000; - } - return false; -} - -bool Ne7sshSftp::receiveWhile (short _cmd, uint32 timeSec) -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 cutoff = timeSec * 1000000, timeout = 0; - uint32 prevSize = 0; - bool status; - - this->sftpCmd = _cmd; - commBuffer.clear(); - - while (true) - { - status = _transport->waitForPacket (0, false); - if (status) - { - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - } - - if (commBuffer.length() > prevSize) timeout = 0; - if (commBuffer.length() == 0) return true; - - prevSize = commBuffer.length(); - - usleep (10000); - - if (sftpCmd != _cmd) return true; - - if (!cutoff) continue; - if (timeout >= cutoff) break; - else timeout += 10000; - } - return false; -} - -bool Ne7sshSftp::handleVersion (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 version; - - version = sftpBuffer.getInt(); - - if (version != SFTP_VERSION) - { - ne7ssh::errors()->push (session->getSshChannel(), "Unsupported SFTP version: %i.", version); - return false; - } - - return true; - -} - -bool Ne7sshSftp::handleStatus (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID, errorID; - SecureVector errorStr; - - - requestID = sftpBuffer.getInt(); - errorID = sftpBuffer.getInt(); - sftpBuffer.getString (errorStr); - - if (errorID) - { - lastError = errorID; - ne7ssh::errors()->push (session->getSshChannel(), "SFTP Error code: <%i>, description: %s.", errorID, errorStr.begin()); - return false; - } - return true; - -} - -bool Ne7sshSftp::addOpenHandle (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID; - SecureVector handle; - uint16 len; - - requestID = sftpBuffer.getInt(); - sftpBuffer.getString (handle); - - if (!this->sftpFiles) this->sftpFiles = (sftpFile**) malloc (sizeof(sftpFile*)); - else this->sftpFiles = (sftpFile**) realloc (sftpFiles, sizeof(sftpFile*) * (this->sftpFilesCount + 1)); - - sftpFiles[sftpFilesCount] = (sftpFile*) malloc (sizeof(sftpFile)); - sftpFiles[sftpFilesCount]->fileID = requestID; - len = handle.size(); - if (len > 256) len = 256; - memcpy (sftpFiles[sftpFilesCount]->handle, handle.begin(), len); - sftpFiles[sftpFilesCount]->handleLen = len; - sftpFilesCount++; - return true; - -} - -bool Ne7sshSftp::handleSftpData (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID; - SecureVector data; - uint16 len; - - requestID = sftpBuffer.getInt(); - sftpBuffer.getString (data); - len = data.size(); - - if (data.size() == 0) - { - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected."); - return false; - } - - commBuffer.clear(); - fileBuffer.destroy(); - fileBuffer.swap (data); - return true; -} - -bool Ne7sshSftp::handleNames (Botan::SecureVector& packet) -{ - Ne7sshSftpPacket sftpBuffer (packet, 0); - ne7ssh_string tmpVar; - uint32 requestID, fileCount, i; - SecureVector fileName; - - requestID = sftpBuffer.getInt(); - fileCount = sftpBuffer.getInt(); - tmpVar.addInt (fileCount); - - if (!fileCount) return true; - - for (i = 0; i < fileCount; i++) - { - sftpBuffer.getString (fileName); - tmpVar.addVectorField (fileName); - sftpBuffer.getString (fileName); - tmpVar.addVectorField (fileName); - attrs.flags = sftpBuffer.getInt(); - if (attrs.flags & SSH2_FILEXFER_ATTR_SIZE) - attrs.size = sftpBuffer.getInt64(); - - if (attrs.flags & SSH2_FILEXFER_ATTR_UIDGID) - { - attrs.owner = sftpBuffer.getInt(); - attrs.group = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) - { - attrs.permissions = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_ACMODTIME) - { - attrs.atime = sftpBuffer.getInt(); - attrs.mtime = sftpBuffer.getInt(); - } - } - fileBuffer.append(tmpVar.value()); - - return true; -} - -bool Ne7sshSftp::processAttrs (Botan::SecureVector& packet) -{ - Ne7sshSftpPacket sftpBuffer (packet, 0); - uint32 requestID; - SecureVector data; - - requestID = sftpBuffer.getInt(); - attrs.flags = sftpBuffer.getInt(); - if (attrs.flags & SSH2_FILEXFER_ATTR_SIZE) - attrs.size = sftpBuffer.getInt64(); - - if (attrs.flags & SSH2_FILEXFER_ATTR_UIDGID) - { - attrs.owner = sftpBuffer.getInt(); - attrs.group = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) - { - attrs.permissions = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_ACMODTIME) - { - attrs.atime = sftpBuffer.getInt(); - attrs.mtime = sftpBuffer.getInt(); - } - - return true; -} - - -uint32 Ne7sshSftp::openFile (const char* filename, uint8 shortMode) -{ - uint32 mode; - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - ne7ssh_string fullPath; - - fullPath = getFullPath (filename); - - if (!fullPath.length()) return 0; - - switch (shortMode) - { - case READ: - mode = SSH2_FXF_READ; - break; - - case OVERWRITE: - mode = SSH2_FXF_WRITE | SSH2_FXF_CREAT | SSH2_FXF_TRUNC; - break; - - case APPEND: - mode = SSH2_FXF_WRITE | SSH2_FXF_CREAT; - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unsupported file opening mode: %i.", shortMode); - return 0; - - } - - packet.addChar (SSH2_FXP_OPEN); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (mode); - packet.addInt (0); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= 21 + fullPath.length(); - - status = receiveUntil (SSH2_FXP_HANDLE, this->timeout); - - if (!status) return 0; - else return (seq - 1); -} - -uint32 Ne7sshSftp::openDir (const char* dirname) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - ne7ssh_string fullPath = getFullPath (dirname); - - if (!fullPath.length()) return 0; - - packet.addChar (SSH2_FXP_OPENDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= 13 + fullPath.length(); - - status = receiveUntil (SSH2_FXP_HANDLE, this->timeout); - - if (!status) return 0; - else return (seq - 1); -} - -bool Ne7sshSftp::readFile (uint32 fileID, uint64 offset) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_READ); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - packet.addInt64 (offset); - packet.addInt (SFTP_MAX_MSG_SIZE); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 25; - - status = receiveWhile (SSH2_FXP_DATA, this->timeout); - - return status; -} - -bool Ne7sshSftp::writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - uint32 sent = 0, currentLen = 0; - Botan::SecureVector sendVector; - - if (len > SFTP_MAX_MSG_SIZE) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not write. Datablock larger than maximum msg size. Remote file ID %i.", fileID); - return false; - } - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_WRITE); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - packet.addInt64 (offset); - packet.addInt (len); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - windowSend -= remoteFile->handleLen + 25; - - while (sent < len) - { - currentLen = len - sent < windowSend ? len - sent : windowSend; - currentLen = currentLen < (uint32)(SFTP_MAX_PACKET_SIZE - (remoteFile->handleLen + 86)) ? currentLen : SFTP_MAX_PACKET_SIZE - (remoteFile->handleLen + 86); - - if (sent) packet.clear(); - packet.addBytes (data + sent, currentLen); - - if (sent) - sendVector = packet.valueFragment(); - else - sendVector = packet.valueFragment(remoteFile->handleLen + 21 + len); - - if (!sendVector.size()) return false; - - status = _transport->sendPacket (sendVector); - if (!status) return false; - - windowSend -= currentLen; - sent += currentLen; - if (!windowSend) - { - if (!receiveWindowAdjust()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote side could not adjust the Window."); - return false; - } - } -// if (sent - currentLen) break; - } - status = receiveUntil (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::closeFile (uint32 fileID) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - uint16 i; - bool status, match=false; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_CLOSE); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 13; - - for (i = 0; i < sftpFilesCount; i++) - { - if (match) sftpFiles[i - 1] = sftpFiles[i]; - else if (sftpFiles[i]->fileID == fileID) - { - free (sftpFiles[i]); - sftpFiles[i] = 0; - match = true; - } - } - if (match) sftpFilesCount--; - - status = receiveUntil (SSH2_FXP_STATUS, this->timeout); - return status; -} - -ne7ssh_string Ne7sshSftp::getFullPath (const char* filename) -{ - Botan::SecureVector result; - char *buffer = 0; - uint32 len, pos, last_char, i = 0; - - if (!filename) return ne7ssh_string(); - len = strlen (filename); - - buffer = (char*) malloc (len + 1); - memcpy (buffer, filename, len); - - while (isspace (buffer[i])) i++; - - for (pos = 0; i < len; i++) - { - if (buffer[i] == '\\') - buffer[pos] = '/'; - else buffer[pos] = buffer[i]; - pos++; - } - pos--; - while (isspace (buffer[pos])) pos--; - if (pos > 1 && buffer[pos] == '.' && buffer[pos-1] != '.') pos--; - else if (!pos && buffer[pos] == '.') buffer[pos] = 0; - - result.destroy(); - if ((buffer[0] != '/') && currentPath) - { - if (currentPath) len = strlen (this->currentPath); - else - { - free (buffer); - return ne7ssh_string(); - } - result.append ((uint8*)currentPath, len); - last_char = len - 1; - if (currentPath[last_char] && currentPath[last_char] != '/') - result.append ((uint8*)"/", 1); - } - while (buffer[pos] == '/') pos--; - buffer[++pos] = 0x00; - result.append ((uint8*)buffer, pos); - free (buffer); - return ne7ssh_string(result, 0); -} - -Ne7sshSftp::sftpFile* Ne7sshSftp::getFileHandle (uint32 fileID) -{ - uint16 i; - uint32 _fileID; - - for (i = 0; i < sftpFilesCount; i++) - { - _fileID = sftpFiles[i]->fileID; - if (sftpFiles[i]->fileID == fileID) - { - return sftpFiles[i]; - } - } - ne7ssh::errors()->push (session->getSshChannel(), "Invalid file ID: %i.", fileID); - return 0; -} - -bool Ne7sshSftp::getFileStats (const char* remoteFile, bool followSymLinks) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - uint8 _cmd = followSymLinks ? SSH2_FXP_STAT : SSH2_FXP_LSTAT; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return 0; - - if (!remoteFile) return false; - - packet.addChar (_cmd); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_SIZE | SSH2_FILEXFER_ATTR_UIDGID | SSH2_FILEXFER_ATTR_PERMISSIONS | SSH2_FILEXFER_ATTR_ACMODTIME); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= 17 + fullPath.length(); - - status = receiveWhile (SSH2_FXP_ATTRS, this->timeout); - return status; -} - -bool Ne7sshSftp::getFStat (uint32 fileID) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - packet.addChar (SSH2_FXP_FSTAT); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 13; - - status = receiveWhile (SSH2_FXP_ATTRS, this->timeout); - return status; -} - -uint64 Ne7sshSftp::getFileSize (uint32 fileID) -{ - if (!getFStat (fileID)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return 0; - } - - return attrs.size; -} - -bool Ne7sshSftp::getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile, bool /* followSymLinks */) -{ - if (!remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - ne7ssh_string fullPath = getFullPath (remoteFile); - if (!fullPath.length()) return false; - - if (!getFileStats ((const char*)fullPath.value().begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - - attributes.size = attrs.size; - attributes.owner = attrs.owner; - attributes.group = attrs.group; - attributes.permissions = attrs.permissions; - attributes.atime = attrs.atime; - attributes.mtime = attrs.mtime; - - return true; -} - -bool Ne7sshSftp::getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector& remoteFile, bool followSymLinks) -{ - if (!remoteFile.size()) return false; - if (!getFileStats ((const char*)remoteFile.begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - attributes.size = attrs.size; - attributes.owner = attrs.owner; - attributes.group = attrs.group; - attributes.permissions = attrs.permissions; - attributes.atime = attrs.atime; - attributes.mtime = attrs.mtime; - - return true; -} - -bool Ne7sshSftp::isType (const char* remoteFile, uint32 type) -{ - uint32 perms; - if (!remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - ne7ssh_string fullPath = getFullPath (remoteFile); - if (!fullPath.length()) return false; - - if (!getFileStats ((const char*)fullPath.value().begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - - perms = attrs.permissions; - if (perms & type) return true; - else return false; -} - -bool Ne7sshSftp::isFile (const char* remoteFile) -{ - return isType (remoteFile, S_IFREG); -} - -bool Ne7sshSftp::isDir (const char* remoteFile) -{ - return isType (remoteFile, S_IFDIR); -} - -bool Ne7sshSftp::get (const char* remoteFile, FILE* localFile) -{ - uint32 size; - uint64 offset = 0; - Botan::SecureVector localBuffer; - uint32 fileID; - - if (!localFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid local or remote file."); - return false; - } - - fileID = openFile (remoteFile, READ); - - if (!fileID) return false; - - size = getFileSize (fileID); - - if (!size) - { - ne7ssh::errors()->push (session->getSshChannel(), "File size is zero."); - return false; - } - - while (size > offset) - { - readFile (fileID, offset); - if (fileBuffer.size() == 0) return false; - localBuffer.destroy(); - localBuffer.swap (fileBuffer); - - if (!fwrite (localBuffer.begin(), (size_t) localBuffer.size(), 1, localFile)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not write to local file. Remote file ID %i.", fileID); - return false; - } - offset += localBuffer.size(); - } - - if (!closeFile (fileID)) return false; - return true; - -} - -bool Ne7sshSftp::put (FILE* localFile, const char* remoteFile) -{ - size_t size; - uint64 offset = 0; - Botan::SecureVector localBuffer; - uint32 fileID; - uint8* buffer = 0; - uint32 len; - - if (!localFile || !remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid local or remote file."); - return false; - } - - fileID = openFile (remoteFile, OVERWRITE); - - if (!fileID) return false; - - fseek (localFile, 0L, SEEK_END); - size = ftell (localFile); - rewind (localFile); - - if (!size) - { - ne7ssh::errors()->push (session->getSshChannel(), "File size is zero."); - return false; - } - - buffer = (uint8*) malloc (SFTP_MAX_MSG_SIZE); - while (size > offset) - { - len = (size - offset) < SFTP_MAX_MSG_SIZE - 384 ? (size - offset) : SFTP_MAX_MSG_SIZE - 384; - - if (!fread (buffer, len, 1, localFile)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not read from local file. Remote file ID %i.", fileID); - if (buffer) free (buffer); - return false; - } - if (!writeFile (fileID, buffer, len, offset)) - { - if (buffer) free (buffer); - return false; - } - offset += len; - } - - if (buffer) free (buffer); - if (!closeFile (fileID)) return false; - return true; - -} - -bool Ne7sshSftp::rm (const char* remoteFile) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_REMOVE); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= 13 + fullPath.length(); - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::mv (const char* oldFile, const char* newFile) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!oldFile || !newFile) return false; - ne7ssh_string oldPath = getFullPath (oldFile); - ne7ssh_string newPath = getFullPath (newFile); - - if (!oldPath.length() || !newPath.length()) return false; - - packet.addChar (SSH2_FXP_RENAME); - packet.addInt (this->seq++); - packet.addVectorField (oldPath.value()); - packet.addVectorField (newPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= oldPath.length() + newPath.length() + 17; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::mkdir (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_MKDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (0); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 17; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::rmdir (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_RMDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 13; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -const char* Ne7sshSftp::ls (const char* remoteDir, bool longNames) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - ne7ssh_string tmpVar; - SecureVector fileName; - bool status = true; - uint32 fileID, fileCount, i; - sftpFile *remoteFile; - if (!remoteDir) return 0; - - fileID = openDir (remoteDir); - - if (!fileID) return 0; - remoteFile = getFileHandle (fileID); - if (!remoteFile) return 0; - fileBuffer.destroy(); - - while (status) - { - packet.clear(); - packet.addChar (SSH2_FXP_READDIR); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= remoteFile->handleLen + 13; - - status = receiveWhile (SSH2_FXP_NAME, this->timeout); - } - if (lastError > 1) return 0; - - packet.clear(); - packet.addVector (fileBuffer); - fileCount = packet.getInt(); - tmpVar.clear(); - for (i = 0; i < fileCount; i++) - { - packet.getString (fileName); - fileName.append ((const Botan::byte*)"\n", 1); - if (!longNames) tmpVar.addVector (fileName); - - packet.getString (fileName); - fileName.append ((const Botan::byte*)"\n", 1); - if (longNames) tmpVar.addVector (fileName); - } - fileBuffer.swap (tmpVar.value()); - - if (!closeFile (fileID)) return 0; - return (const char*)fileBuffer.begin(); -} - -bool Ne7sshSftp::cd (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - SecureVector fileName; - uint32 fileCount; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - fileBuffer.destroy(); - - packet.addChar (SSH2_FXP_REALPATH); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 13; - - status = receiveWhile (SSH2_FXP_NAME, this->timeout); - if (!status) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not change to remote directory: %s.", remoteDir); - return false; - } - - - packet.clear(); - packet.addVector (fileBuffer); - fileCount = packet.getInt(); - if (!fileCount) return false; - packet.getString (fileName); - - if (!currentPath) currentPath = (char*) malloc (fileName.size() + 1); - else currentPath = (char*) realloc (currentPath, fileName.size() + 1); - memcpy (currentPath, fileName.begin(), fileName.size()); - currentPath[fileName.size()] = 0; - return status; -} - -bool Ne7sshSftp::chmod (const char* remoteFile, const char* mode) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - uint32 perms, len, octet = 0; - bool u, g, o, plus; - const char* _pos; - uint8 i; - char converter[] = {'0', '0', '0', '0', '0'}; - - if (!fullPath.length()) return false; - - if (!getFileAttrs (attrs, fullPath.value(), true)) - return false; - - perms = attrs.permissions; - - len = strlen (mode); - if (len < 5 && len > 2) - { - for (i = 0; i < len; i++) - { - if (!isdigit (mode[i])) break; - } - - if (i != len) _pos = mode; - else - { - memcpy (converter + (5 - len), mode, len); - octet = strtol (converter, (char**)&_pos, 8); - if (octet > 07777) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid permission octet."); - return false; - } - if (len == 3) perms = (perms & ~0777) | octet; - else perms = (perms & ~07777) | octet; - } - } - - _pos = mode; - if (!octet) - { - while (*_pos) - { - if (*_pos == ',') _pos++; - u = g = o = plus = false; - while (*_pos && *_pos != '+' && *_pos != '-') - { - switch (*_pos) - { - case 'u': - u = true; - break; - - case 'g': - g = true; - break; - - case 'o': - o = true; - break; - - case 'a': - u = g = o = true; - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Invalid mode string."); - return false; - - } - _pos++; - } - - if (*_pos == '+') plus = true; - _pos++; - while (*_pos && *_pos != ',') - { - switch (*_pos) - { - case 'r': - if (u) perms = plus ? perms | S_IRUSR : perms ^ S_IRUSR; - if (g) perms = plus ? perms | S_IRGRP : perms ^ S_IRGRP; - if (o) perms = plus ? perms | S_IROTH : perms ^ S_IROTH; - break; - - case 'w': - if (u) perms = plus ? perms | S_IWUSR : perms ^ S_IWUSR; - if (g) perms = plus ? perms | S_IWGRP : perms ^ S_IWGRP; - if (o) perms = plus ? perms | S_IWOTH : perms ^ S_IWOTH; - break; - - case 'x': - if (u) perms = plus ? perms | S_IXUSR : perms ^ S_IXUSR; - if (g) perms = plus ? perms | S_IXGRP : perms ^ S_IXGRP; - if (o) perms = plus ? perms | S_IXOTH : perms ^ S_IXOTH; - break; - - case 's': - if (u) perms = plus ? perms | S_ISUID : perms ^ S_ISUID; - if (g) perms = plus ? perms | S_ISGID : perms ^ S_ISGID; - break; - - case 't': - perms = plus ? perms | S_ISVTX : perms ^ S_ISVTX; - break; - - case 'X': - if ((perms & 111) == 0) break; - if (u) perms = plus ? perms | S_IXUSR : perms ^ S_IXUSR; - if (g) perms = plus ? perms | S_IXGRP : perms ^ S_IXGRP; - if (o) perms = plus ? perms | S_IXOTH : perms ^ S_IXOTH; - break; - - case 'u': - if (u) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - if (g) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - if (o) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - break; - - case 'g': - if (u) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - if (g) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - if (o) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - break; - - case 'o': - if (u) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - if (g) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - if (o) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Invalid mode string."); - return false; - } - _pos++; - } - } - } - - - packet.addChar (SSH2_FXP_SETSTAT); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_PERMISSIONS); - packet.addInt (perms); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 21; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::chown (const char* remoteFile, uint32 uid, uint32 gid) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - uint32 old_uid, old_gid; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return false; - - if (!getFileAttrs (attrs, fullPath.value(), true)) - return false; - - old_uid = attrs.owner; - old_gid = attrs.group; - - packet.addChar (SSH2_FXP_SETSTAT); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_UIDGID); - if (uid) packet.addInt (uid); - else packet.addInt (old_uid); - if (gid) packet.addInt (gid); - else packet.addInt (old_gid); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 25; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h deleted file mode 100644 index 64074401b3e..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h +++ /dev/null @@ -1,438 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#ifndef NE7SSHSFTP_H -#define NE7SSHSFTP_H - -#include "ne7ssh_channel.h" -#include "ne7ssh.h" - -#ifdef WIN32 -// 777 = 0x1ff -#ifndef __MINGW32__ -#define S_IRUSR 0x100 -#endif -#define S_IRGRP 0x020 -#define S_IROTH 0x004 -#ifndef __MINGW32__ -#define S_IWUSR 0x080 -#endif -#define S_IWGRP 0x010 -#define S_IWOTH 0x002 -#ifndef __MINGW32__ -#define S_IXUSR 0x040 -#endif -#define S_IXGRP 0x008 -#define S_IXOTH 0x001 -#define S_ISUID 0x800 -#define S_ISGID 0x400 -#define S_ISVTX 0x200 -#ifndef __MINGW32__ -#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#endif -#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#endif - -#define SSH2_FXP_INIT 1 -#define SSH2_FXP_VERSION 2 -#define SSH2_FXP_OPEN 3 -#define SSH2_FXP_CLOSE 4 -#define SSH2_FXP_READ 5 -#define SSH2_FXP_WRITE 6 -#define SSH2_FXP_LSTAT 7 -#define SSH2_FXP_FSTAT 8 -#define SSH2_FXP_SETSTAT 9 -#define SSH2_FXP_FSETSTAT 10 -#define SSH2_FXP_OPENDIR 11 -#define SSH2_FXP_READDIR 12 -#define SSH2_FXP_REMOVE 13 -#define SSH2_FXP_MKDIR 14 -#define SSH2_FXP_RMDIR 15 -#define SSH2_FXP_REALPATH 16 -#define SSH2_FXP_STAT 17 -#define SSH2_FXP_RENAME 18 -#define SSH2_FXP_READLINK 19 -#define SSH2_FXP_LINK 21 -#define SSH2_FXP_BLOCK 22 -#define SSH2_FXP_UNBLOCK 23 - -#define SSH2_FXP_STATUS 101 -#define SSH2_FXP_HANDLE 102 -#define SSH2_FXP_DATA 103 -#define SSH2_FXP_NAME 104 -#define SSH2_FXP_ATTRS 105 - -#define SSH2_FXP_EXTENDED 200 -#define SSH2_FXP_EXTENDED_REPLY 201 - -#define SFTP_VERSION 3 -#define SFTP_MAX_SEQUENCE 4294967295U -#define SFTP_MAX_PACKET_SIZE (32 * 1024) -#define SFTP_MAX_MSG_SIZE (256 * 1024) - -#define SSH2_FXF_READ 0x00000001 -#define SSH2_FXF_WRITE 0x00000002 -#define SSH2_FXF_APPEND 0x00000004 -#define SSH2_FXF_CREAT 0x00000008 -#define SSH2_FXF_TRUNC 0x00000010 -#define SSH2_FXF_EXCL 0x00000020 - -#define SSH2_FILEXFER_ATTR_SIZE 0x00000001 -#define SSH2_FILEXFER_ATTR_UIDGID 0x00000002 -#define SSH2_FILEXFER_ATTR_ACMODTIME 0x00000008 -#define SSH2_FILEXFER_ATTR_PERMISSIONS 0x00000004 - -class ne7ssh_session; -class ne7ssh_transport; - -/** - @author Andrew Useckas -*/ -class Ne7sshSftp : public ne7ssh_channel -{ - private: - ne7ssh_session* session; - uint32 timeout; - uint32 seq; - uint8 sftpCmd; - ne7ssh_string commBuffer; - Botan::SecureVector fileBuffer; - enum writeMode { READ, OVERWRITE, APPEND }; - uint8 lastError; - char* currentPath; - - /** - * Structure used to store rmote file attributes. - */ - typedef struct - { - uint32 flags; - uint64 size; - uint32 owner; - uint32 group; - uint32 permissions; - uint32 atime; - uint32 mtime; - } sftpFileAttrs; - - sftpFileAttrs attrs; - - /** - * Structure used to store open rmote file. - */ - typedef struct - { - uint32 fileID; - uint16 handleLen; - char handle[256]; - } sftpFile; - sftpFile **sftpFiles; - uint16 sftpFilesCount; - - /** - * Replacement for ne7ssh_channel handleData method. Processes SFTP specific packets. - * @param packet Reference to the newly received packet. - * @return True if data successfully processed. False on any error. - */ - bool handleData (Botan::SecureVector& packet); - - /** - * Processes the VERSION packet received from the server. - * @param packet VERSION packet. - * @return True if processing successful, otherwise false. - */ - bool handleVersion (Botan::SecureVector& packet); - - /** - * Processes the STATUS packet received from the server. - * @param packet STATUS packet. - * @return True if processing successful, otherwise false. - */ - bool handleStatus (Botan::SecureVector& packet); - - /** - * Method to add a new file to sftpFiles variable from the HANDLE packet. - * @param packet HANDLE packet. - * @return True if processing successful, otherwise false. - */ - bool addOpenHandle (Botan::SecureVector& packet); - - /** - * Method to process DATA packets. - * @param packet DATA packet. - * @return True if processing successful, otherwise false. - */ - bool handleSftpData (Botan::SecureVector& packet); - - /** - * Method to process NAME packets. - * @param packet NAME packet. - * @return True if processing successful, otherwise false. - */ - bool handleNames (Botan::SecureVector& packet); - - /** - * This method is used to get a pointer to currently open file stored in sftpFile structure. - * @param fileID File ID, received from fileOpen() method. - * @return Returns a pointer to sftpFile structyure containing opened file or directory. If file specified by fileID has not been opened, NULL is returned. - */ - sftpFile* getFileHandle (uint32 fileID); - - /** - * Receive packets until specific SFTP subsystem command is received. - * @param _cmd SFTP command to wait for. - * @param timeSec Timeout in seconds. - * @return True if the command specified has been received. Otherwise false. - */ - bool receiveUntil (short _cmd, uint32 timeSec = 0); - - /** - * Receive packets while SFTP subsystem commands received matches specified command. - * @param _cmd Command to receive. - * @param timeSec Timeout in seconds. - * @return True if all expected data received. Otherwise false. - */ - bool receiveWhile (short _cmd, uint32 timeSec = 0); - - /** - * Method to process ATTRS packet. - * @param packet ATTRS packet. - * @return True if processing successful, otherwise false. - */ - bool processAttrs (Botan::SecureVector& packet); - - /** - * Low level method to request file attributes. - * @param remoteFile Full or relative path to a remote file. - * @param followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false". - * @return True if the request succeeds. False on any error. - */ - bool getFileStats (const char* remoteFile, bool followSymLinks = true); - - /** - * Gets attributes of a remote file and dumps them into sfptFileAtts structure. - * @param attributes reference to sftpFileAttrs structure where the result will be stored. - * @param remoteFile Full or relative path to a remote file. - * @param followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false". - * @return True if the attributes successfully received. False on any error. - */ - bool getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector& remoteFile, bool followSymLinks = true); - - /** - * Works like getFileStats() method, except that it operates on a handle of already opened file instead of path. - * @param fileID File ID, returned by the openFile() method. - * @return True if the request succeeds. False on any error. - */ - bool getFStat (uint32 fileID); - - /** - * This methods returnes the size of an open file. - * @param fileID File ID, returned by the openFile() method. - * @return The size of the remote file. False on any error. - */ - uint64 getFileSize (uint32 fileID); - - /** - * This method is used to wait for an ADJUST_WINDOW packet, when the send window size is zero. - * @return True if the ADJUST_WINDOW packet has been received, otherwise false. - */ - bool receiveWindowAdjust (); - - /** - * Returns full path to a file or directory. - * @param filename Relative path to a remote file or directory. - * @return ne7ssh_string class containing full path to the remote file or directory. The class will contain an empty string on error. - */ - ne7ssh_string getFullPath (const char* filename); - - /** - * Determines the type of a remote file. - * @param remoteFile Relative or full path to the remote file. - * @param type Type, taken from sys/stat.h. - * @return True if file is of specified type. Otherwise false. - */ - bool isType (const char* remoteFile, uint32 type); - - public: - /** - * Constructor. - * @param _session Pointer to connections session data. - * @param _channel Pointer to the ne7ssh_channel instance, taken from the new ne7ssh_connection instance. - */ - Ne7sshSftp(ne7ssh_session* _session, ne7ssh_channel* _channel); - - /** - * Default destructor. - */ - ~Ne7sshSftp(); - - /** - * Initializes SFTP subsystem. - * @return True if the subsystem successfully initialized. False on any error. - */ - bool init(); - - /** - * This method is used to set a timeout for all SFTP subsystem communications. - * @param _timeout Timeout in seconds. - */ - void setTimeout (uint32 _timeout) { timeout = _timeout; } - - /** - * Low level method used to open a remote file. - * @param filename Relative or full path to the file. - * @param shortMode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable. - * @return Newly opened file ID or 0 if file could not be opened. - */ - uint32 openFile (const char* filename, uint8 shortMode); - - /** - * Low level method used to open an inode containing file entries a.k.a directory. - * @param dirname Relative or full path to the inode. - * @return Newly opened file ID or 0 if the inode could not be opened. - */ - uint32 openDir (const char* dirname); - - /** - * Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file. - * @param fileID File ID retruned by openFile() method. - * @param offset Offset. 0 by default. - * @return True if file content successfully read and placed in the buffer. Otherwise false. - */ - bool readFile (uint32 fileID, uint64 offset = 0); - - /** - * Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file. - * @param fileID File ID returned by openFile() method. - * @param data Pointer to a buffer containing the data. - * @param len Length of the block. - * @param offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. Variable is set to 0 by default. - * @return True if file contect successfully written. False on any error. - */ - bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0); - - /** - * Low level method used to close a file opened using openFile() method. - * @param fileID File ID returned by openFile() method. - * @return True on success. False on any error. - */ - bool closeFile (uint32 fileID); - - /** - * This method is used to retrieve remote file attributes and place them into fileAttrs structure. - * @param attributes Reference to fileAttrs structure where retrieved attributes should be placed. - * @param remoteFile Name of the remote file. - * @param followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false". - * @return True if the attributes successfully retrieved. Otherwise false is returned. - */ - bool getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile, bool followSymLinks = true); - - /** - * This method is used to determine if a remote inode is a regular file. - * @param remoteFile Full or relative path to the remote inode. - * @return True if the remote inode is a regular file. Otherwise false. - */ - bool isFile (const char* remoteFile); - - /** - * This method is used to determine if a remote inode is a directory. - * @param remoteFile Full or relative path to the remote file. - * @return True if the remote inode is a directory. Otherwise false. - */ - bool isDir (const char* remoteFile); - - - /** - * This method is used to retrieve a remote file and dump it into local file. - * @param remoteFile Full or relative path to the file on the remote side. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @return True if getting the file is succeeds. False on any error. - */ - bool get (const char* remoteFile, FILE* localFile); - - /** - * This method is used to upload a file to a remote server. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if putting the file succeeds. False on any error. - */ - bool put (FILE* localFile, const char* remoteFile); - - /** - * This method is used to remove a file on a remote server. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if remove succeeds. False on any error. - */ - bool rm (const char* remoteFile); - - /** - * This method is used to rename/move files. - * @param oldFile Full or relative path to an old file on the remote server. - * @param newFile Full or relative path to a new file on the remote side. - * @return True if renaming successfull. False on any error. - */ - bool mv (const char* oldFile, const char* newFile); - - /** - * This method is used to create a new directory. - * @param remoteDir Full or relative path to a new directory on the remote server. - * @return True if the directory successfully created. False on any error. - */ - bool mkdir (const char* remoteDir); - - /** - * This method is used to remove a remote directory. - * @param remoteDir Full or relative path to a directory to be removed. - * @return True if the directory successfully removed. False on any error. - */ - bool rmdir (const char* remoteDir); - - /** - * This methods is used retrieve a listing of a remote directory. - * @param remoteDir Full or relative path to a directory. - * @param longNames If set to "true" the returned string in addition to file strings will contain attributes for each file. - * @return A pointer to a string containing the directory listing. - */ - const char* ls (const char* remoteDir, bool longNames=false); - - /** - * This method is used to change the current working directory. - * @param remoteDir Full or relative path to the new working directory on the remote server. - * @return True if change of directory succedded. False on any error. - */ - bool cd (const char* remoteDir); - - /** - * This method is used for changing the permissions associated with a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param mode Mode string. It can be wither a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command. - * @return True if the new permissions are succesfully applied to the remote file. False on any error. - */ - bool chmod (const char* remoteFile, const char* mode); - - /** - * This method is used to change the owner of a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param uid Numerical new owner user ID. - * @param gid Numerical new owner group ID. - * @return True if the change of ownership succeeds. False on any error. - */ - bool chown (const char* remoteFile, uint32 uid, uint32 gid = 0); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp deleted file mode 100644 index e926fe57aa6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_sftp_packet.h" -#include "ne7ssh.h" - -using namespace Botan; - -Ne7sshSftpPacket::Ne7sshSftpPacket () : ne7ssh_string(), channel(-1) -{ -} - -Ne7sshSftpPacket::Ne7sshSftpPacket (int _channel) : ne7ssh_string (), channel (_channel) -{ -} - -Ne7sshSftpPacket::Ne7sshSftpPacket (Botan::SecureVector& var, uint32 position) : ne7ssh_string (var, position), channel(-1) -{ -} - -Ne7sshSftpPacket::~Ne7sshSftpPacket() -{ -} - -Botan::SecureVector &Ne7sshSftpPacket::value () -{ - ne7ssh_string tmpVar; - - if (this->channel < 0) - { - buffer.destroy(); - return buffer; - } - - tmpVar.addChar (SSH2_MSG_CHANNEL_DATA); - tmpVar.addInt (channel); - tmpVar.addInt (sizeof(uint32) + buffer.size()); - tmpVar.addVectorField (buffer); - - buffer.swap (tmpVar.value()); - return buffer; -} - -Botan::SecureVector Ne7sshSftpPacket::valueFragment (uint32 len) -{ - ne7ssh_string tmpVar; - - if (this->channel < 0) - { - buffer.destroy(); - return Botan::SecureVector(); - } - - tmpVar.addChar (SSH2_MSG_CHANNEL_DATA); - tmpVar.addInt (channel); - if (len) - { - tmpVar.addInt (sizeof(uint32) + buffer.size()); - tmpVar.addInt (len); - tmpVar.addVector (buffer); - } - else tmpVar.addVectorField (buffer); - - return Botan::SecureVector (tmpVar.value()); -} - -void Ne7sshSftpPacket::addInt64 (const uint64 var) -{ - uint8 converter[8]; - - converter[0] = (uint8) (var >> 56); - converter[1] = (uint8) (var >> 48); - converter[2] = (uint8) (var >> 40); - converter[3] = (uint8) (var >> 32); - converter[4] = (uint8) (var >> 24); - converter[5] = (uint8) (var >> 16); - converter[6] = (uint8) (var >> 8); - converter[7] = (uint8) var; - - addBytes (converter, 8); -} - - -uint64 Ne7sshSftpPacket::getInt64 () -{ - SecureVector tmpVar (buffer); - uint64 result; - uint8 converter[8]; - memcpy (converter, tmpVar.begin(), 8); - - result = (uint64)converter[0] << 56; - result |= (uint64)converter[1] << 48; - result |= (uint64)converter[2] << 40; - result |= (uint64)converter[3] << 32; - result |= (uint64)converter[4] << 24; - result |= (uint64)converter[5] << 16; - result |= (uint64)converter[6] << 8; - result |= (uint64)converter[7]; - - buffer.set (tmpVar.begin() + sizeof(uint64), tmpVar.size() - sizeof(uint64)); - return result; -} - -bool Ne7sshSftpPacket::isChannelSet () -{ - if (this->channel == -1) return false; - else return true; -} - - - - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h deleted file mode 100644 index ab7408e5bc1..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSHSFTPPACKET_H -#define NE7SSHSFTPPACKET_H - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -/** - @author Andrew Useckas -*/ -class Ne7sshSftpPacket : public ne7ssh_string -{ - private: - int channel; - - public: - /** - * Default constructor. - */ - - Ne7sshSftpPacket(); - /** - * Constructor. - * @param channel Channel ID, returned by connect methods. - */ - Ne7sshSftpPacket(int channel); - - /** - * Constructor. Intializes the class with packet data. - * @param var Reference to packet data. - * @param position Offset. - */ - Ne7sshSftpPacket(Botan::SecureVector& var, uint32 position); - - /** - * Default destructor. - */ - ~Ne7sshSftpPacket(); - - /** - * Returns buffer as a vector appending the SFTP subsystem specific packet headers. - * @return Reference to the buffer. - */ - Botan::SecureVector &value (); - - /** - * Returns buffer as a vector appending the SFTP subsystem specific packet headers, including the length in the first packet transmitted. Used in transmissions when it's necessary to split the message into multiple packets. - * @param len Length to append to the first packet in the message. - * @return Reference to SFTP packet or empty vector on error. - */ - Botan::SecureVector valueFragment (uint32 len = 0); - - /** - * Appends 64 bit integer to the packet buffer. - * @param var 64 bit integer. - */ - void addInt64 (const uint64 var); - - /** - * Retrieves a 64 bit integer from a packet buffer. - * @return Unsigned 64 bit integer. - */ - uint64 getInt64 (); - - /** - * Checks if the channel ID is set in the instance. Channel ID is needed to construct a SFTP packet. - * @return True if the channel ID is set. Otherwise false. - */ - bool isChannelSet (); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp deleted file mode 100644 index ef64f143206..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_string.h" -#include "ne7ssh.h" -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -#endif - -using namespace Botan; - -ne7ssh_string::ne7ssh_string() : positions(0), parts(0) -{ -} - -ne7ssh_string::ne7ssh_string(Botan::SecureVector& var, uint32 position) : positions(0), parts(0) -{ - buffer.set ((var.begin() + position), (var.size() - position)); -} - -ne7ssh_string::ne7ssh_string(const char* var, uint32 position) : positions(0), parts(0) -{ - char null_char=0x0; - buffer.set ((Botan::byte*)(var + position), (u32bit) (strlen(var) - position)); - buffer.append ((Botan::byte*) &null_char, 1); -} - -ne7ssh_string::~ne7ssh_string() -{ - if (positions) - free (positions); -} - -void ne7ssh_string::addString (const char* str) -{ - Botan::byte* value = (Botan::byte*) str; - size_t len = strlen(str); - uint32 nLen = htonl((long) len); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (value, (u32bit) len); -} - -bool ne7ssh_string::addFile (const char* filename) -{ - FILE *FI = fopen (filename, "rb"); - size_t size; - Botan::byte* data; - - if (!FI) - { - ne7ssh::errors()->push (-1, "Could not open key file: %s.", filename); - return false; - } - - fseek (FI, 0L, SEEK_END); - size = ftell (FI); - if(size > 0) { - rewind (FI); - - data = (Botan::byte*) malloc (size); - fread (data, size, 1, FI); - fclose (FI); - buffer.append (data, (u32bit) size); - free (data); - return true; - } - fclose(FI); - return false; -} - -void ne7ssh_string::addBigInt (const Botan::BigInt& bn) -{ - SecureVector converted; - bn2vector (converted, bn); - uint32 nLen = htonl (converted.size()); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (converted); -} - -void ne7ssh_string::addVectorField (const Botan::SecureVector &vector) -{ - uint32 nLen = htonl (vector.size()); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (vector); -} - - -void ne7ssh_string::addBytes (const Botan::byte* buff, uint32 len) -{ - buffer.append(buff, len); -} - -void ne7ssh_string::addVector (Botan::SecureVector &secvec) -{ - buffer.append(secvec.begin(), secvec.size()); -} - -void ne7ssh_string::addChar (const char ch) -{ - buffer.append((Botan::byte*)&ch, 1); -} - -void ne7ssh_string::addInt (const uint32 var) -{ - uint32 nVar = htonl (var); - - buffer.append((Botan::byte*)&nVar, sizeof(uint32)); -} - -bool ne7ssh_string::getString (Botan::SecureVector& result) -{ - SecureVector tmpVar (buffer); - uint32 len; - - len = ntohl (*((uint32*)tmpVar.begin())); - if (len > tmpVar.size()) return false; - - result.set (tmpVar.begin() + sizeof(uint32), len); - buffer.set (tmpVar.begin() + sizeof(uint32) + len, tmpVar.size() - sizeof(uint32) - len); - return true; -} - -bool ne7ssh_string::getBigInt (Botan::BigInt& result) -{ - SecureVector tmpVar (buffer); - uint32 len; - - len = ntohl (*((uint32*)tmpVar.begin())); - if (len > tmpVar.size()) return false; - - BigInt tmpBI (tmpVar.begin() + sizeof(uint32), len); - result.swap (tmpBI); - buffer.set (tmpVar.begin() + sizeof(uint32) + len, tmpVar.size() - sizeof(uint32) - len); - return true; -} - -uint32 ne7ssh_string::getInt () -{ - SecureVector tmpVar (buffer); - uint32 result; - - result = ntohl (*((uint32*)tmpVar.begin())); - buffer.set (tmpVar.begin() + sizeof(uint32), tmpVar.size() - sizeof(uint32)); - return result; -} - -Botan::byte ne7ssh_string::getByte () -{ - SecureVector tmpVar (buffer); - Botan::byte result; - - result = *(tmpVar.begin()); - buffer.set (tmpVar.begin() + 1, tmpVar.size() - 1); - return result; -} - - -void ne7ssh_string::split (const char token) -{ - Botan::byte* _buffer = buffer.begin(); - uint32 len = buffer.size(); - uint32 i; - - if (positions) return; - positions = (Botan::byte**) malloc (sizeof(Botan::byte*) * (parts + 1)); - positions[parts] = _buffer; - parts++; - - for (i = 0; i < len; i++) - { - if (_buffer[i] == token) - { - _buffer[i] = '\0'; - positions = (Botan::byte**) realloc (positions, sizeof(Botan::byte*) * (parts + 1)); - - positions[parts] = _buffer + i + 1; - parts++; - } - } -} - -char* ne7ssh_string::nextPart () -{ - char* result; - if (currentPart >= parts || !positions) return 0; - - result = (char*) positions[currentPart]; - currentPart++; - - return result; -} - -void ne7ssh_string::chop (uint32 nBytes) -{ - SecureVector tmpVar (buffer); - buffer.set (tmpVar.begin(), tmpVar.size() - nBytes); -} - - -void ne7ssh_string::bn2vector (Botan::SecureVector& result, const Botan::BigInt& bi) -{ - int high; - Botan::byte zero = '\0'; - - SecureVector strVector = BigInt::encode (bi); - - high = (*(strVector.begin()) & 0x80) ? 1 : 0; - - if (high) result.set (&zero, 1); - else result.clear(); - result.append (strVector); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h deleted file mode 100644 index 1829fb48682..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h +++ /dev/null @@ -1,196 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_STRING_H -#define NE7SSH_STRING_H - -#include "ne7ssh_types.h" -#include - -/** -@author Andrew Useckas -*/ -class ne7ssh_string -{ -private: - Botan::byte **positions; - uint32 parts; - uint32 currentPart; - -protected: - Botan::SecureVector buffer; - -public: - /** - * ne7ssh_string class default consturctor. - *

Zeros out 'positions' and 'parts'. - */ - ne7ssh_string(); - - /** - * ne7ssh_string class consturctor. - *

Takes a vector as an argument and places the data into 'buffer'. - * @param var Reference to a vector containing a string. - * @param position Position in the vector to start reading from. If '0', the entire vector is dumped into 'buffer'. - */ - ne7ssh_string(Botan::SecureVector& var, uint32 position); - - /** - * Same as above costructor, but instead of vector it works with a string (const char*). - * @param var Pointer to a string terminated by '/0'. - * @param position Read from this position onwards. - */ - ne7ssh_string(const char* var, uint32 position); - - /** - * ne7ssh_string class destructor. - */ - virtual ~ne7ssh_string(); - - /** - * Zeros out the buffer - */ - void clear() { buffer.destroy(); } - - /** - * Adds a string to the buffer. - *

Adds an integer representing the length of the string, converted to the network format, before the actual string data. - * Required by SSH protocol specifications. - * @param str pointer to a string. - */ - void addString (const char* str); - - /** - * Reads content of an ASCII file and appends it to the buffer. - * @param filename Full path to ASCII file. - * @return True is file is successfully read. Otherwise False is returned. - */ - bool addFile (const char* filename); - - /** - * Adds a byte stream to the buffer. - * @param buff Pointer to the byte stream. - * @param len Length of the byte stream. - */ - void addBytes (const Botan::byte* buff, uint32 len); - - /** - * Adds a vector to the buffer. - * @param secvec Reference to the vector. - */ - void addVector (Botan::SecureVector& secvec); - - /** - * Adds a vector to the buffer. - *

Adds an integer representing the length of the vector, converted to the network format, before the actual data. - * Required by SSH protocol specifications. - * @param vector Reference to a vector. - */ - void addVectorField (const Botan::SecureVector& vector); - - /** - * Adds a single character to the buffer. - * @param ch a single character. - */ - void addChar (const char ch); - - /** - * Adds a single integer to the buffer. - *

Integer is converted to network format as required by SSH protocol specifications. - * @param var a single integer. - */ - void addInt (const uint32 var); - - /** - * Adds a BigInt variable to the buffer. - *

BigInt is first converted to a vector, then the integer, representing length of the vector is converted to the network format. - * Converted ingeger is added to the buffer, followed by the vector. - * @param bn Reference to BigInt variable. - */ - void addBigInt (const Botan::BigInt& bn); - - /** - * Returns the buffer as a vector. - * @return Reference to the 'buffer' vector. - */ - virtual Botan::SecureVector &value () { return buffer; } - - /** - * Returns current length of the buffer. - * @return Length of the buffer. - */ - uint32 length () { return buffer.size(); } - - /** - * Extracts a single string from the payload field of SSH packet. - * @param result Reference to a buffer where the result will be stored. - * @return True if string field was found and successfully parsed, otherwise false is returned. - */ - bool getString (Botan::SecureVector& result); - - /** - * Extracts a single BigInt variable from the payload field of SSH packet. - * @param result Reference to a BigInt variable where the result will be stored. - * @return True if BigInt field was found and successfully parsed, otherwise false is returned. - */ - bool getBigInt (Botan::BigInt& result); - - /** - * Extracts a single unsigned integer (uint32) from the payload field of SSH packet. - * @return The integer extracted from the next 4 bytes of the payload. - */ - uint32 getInt (); - - /** - * Extracts a single byte from tje payload field of SSH packet. - * @return A byte extracted from thenext byte of the payload. - */ - Botan::byte getByte (); - - /** - * Splits the buffer into strings separated by null character. - * @param token Searches for this character in the buffer, replaces it with null and creates a part index. - */ - void split (const char token); - - /** - * Returns to the first part. - */ - void resetParts () { currentPart = 0; } - - /** - * Returns the next part. - * @return NULL terminated string, or 0 if this is the last part. - */ - char* nextPart (); - - /** - * Chops bytes off of the end of the buffer. - * @param nBytes How many bytes to chop off the end of the buffer. - */ - void chop (uint32 nBytes); - - /** - * Converts BigInt into vector - *

For internal use only - * @param result Reference to vector where the converted result will be dumped. - * @param bi Reference to BigInt to convert. - */ - static void bn2vector (Botan::SecureVector& result, const Botan::BigInt& bi); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp deleted file mode 100644 index 5ad1b0dc7c6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_transport.h" -#include "ne7ssh.h" -#include "ne7ssh_session.h" - -#if defined(WIN32) || defined(__MINGW32__) -# define SOCKET_BUFFER_TYPE char -# define close closesocket -# define SOCK_CAST (char *) -class WSockInitializer -{ -public: - WSockInitializer() - { - static WSADATA wsaData; - WSAStartup(MAKEWORD(2, 2), &wsaData); - } - ~WSockInitializer() - { - WSACleanup(); - } -} -; -WSockInitializer _wsock32_; -#else -# define SOCKET_BUFFER_TYPE void -# define SOCK_CAST (void *) -# include -# include -# include -#endif - -using namespace Botan; - -ne7ssh_transport::ne7ssh_transport(ne7ssh_session* _session) : seq(0), rSeq(0), session(_session), sock(-1) -{ -} - -ne7ssh_transport::~ne7ssh_transport() -{ - if (((long) sock) > -1) close (sock); -} - -SOCKET ne7ssh_transport::establish (const char *host, uint32 port, int timeout) -{ - sockaddr_in remoteAddr; - hostent *remoteHost; - - remoteHost = gethostbyname (host); - if (!remoteHost || remoteHost->h_length == 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Host: '%s' not found.", host); - return -1; - } - remoteAddr.sin_family = AF_INET; - remoteAddr.sin_addr.s_addr = *(long*) remoteHost->h_addr_list[0]; - remoteAddr.sin_port = htons (port); - - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Failure to bind to socket."); - return -1; - } - - if (timeout < 1) - { - if (connect (sock, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr))) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Unable to connect to remote server: '%s'.", host); - return -1; - } - - if (!NoBlock (sock, true)) return -1; - else return sock; - } - else - { - if (!NoBlock (sock, true)) - return -1; - - if (connect (sock, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr)) == -1) - { - fd_set rfds; - struct timeval waitTime; - - waitTime.tv_sec = timeout; - waitTime.tv_usec = 0; - - FD_ZERO(&rfds); - FD_SET(sock, &rfds); - - int status; - status = select(sock+1, &rfds, NULL, NULL, &waitTime); - - if ( status == 0 ) - { - if ( ! FD_ISSET(sock, &rfds) ) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Couldn't connect to remote server : timeout"); - return -1; - } - } - if ( status < 0 ) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Couldn't connect to remote server during select"); - return -1; - } - } - return sock; - } -} - -bool ne7ssh_transport::NoBlock (SOCKET socket, bool on) -{ -#ifndef WIN32 - int options; - if ((options = fcntl ( socket, F_GETFL )) < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot read options of the socket: %i.", (int)socket); - return false; - } - - if ( on ) options = ( options | O_NONBLOCK ); - else options = ( options & ~O_NONBLOCK ); - fcntl (socket, F_SETFL, options); -#else - unsigned long options = 1; - if (ioctlsocket(socket, FIONBIO, &options)) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot set asynch I/O on the socket: %i.", (int)socket); - return false; - } -#endif - return true; -} - -bool ne7ssh_transport::haveData () -{ - return wait (sock, 0, 0); -} - -bool ne7ssh_transport::wait (SOCKET socket, int rw, int timeout) -{ - int status; - fd_set rfds, wfds; - struct timeval waitTime; - - if (timeout > -1) - { - waitTime.tv_sec = timeout; - waitTime.tv_usec = 0; - } - - if (!rw) - { - FD_ZERO(&rfds); - FD_SET(socket, &rfds); - } - else - { - FD_ZERO(&wfds); - FD_SET(socket, &wfds); - } - - if (!rw) - { - if (timeout > -1) status = select(socket + 1, &rfds, NULL, NULL, &waitTime); - else status = select(socket + 1, &rfds, NULL, NULL, NULL); - } - else status = select(socket + 1, NULL, &wfds, NULL, NULL); - - if (status > 0) - return true; - else - return false; -} - - -bool ne7ssh_transport::send (Botan::SecureVector& buffer) -{ - long byteCount; - uint32 sent = 0; - - if (buffer.size() > MAX_PACKET_LEN) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot send. Packet too large for the transport layer."); - return false; - } - - while (sent < buffer.size()) - { - if (wait(sock, 1)) - byteCount = ::send(sock, (const SOCKET_BUFFER_TYPE *) (buffer.begin() + sent), buffer.size() - sent, 0); - else return false; - if (byteCount < 0) - return false; - sent += byteCount; - } - - return true; -} - -bool ne7ssh_transport::receive (Botan::SecureVector& buffer, bool append) -{ - Botan::byte in_buffer[MAX_PACKET_LEN]; - int len; - - if (wait(sock, 0)) - len = ::recv (sock, (char*) in_buffer, MAX_PACKET_LEN, 0); - - if (!len) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Received a packet of zero length."); - return false; - } - - if (len > MAX_PACKET_LEN) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Received packet exceeds the maximum size"); - return false; - } - - if (len < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Connection dropped"); - return false; - } - - if (append) buffer.append (in_buffer, len); - else - { - buffer.clear(); - buffer.set (in_buffer, len); - } - - return true; -} - -bool ne7ssh_transport::sendPacket (Botan::SecureVector &buffer) -{ - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string out; - uint32 crypt_block; - char padLen; - uint32 packetLen; - Botan::byte *padBytes; - uint32 length; - SecureVector crypted, hmac; - -// No Zlib support right now -// if (_crypto->isInited()) _crypto->compressData (buffer); - length = buffer.size(); - - crypt_block = _crypto->getEncryptBlock(); - if (!crypt_block) crypt_block = 8; - - padLen = 3 + crypt_block - ((length + 8) % crypt_block); - packetLen = 1 + length + padLen; - - out.addInt (packetLen); - out.addChar (padLen); - out.addVector (buffer); - - padBytes = (Botan::byte*) malloc (padLen); - memset (padBytes, 0x00, padLen); - out.addBytes (padBytes, padLen); - free (padBytes); - - if (_crypto->isInited()) - { - if (!_crypto->encryptPacket (crypted, hmac, out.value(), seq)) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Failure to encrypt the payload."); - return false; - } - crypted.append (hmac); - if (!send (crypted)) return false; - } - else if (!send (out.value())) return false; - if (seq == MAX_SEQUENCE) seq = 0; - else seq++; - return true; -} - -short ne7ssh_transport::waitForPacket (Botan::byte cmd, bool bufferOnly) -{ - ne7ssh_crypt *_crypto = session->crypto; - Botan::byte _cmd; - SecureVector tmpVar, decrypted, uncommpressed, ourMac, hMac; - uint32 len, cryptoLen; - bool havePacket = false; - -/* if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock(), seq); - else tmpVar.destroy(); - } - else*/ - tmpVar.set (in); - - if (!tmpVar.is_empty()) - { - if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock()); - else tmpVar.destroy(); - } - _cmd = *(tmpVar.begin() + 5); - - if (_cmd > 0 && _cmd < 0xff) havePacket = true; - } - - if (!havePacket) - { - if (bufferOnly) return 0; - if (!receive(in)) return -1; - - if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock()); - else tmpVar.destroy(); - } - else - { - while (in.size() < 4) - if (!receive(in, true)) return -1; - - cryptoLen = ntohl (*((int*)in.begin())) + sizeof(uint32); - while (in.size() < cryptoLen) - if (!receive(in, true)) return -1; - - tmpVar.set (in); - } - } - - len = ntohl (*((int*)tmpVar.begin())); - cryptoLen = len + sizeof(uint32); - - decrypted.set (tmpVar); - if (_crypto->isInited()) - { - while (((cryptoLen + _crypto->getMacInLen()) > in.size()) || (in.size() % _crypto->getDecryptBlock())) - { - if (!receive(in, true)) return 0; - } - if (cryptoLen > _crypto->getDecryptBlock()) - { - tmpVar.set (in.begin() + _crypto->getDecryptBlock(), (cryptoLen - _crypto->getDecryptBlock())); - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, tmpVar, tmpVar.size()); - decrypted.append (tmpVar); - } - if (_crypto->getMacInLen()) - { - _crypto->computeMac (ourMac, decrypted, rSeq ); - hMac.set (in.begin() + cryptoLen, _crypto->getMacInLen()); - if (hMac != ourMac) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Mismatched HMACs."); - return -1; - } - cryptoLen += _crypto->getMacInLen(); - } - - -// No Zlib support right now -/* if (_crypto->isCompressed()) - { - tmpVar.set (decrypted.begin() + 5, len); - _crypto->decompressData (tmpVar); - uncommpressed.set (decrypted.begin(), 4); - uncommpressed.append (tmpVar); - decrypted.set (uncommpressed); - }*/ - } - - if (rSeq == MAX_SEQUENCE) rSeq = 0; - else rSeq++; - _cmd = *(decrypted.begin() + 5); - - if (cmd == _cmd || !cmd) - { - inBuffer.set (decrypted); - if (!(in.size() - cryptoLen)) in.destroy(); - else - { - tmpVar.swap (in); - in.set (tmpVar.begin() + cryptoLen, tmpVar.size() - cryptoLen); - } - return _cmd; - } - else return 0; - -} - -uint32 ne7ssh_transport::getPacket (Botan::SecureVector &result) -{ - ne7ssh_crypt *_crypto = session->crypto; - SecureVector tmpVector(inBuffer); - uint32 len = ntohl (*((uint32*)tmpVector.begin())); - Botan::byte padLen = *(tmpVector.begin() + 4); - uint32 macLen = _crypto->getMacInLen(); - - if (inBuffer.is_empty()) - { - result.clear(); - return 0; - } - - if (_crypto->isInited()) - { - len += macLen; - if (len > tmpVector.size()) len -= macLen; - } - - tmpVector.append ((uint8*)"\0", 1); - result.set (tmpVector.begin() + 5, len); - _crypto->decompressData (result); - - inBuffer.destroy(); - return padLen; -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h deleted file mode 100644 index 2cbc6ced271..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_TRANSPORT_H -#define NE7SSH_TRANSPORT_H - -#include "crypt.h" -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -#if defined(WIN32) || defined(__MINGW32__) -# include -#endif -#include - -//#define MAX_PACKET_LEN 35000 -#define MAX_PACKET_LEN 34816 -#define MAX_SEQUENCE 4294967295U - -#if !defined(WIN32) && !defined(__MINGW32__) -# define SOCKET int -#endif - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_transport -{ - private: - uint32 seq, rSeq; - const ne7ssh_session* session; - SOCKET sock; - Botan::SecureVector in; - Botan::SecureVector inBuffer; - - /** - * Switches socket's NonBlocking option on or off. - * @param socket Socket number. - * @param on If set to true, NonBlocking option will be turned on, and vice versa. - * @return True if options have been successfuly set, otherwise false is returned. - */ - bool NoBlock (SOCKET socket, bool on); - - /** - * Waits for activity on a socket. - * @param socket Socket number. - * @param rw If set to true, checks if process can write to the socket, otherwise checks if there is data to be read from the socket. - * @param timeout Desired timeout. By default the function will block until socket is ready for reading/writting. If set to '0', the function will return right away. - * @return True if socket is ready for reading/writting, otherwise false is returned. - */ - bool wait (SOCKET socket, int rw, int timeout = -1); - - public: - /** - * ne7ssh_transport class constructor. - *

Transport class handles all socket communications for the ne7ssh library. - * @param _session Pointer to ne7ssh_session instance. - */ - ne7ssh_transport(ne7ssh_session* _session); - - /** - * ne7ssh_transport class destructor. - */ - ~ne7ssh_transport(); - - /** - * Establishes connection to a remote host. - * @param host Host name or IP. - * @param port Port. - * @param timeout Timeout for the establish procedure, in seconds. - * @return Socket number or -1 on failure. - */ - SOCKET establish (const char *host, uint32 port, int timeout = 0); - - /** - * Reads data from the socket. - * @param buffer The data will be placed here. - * @param append If set to true, received data will be appended to the buffer, instead of overwriting it. - * @return True if data successfuly read, otherwise false is returned. - */ - bool receive (Botan::SecureVector& buffer, bool append = false); - - /** - * Writes a buffer to the socket. - * @param buffer Data to be written to the socket. - * @return True if data successful sent, otherwise false is returned. - */ - bool send (Botan::SecureVector& buffer); - - /** - * Assembles an SSH packet, as specified in SSH standards and passes the buffer to send() function. - * @param buffer Payload to be sent. - * @return True if send successful, otherwise false is returned. - */ - bool sendPacket (Botan::SecureVector& buffer); - - /** - * Waits until specified type of packet is received. - *

If cmd is 0, waits for the first available packet of any kind. - *

Once the desired packet is received, it is decrypted / decommpressed, the hMac is checked, and dropped into inBuffer class variable. - * @param cmd SSH2 packet to wait for. If 0, first available packet will be read into inBuffer class variable. - * @param bufferOnly Does not wait to receive a new packet, only checks existing receive buffer for unprocessed packets. - * @return 1 if desired packet is received, 0 if there another packet is received, or -1 if HMAC checking is enabled, and remote and local HMACs do not match. - */ - short waitForPacket (Botan::byte cmd, bool bufferOnly = false); - - /** - * Gets the payload section from an SSH packet received by waitForPacket() function. - * @param result The payload will be stored here. - * @return The SSH packet passing length. - */ - uint32 getPacket (Botan::SecureVector& result); - - /** - * Checks to see if there is more data to be read from the socket. - * @return True if there is data to be read, otherwise false is returned. - */ - bool haveData (); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h deleted file mode 100644 index 68af80c0047..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_TYPES_H -#define NE7SSH_TYPES_H - -#if defined(WIN32) || defined(__MINGW32) - typedef int int32_t; - typedef long long int64_t; - typedef short int16_t; - typedef signed char int8_t; - - typedef unsigned int uint32_t; - typedef unsigned long long uint64_t; - typedef unsigned short uint16_t; - typedef unsigned char uint8_t; - -# if defined(_WINDLL) || defined(_USRDLL) || defined(_CONSOLE) || defined(_WINDOWS) -# ifdef NE7SSH_EXPORTS -# define SSH_EXPORT __declspec(dllexport) -# else -# define SSH_EXPORT __declspec(dllimport) -# endif -# else -# define SSH_EXPORT -# endif -#else -# include -# define SSH_EXPORT __attribute__ ((visibility("default"))) -#endif - -#ifndef int64_defined -#define int64_defined -typedef int64_t int64; -#endif - -#ifndef uint64_defined -#define uint64_defined -typedef uint64_t uint64; -#endif - -#ifndef int32_defined -#define int32_defined -typedef int32_t int32; -#endif - -#ifndef uint32_defined -#define uint32_defined -typedef uint32_t uint32; -#endif - -#ifndef int16_defined -#define int16_defined -typedef int16_t int16; -#endif - -#ifndef uint16_defined -#define uint16_defined -typedef uint16_t uint16; -#endif - -#ifndef int8_defined -#define int8_defined -typedef int8_t int8; -#endif - -#ifndef uint8_defined -#define uint8_defined -typedef uint8_t uint8; -#endif - -#ifndef Byte_defined -#define Byte_defined -typedef uint8_t Byte; -#endif - -#if defined(WIN32) || defined(__MINGW32__) -# define usleep(time) Sleep(time / 1000) -#endif - -#endif - diff --git a/src/libs/3rdparty/net7ssh/src/src.pro b/src/libs/3rdparty/net7ssh/src/src.pro deleted file mode 100644 index 1584dc722c0..00000000000 --- a/src/libs/3rdparty/net7ssh/src/src.pro +++ /dev/null @@ -1,54 +0,0 @@ -TEMPLATE = lib -TARGET = Net7ssh - -CONFIG += dll - -include(../../../../qtcreatorlibrary.pri) - -DEPENDPATH += . -INCLUDEPATH += $$PWD $$PWD/../../botan $$PWD/../../botan/build - -include(../net7ssh_dependencies.pri) - -win32 { - LIBS += -lWs2_32 - win32-msvc*: QMAKE_CXXFLAGS += -wd4100 -wd4101 -wd4250 -wd4251 -wd4290 - - DEFINES += _CRT_SECURE_NO_WARNINGS - DEFINES += NE7SSH_EXPORTS=1 _WINDLL _USRDLL _CONSOLE _WINDOWS -} - -unix { - QMAKE_CXXFLAGS_HIDESYMS -= -fvisibility-inlines-hidden # for ubuntu 7.04 - QMAKE_CXXFLAGS += -Wno-unused-parameter -} - -# Input -HEADERS += crypt.h \ - ne7ssh.h \ - ne7ssh_channel.h \ - ne7ssh_connection.h \ - ne7ssh_error.h \ - ne7ssh_kex.h \ - ne7ssh_keys.h \ - ne7ssh_mutex.h \ - ne7ssh_session.h \ - ne7ssh_sftp.h \ - ne7ssh_sftp_packet.h \ - ne7ssh_string.h \ - ne7ssh_transport.h \ - ne7ssh_types.h - -SOURCES += crypt.cpp \ - ne7ssh.cpp \ - ne7ssh_channel.cpp \ - ne7ssh_connection.cpp \ - ne7ssh_error.cpp \ - ne7ssh_kex.cpp \ - ne7ssh_keys.cpp \ - ne7ssh_mutex.cpp \ - ne7ssh_session.cpp \ - ne7ssh_sftp.cpp \ - ne7ssh_sftp_packet.cpp \ - ne7ssh_string.cpp \ - ne7ssh_transport.cpp diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index 9c8ebfe3b58..56b05e39a69 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -256,27 +256,48 @@ private: _type = control()->namedType(templId); } - virtual void visit(const QualifiedNameId *name) + const Name *instantiate(const Name *name) { - QVarLengthArray names(name->nameCount()); - for (unsigned i = 0; i < name->nameCount(); ++i) { - const Name *n = name->nameAt(i); + if (! name) + return name; - if (const TemplateNameId *templId = n->asTemplateNameId()) { - QVarLengthArray arguments(templId->templateArgumentCount()); - for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) { - FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex); - arguments[templateArgIndex] = q->apply(argTy); - } + else if (const Name *nameId = name->asNameId()) { + const Identifier *id = control()->findOrInsertIdentifier(nameId->identifier()->chars(), + nameId->identifier()->size()); + return control()->nameId(id); - n = control()->templateNameId(templId->identifier(), arguments.data(), arguments.size()); + } else if (const TemplateNameId *templId = name->asTemplateNameId()) { + QVarLengthArray arguments(templId->templateArgumentCount()); + for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) { + FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex); + arguments[templateArgIndex] = q->apply(argTy); } + const Identifier *id = control()->findOrInsertIdentifier(templId->identifier()->chars(), + templId->identifier()->size()); + return control()->templateNameId(id, arguments.data(), arguments.size()); + + } else if (const QualifiedNameId *qq = name->asQualifiedNameId()) { + const Name *base = instantiate(qq->base()); + const Name *name = instantiate(qq->name()); + + return control()->qualifiedNameId(base, name); + + } else if (const OperatorNameId *op = name->asOperatorNameId()) { + return control()->operatorNameId(op->kind()); + + } else if (const ConversionNameId *c = name->asConversionNameId()) { + FullySpecifiedType ty = q->apply(c->type()); + return control()->conversionNameId(ty); - names[i] = n; } - const QualifiedNameId *q = control()->qualifiedNameId(names.data(), names.size(), name->isGlobal()); - _type = control()->namedType(q); + return 0; + } + + virtual void visit(const QualifiedNameId *name) + { + if (const Name *n = instantiate(name)) + _type = control()->namedType(n); } virtual void visit(const DestructorNameId *name) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 83f118b449f..ce832e2df60 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -47,32 +47,37 @@ namespace { using namespace CPlusPlus; -static void fullyQualifiedName_helper(Symbol *symbol, QList *names) +static void addNames(const Name *name, QList *names, bool addAllNames = false) +{ + if (! name) + return; + else if (const QualifiedNameId *q = name->asQualifiedNameId()) { + addNames(q->base(), names); + addNames(q->name(), names); + } else if (addAllNames || name->isNameId() || name->isTemplateNameId()) { + names->append(name); + } +} + +static void path_helper(Symbol *symbol, QList *names) { if (! symbol) return; - fullyQualifiedName_helper(symbol->enclosingSymbol(), names); + path_helper(symbol->enclosingSymbol(), names); if (symbol->name()) { if (symbol->isClass() || symbol->isNamespace()) { - if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) { - for (unsigned i = 0; i < q->nameCount(); ++i) - names->append(q->nameAt(i)); + addNames(symbol->name(), names); - } else if (symbol->name()->isNameId() || symbol->name()->isTemplateNameId()) { - names->append(symbol->name()); - } } else if (symbol->isObjCClass() || symbol->isObjCBaseClass() || symbol->isObjCProtocol() || symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration() || symbol->isForwardClassDeclaration()) { - if (symbol->name()) - names->append(symbol->name()); + addNames(symbol->name(), names); + } else if (symbol->isFunction()) { - if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) { - for (unsigned i = 0; i < q->nameCount() - 1; ++i) - names->append(q->nameAt(i)); - } + if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) + addNames(q->base(), names); } } } @@ -132,12 +137,62 @@ LookupContext &LookupContext::operator = (const LookupContext &other) } QList LookupContext::fullyQualifiedName(Symbol *symbol) +{ + QList qualifiedName = path(symbol->enclosingSymbol()); + addNames(symbol->name(), &qualifiedName, /*add all names*/ true); + return qualifiedName; +} + +QList LookupContext::path(Symbol *symbol) { QList names; - fullyQualifiedName_helper(symbol, &names); + path_helper(symbol, &names); return names; } + +const Name *LookupContext::minimalName(const Name *name, + Scope *scope, + ClassOrNamespace *target) const +{ + qWarning() << "TODO:" << Q_FUNC_INFO; + +#if 0 + Q_ASSERT(name); + Q_ASSERT(source); + Q_ASSERT(target); + + QList symbols = lookup(name, source); + if (symbols.isEmpty()) + return 0; + + Symbol *canonicalSymbol = symbols.first(); + std::vector fqNames = fullyQualifiedName(canonicalSymbol).toVector().toStdVector(); + if (const QualifiedNameId *qId = name->asQualifiedNameId()) + fqNames.push_back(qId->name()); + else + fqNames.push_back(name); + + const QualifiedNameId *lastWorking = 0; + for (unsigned i = 0; i < fqNames.size(); ++i) { + const QualifiedNameId *newName = control()->qualifiedNameId(&fqNames[i], + fqNames.size() - i); + QList candidates = target->lookup(newName); + if (candidates.contains(canonicalSymbol)) + lastWorking = newName; + else + break; + } + + if (lastWorking && lastWorking->nameCount() == 1) + return lastWorking->nameAt(0); + else + return lastWorking; +#endif + return 0; +} + + QSharedPointer LookupContext::bindings() const { if (! _bindings) @@ -280,6 +335,19 @@ QList LookupContext::lookup(const Name *name, Scope *scope) const return candidates; } +ClassOrNamespace *LookupContext::lookupParent(Symbol *symbol) const +{ + QList fqName = path(symbol); + ClassOrNamespace *binding = globalNamespace(); + foreach (const Name *name, fqName) { + binding = binding->findType(name); + if (!binding) + return 0; + } + + return binding; +} + ClassOrNamespace::ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *parent) : _factory(factory), _parent(parent), _templateId(0) { @@ -346,21 +414,11 @@ QList ClassOrNamespace::lookup_helper(const Name *name, bool searchInE if (name) { if (const QualifiedNameId *q = name->asQualifiedNameId()) { - ClassOrNamespace *binding = this; + if (! q->base()) + result = globalNamespace()->find(q->name()); - if (q->isGlobal()) - binding = globalNamespace(); - - if (q->nameCount() == 1) - return binding->find(q->unqualifiedNameId()); - - binding = binding->lookupType(q->nameAt(0)); - - for (unsigned index = 1; binding && index < q->nameCount() - 1; ++index) - binding = binding->findType(q->nameAt(index)); - - if (binding) - result = binding->find(q->unqualifiedNameId()); + else if (ClassOrNamespace *binding = lookupType(q->base())) + result = binding->find(q->name()); return result; } @@ -432,7 +490,6 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope, else if (s->name()->isQualifiedNameId()) continue; // skip qualified ids. -#if 0 if (templateId && (s->isDeclaration() || s->isFunction())) { FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, _control); @@ -457,7 +514,6 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope, continue; } } -#endif result->append(s); } @@ -485,17 +541,14 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name, bool searchInEnclosingScope) { if (const QualifiedNameId *q = name->asQualifiedNameId()) { - ClassOrNamespace *e = this; - if (q->isGlobal()) - e = globalNamespace(); + if (! q->base()) + return globalNamespace()->findType(q->name()); - e = e->lookupType(q->nameAt(0)); + else if (ClassOrNamespace *binding = lookupType(q->base())) + return binding->findType(q->name()); - for (unsigned index = 1; e && index < q->nameCount(); ++index) - e = e->findType(q->nameAt(index)); - - return e; + return 0; } else if (! processed->contains(this)) { processed->insert(this); @@ -605,12 +658,10 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name) return this; if (const QualifiedNameId *q = name->asQualifiedNameId()) { - ClassOrNamespace *e = this; + if (! q->base()) + return globalNamespace()->findOrCreateType(q->name()); - for (unsigned i = 0; e && i < q->nameCount(); ++i) - e = e->findOrCreateType(q->nameAt(i)); - - return e; + return findOrCreateType(q->base())->findOrCreateType(q->name()); } else if (name->isNameId() || name->isTemplateNameId()) { ClassOrNamespace *e = nestedType(name); @@ -654,15 +705,19 @@ ClassOrNamespace *CreateBindings::globalNamespace() const ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol) { - const QList names = LookupContext::fullyQualifiedName(symbol); + const QList path = LookupContext::path(symbol); + return lookupType(path); +} - if (names.isEmpty()) +ClassOrNamespace *CreateBindings::lookupType(const QList &path) +{ + if (path.isEmpty()) return _globalNamespace; - ClassOrNamespace *b = _globalNamespace->lookupType(names.at(0)); + ClassOrNamespace *b = _globalNamespace->lookupType(path.at(0)); - for (int i = 1; b && i < names.size(); ++i) - b = b->findType(names.at(i)); + for (int i = 1; b && i < path.size(); ++i) + b = b->findType(path.at(i)); return b; } @@ -823,7 +878,7 @@ bool CreateBindings::visit(UsingDeclaration *u) { if (u->name()) { if (const QualifiedNameId *q = u->name()->asQualifiedNameId()) { - if (const NameId *unqualifiedId = q->unqualifiedNameId()->asNameId()) { + if (const NameId *unqualifiedId = q->name()->asNameId()) { if (ClassOrNamespace *delegate = _currentClassOrNamespace->lookupType(q)) { ClassOrNamespace *b = _currentClassOrNamespace->findOrCreateType(unqualifiedId); b->addUsing(delegate); diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 73893a66701..3854b4cb7b7 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -125,6 +125,7 @@ public: /// Finds the binding associated to the given symbol. ClassOrNamespace *lookupType(Symbol *symbol); + ClassOrNamespace *lookupType(const QList &path); /// Returns the Control that must be used to create temporary symbols. /// \internal @@ -216,6 +217,7 @@ public: QList lookup(const Name *name, Scope *scope) const; ClassOrNamespace *lookupType(const Name *name, Scope *scope) const; ClassOrNamespace *lookupType(Symbol *symbol) const; + ClassOrNamespace *lookupParent(Symbol *symbol) const; /// \internal QSharedPointer bindings() const; @@ -226,6 +228,10 @@ public: QSharedPointer control() const; // ### deprecate static QList fullyQualifiedName(Symbol *symbol); + static QList path(Symbol *symbol); + + Q_DECL_DEPRECATED const Name *minimalName(const Name *name, Scope *source, + ClassOrNamespace *target) const; private: // The current expression. diff --git a/src/libs/cplusplus/NamePrettyPrinter.cpp b/src/libs/cplusplus/NamePrettyPrinter.cpp index 89c6ddb4764..5c6146d0e98 100644 --- a/src/libs/cplusplus/NamePrettyPrinter.cpp +++ b/src/libs/cplusplus/NamePrettyPrinter.cpp @@ -246,14 +246,10 @@ void NamePrettyPrinter::visit(const ConversionNameId *name) void NamePrettyPrinter::visit(const QualifiedNameId *name) { - if (name->isGlobal()) - _name += QLatin1String("::"); - - for (unsigned index = 0; index < name->nameCount(); ++index) { - if (index != 0) - _name += QLatin1String("::"); - _name += operator()(name->nameAt(index)); - } + if (name->base()) + _name += operator()(name->base()); + _name += QLatin1String("::"); + _name += operator()(name->name()); } void NamePrettyPrinter::visit(const SelectorNameId *name) diff --git a/src/libs/cplusplus/Overview.cpp b/src/libs/cplusplus/Overview.cpp index 37ec7d7e1db..48cdb009b75 100644 --- a/src/libs/cplusplus/Overview.cpp +++ b/src/libs/cplusplus/Overview.cpp @@ -30,6 +30,9 @@ #include "Overview.h" #include "NamePrettyPrinter.h" #include "TypePrettyPrinter.h" + +#include +#include #include using namespace CPlusPlus; @@ -145,3 +148,23 @@ QString Overview::prettyType(const FullySpecifiedType &ty, TypePrettyPrinter pp(this); return pp(ty, name); } + +/** + * Pretty-prints the given fully-specified type, but replacing the contained + * type with the given name. + * + * \param type the fully-specified type to convert to string + * \param the name for the named-type to use + * \param the control where the name is registered + * \return the pretty-printed name + */ +QString Overview::prettyTypeWithName(const FullySpecifiedType &type, + const Name *name, + Control *control) +{ + NamedType *namedTy = control->namedType(name); + FullySpecifiedType newTy = type; + newTy.setType(namedTy); + + return prettyType(newTy); +} diff --git a/src/libs/cplusplus/Overview.h b/src/libs/cplusplus/Overview.h index 9cebefed01f..7471f306a12 100644 --- a/src/libs/cplusplus/Overview.h +++ b/src/libs/cplusplus/Overview.h @@ -79,6 +79,10 @@ public: QString prettyType(const FullySpecifiedType &type, const Name *name = 0) const; QString prettyType(const FullySpecifiedType &type, const QString &name) const; + QString prettyTypeWithName(const FullySpecifiedType &type, + const Name *name, + Control *control); + private: unsigned _markedArgument; int _markedArgumentBegin; diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index aadc1f5273a..b02b7ecf5d1 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -221,11 +221,10 @@ bool ResolveExpression::visit(NewExpressionAST *ast) bool ResolveExpression::visit(TypeidExpressionAST *) { - const Name *std_type_info[2]; - std_type_info[0] = control()->nameId(control()->findOrInsertIdentifier("std")); - std_type_info[1] = control()->nameId(control()->findOrInsertIdentifier("type_info")); + const Name *stdName = control()->nameId(control()->findOrInsertIdentifier("std")); + const Name *tiName = control()->nameId(control()->findOrInsertIdentifier("type_info")); + const Name *q = control()->qualifiedNameId(control()->qualifiedNameId(/* :: */ 0, stdName), tiName); - const Name *q = control()->qualifiedNameId(std_type_info, 2, /*global=*/ true); FullySpecifiedType ty(control()->namedType(q)); addResult(ty, _scope); @@ -314,14 +313,11 @@ void ResolveExpression::thisObject() addResult(ptrTy, fun->scope()); break; } else if (const QualifiedNameId *q = fun->name()->asQualifiedNameId()) { - const Name *nestedNameSpecifier = 0; - if (q->nameCount() == 1 && q->isGlobal()) - nestedNameSpecifier = q->nameAt(0); - else - nestedNameSpecifier = control()->qualifiedNameId(q->names(), q->nameCount() - 1); - FullySpecifiedType classTy(control()->namedType(nestedNameSpecifier)); - FullySpecifiedType ptrTy(control()->pointerType(classTy)); - addResult(ptrTy, fun->scope()); + if (q->base()) { + FullySpecifiedType classTy(control()->namedType(q->base())); + FullySpecifiedType ptrTy(control()->pointerType(classTy)); + addResult(ptrTy, fun->scope()); + } break; } } @@ -604,7 +600,12 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), overload->scope())) return retBinding; - else if (debug) { + else if (scope != overload->scope()) { + if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), scope)) + return retBinding; + } + + if (debug) { Overview oo; qDebug() << "no class for:" << oo(ptrTy->elementType()); } diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 40e87760b93..e5cd8579ed0 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -79,11 +79,20 @@ QList TypeOfExpression::operator()(const QString &expression, Document::Ptr expressionDoc = documentForExpression(code); expressionDoc->check(); - m_ast = extractExpressionAST(expressionDoc); + return this->operator ()(extractExpressionAST(expressionDoc), + expressionDoc, + scope); +} + +QList TypeOfExpression::operator()(ExpressionAST *expression, + Document::Ptr document, + Scope *scope) +{ + m_ast = expression; m_scope = scope; - m_lookupContext = LookupContext(expressionDoc, m_thisDocument, m_snapshot); + m_lookupContext = LookupContext(document, m_thisDocument, m_snapshot); m_lookupContext.setBindings(m_bindings); ResolveExpression resolve(m_lookupContext); diff --git a/src/libs/cplusplus/TypeOfExpression.h b/src/libs/cplusplus/TypeOfExpression.h index 9d32e57f8e0..c1ab1288aac 100644 --- a/src/libs/cplusplus/TypeOfExpression.h +++ b/src/libs/cplusplus/TypeOfExpression.h @@ -82,6 +82,22 @@ public: Scope *scope, PreprocessMode mode = NoPreprocess); + /** + * Returns a list of possible fully specified types associated with the + * given expression AST from the given document. + * + * NOTE: The fully specified types only stay valid for as long as this + * expression evaluator instance still exists, and no new call to evaluate + * has been made! + * + * @param expression The expression to evaluate. + * @param document The document in which the expression lives. + * @param scope The scope enclosing the expression. + */ + QList operator()(ExpressionAST *expression, + Document::Ptr document, + Scope *scope); + QString preprocess(const QString &expression) const; /** diff --git a/src/libs/extensionsystem/iplugin.cpp b/src/libs/extensionsystem/iplugin.cpp index 57fc9d9e86b..d5cfdfd61d9 100644 --- a/src/libs/extensionsystem/iplugin.cpp +++ b/src/libs/extensionsystem/iplugin.cpp @@ -217,36 +217,62 @@ /*! \fn bool IPlugin::initialize(const QStringList &arguments, QString *errorString) - Called after the plugin has been loaded and the IPlugin instance - has been created. The initialize methods of plugins that depend + \brief Called after the plugin has been loaded and the IPlugin instance + has been created. + + The initialize methods of plugins that depend on this plugin are called after the initialize method of this plugin has been called. Plugins should initialize their internal state in this method. Returns if initialization of successful. If it wasn't successful, the \a errorString should be set to a user-readable message describing the reason. + \sa extensionsInitialized() */ /*! \fn void IPlugin::extensionsInitialized() - Called after the IPlugin::initialize() method has been called, + \brief Called after the IPlugin::initialize() method has been called, and after both the IPlugin::initialize() and IPlugin::extensionsInitialized() methods of plugins that depend on this plugin have been called. + In this method, the plugin can assume that plugins that depend on this plugin are fully 'up and running'. It is a good place to look in the plugin manager's object pool for objects that have been provided by dependent plugins. + \sa initialize() */ /*! - \fn void IPlugin::aboutToShutdown() - Called during a shutdown sequence in the same order as initialization + \fn IPlugin::ShutdownFlag IPlugin::aboutToShutdown() + \brief Called during a shutdown sequence in the same order as initialization before the plugins get deleted in reverse order. - This method can be used to optimize the shutdown down, e.g. to - disconnect from the PluginManager::aboutToRemoveObject() signal - if getting the signal (and probably doing lots of stuff to update - the internal and visible state) doesn't make sense during shutdown. + + This method should be used to disconnect from other plugins, + hide all UI, and optimize shutdown in general. + If a plugin needs to delay the real shutdown for a while, for example if + it needs to wait for external processes to finish for a clean shutdown, + the plugin can return IPlugin::AsynchronousShutdown from this method. This + will keep the main event loop running after the aboutToShutdown() sequence + has finished, until all plugins requesting AsynchronousShutdown have sent + the asynchronousShutdownFinished() signal. + + The default implementation of this method does nothing and returns + IPlugin::SynchronousShutdown. + + Returns IPlugin::AsynchronousShutdown if the plugin needs to perform + asynchonous actions before performing the shutdown. + + \sa asynchronousShutdownFinished() +*/ + +/*! + \fn void IPlugin::asynchronousShutdownFinished() + Sent by the plugin implementation after a asynchronous shutdown + is ready to proceed with the shutdown sequence. + + \sa aboutToShutdown() */ using namespace ExtensionSystem; diff --git a/src/libs/extensionsystem/iplugin.h b/src/libs/extensionsystem/iplugin.h index 889daecd736..d4125723438 100644 --- a/src/libs/extensionsystem/iplugin.h +++ b/src/libs/extensionsystem/iplugin.h @@ -49,12 +49,17 @@ class EXTENSIONSYSTEM_EXPORT IPlugin : public QObject Q_OBJECT public: + enum ShutdownFlag { + SynchronousShutdown, + AsynchronousShutdown + }; + IPlugin(); virtual ~IPlugin(); virtual bool initialize(const QStringList &arguments, QString *errorString) = 0; virtual void extensionsInitialized() = 0; - virtual void aboutToShutdown() { } + virtual ShutdownFlag aboutToShutdown() { return SynchronousShutdown; } virtual void remoteCommand(const QStringList & /* options */, const QStringList & /* arguments */) { } PluginSpec *pluginSpec() const; @@ -63,6 +68,9 @@ public: void addAutoReleasedObject(QObject *obj); void removeObject(QObject *obj); +signals: + void asynchronousShutdownFinished(); + private: Internal::IPluginPrivate *d; diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index f7b41b67746..37dd4daeb9a 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -253,6 +253,16 @@ void PluginManager::loadPlugins() return d->loadPlugins(); } +/*! + \fn void PluginManager::shutdown() + Shuts down and deletes all plugins. +*/ +void PluginManager::shutdown() +{ + d->shutdown(); +} + + /*! \fn QStringList PluginManager::pluginPaths() const The list of paths were the plugin manager searches for plugins. @@ -628,20 +638,21 @@ PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) : { } + /*! \fn PluginManagerPrivate::~PluginManagerPrivate() \internal */ PluginManagerPrivate::~PluginManagerPrivate() { - stopAll(); qDeleteAll(pluginSpecs); qDeleteAll(pluginCategories); - if (!allObjects.isEmpty()) { - qDebug() << "There are" << allObjects.size() << "objects left in the plugin manager pool: " << allObjects; - } } +/*! + \fn void PluginManagerPrivate::writeSettings() + \internal +*/ void PluginManagerPrivate::writeSettings() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, @@ -660,6 +671,10 @@ void PluginManagerPrivate::writeSettings() settings.setValue(QLatin1String(C_FORCEENABLED_PLUGINS), tempForceEnabledPlugins); } +/*! + \fn void PluginManagerPrivate::loadSettings() + \internal +*/ void PluginManagerPrivate::loadSettings() { const QSettings settings(QSettings::IniFormat, QSettings::UserScope, @@ -669,12 +684,25 @@ void PluginManagerPrivate::loadSettings() forceEnabledPlugins = settings.value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList(); } +/*! + \fn void PluginManagerPrivate::stopAll() + \internal +*/ void PluginManagerPrivate::stopAll() { QList queue = loadQueue(); foreach (PluginSpec *spec, queue) { loadPlugin(spec, PluginSpec::Stopped); } +} + +/*! + \fn void PluginManagerPrivate::deleteAll() + \internal +*/ +void PluginManagerPrivate::deleteAll() +{ + QList queue = loadQueue(); QListIterator it(queue); it.toBack(); while (it.hasPrevious()) { @@ -759,6 +787,36 @@ void PluginManagerPrivate::loadPlugins() emit q->pluginsChanged(); } +/*! + \fn void PluginManagerPrivate::shutdown() + \internal +*/ +void PluginManagerPrivate::shutdown() +{ + stopAll(); + if (!asynchronousPlugins.isEmpty()) { + shutdownEventLoop = new QEventLoop; + shutdownEventLoop->exec(); + } + deleteAll(); + if (!allObjects.isEmpty()) { + qDebug() << "There are" << allObjects.size() << "objects left in the plugin manager pool: " << allObjects; + } +} + +/*! + \fn void PluginManagerPrivate::asyncShutdownFinished() + \internal +*/ +void PluginManagerPrivate::asyncShutdownFinished() +{ + IPlugin *plugin = qobject_cast(sender()); + Q_ASSERT(plugin); + asynchronousPlugins.removeAll(plugin->pluginSpec()); + if (asynchronousPlugins.isEmpty()) + shutdownEventLoop->exit(); +} + /*! \fn void PluginManagerPrivate::loadQueue() \internal @@ -836,7 +894,9 @@ void PluginManagerPrivate::loadPlugin(PluginSpec *spec, PluginSpec::State destSt profilingReport("delete", spec); spec->d->kill(); + profilingReport("stop", spec); - spec->d->stop(); + if (spec->d->stop() == IPlugin::AsynchronousShutdown) { + asynchronousPlugins << spec; + connect(spec->plugin(), SIGNAL(asynchronousShutdownFinished()), + this, SLOT(asyncShutdownFinished())); + } profilingReport(" loadQueue(); void loadPlugins(); + void shutdown(); QStringList pluginPaths() const; void setPluginPaths(const QStringList &paths); QList plugins() const; diff --git a/src/libs/extensionsystem/pluginmanager_p.h b/src/libs/extensionsystem/pluginmanager_p.h index fe7ed3da44c..7544d629d3a 100644 --- a/src/libs/extensionsystem/pluginmanager_p.h +++ b/src/libs/extensionsystem/pluginmanager_p.h @@ -37,6 +37,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE class QTime; @@ -51,8 +52,9 @@ namespace Internal { class PluginSpecPrivate; -class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate +class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : QObject { + Q_OBJECT public: PluginManagerPrivate(PluginManager *pluginManager); virtual ~PluginManagerPrivate(); @@ -63,6 +65,7 @@ public: // Plugin operations void loadPlugins(); + void shutdown(); void setPluginPaths(const QStringList &paths); QList loadQueue(); void loadPlugin(PluginSpec *spec, PluginSpec::State destState); @@ -81,6 +84,8 @@ public: QList allObjects; // ### make this a QList > > ? QStringList disabledPlugins; QStringList forceEnabledPlugins; + QList asynchronousPlugins; // plugins that have requested async shutdown + QEventLoop *shutdownEventLoop; // used for async shutdown QStringList arguments; QScopedPointer m_profileTimer; @@ -94,6 +99,10 @@ public: // used by tests static PluginSpec *createSpec(); static PluginSpecPrivate *privateSpec(PluginSpec *spec); + +private slots: + void asyncShutdownFinished(); + private: PluginCollection *defaultCollection; PluginManager *q; @@ -103,6 +112,7 @@ private: QList &queue, QList &circularityCheckQueue); void stopAll(); + void deleteAll(); }; } // namespace Internal diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index 4bc231c4f3f..709785dd681 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -959,12 +959,12 @@ bool PluginSpecPrivate::initializeExtensions() \fn bool PluginSpecPrivate::stop() \internal */ -void PluginSpecPrivate::stop() +IPlugin::ShutdownFlag PluginSpecPrivate::stop() { if (!plugin) - return; - plugin->aboutToShutdown(); + return IPlugin::SynchronousShutdown; state = PluginSpec::Stopped; + return plugin->aboutToShutdown(); } /*! diff --git a/src/libs/extensionsystem/pluginspec_p.h b/src/libs/extensionsystem/pluginspec_p.h index e8c8c9443aa..5048dc13b30 100644 --- a/src/libs/extensionsystem/pluginspec_p.h +++ b/src/libs/extensionsystem/pluginspec_p.h @@ -31,6 +31,7 @@ #define PLUGINSPEC_P_H #include "pluginspec.h" +#include "iplugin.h" #include #include @@ -56,7 +57,7 @@ public: bool loadLibrary(); bool initializePlugin(); bool initializeExtensions(); - void stop(); + IPlugin::ShutdownFlag stop(); void kill(); QString name; diff --git a/src/libs/qmljs/images/publicmember.png b/src/libs/qmljs/images/publicmember.png new file mode 100644 index 00000000000..e515e76e61f Binary files /dev/null and b/src/libs/qmljs/images/publicmember.png differ diff --git a/src/libs/qmljs/qmljs.qrc b/src/libs/qmljs/qmljs.qrc index b5f83399f23..59c7cea4bdb 100644 --- a/src/libs/qmljs/qmljs.qrc +++ b/src/libs/qmljs/qmljs.qrc @@ -2,5 +2,6 @@ images/element.png images/property.png + images/publicmember.png diff --git a/src/libs/qmljs/qmljscompletioncontextfinder.cpp b/src/libs/qmljs/qmljscompletioncontextfinder.cpp index c316b7b4a74..68b0db89962 100644 --- a/src/libs/qmljs/qmljscompletioncontextfinder.cpp +++ b/src/libs/qmljs/qmljscompletioncontextfinder.cpp @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "qmljscompletioncontextfinder.h" #include diff --git a/src/libs/qmljs/qmljscompletioncontextfinder.h b/src/libs/qmljs/qmljscompletioncontextfinder.h index b23d158f16f..c3a4d2ac0e3 100644 --- a/src/libs/qmljs/qmljscompletioncontextfinder.h +++ b/src/libs/qmljs/qmljscompletioncontextfinder.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSCOMPLETIONCONTEXTFINDER_H #define QMLJSCOMPLETIONCONTEXTFINDER_H diff --git a/src/libs/qmljs/qmljscomponentversion.cpp b/src/libs/qmljs/qmljscomponentversion.cpp index 37f5ac514a0..ab1e6219ff2 100644 --- a/src/libs/qmljs/qmljscomponentversion.cpp +++ b/src/libs/qmljs/qmljscomponentversion.cpp @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "qmljscomponentversion.h" using namespace QmlJS; diff --git a/src/libs/qmljs/qmljscomponentversion.h b/src/libs/qmljs/qmljscomponentversion.h index 97edc9dec51..5f027fbc865 100644 --- a/src/libs/qmljs/qmljscomponentversion.h +++ b/src/libs/qmljs/qmljscomponentversion.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSCOMPONENTVERSION_H #define QMLJSCOMPONENTVERSION_H diff --git a/src/libs/qmljs/qmljsicons.cpp b/src/libs/qmljs/qmljsicons.cpp index a8579412851..964b7c9cc82 100644 --- a/src/libs/qmljs/qmljsicons.cpp +++ b/src/libs/qmljs/qmljsicons.cpp @@ -1,15 +1,57 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "qmljsicons.h" +#include +#include +#include +#include using namespace QmlJS; using namespace QmlJS::AST; +enum { + debug = false +}; + namespace QmlJS { +Icons *Icons::m_instance = 0; + class IconsPrivate { public: QIcon elementIcon; QIcon propertyIcon; + QIcon publicMemberIcon; + QHash,QIcon> iconHash; + QString resourcePath; }; } // namespace QmlJS @@ -19,13 +61,60 @@ Icons::Icons() { m_d->elementIcon = QIcon(QLatin1String(":/qmljs/images/element.png")); m_d->propertyIcon = QIcon(QLatin1String(":/qmljs/images/property.png")); + m_d->publicMemberIcon = QIcon(QLatin1String(":/qmljs/images/publicmember.png")); } Icons::~Icons() { + m_instance = 0; delete m_d; } +Icons *Icons::instance() +{ + if (!m_instance) + m_instance = new Icons(); + return m_instance; +} + +void Icons::setIconFilesPath(const QString &iconPath) +{ + if (iconPath == m_d->resourcePath) + return; + + m_d->resourcePath = iconPath; + + if (debug) + qDebug() << "QmlJSIcons -" << "parsing" << iconPath; + QDir topDir(iconPath); + foreach (const QFileInfo &subDirInfo, topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { + if (debug) + qDebug() << "QmlJSIcons - parsing" << subDirInfo.absoluteFilePath(); + const QString packageName = subDirInfo.fileName(); + QDir subDir(subDirInfo.absoluteFilePath() + QLatin1String("/16x16")); + foreach (const QFileInfo &iconFile, subDir.entryInfoList(QDir::Files)) { + QIcon icon(iconFile.absoluteFilePath()); + if (icon.isNull()) { + if (debug) + qDebug() << "QmlJSIcons - skipping" << iconFile.absoluteFilePath(); + continue; + } + if (debug) + qDebug() << "QmlJSIcons - adding" << packageName << iconFile.baseName() << "icon to database"; + QPair element(packageName, iconFile.baseName()); + m_d->iconHash.insert(element, icon); + } + } +} + +QIcon Icons::icon(const QString &packageName, const QString typeName) const +{ + QPair element(packageName, typeName); + if (debug) + qDebug() << "QmlJSIcons - icon for" << packageName << typeName << "requested" << m_d->iconHash.contains(element); + return m_d->iconHash.value(element); +} + QIcon Icons::icon(Node *node) const { if (dynamic_cast(node)) { @@ -47,3 +136,8 @@ QIcon Icons::scriptBindingIcon() const { return m_d->propertyIcon; } + +QIcon Icons::publicMemberIcon() const +{ + return m_d->publicMemberIcon; +} diff --git a/src/libs/qmljs/qmljsicons.h b/src/libs/qmljs/qmljsicons.h index b45d21acda7..0382bfe722c 100644 --- a/src/libs/qmljs/qmljsicons.h +++ b/src/libs/qmljs/qmljsicons.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSICONS_H #define QMLJSICONS_H @@ -12,14 +41,22 @@ class IconsPrivate; class QMLJS_EXPORT Icons { public: - Icons(); ~Icons(); + static Icons *instance(); + + void setIconFilesPath(const QString &iconPath); + + QIcon icon(const QString &packageName, const QString typeName) const; QIcon icon(AST::Node *node) const; QIcon objectDefinitionIcon() const; QIcon scriptBindingIcon() const; + QIcon publicMemberIcon() const; +private: + Icons(); + static Icons *m_instance; IconsPrivate *m_d; }; diff --git a/src/libs/qmljs/qmljsicontextpane.h b/src/libs/qmljs/qmljsicontextpane.h index 48da6eaeb1e..34b42f1269f 100644 --- a/src/libs/qmljs/qmljsicontextpane.h +++ b/src/libs/qmljs/qmljsicontextpane.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSICONTEXTPANE_H #define QMLJSICONTEXTPANE_H @@ -23,7 +52,7 @@ class QMLJS_EXPORT IContextPane : public QObject public: IContextPane(QObject *parent = 0) : QObject(parent) {} virtual ~IContextPane() {} - virtual void apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, AST::Node *node, bool update) = 0; + virtual void apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, const QmlJS::Snapshot &snapshot, AST::Node *node, bool update) = 0; virtual void setEnabled(bool) = 0; }; diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 41e713e62ad..2ff810ffb1b 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "qmljslink.h" #include "parser/qmljsast_p.h" diff --git a/src/libs/qmljs/qmljslink.h b/src/libs/qmljs/qmljslink.h index 44074447246..54e85446aae 100644 --- a/src/libs/qmljs/qmljslink.h +++ b/src/libs/qmljs/qmljslink.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSLINK_H #define QMLJSLINK_H diff --git a/src/libs/qmljs/qmljspropertyreader.cpp b/src/libs/qmljs/qmljspropertyreader.cpp index 181508d6662..9671cd9830b 100644 --- a/src/libs/qmljs/qmljspropertyreader.cpp +++ b/src/libs/qmljs/qmljspropertyreader.cpp @@ -30,6 +30,7 @@ #include "qmljspropertyreader.h" #include "qmljsdocument.h" #include +#include namespace QmlJS { @@ -175,6 +176,14 @@ static bool isEnum(AST::Statement *ast) return false; } +static QString cleanupSemicolon(const QString &str) +{ + QString out = str; + while (out.endsWith(QLatin1Char(';'))) + out.chop(1); + return out; +} + } // anonymous namespace PropertyReader::PropertyReader(Document *doc, AST::UiObjectInitializer *ast) @@ -186,9 +195,9 @@ PropertyReader::PropertyReader(Document *doc, AST::UiObjectInitializer *ast) if (!property->qualifiedId) continue; // better safe than sorry. const QString propertyName = flatten(property->qualifiedId); - const QString astValue = textAt(doc, + const QString astValue = cleanupSemicolon(textAt(doc, property->statement->firstSourceLocation(), - property->statement->lastSourceLocation()); + property->statement->lastSourceLocation())); if (isLiteralValue(property)) { m_properties.insert(propertyName, QVariant(deEscape(stripQuotes(astValue)))); } else if (isEnum(property->statement)) { //enum @@ -201,9 +210,9 @@ PropertyReader::PropertyReader(Document *doc, AST::UiObjectInitializer *ast) UiObjectMember *objectMember = iter->member; if (UiScriptBinding *property = cast(objectMember)) { const QString propertyNamePart2 = flatten(property->qualifiedId); - const QString astValue = textAt(doc, + const QString astValue = cleanupSemicolon(textAt(doc, property->statement->firstSourceLocation(), - property->statement->lastSourceLocation()); + property->statement->lastSourceLocation())); if (isLiteralValue(property)) { m_properties.insert(propertyName + '.' + propertyNamePart2, QVariant(deEscape(stripQuotes(astValue)))); } else if (isEnum(property->statement)) { //enum diff --git a/src/libs/qmljs/qmljsrewriter.cpp b/src/libs/qmljs/qmljsrewriter.cpp index 2b5a773ad00..093f671c66f 100644 --- a/src/libs/qmljs/qmljsrewriter.cpp +++ b/src/libs/qmljs/qmljsrewriter.cpp @@ -406,7 +406,7 @@ void Rewriter::removeMember(UiObjectMember *member) includeSurroundingWhitespace(start, end); - m_changeSet->replace(start, end, QLatin1String("")); + m_changeSet->remove(start, end); } bool Rewriter::includeSurroundingWhitespace(int &start, int &end) const @@ -416,10 +416,10 @@ bool Rewriter::includeSurroundingWhitespace(int &start, int &end) const if (end >= 0) { QChar c = m_originalText.at(end); + while (c.isSpace()) { ++end; - - if (c == QChar::ParagraphSeparator) { + if (c.unicode() == 10) { paragraphFound = true; break; } else if (end == m_originalText.length()) { @@ -432,18 +432,23 @@ bool Rewriter::includeSurroundingWhitespace(int &start, int &end) const includeStartingWhitespace = paragraphFound; } + paragraphFound = false; if (includeStartingWhitespace) { while (start > 0) { const QChar c = m_originalText.at(start - 1); - if (!c.isSpace()) + if (c.unicode() == 10) { + paragraphFound = true; break; - else if (c == QChar::ParagraphSeparator) + } + if (!c.isSpace()) break; --start; } } + if (!paragraphFound) //keep the line ending + --end; return paragraphFound; } @@ -590,7 +595,7 @@ void Rewriter::removeObjectMember(UiObjectMember *member, UiObjectMember *parent } includeLeadingEmptyLine(start); - m_changeSet->replace(start, end, QLatin1String("")); + m_changeSet->remove(start, end); } void Rewriter::extendToLeadingOrTrailingComma(UiArrayBinding *parentArray, diff --git a/src/libs/qmljs/qmljsscopebuilder.cpp b/src/libs/qmljs/qmljsscopebuilder.cpp index 2cc24a8cd53..77577c5959e 100644 --- a/src/libs/qmljs/qmljsscopebuilder.cpp +++ b/src/libs/qmljs/qmljsscopebuilder.cpp @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "qmljsscopebuilder.h" #include "qmljsbind.h" diff --git a/src/libs/qmljs/qmljsscopebuilder.h b/src/libs/qmljs/qmljsscopebuilder.h index 7141eee25c7..954a746fcf7 100644 --- a/src/libs/qmljs/qmljsscopebuilder.h +++ b/src/libs/qmljs/qmljsscopebuilder.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef QMLJSSCOPEBUILDER_H #define QMLJSSCOPEBUILDER_H diff --git a/src/libs/utils/htmldocextractor.cpp b/src/libs/utils/htmldocextractor.cpp new file mode 100644 index 00000000000..7690dae79d2 --- /dev/null +++ b/src/libs/utils/htmldocextractor.cpp @@ -0,0 +1,417 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "htmldocextractor.h" + +#include +#include +#include +#include + +using namespace Utils; + +namespace { + QRegExp createMinimalExp(const QString &pattern) { + QRegExp exp(pattern); + exp.setMinimal(true); + return exp; + } +} + +HtmlDocExtractor::HtmlDocExtractor() : + m_lengthReference(-1), + m_truncateAtParagraph(false), + m_formatContents(true) +{} + +void HtmlDocExtractor::setLengthReference(const int length, const bool truncateAtParagraph) +{ + m_lengthReference = length; + m_truncateAtParagraph = truncateAtParagraph; +} + +void HtmlDocExtractor::setFormatContents(const bool format) +{ m_formatContents = format; } + +QString HtmlDocExtractor::assemble(const QString &elementAttr, + const QString &elementTemplate) const +{ + const QString &cleanAttr = cleanReference(elementAttr); + return QString(elementTemplate).arg(cleanAttr); +} + +QString HtmlDocExtractor::getClassOrNamespaceBrief(const QString &html, const QString &name) const +{ + QString contents = getContentsByMarks(html, name + QLatin1String("-brief"), false); + if (contents.isEmpty()) { + QLatin1String pattern("

.*

"); + contents = findByPattern(html, pattern); + if (!contents.isEmpty()) + contents.remove(QRegExp(QLatin1String(""))); + } + if (!contents.isEmpty()) { + contents.remove(QLatin1String("More...")); + if (m_formatContents) { + contents.prepend(QLatin1String("")); + contents.append(QLatin1String("")); + } + } + + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getClassOrNamespaceDescription(const QString &html, + const QString &name) const +{ + QString contents = getContentsByMarks(html, name + QLatin1String("-description"), false); + if (contents.isEmpty()) { + QLatin1String pattern(".*
.*
"); + contents = findByPattern(html, pattern); + } + if (!contents.isEmpty()) + contents.replace(QLatin1String("

Detailed Description

"), name); + + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getEnumDescription(const QString &html, const QString &name) const +{ + const QString &enumm = name + QLatin1String("-enum"); + QString contents = getClassOrNamespaceMemberDescription(html, name, enumm, false); + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getTypedefDescription(const QString &html, const QString &name) const +{ + const QString &typedeff = name + QLatin1String("-typedef"); + QString contents = getClassOrNamespaceMemberDescription(html, name, typedeff, false); + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getVarDescription(const QString &html, const QString &name) const +{ + const QString &var = name + QLatin1String("-var"); + QString contents = getClassOrNamespaceMemberDescription(html, name, var, false); + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getMacroDescription(const QString &html, + const QString &mark, + const QString &anchorName) const +{ + QString contents = getClassOrNamespaceMemberDescription(html, mark, anchorName, false, true); + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getFunctionDescription(const QString &html, + const QString &mark, + const QString &anchorName, + const bool mainOverload) const +{ + QString contents = getClassOrNamespaceMemberDescription(html, mark, anchorName, mainOverload); + if (contents.isEmpty()) { + // Maybe marks are not present and/or this is a property. Besides setX/isX/hasX there are + // other (not so usual) names for property based functions. A few examples of those: + // - toPlainText / Prop. plainText from QPlainTextEdit. + // - resize / Prop. size from QWidget. + // - move / Prop. pos from QWidget (nothing similar in the names in this case). + // So I try to find the link to this property in the list of properties, extract its + // anchor and then follow by the name found. + QString pattern = assemble(anchorName, + QLatin1String("%1")); + QRegExp exp = createMinimalExp(pattern); + if (exp.indexIn(html) != -1) { + const QString &prop = exp.cap(1); + contents = getClassOrNamespaceMemberDescription(html, prop, prop, false); + } + } + formatContents(&contents); + return contents; +} + +QString HtmlDocExtractor::getClassOrNamespaceMemberDescription(const QString &html, + const QString &mark, + const QString &anchorName, + const bool mainOverload, + const bool relaxedMatch) const +{ + // Try with extraction marks (present in newer verions of the docs). If nothing is found try + // with the anchor. + QString contents; + if (!mark.isEmpty()) + contents = getContentsByMarks(html, mark, mainOverload); + if (contents.isEmpty()) + contents = getContentsByAnchor(html, anchorName, relaxedMatch); + + return contents; +} + +QString HtmlDocExtractor::getContentsByAnchor(const QString &html, + const QString &name, + const bool relaxedMatch) const +{ + // This approach is not very accurate. + QString pattern; + if (relaxedMatch) { + pattern = QLatin1String( + "(?:

)?|
|)"); + } else { + // When there are duplicates the HTML generator incrementally appends 'x' to references. + pattern = QLatin1String( + "(?:

)?.*(?:

|
|)"); + } + + return findByPattern(html, assemble(name, pattern)); +} + +QString HtmlDocExtractor::getContentsByMarks(const QString &html, + const QString &id, + const bool mainOverload) const +{ + QString endMark; + QString startMark; + if (id.contains(QLatin1Char('('))) { + const int index = id.indexOf(QLatin1Char('(')); + startMark = id.left(index); + endMark = startMark; + if (mainOverload) { + startMark.append(QLatin1String("[overload1]")); + } else { + QString complementaryId = id.right(id.length() - index); + complementaryId.remove(QRegExp(QLatin1String("[\\(\\), ]"))); + startMark.append(complementaryId); + } + } else { + startMark = id; + } + startMark.prepend(QLatin1String("$$$")); + + if (endMark.isEmpty()) { + if (id.contains(QLatin1Char('-'))) { + const int index = id.indexOf(QLatin1Char('-')); + endMark = id.left(index); + } else { + endMark = id; + } + } + endMark.prepend(QLatin1String(""), start); + if (start != -1) { + int end = html.indexOf(endMark, start); + if (end != -1) { + start += 3; + contents = html.mid(start, end - start); + } + } + } + return contents; +} + +QString HtmlDocExtractor::findByPattern(const QString &html, const QString &pattern) const +{ + QRegExp exp(pattern); + exp.setMinimal(true); + const int match = exp.indexIn(html); + if (match != -1) + return html.mid(match, exp.matchedLength()); + return QString(); +} + +void HtmlDocExtractor::formatContents(QString *html) const +{ + if (html->isEmpty()) + return; + + if (m_formatContents) { + replaceNonStyledHeadingsForBold(html); + replaceTablesForSimpleLines(html); + replaceListsForSimpleLines(html); + stripLinks(html); + stripHorizontalLines(html); + stripDivs(html); + stripTagsStyles(html); + stripHeadings(html); + } + + if (m_lengthReference > -1 && html->length() > m_lengthReference) { + if (m_truncateAtParagraph) { + const int nextBegin = html->indexOf(QLatin1String("

"), m_lengthReference); + QRegExp exp = createMinimalExp(QLatin1String("

|
")); + const int previousEnd = html->lastIndexOf(exp, m_lengthReference); + if (nextBegin != -1 && previousEnd != -1) + html->truncate(qMin(nextBegin, previousEnd + exp.matchedLength())); + else if (nextBegin != -1 || previousEnd != -1) + html->truncate((nextBegin != -1? nextBegin : previousEnd + exp.matchedLength())); + } else { + html->truncate(m_lengthReference); + } + html->append(QLatin1String("...")); + if (m_formatContents) + html->append(QLatin1String("
")); + } +} + +void HtmlDocExtractor::stripAllHtml(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("<.*>"))); +} + +void HtmlDocExtractor::stripHeadings(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("|"))); +} + +void HtmlDocExtractor::stripLinks(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("|
"))); +} + +void HtmlDocExtractor::stripHorizontalLines(QString *html) +{ + html->remove(createMinimalExp(QLatin1String(""))); +} + +void HtmlDocExtractor::stripDivs(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("||"))); +} + +void HtmlDocExtractor::stripTagsStyles(QString *html) +{ + const QRegExp &exp = createMinimalExp(QLatin1String("<(.*\\s+)class=\".*\">")); + html->replace(exp, QLatin1String("<\\1>")); +} + +void HtmlDocExtractor::stripTeletypes(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("|"))); +} + +void HtmlDocExtractor::replaceNonStyledHeadingsForBold(QString *html) +{ + const QRegExp &hStart = createMinimalExp(QLatin1String("")); + const QRegExp &hEnd = createMinimalExp(QLatin1String("")); + html->replace(hStart, QLatin1String("

")); + html->replace(hEnd, QLatin1String("

")); +} + +void HtmlDocExtractor::replaceTablesForSimpleLines(QString *html) +{ + html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QLatin1String("")); + html->remove(createMinimalExp(QLatin1String(".*"))); + html->replace(QLatin1String(" remove(createMinimalExp(QLatin1String(""))); + html->remove(QLatin1String("")); + html->replace(QLatin1String(""), QLatin1String("  - ")); + html->replace(QLatin1String(""), QLatin1String("
")); +} + +void HtmlDocExtractor::replaceListsForSimpleLines(QString *html) +{ + html->remove(createMinimalExp(QLatin1String("<(?:ul|ol).*>"))); + html->remove(createMinimalExp(QLatin1String(""))); + html->replace(QLatin1String("
  • "), QLatin1String("  - ")); + html->replace(QLatin1String("
  • "), QLatin1String("
    ")); +} + +/* + @todo: We need to clean the anchor in the same way qtdoc does. Currently, this method is a + duplicate of HtmlGenerator::cleanRef. It would be good to reuse the same code either by exposing + parts of qtdocs or by refactoring the behavior to use some Qt component for example. + */ +QString HtmlDocExtractor::cleanReference(const QString &reference) +{ + QString clean; + + if (reference.isEmpty()) + return clean; + + clean.reserve(reference.size() + 20); + const QChar c = reference[0]; + const uint u = c.unicode(); + + if ((u >= QLatin1Char('a') && u <= QLatin1Char('z')) || + (u >= QLatin1Char('A') && u <= QLatin1Char('Z')) || + (u >= QLatin1Char('0') && u <= QLatin1Char('9'))) { + clean += c; + } else if (u == QLatin1Char('~')) { + clean += QLatin1String("dtor."); + } else if (u == QLatin1Char('_')) { + clean += QLatin1String("underscore."); + } else { + clean += QLatin1String("A"); + } + + for (int i = 1; i < (int) reference.length(); i++) { + const QChar c = reference[i]; + const uint u = c.unicode(); + if ((u >= QLatin1Char('a') && u <= QLatin1Char('z')) || + (u >= QLatin1Char('A') && u <= QLatin1Char('Z')) || + (u >= QLatin1Char('0') && u <= QLatin1Char('9')) || u == QLatin1Char('-') || + u == QLatin1Char('_') || u == QLatin1Char(':') || u == QLatin1Char('.')) { + clean += c; + } else if (c.isSpace()) { + clean += QLatin1String("-"); + } else if (u == QLatin1Char('!')) { + clean += QLatin1String("-not"); + } else if (u == QLatin1Char('&')) { + clean += QLatin1String("-and"); + } else if (u == QLatin1Char('<')) { + clean += QLatin1String("-lt"); + } else if (u == QLatin1Char('=')) { + clean += QLatin1String("-eq"); + } else if (u == QLatin1Char('>')) { + clean += QLatin1String("-gt"); + } else if (u == QLatin1Char('#')) { + clean += QLatin1String("#"); + } else { + clean += QLatin1String("-"); + clean += QString::number((int)u, 16); + } + } + return clean; +} diff --git a/src/libs/utils/htmldocextractor.h b/src/libs/utils/htmldocextractor.h new file mode 100644 index 00000000000..86728d47884 --- /dev/null +++ b/src/libs/utils/htmldocextractor.h @@ -0,0 +1,101 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef HTMLDOCEXTRACTOR_H +#define HTMLDOCEXTRACTOR_H + +#include "utils_global.h" + +#include + +namespace Utils { + +class QTCREATOR_UTILS_EXPORT HtmlDocExtractor +{ +public: + HtmlDocExtractor(); + + void setLengthReference(const int reference, const bool truncateAtParagraph); + void setFormatContents(const bool format); + + QString getClassOrNamespaceBrief(const QString &html, const QString &name) const; + QString getClassOrNamespaceDescription(const QString &html, const QString &name) const; + QString getEnumDescription(const QString &html, const QString &name) const; + QString getTypedefDescription(const QString &html, const QString &name) const; + QString getVarDescription(const QString &html, const QString &name) const; + QString getMacroDescription(const QString &html, + const QString &mark, + const QString &anchorName) const; + QString getFunctionDescription(const QString &html, + const QString &mark, + const QString &anchorName, + const bool mainOverload = true) const; + +private: + QString assemble(const QString& elementAttr, const QString &elementTemplate) const; + QString getContentsByAnchor(const QString &html, + const QString &name, + const bool relaxedMatch) const; + QString getContentsByMarks(const QString &html, + const QString &id, + const bool mainOverload) const; + QString getClassOrNamespaceMemberDescription(const QString &html, + const QString &mark, + const QString &anchorName, + const bool mainOverload, + const bool relaxedMatch = false) const; + + QString findByMarks(const QString &html, + const QString &startMark, + const QString &endMark) const; + QString findByPattern(const QString &html, const QString &pattern) const; + + void formatContents(QString *html) const; + + static void stripAllHtml(QString *html); + static void stripHeadings(QString *html); + static void stripLinks(QString *html); + static void stripHorizontalLines(QString *html); + static void stripDivs(QString *html); + static void stripTagsStyles(QString *html); + static void stripTeletypes(QString *html); + static void replaceNonStyledHeadingsForBold(QString *html); + static void replaceTablesForSimpleLines(QString *html); + static void replaceListsForSimpleLines(QString *html); + + static QString cleanReference(const QString &reference); + + int m_lengthReference; + bool m_truncateAtParagraph; + bool m_formatContents; +}; + +} // namespace Utils + +#endif // HTMLDOCEXTRACTOR_H diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index cf1b4b36cf9..10a2d418391 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -31,6 +31,8 @@ #include #include +#include +#include #include @@ -100,4 +102,21 @@ QTCREATOR_UTILS_EXPORT QString commonPath(const QStringList &files) return common; } +QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path) +{ +#ifdef Q_OS_WIN + QString outPath = path; +#else + static const QString homePath = QDir::homePath(); + + QFileInfo fi(QDir::cleanPath(path)); + QString outPath = fi.absoluteFilePath(); + if (outPath.startsWith(homePath)) + outPath = QLatin1Char('~') + outPath.mid(homePath.size()); + else + outPath = path; +#endif + return outPath; +} + } // namespace Utils diff --git a/src/libs/utils/stringutils.h b/src/libs/utils/stringutils.h index 16cac815ded..a863a617719 100644 --- a/src/libs/utils/stringutils.h +++ b/src/libs/utils/stringutils.h @@ -50,6 +50,11 @@ QTCREATOR_UTILS_EXPORT QString commonPrefix(const QStringList &strings); // "C:\foo\bar1" "C:\foo\bar2" -> "C:\foo" QTCREATOR_UTILS_EXPORT QString commonPath(const QStringList &files); +// On Linux/Mac replace user's home path with ~ +// Uses cleaned path and tries to use absolute path of "path" if possible +// If path is not sub of home path, or when running on Windows, returns the input +QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path); + } // namespace Utils #endif // SETTINGSTUTILS_H diff --git a/src/libs/utils/utils.pro b/src/libs/utils/utils.pro index bf2691171ba..a189b672508 100644 --- a/src/libs/utils/utils.pro +++ b/src/libs/utils/utils.pro @@ -40,7 +40,8 @@ SOURCES += reloadpromptutils.cpp \ detailswidget.cpp \ changeset.cpp \ filterlineedit.cpp \ - faketooltip.cpp + faketooltip.cpp \ + htmldocextractor.cpp win32 { SOURCES += abstractprocess_win.cpp \ consoleprocess_win.cpp \ @@ -93,7 +94,8 @@ HEADERS += utils_global.h \ detailswidget.h \ changeset.h \ filterlineedit.h \ - faketooltip.h + faketooltip.h \ + htmldocextractor.h FORMS += filewizardpage.ui \ projectintropage.ui \ newclasswidget.ui \ diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index 0a6dbcfbb22..23b5d04ffbd 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -1042,7 +1042,7 @@ bool BinEditor::event(QEvent *e) { selEnd = selStart + 1; byteCount = 1; } - if (byteCount <= 8) { + if (m_hexCursor && byteCount <= 8) { const QPoint &startPoint = offsetToPos(selStart); const QPoint &endPoint = offsetToPos(selEnd); const QPoint expandedEndPoint @@ -1138,14 +1138,25 @@ void BinEditor::keyPressEvent(QKeyEvent *e) } break; case Qt::Key_Home: - setCursorPosition((e->modifiers() & Qt::ControlModifier) ? - 0 : (m_cursorPosition/16 * 16), moveMode); + if (e->modifiers() & Qt::ControlModifier) { + if (m_inLazyMode) + emit startOfFileRequested(editorInterface()); + else + setCursorPosition(0); + } else { + setCursorPosition(m_cursorPosition/16 * 16, moveMode); + } break; case Qt::Key_End: - setCursorPosition((e->modifiers() & Qt::ControlModifier) ? - (m_size-1) : (m_cursorPosition/16 * 16 + 15), moveMode); + if (e->modifiers() & Qt::ControlModifier) { + if (m_inLazyMode) + emit endOfFileRequested(editorInterface()); + else + setCursorPosition(m_size - 1); + } else { + setCursorPosition(m_cursorPosition/16 * 16 + 15, moveMode); + } break; - default: if (m_readOnly) break; @@ -1380,7 +1391,7 @@ void BinEditor::jumpToAddress(quint64 address) { if (address >= m_baseAddr && address < m_baseAddr + m_data.size()) setCursorPosition(address - m_baseAddr); - else + else if (m_inLazyMode) emit newRangeRequested(editorInterface(), address); } @@ -1392,7 +1403,7 @@ void BinEditor::setNewWindowRequestAllowed() QPoint BinEditor::offsetToPos(int offset) { const int x = m_labelWidth + (offset % 16) * m_columnWidth; - const int y = (offset / 16) * m_lineHeight; + const int y = (offset / 16 - verticalScrollBar()->value()) * m_lineHeight; return QPoint(x, y); } diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h index cea7b8d1684..70241a7e63b 100644 --- a/src/plugins/bineditor/bineditor.h +++ b/src/plugins/bineditor/bineditor.h @@ -84,7 +84,7 @@ public: }; int cursorPosition() const; - void setCursorPosition(int pos, MoveMode moveMode = MoveAnchor); + Q_INVOKABLE void setCursorPosition(int pos, MoveMode moveMode = MoveAnchor); void jumpToAddress(quint64 address); void setModified(bool); @@ -133,6 +133,8 @@ Q_SIGNALS: void lazyDataRequested(Core::IEditor *editor, quint64 block, bool synchronous); void newWindowRequested(quint64 address); void newRangeRequested(Core::IEditor *, quint64 address); + void startOfFileRequested(Core::IEditor *); + void endOfFileRequested(Core::IEditor *); protected: void scrollContentsBy(int dx, int dy); diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index b6fa5011185..b7858db4f3c 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -154,6 +154,8 @@ public: return result; } + void replace(const QString &, const QString &, + Find::IFindSupport::FindFlags) { } bool replaceStep(const QString &, const QString &, Find::IFindSupport::FindFlags) { return false;} int replaceAll(const QString &, const QString &, @@ -180,6 +182,10 @@ public: this, SLOT(provideData(Core::IEditor *, quint64))); connect(m_editor, SIGNAL(newRangeRequested(Core::IEditor*,quint64)), this, SLOT(provideNewRange(Core::IEditor*,quint64))); + connect(m_editor, SIGNAL(startOfFileRequested(Core::IEditor*)), this, + SLOT(handleStartOfFileRequested(Core::IEditor*))); + connect(m_editor, SIGNAL(endOfFileRequested(Core::IEditor*)), this, + SLOT(handleEndOfFileRequested(Core::IEditor*))); } ~BinEditorFile() {} @@ -209,7 +215,7 @@ public: && file.open(QIODevice::ReadOnly)) { m_fileName = fileName; qint64 maxRange = 64 * 1024 * 1024; - if (file.isSequential() && file.size() <= maxRange) { + if (file.size() <= maxRange) { m_editor->setData(file.readAll()); } else { m_editor->setLazyData(offset, maxRange); @@ -241,6 +247,14 @@ private slots: open(m_fileName, offset); } + void handleStartOfFileRequested(Core::IEditor *) { + open(m_fileName, 0); + } + + void handleEndOfFileRequested(Core::IEditor *) { + open(m_fileName, QFileInfo(m_fileName).size() - 1); + } + public: void setFilename(const QString &filename) { diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp index b42a5705862..39172a36a41 100644 --- a/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakehighlighter.cpp @@ -46,7 +46,7 @@ static bool isVariable(const QString &word) CMakeHighlighter::CMakeHighlighter(QTextDocument *document) : - QSyntaxHighlighter(document) + TextEditor::SyntaxHighlighter(document) { } diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighter.h b/src/plugins/cmakeprojectmanager/cmakehighlighter.h index dce5acf0579..5c76a218075 100644 --- a/src/plugins/cmakeprojectmanager/cmakehighlighter.h +++ b/src/plugins/cmakeprojectmanager/cmakehighlighter.h @@ -30,6 +30,7 @@ #ifndef CMAKEHIGHLIGHTER_H #define CMAKEHIGHLIGHTER_H +#include #include #include #include @@ -40,7 +41,7 @@ namespace Internal { /* This is a simple syntax highlighter for CMake files. * It highlights variables, commands, strings and comments. * Multi-line strings and variables inside strings are also recognized. */ -class CMakeHighlighter : public QSyntaxHighlighter +class CMakeHighlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT public: diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 8e0107ed406..f589e8703c1 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -34,7 +34,6 @@ #include "modemanager.h" #include "fileiconprovider.h" #include "designmode.h" -#include "ssh/ne7sshobject.h" #include @@ -89,7 +88,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) m_designMode = new DesignMode(editorManager); addObject(m_designMode); - Ne7SshObject::instance(); } return success; } @@ -110,10 +108,10 @@ void CorePlugin::fileOpenRequest(const QString &f) remoteCommand(QStringList(), QStringList(f)); } -void CorePlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown() { m_mainWindow->aboutToShutdown(); - Ne7SshObject::removeInstance(); + return SynchronousShutdown; } Q_EXPORT_PLUGIN(CorePlugin) diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h index bd602550478..af0f85f94b0 100644 --- a/src/plugins/coreplugin/coreplugin.h +++ b/src/plugins/coreplugin/coreplugin.h @@ -49,7 +49,7 @@ public: virtual bool initialize(const QStringList &arguments, QString *errorMessage = 0); virtual void extensionsInitialized(); - virtual void aboutToShutdown(); + virtual ShutdownFlag aboutToShutdown(); virtual void remoteCommand(const QStringList & /* options */, const QStringList &args); public slots: diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 3b607d037b6..ad81f39dc6e 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -85,10 +85,27 @@ SOURCES += mainwindow.cpp \ editormanager/systemeditor.cpp \ designmode.cpp \ editortoolbar.cpp \ - ssh/ne7sshobject.cpp \ - ssh/sshconnection.cpp \ + helpmanager.cpp \ + ssh/sshsendfacility.cpp \ + ssh/sshremoteprocess.cpp \ + ssh/sshpacketparser.cpp \ + ssh/sshpacket.cpp \ + ssh/sshoutgoingpacket.cpp \ ssh/sshkeygenerator.cpp \ - helpmanager.cpp + ssh/sshkeyexchange.cpp \ + ssh/sshincomingpacket.cpp \ + ssh/sshcryptofacility.cpp \ + ssh/sshconnection.cpp \ + ssh/sshchannelmanager.cpp \ + ssh/sshchannel.cpp \ + ssh/sshcapabilities.cpp \ + ssh/sftppacket.cpp \ + ssh/sftpoutgoingpacket.cpp \ + ssh/sftpoperation.cpp \ + ssh/sftpincomingpacket.cpp \ + ssh/sftpdefs.cpp \ + ssh/sftpchannel.cpp \ + ssh/sshdelayedsignal.cpp HEADERS += mainwindow.h \ editmode.h \ @@ -171,10 +188,33 @@ HEADERS += mainwindow.h \ editormanager/systemeditor.h \ designmode.h \ editortoolbar.h \ - ssh/ne7sshobject.h \ - ssh/sshconnection.h \ + helpmanager.h \ + ssh/sshsendfacility_p.h \ + ssh/sshremoteprocess.h \ + ssh/sshremoteprocess_p.h \ + ssh/sshpacketparser_p.h \ + ssh/sshpacket_p.h \ + ssh/sshoutgoingpacket_p.h \ ssh/sshkeygenerator.h \ - helpmanager.h + ssh/sshkeyexchange_p.h \ + ssh/sshincomingpacket_p.h \ + ssh/sshexception_p.h \ + ssh/ssherrors.h \ + ssh/sshcryptofacility_p.h \ + ssh/sshconnection.h \ + ssh/sshconnection_p.h \ + ssh/sshchannelmanager_p.h \ + ssh/sshchannel_p.h \ + ssh/sshcapabilities_p.h \ + ssh/sshbotanconversions_p.h \ + ssh/sftppacket_p.h \ + ssh/sftpoutgoingpacket_p.h \ + ssh/sftpoperation_p.h \ + ssh/sftpincomingpacket_p.h \ + ssh/sftpdefs.h \ + ssh/sftpchannel.h \ + ssh/sftpchannel_p.h \ + ssh/sshdelayedsignal_p.h FORMS += dialogs/newdialog.ui \ actionmanager/commandmappings.ui \ diff --git a/src/plugins/coreplugin/coreplugin_dependencies.pri b/src/plugins/coreplugin/coreplugin_dependencies.pri index 8726e1be080..e908601b226 100644 --- a/src/plugins/coreplugin/coreplugin_dependencies.pri +++ b/src/plugins/coreplugin/coreplugin_dependencies.pri @@ -1,3 +1,3 @@ include(../../libs/extensionsystem/extensionsystem.pri) include(../../libs/utils/utils.pri) -include(../../libs/3rdparty/net7ssh/net7ssh.pri) +include(../../libs/3rdparty/botan/botan.pri) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index a9eb40b6868..fc3ee7d4e0d 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1080,7 +1080,7 @@ IEditor *EditorManager::createEditor(const QString &editorId, mimeType = m_d->m_core->mimeDatabase()->findByType(QLatin1String("text/plain")); } // open text files > 48 MB in binary editor - if (fileInfo.size() > qint64(3) << 24 && mimeType.type().startsWith(QLatin1String("text"))) + if (fileInfo.size() > maxTextFileSize() && mimeType.type().startsWith(QLatin1String("text"))) mimeType = m_d->m_core->mimeDatabase()->findByType(QLatin1String("application/octet-stream")); factories = editorFactories(mimeType, true); } else { @@ -1389,13 +1389,22 @@ EditorManager::ReadOnlyAction QWidget *parent, bool displaySaveAsButton) { + // Version Control: If automatic open is desired, open right away. + bool promptVCS = false; + if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) { + if (versionControl->settingsFlags() & IVersionControl::AutoOpen) + return RO_OpenVCS; + promptVCS = true; + } + + // Create message box. QMessageBox msgBox(QMessageBox::Question, tr("File is Read Only"), - tr("The file %1 is read only.").arg(QDir::toNativeSeparators(fileName)), + tr("The file %1 is read only.").arg(QDir::toNativeSeparators(fileName)), QMessageBox::Cancel, parent); - QPushButton *sccButton = 0; - if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) - sccButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->displayName()), QMessageBox::AcceptRole); + QPushButton *vcsButton = 0; + if (promptVCS) + vcsButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->displayName()), QMessageBox::AcceptRole); QPushButton *makeWritableButton = msgBox.addButton(tr("Make writable"), QMessageBox::AcceptRole); @@ -1403,11 +1412,11 @@ EditorManager::ReadOnlyAction if (displaySaveAsButton) saveAsButton = msgBox.addButton(tr("Save as ..."), QMessageBox::ActionRole); - msgBox.setDefaultButton(sccButton ? sccButton : makeWritableButton); + msgBox.setDefaultButton(vcsButton ? vcsButton : makeWritableButton); msgBox.exec(); QAbstractButton *clickedButton = msgBox.clickedButton(); - if (clickedButton == sccButton) + if (clickedButton == vcsButton) return RO_OpenVCS; if (clickedButton == makeWritableButton) return RO_MakeWriteable; @@ -2004,5 +2013,10 @@ void EditorManager::gotoOtherSplit() } } } + +qint64 EditorManager::maxTextFileSize() +{ + return (qint64(3) << 24); +} //===================EditorClosingCoreListener====================== diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index e488f040ea0..541c5d33556 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -199,6 +199,8 @@ public: QWidget *parent, bool displaySaveAsButton = false); + static qint64 maxTextFileSize(); + signals: void currentEditorChanged(Core::IEditor *editor); void editorCreated(Core::IEditor *editor, const QString &fileName); diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 2e6fa7f0ae1..9242dc3db1e 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -274,7 +274,7 @@ void EditorToolBar::listContextMenu(QPoint pos) if (fileName.isEmpty()) return; QMenu menu; - menu.addAction(tr("Copy full path to clipboard")); + menu.addAction(tr("Copy Full Path to Clipboard")); if (menu.exec(m_editorList->mapToGlobal(pos))) { QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName)); } diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp index de29e822b7b..de89e4dc8eb 100644 --- a/src/plugins/coreplugin/filemanager.cpp +++ b/src/plugins/coreplugin/filemanager.cpp @@ -745,7 +745,11 @@ QStringList FileManager::getOpenFileNames(const QString &filters, const QString pathIn, QString *selectedFilter) { - const QString path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn; + QString path = pathIn; + if (path.isEmpty()) { + if (!d->m_currentFile.isEmpty()) + path = QFileInfo(d->m_currentFile).absoluteFilePath(); + } const QStringList files = QFileDialog::getOpenFileNames(d->m_mainWindow, tr("Open File"), path, filters, @@ -1009,7 +1013,7 @@ QString FileManager::currentFile() const QString FileManager::fileDialogInitialDirectory() const { if (!d->m_currentFile.isEmpty()) - return QFileInfo(d->m_currentFile).absoluteFilePath(); + return QFileInfo(d->m_currentFile).absolutePath(); return d->m_lastVisitedDirectory; } diff --git a/src/plugins/coreplugin/helpmanager.cpp b/src/plugins/coreplugin/helpmanager.cpp index 7d2ebc92c42..02bd88acffd 100644 --- a/src/plugins/coreplugin/helpmanager.cpp +++ b/src/plugins/coreplugin/helpmanager.cpp @@ -240,6 +240,13 @@ QUrl HelpManager::findFile(const QUrl &url) const return m_helpEngine->findFile(url); } +QByteArray HelpManager::fileData(const QUrl &url) const +{ + if (m_needsSetup) + return QByteArray(); + return m_helpEngine->fileData(url); +} + void HelpManager::handleHelpRequest(const QString &url) { emit helpRequested(QUrl(url)); diff --git a/src/plugins/coreplugin/helpmanager.h b/src/plugins/coreplugin/helpmanager.h index 7df6c55659c..a3096430929 100644 --- a/src/plugins/coreplugin/helpmanager.h +++ b/src/plugins/coreplugin/helpmanager.h @@ -38,6 +38,7 @@ #include #include #include +#include QT_FORWARD_DECLARE_CLASS(QHelpEngineCore) QT_FORWARD_DECLARE_CLASS(QSqlQuery) @@ -64,6 +65,7 @@ public: QStringList findKeywords(const QString &key, int maxHits = INT_MAX) const; QUrl findFile(const QUrl &url) const; + QByteArray fileData(const QUrl &url) const; void handleHelpRequest(const QString &url); QStringList registeredNamespaces() const; diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h index 0cd29f94388..c402c1fb77c 100644 --- a/src/plugins/coreplugin/iversioncontrol.h +++ b/src/plugins/coreplugin/iversioncontrol.h @@ -34,13 +34,20 @@ #include #include +#include namespace Core { class CORE_EXPORT IVersionControl : public QObject { Q_OBJECT + Q_ENUMS(SettingsFlag Operation) public: + enum SettingsFlag { + AutoOpen = 0x1 + }; + Q_DECLARE_FLAGS(SettingsFlags, SettingsFlag) + enum Operation { AddOperation, DeleteOperation, OpenOperation, MoveOperation, CreateRepositoryOperation, @@ -76,6 +83,12 @@ public: */ virtual bool vcsOpen(const QString &fileName) = 0; + /*! + * Returns settings. + */ + + virtual SettingsFlags settingsFlags() const { return 0; } + /*! * Called after a file has been added to a project If the version control * needs to know which files it needs to track you should reimplement this @@ -137,6 +150,8 @@ signals: // virtual bool sccManaged(const QString &filename) = 0; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IVersionControl::SettingsFlags) + } // namespace Core #endif // IVERSIONCONTROL_H diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index e2edbfce8b5..e8dfa3af655 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include @@ -238,7 +239,6 @@ void MainWindow::setOverrideColor(const QColor &color) MainWindow::~MainWindow() { - hide(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); pm->removeObject(m_shortcutSettings); pm->removeObject(m_generalSettings); @@ -1134,6 +1134,7 @@ void MainWindow::aboutToShutdown() disconnect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(updateFocusWidget(QWidget*,QWidget*))); m_activeContext = 0; + hide(); } static const char *settingsGroup = "MainWindow"; @@ -1253,7 +1254,8 @@ void MainWindow::aboutToShowRecentFiles() bool hasRecentFiles = false; foreach (const QString &fileName, m_fileManager->recentFiles()) { hasRecentFiles = true; - QAction *action = aci->menu()->addAction(fileName); + QAction *action = aci->menu()->addAction( + Utils::withTildeHomePath(fileName)); action->setData(fileName); connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); } diff --git a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp index 05fc9dacd47..882a642ba50 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager_win.cpp @@ -95,7 +95,7 @@ void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString & font.setPointSize(font.pointSize()-2); p.setFont(font); p.drawText(QRect(QPoint(0,0), pix.size()), Qt::AlignHCenter|Qt::AlignCenter, text); - pITask->SetOverlayIcon(winId, pix.toWinHICON(), text.utf16()); + pITask->SetOverlayIcon(winId, pix.toWinHICON(), (wchar_t*)text.utf16()); } } diff --git a/src/plugins/coreplugin/ssh/ne7sshobject.cpp b/src/plugins/coreplugin/ssh/ne7sshobject.cpp deleted file mode 100644 index 9f94a55b970..00000000000 --- a/src/plugins/coreplugin/ssh/ne7sshobject.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ne7sshobject.h" - -#include - -#include - -namespace Core { -namespace Internal { - -Ne7SshObject *Ne7SshObject::instance() -{ - if (!m_instance) - m_instance = new Ne7SshObject; - return m_instance; -} - -void Ne7SshObject::removeInstance() -{ - delete m_instance; -} - -Ne7SshObject::Ptr Ne7SshObject::get() -{ - QMutexLocker locker(&m_mutex); - QSharedPointer shared = m_weakRef.toStrongRef(); - if (!shared) { - shared = QSharedPointer(new ne7ssh); - m_weakRef = shared; - } - return shared; -} - -Ne7SshObject::Ne7SshObject() -{ -} - -Ne7SshObject *Ne7SshObject::m_instance = 0; - -} // namespace Internal -} // namespace Core diff --git a/src/plugins/coreplugin/ssh/ne7sshobject.h b/src/plugins/coreplugin/ssh/ne7sshobject.h deleted file mode 100644 index 77d601ec869..00000000000 --- a/src/plugins/coreplugin/ssh/ne7sshobject.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef NE7SSHOBJECT_H -#define NE7SSHOBJECT_H - -#include - -#include -#include -#include - -class ne7ssh; - -namespace Core { -namespace Internal { - -class Ne7SshObject -{ -public: - typedef QSharedPointer Ptr; - - static Ne7SshObject *instance(); - static void removeInstance(); - - Ptr get(); - -private: - Ne7SshObject(); - Ne7SshObject(const Ne7SshObject &); - Ne7SshObject &operator=(const Ne7SshObject &); - - static Ne7SshObject *m_instance; - - QWeakPointer m_weakRef; - QMutex m_mutex; -}; - -} // namespace Internal -} // namespace Core - -#endif // NE7SSHOBJECT_H diff --git a/src/plugins/coreplugin/ssh/sftpchannel.cpp b/src/plugins/coreplugin/ssh/sftpchannel.cpp new file mode 100644 index 00000000000..2cb31a3bcec --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel.cpp @@ -0,0 +1,756 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpchannel.h" +#include "sftpchannel_p.h" + +#include "sshdelayedsignal_p.h" +#include "sshexception_p.h" +#include "sshsendfacility_p.h" + +#include +#include + +namespace Core { + +namespace Internal { +namespace { + const quint32 ProtocolVersion = 3; + + QString errorMessage(const QString &serverMessage, + const QString &alternativeMessage) + { + return serverMessage.isEmpty() ? alternativeMessage : serverMessage; + } + + QString errorMessage(const SftpStatusResponse &response, + const QString &alternativeMessage) + { + return response.status == SSH_FX_OK ? QString() + : errorMessage(response.errorString, alternativeMessage); + } +} // anonymous namespace +} // namespace Internal + +SftpChannel::SftpChannel(quint32 channelId, + Internal::SshSendFacility &sendFacility) + : d(new Internal::SftpChannelPrivate(channelId, sendFacility, this)) +{ +} + +SftpChannel::State SftpChannel::state() const +{ + switch (d->channelState()) { + case Internal::AbstractSshChannel::Inactive: + return Uninitialized; + case Internal::AbstractSshChannel::SessionRequested: + return Initializing; + case Internal::AbstractSshChannel::CloseRequested: + return Closing; + case Internal::AbstractSshChannel::Closed: + return Closed; + case Internal::AbstractSshChannel::SessionEstablished: + return d->m_sftpState == Internal::SftpChannelPrivate::Initialized + ? Initialized : Initializing; + default: + Q_ASSERT(!"Oh no, we forgot to handle a channel state!"); + return Closed; // For the compiler. + } +} + +void SftpChannel::initialize() +{ + d->requestSessionStart(); + d->m_sftpState = Internal::SftpChannelPrivate::SubsystemRequested; +} + +void SftpChannel::closeChannel() +{ + d->closeChannel(); +} + +SftpJobId SftpChannel::listDirectory(const QString &path) +{ + return d->createJob(Internal::SftpListDir::Ptr( + new Internal::SftpListDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::createDirectory(const QString &path) +{ + return d->createJob(Internal::SftpMakeDir::Ptr( + new Internal::SftpMakeDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::removeDirectory(const QString &path) +{ + return d->createJob(Internal::SftpRmDir::Ptr( + new Internal::SftpRmDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::removeFile(const QString &path) +{ + return d->createJob(Internal::SftpRm::Ptr( + new Internal::SftpRm(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::renameFileOrDirectory(const QString &oldPath, + const QString &newPath) +{ + return d->createJob(Internal::SftpRename::Ptr( + new Internal::SftpRename(++d->m_nextJobId, oldPath, newPath))); +} + +SftpJobId SftpChannel::createFile(const QString &path, SftpOverwriteMode mode) +{ + return d->createJob(Internal::SftpCreateFile::Ptr( + new Internal::SftpCreateFile(++d->m_nextJobId, path, mode))); +} + +SftpJobId SftpChannel::uploadFile(const QString &localFilePath, + const QString &remoteFilePath, SftpOverwriteMode mode) +{ + QSharedPointer localFile(new QFile(localFilePath)); + if (!localFile->open(QIODevice::ReadOnly)) + return SftpInvalidJob; + return d->createJob(Internal::SftpUpload::Ptr( + new Internal::SftpUpload(++d->m_nextJobId, remoteFilePath, localFile, mode))); +} + +SftpJobId SftpChannel::downloadFile(const QString &remoteFilePath, + const QString &localFilePath, SftpOverwriteMode mode) +{ + QSharedPointer localFile(new QFile(localFilePath)); + if (mode == SftpSkipExisting && localFile->exists()) + return SftpInvalidJob; + QIODevice::OpenMode openMode = QIODevice::WriteOnly; + if (mode == SftpOverwriteExisting) + openMode |= QIODevice::Truncate; + else if (mode == SftpAppendToExisting) + openMode |= QIODevice::Append; + if (!localFile->open(openMode)) + return SftpInvalidJob; + return d->createJob(Internal::SftpDownload::Ptr( + new Internal::SftpDownload(++d->m_nextJobId, remoteFilePath, localFile))); +} + +SftpChannel::~SftpChannel() +{ + delete d; +} + + +namespace Internal { + +SftpChannelPrivate::SftpChannelPrivate(quint32 channelId, + SshSendFacility &sendFacility, SftpChannel *sftp) + : AbstractSshChannel(channelId, sendFacility), + m_nextJobId(0), m_sftpState(Inactive), m_sftp(sftp) +{ +} + +SftpJobId SftpChannelPrivate::createJob(const AbstractSftpOperation::Ptr &job) +{ + if (m_sftp->state() != SftpChannel::Initialized) + return SftpInvalidJob; + m_jobs.insert(job->jobId, job); + sendData(job->initialPacket(m_outgoingPacket).rawData()); + return job->jobId; +} + +void SftpChannelPrivate::handleChannelSuccess() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("sftp subsystem initialized"); +#endif + sendData(m_outgoingPacket.generateInit(ProtocolVersion).rawData()); + m_sftpState = InitSent; +} + +void SftpChannelPrivate::handleChannelFailure() +{ + if (m_sftpState != SubsystemRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_FAILURE packet."); + } + createDelayedInitFailedSignal(SSH_TR("Server could not start sftp subsystem.")); + closeChannel(); +} + +void SftpChannelPrivate::handleChannelDataInternal(const QByteArray &data) +{ + m_incomingData += data; + m_incomingPacket.consumeData(m_incomingData); + while (m_incomingPacket.isComplete()) { + handleCurrentPacket(); + m_incomingPacket.clear(); + m_incomingPacket.consumeData(m_incomingData); + } +} + +void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data) +{ + qWarning("Unexpected extended data '%s' of type %d on SFTP channel.", + data.data(), type); +} + +void SftpChannelPrivate::handleCurrentPacket() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Handling SFTP packet of type %d", m_incomingPacket.type()); +#endif + switch (m_incomingPacket.type()) { + case SSH_FXP_VERSION: + handleServerVersion(); + break; + case SSH_FXP_HANDLE: + handleHandle(); + break; + case SSH_FXP_NAME: + handleName(); + break; + case SSH_FXP_STATUS: + handleStatus(); + break; + case SSH_FXP_DATA: + handleReadData(); + break; + case SSH_FXP_ATTRS: + handleAttrs(); + break; + default: + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected packet.", + SSH_TR("Unexpected packet of type %d.").arg(m_incomingPacket.type())); + } +} + +void SftpChannelPrivate::handleServerVersion() +{ + checkChannelActive(); + if (m_sftpState != InitSent) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_VERSION packet."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("sftp init received"); +#endif + const quint32 serverVersion = m_incomingPacket.extractServerVersion(); + if (serverVersion != ProtocolVersion) { + createDelayedInitFailedSignal(SSH_TR("Protocol version mismatch: Expected %1, got %2") + .arg(serverVersion).arg(ProtocolVersion)); + closeChannel(); + } else { + m_sftpState = Initialized; + createDelayedInitializedSignal(); + } +} + +void SftpChannelPrivate::handleHandle() +{ + const SftpHandleResponse &response = m_incomingPacket.asHandleResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + const QSharedPointer job + = it.value().dynamicCast(); + if (job.isNull()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_HANDLE packet."); + } + if (job->state != AbstractSftpOperationWithHandle::OpenRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_HANDLE packet."); + } + job->remoteHandle = response.handle; + job->state = AbstractSftpOperationWithHandle::Open; + + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: + handleLsHandle(it); + break; + case AbstractSftpOperation::CreateFile: + handleCreateFileHandle(it); + break; + case AbstractSftpOperation::Download: + handleGetHandle(it); + break; + case AbstractSftpOperation::Upload: + handlePutHandle(it); + break; + default: + Q_ASSERT(!"Oh no, I forgot to handle an SFTP operation type!"); + } +} + +void SftpChannelPrivate::handleLsHandle(const JobMap::Iterator &it) +{ + SftpListDir::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateReadDir(op->remoteHandle, + op->jobId).rawData()); +} + +void SftpChannelPrivate::handleCreateFileHandle(const JobMap::Iterator &it) +{ + SftpCreateFile::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateCloseHandle(op->remoteHandle, + op->jobId).rawData()); +} + +void SftpChannelPrivate::handleGetHandle(const JobMap::Iterator &it) +{ + SftpDownload::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateFstat(op->remoteHandle, + op->jobId).rawData()); + op->statRequested = true; +} + +void SftpChannelPrivate::handlePutHandle(const JobMap::Iterator &it) +{ + SftpUpload::Ptr op = it.value().staticCast(); + + // OpenSSH does not implement the RFC's append functionality, so we + // have to emulate it. + if (op->mode == SftpAppendToExisting) { + sendData(m_outgoingPacket.generateFstat(op->remoteHandle, + op->jobId).rawData()); + op->statRequested = true; + } else { + spawnWriteRequests(it); + } +} + +void SftpChannelPrivate::handleStatus() +{ + const SftpStatusResponse &response = m_incomingPacket.asStatusResponse(); +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: status = %d", Q_FUNC_INFO, response.status); +#endif + JobMap::Iterator it = lookupJob(response.requestId); + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: + handleLsStatus(it, response); + break; + case AbstractSftpOperation::Download: + handleGetStatus(it, response); + break; + case AbstractSftpOperation::Upload: + handlePutStatus(it, response); + break; + case AbstractSftpOperation::MakeDir: + case AbstractSftpOperation::RmDir: + case AbstractSftpOperation::Rm: + case AbstractSftpOperation::Rename: + case AbstractSftpOperation::CreateFile: + handleStatusGeneric(it, response); + break; + } +} + +void SftpChannelPrivate::handleStatusGeneric(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + AbstractSftpOperation::Ptr op = it.value(); + const QString error = errorMessage(response, SSH_TR("Unknown error.")); + createDelayedJobFinishedSignal(op->jobId, error); + m_jobs.erase(it); +} + +void SftpChannelPrivate::handleLsStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpListDir::Ptr op = it.value().staticCast(); + switch (op->state) { + case SftpListDir::OpenRequested: + createDelayedJobFinishedSignal(op->jobId, errorMessage(response.errorString, + SSH_TR("Remote directory could not be opened for reading."))); + m_jobs.erase(it); + break; + case SftpListDir::Open: + if (response.status != SSH_FX_EOF) + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to list remote directory contents."))); + op->state = SftpListDir::CloseRequested; + sendData(m_outgoingPacket.generateCloseHandle(op->remoteHandle, + op->jobId).rawData()); + break; + case SftpListDir::CloseRequested: + if (!op->hasError) { + const QString error = errorMessage(response, + SSH_TR("Failed to close remote directory.")); + createDelayedJobFinishedSignal(op->jobId, error); + } + m_jobs.erase(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handleGetStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpDownload::Ptr op = it.value().staticCast(); + switch (op->state) { + case SftpDownload::OpenRequested: + createDelayedJobFinishedSignal(op->jobId, + errorMessage(response.errorString, + SSH_TR("Failed to open remote file for reading."))); + m_jobs.erase(it); + break; + case SftpDownload::Open: + if (op->statRequested) { + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to stat remote file."))); + sendTransferCloseHandle(op, response.requestId); + } else { + if ((response.status != SSH_FX_EOF || response.requestId != op->eofId) + && !op->hasError) + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to read remote file."))); + finishTransferRequest(it); + } + break; + case SftpDownload::CloseRequested: + Q_ASSERT(op->inFlightCount == 1); + if (!op->hasError) { + if (response.status == SSH_FX_OK) + createDelayedJobFinishedSignal(op->jobId); + else + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to close remote file."))); + } + removeTransferRequest(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handlePutStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpUpload::Ptr job = it.value().staticCast(); + switch (job->state) { + case SftpUpload::OpenRequested: + createDelayedJobFinishedSignal(job->jobId, + errorMessage(response.errorString, + SSH_TR("Failed to open remote file for writing."))); + m_jobs.erase(it); + break; + case SftpUpload::Open: + if (response.status == SSH_FX_OK) { + sendWriteRequest(it); + } else if(!job->hasError) { + reportRequestError(job, errorMessage(response.errorString, + SSH_TR("Failed to write remote file."))); + finishTransferRequest(it); + } + break; + case SftpUpload::CloseRequested: + Q_ASSERT(job->inFlightCount == 1); + if (!job->hasError) { + const QString error = errorMessage(response, + SSH_TR("Failed to close remote file.")); + createDelayedJobFinishedSignal(job->jobId, error); + } + m_jobs.erase(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handleName() +{ + const SftpNameResponse &response = m_incomingPacket.asNameResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: { + SftpListDir::Ptr op = it.value().staticCast(); + if (op->state != SftpListDir::Open) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_NAME packet."); + } + + for (int i = 0; i < response.files.count(); ++i) { + const SftpFile &file = response.files.at(i); + createDelayedDataAvailableSignal(op->jobId, file.fileName); + } + sendData(m_outgoingPacket.generateReadDir(op->remoteHandle, + op->jobId).rawData()); + break; + } + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_NAME packet."); + } +} + +void SftpChannelPrivate::handleReadData() +{ + const SftpDataResponse &response = m_incomingPacket.asDataResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + if (it.value()->type() != AbstractSftpOperation::Download) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_DATA packet."); + } + + SftpDownload::Ptr op = it.value().staticCast(); + if (op->hasError) { + finishTransferRequest(it); + return; + } + + if (!op->localFile->seek(op->offsets[response.requestId])) { + reportRequestError(op, op->localFile->errorString()); + finishTransferRequest(it); + return; + } + + if (op->localFile->write(response.data) != response.data.size()) { + reportRequestError(op, op->localFile->errorString()); + finishTransferRequest(it); + return; + } + + if (op->offset >= op->fileSize && op->fileSize != 0) + finishTransferRequest(it); + else + sendReadRequest(op, response.requestId); +} + +void SftpChannelPrivate::handleAttrs() +{ + const SftpAttrsResponse &response = m_incomingPacket.asAttrsResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + AbstractSftpTransfer::Ptr transfer + = it.value().dynamicCast(); + if (!transfer || transfer->state != AbstractSftpTransfer::Open + || !transfer->statRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_ATTRS packet."); + } + Q_ASSERT(transfer->type() == AbstractSftpOperation::Upload + || transfer->type() == AbstractSftpOperation::Download); + + if (transfer->type() == AbstractSftpOperation::Download) { + SftpDownload::Ptr op = transfer.staticCast(); + if (response.attrs.sizePresent) { + op->fileSize = response.attrs.size; + } else { + op->fileSize = 0; + op->eofId = op->jobId; + } + op->statRequested = false; + spawnReadRequests(op); + } else { + SftpUpload::Ptr op = transfer.staticCast(); + if (response.attrs.sizePresent) { + op->offset = response.attrs.size; + spawnWriteRequests(it); + } else { + reportRequestError(op, SSH_TR("Cannot append to remote file: " + "Server does not support file size attribute.")); + sendTransferCloseHandle(op, op->jobId); + } + } +} + +SftpChannelPrivate::JobMap::Iterator SftpChannelPrivate::lookupJob(SftpJobId id) +{ + JobMap::Iterator it = m_jobs.find(id); + if (it == m_jobs.end()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid request id in SFTP packet."); + } + return it; +} + +void SftpChannelPrivate::closeHook() +{ + createClosedSignal(); +} + +void SftpChannelPrivate::handleOpenSuccessInternal() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("SFTP session started"); +#endif + m_sendFacility.sendSftpPacket(remoteChannel()); + m_sftpState = SubsystemRequested; +} + +void SftpChannelPrivate::handleOpenFailureInternal() +{ + if (channelState() != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + createDelayedInitFailedSignal(SSH_TR("Server could not start session.")); +} + +void SftpChannelPrivate::sendReadRequest(const SftpDownload::Ptr &job, + quint32 requestId) +{ + Q_ASSERT(job->eofId == SftpInvalidJob); + sendData(m_outgoingPacket.generateReadFile(job->remoteHandle, job->offset, + AbstractSftpPacket::MaxDataSize, requestId).rawData()); + job->offsets[requestId] = job->offset; + job->offset += AbstractSftpPacket::MaxDataSize; + if (job->offset >= job->fileSize) + job->eofId = requestId; +} + +void SftpChannelPrivate::reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job, + const QString &error) +{ + createDelayedJobFinishedSignal(job->jobId, error); + job->hasError = true; +} + +void SftpChannelPrivate::finishTransferRequest(const JobMap::Iterator &it) +{ + AbstractSftpTransfer::Ptr job = it.value().staticCast(); + if (job->inFlightCount == 1) + sendTransferCloseHandle(job, it.key()); + else + removeTransferRequest(it); +} + +void SftpChannelPrivate::sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job, + quint32 requestId) +{ + sendData(m_outgoingPacket.generateCloseHandle(job->remoteHandle, + requestId).rawData()); + job->state = SftpDownload::CloseRequested; +} + +void SftpChannelPrivate::removeTransferRequest(const JobMap::Iterator &it) +{ + --it.value().staticCast()->inFlightCount; + m_jobs.erase(it); +} + +void SftpChannelPrivate::sendWriteRequest(const JobMap::Iterator &it) +{ + SftpUpload::Ptr job = it.value().staticCast(); + QByteArray data = job->localFile->read(AbstractSftpPacket::MaxDataSize); + if (job->localFile->error() != QFile::NoError) { + if (!job->hasError) { + reportRequestError(job, SSH_TR("Error reading local file: %1") + .arg(job->localFile->errorString())); + } + finishTransferRequest(it); + } else if (data.isEmpty()) { + finishTransferRequest(it); + } else { + sendData(m_outgoingPacket.generateWriteFile(job->remoteHandle, + job->offset, data, it.key()).rawData()); + job->offset += AbstractSftpPacket::MaxDataSize; + } +} + +void SftpChannelPrivate::spawnWriteRequests(const JobMap::Iterator &it) +{ + SftpUpload::Ptr op = it.value().staticCast(); + op->calculateInFlightCount(AbstractSftpPacket::MaxDataSize); + sendWriteRequest(it); + for (int i = 1; i < op->inFlightCount; ++i) + sendWriteRequest(m_jobs.insert(++m_nextJobId, op)); +} + +void SftpChannelPrivate::spawnReadRequests(const SftpDownload::Ptr &job) +{ + job->calculateInFlightCount(AbstractSftpPacket::MaxDataSize); + sendReadRequest(job, job->jobId); + for (int i = 1; i < job->inFlightCount; ++i) { + const quint32 requestId = ++m_nextJobId; + m_jobs.insert(requestId, job); + sendReadRequest(job, requestId); + } +} + +void SftpChannelPrivate::createDelayedInitFailedSignal(const QString &reason) +{ + new SftpInitializationFailedSignal(this, QWeakPointer(m_sftp), + reason); +} + +void SftpChannelPrivate::emitInitializationFailedSignal(const QString &reason) +{ + emit m_sftp->initializationFailed(reason); +} + +void SftpChannelPrivate::createDelayedInitializedSignal() +{ + new SftpInitializedSignal(this, QWeakPointer(m_sftp)); +} + +void SftpChannelPrivate::emitInitialized() +{ + emit m_sftp->initialized(); +} + +void SftpChannelPrivate::createDelayedJobFinishedSignal(SftpJobId jobId, + const QString &error) +{ + new SftpJobFinishedSignal(this, QWeakPointer(m_sftp), jobId, error); +} + +void SftpChannelPrivate::emitJobFinished(SftpJobId jobId, const QString &error) +{ + emit m_sftp->finished(jobId, error); +} + +void SftpChannelPrivate::createDelayedDataAvailableSignal(SftpJobId jobId, + const QString &data) +{ + new SftpDataAvailableSignal(this, QWeakPointer(m_sftp), jobId, data); +} + +void SftpChannelPrivate::emitDataAvailable(SftpJobId jobId, const QString &data) +{ + emit m_sftp->dataAvailable(jobId, data); +} + +void SftpChannelPrivate::createClosedSignal() +{ + new SftpClosedSignal(this, QWeakPointer(m_sftp)); +} + +void SftpChannelPrivate::emitClosed() +{ + emit m_sftp->closed(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpchannel.h b/src/plugins/coreplugin/ssh/sftpchannel.h new file mode 100644 index 00000000000..6b4ffea7e50 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel.h @@ -0,0 +1,120 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTCHANNEL_H +#define SFTCHANNEL_H + +#include "sftpdefs.h" +#include "sftpincomingpacket_p.h" + +#include + +#include +#include +#include +#include + +namespace Core { + +namespace Internal { +class SftpChannelPrivate; +class SshChannelManager; +class SshSendFacility; +} // namespace Internal + +/* + * This class provides SFTP operations. + * Objects are created via SshConnection::createSftpChannel(). + * The channel needs to be initialized with + * a call to initialize() and is closed via closeChannel(). After closing + * a channel, no more operations are possible. It cannot be re-opened + * using initialize(); use SshConnection::createSftpChannel() if you need + * a new one. + * After the initialized() signal has been emitted, operations can be started. + * All SFTP operations are asynchronous (non-blocking) and can be in-flight + * simultaneously (though callers must ensure that concurrently running jobs + * are independent of each other, e.g. they must not write to the same file). + * Operations are identified by their job id, which is returned by + * the respective member function. If the function can right away detect that + * the operation cannot succeed, it returns SftpInvalidJob. If an error occurs + * later, the finishedWithError() signal is emitted for the respective job. + * Note that directory names must not have a trailing slash. + */ +class CORE_EXPORT SftpChannel : public QObject +{ + Q_OBJECT + + friend class Internal::SftpChannelPrivate; + friend class Internal::SshChannelManager; +public: + typedef QSharedPointer Ptr; + + enum State { Uninitialized, Initializing, Initialized, Closing, Closed }; + State state() const; + + void initialize(); + void closeChannel(); + + SftpJobId listDirectory(const QString &dirPath); + SftpJobId createDirectory(const QString &dirPath); + SftpJobId removeDirectory(const QString &dirPath); + SftpJobId removeFile(const QString &filePath); + SftpJobId renameFileOrDirectory(const QString &oldPath, + const QString &newPath); + SftpJobId createFile(const QString &filePath, SftpOverwriteMode mode); + SftpJobId uploadFile(const QString &localFilePath, + const QString &remoteFilePath, SftpOverwriteMode mode); + SftpJobId downloadFile(const QString &remoteFilePath, + const QString &localFilePath, SftpOverwriteMode mode); + + ~SftpChannel(); + +signals: + void initialized(); + void initializationFailed(const QString &reason); + void closed(); + + // error.isEmpty <=> finished successfully + void finished(Core::SftpJobId job, const QString &error = QString()); + + /* + * This signal is only emitted by the "List Directory" operation, + * one file at a time. + */ + void dataAvailable(SftpJobId job, const QString &data); + +private: + SftpChannel(quint32 channelId, Internal::SshSendFacility &sendFacility); + + Internal::SftpChannelPrivate *d; +}; + +} // namespace Core + +#endif // SFTPCHANNEL_H diff --git a/src/plugins/coreplugin/ssh/sftpchannel_p.h b/src/plugins/coreplugin/ssh/sftpchannel_p.h new file mode 100644 index 00000000000..8d27a2c01dc --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel_p.h @@ -0,0 +1,130 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTCHANNEL_P_H +#define SFTCHANNEL_P_H + +#include "sftpdefs.h" +#include "sftpincomingpacket_p.h" +#include "sftpoperation_p.h" +#include "sftpoutgoingpacket_p.h" +#include "sshchannel_p.h" + +#include +#include + +namespace Core { +class SftpChannel; +namespace Internal { + +class SftpChannelPrivate : public AbstractSshChannel +{ + friend class Core::SftpChannel; +public: + + enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized }; + + virtual void handleChannelSuccess(); + virtual void handleChannelFailure(); + + virtual void closeHook(); + + void emitInitializationFailedSignal(const QString &reason); + void emitInitialized(); + void emitJobFinished(SftpJobId jobId, const QString &error); + void emitDataAvailable(SftpJobId jobId, const QString &data); + void emitClosed(); + +private: + typedef QMap JobMap; + + SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility, + SftpChannel *sftp); + SftpJobId createJob(const AbstractSftpOperation::Ptr &job); + + virtual void handleOpenSuccessInternal(); + virtual void handleOpenFailureInternal(); + virtual void handleChannelDataInternal(const QByteArray &data); + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data); + + void handleCurrentPacket(); + void handleServerVersion(); + void handleHandle(); + void handleStatus(); + void handleName(); + void handleReadData(); + void handleAttrs(); + + void handleStatusGeneric(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handleLsStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handleGetStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handlePutStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + + void handleLsHandle(const JobMap::Iterator &it); + void handleCreateFileHandle(const JobMap::Iterator &it); + void handleGetHandle(const JobMap::Iterator &it); + void handlePutHandle(const JobMap::Iterator &it); + + void spawnReadRequests(const SftpDownload::Ptr &job); + void spawnWriteRequests(const JobMap::Iterator &it); + void sendReadRequest(const SftpDownload::Ptr &job, quint32 requestId); + void sendWriteRequest(const JobMap::Iterator &it); + void finishTransferRequest(const JobMap::Iterator &it); + void removeTransferRequest(const JobMap::Iterator &it); + void reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job, + const QString &error); + void sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job, + quint32 requestId); + + void createDelayedInitFailedSignal(const QString &reason); + void createDelayedInitializedSignal(); + void createDelayedJobFinishedSignal(SftpJobId jobId, + const QString &error = QString()); + void createDelayedDataAvailableSignal(SftpJobId jobId, const QString &data); + void createClosedSignal(); + + JobMap::Iterator lookupJob(SftpJobId id); + JobMap m_jobs; + SftpOutgoingPacket m_outgoingPacket; + SftpIncomingPacket m_incomingPacket; + QByteArray m_incomingData; + SftpJobId m_nextJobId; + SftpState m_sftpState; + SftpChannel *m_sftp; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPCHANNEL_P_H diff --git a/src/plugins/coreplugin/ssh/sftpdefs.cpp b/src/plugins/coreplugin/ssh/sftpdefs.cpp new file mode 100644 index 00000000000..6a2f6de45e1 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpdefs.cpp @@ -0,0 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpdefs.h" + +namespace Core { const SftpJobId SftpInvalidJob = 0; } diff --git a/src/plugins/coreplugin/ssh/sftpdefs.h b/src/plugins/coreplugin/ssh/sftpdefs.h new file mode 100644 index 00000000000..5f59582a055 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpdefs.h @@ -0,0 +1,48 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPDEFS_H +#define SFTPDEFS_H + +#include + +#include + +namespace Core { + +typedef quint32 SftpJobId; +CORE_EXPORT extern const SftpJobId SftpInvalidJob; + +enum SftpOverwriteMode { + SftpOverwriteExisting, SftpAppendToExisting, SftpSkipExisting +}; + +} // namespace Core + +#endif // SFTPDEFS_H diff --git a/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp b/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp new file mode 100644 index 00000000000..804bdb21d5c --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp @@ -0,0 +1,230 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpincomingpacket_p.h" + +#include "sshexception_p.h" +#include "sshpacketparser_p.h" + +namespace Core { +namespace Internal { + +namespace { + const int SSH_FILEXFER_ATTR_SIZE = 0x00000001; + const int SSH_FILEXFER_ATTR_UIDGID = 0x00000002; + const int SSH_FILEXFER_ATTR_PERMISSIONS = 0x00000004; + const int SSH_FILEXFER_ATTR_ACMODTIME = 0x00000008; + const int SSH_FILEXFER_ATTR_EXTENDED = 0x80000000; +} // anonymous namespace + +SftpIncomingPacket::SftpIncomingPacket() : m_length(0) +{ +} + +void SftpIncomingPacket::consumeData(QByteArray &newData) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: current data size = %d, new data size = %d", Q_FUNC_INFO, + m_data.size(), newData.size()); +#endif + + if (isComplete() || dataSize() + newData.size() < sizeof m_length) + return; + + if (dataSize() < sizeof m_length) { + moveFirstBytes(m_data, newData, sizeof m_length - m_data.size()); + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); + if (m_length < static_cast(TypeOffset + 1) + || m_length > MaxPacketSize) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid length field in SFTP packet."); + } + } + + moveFirstBytes(m_data, newData, + qMin(m_length - dataSize() + 4, newData.size())); +} + +void SftpIncomingPacket::moveFirstBytes(QByteArray &target, QByteArray &source, + int n) +{ + target.append(source.left(n)); + source.remove(0, n); +} + +bool SftpIncomingPacket::isComplete() const +{ + return m_length == dataSize() - 4; +} + +void SftpIncomingPacket::clear() +{ + m_data.clear(); + m_length = 0; +} + +quint32 SftpIncomingPacket::extractServerVersion() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_VERSION); + try { + return SshPacketParser::asUint32(m_data, TypeOffset + 1); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_VERSION packet."); + } +} + +SftpHandleResponse SftpIncomingPacket::asHandleResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_HANDLE); + try { + SftpHandleResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.handle = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_HANDLE packet"); + } +} + +SftpStatusResponse SftpIncomingPacket::asStatusResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_STATUS); + try { + SftpStatusResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.status = static_cast(SshPacketParser::asUint32(m_data, &offset)); + response.errorString = SshPacketParser::asUserString(m_data, &offset); + response.language = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_STATUS packet."); + } +} + +SftpNameResponse SftpIncomingPacket::asNameResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_NAME); + try { + SftpNameResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + const quint32 count = SshPacketParser::asUint32(m_data, &offset); + for (quint32 i = 0; i < count; ++i) + response.files << asFile(offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_NAME packet."); + } +} + +SftpDataResponse SftpIncomingPacket::asDataResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_DATA); + try { + SftpDataResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.data = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_DATA packet."); + } +} + +SftpAttrsResponse SftpIncomingPacket::asAttrsResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_ATTRS); + try { + SftpAttrsResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.attrs = asFileAttributes(offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_ATTRS packet."); + } +} + +SftpFile SftpIncomingPacket::asFile(quint32 &offset) const +{ + SftpFile file; + file.fileName + = QString::fromUtf8(SshPacketParser::asString(m_data, &offset)); + file.longName + = QString::fromUtf8(SshPacketParser::asString(m_data, &offset)); + file.attributes = asFileAttributes(offset); + return file; +} + +SftpFileAttributes SftpIncomingPacket::asFileAttributes(quint32 &offset) const +{ + SftpFileAttributes attributes; + const quint32 flags = SshPacketParser::asUint32(m_data, &offset); + attributes.sizePresent = flags & SSH_FILEXFER_ATTR_SIZE; + attributes.timesPresent = flags & SSH_FILEXFER_ATTR_ACMODTIME; + attributes.uidAndGidPresent = flags & SSH_FILEXFER_ATTR_UIDGID; + attributes.permissionsPresent = flags & SSH_FILEXFER_ATTR_PERMISSIONS; + if (attributes.sizePresent) + attributes.size = SshPacketParser::asUint64(m_data, &offset); + if (attributes.uidAndGidPresent) { + attributes.uid = SshPacketParser::asUint32(m_data, &offset); + attributes.gid = SshPacketParser::asUint32(m_data, &offset); + } + if (attributes.permissionsPresent) + attributes.permissions = SshPacketParser::asUint32(m_data, &offset); + if (attributes.timesPresent) { + attributes.atime = SshPacketParser::asUint32(m_data, &offset); + attributes.mtime = SshPacketParser::asUint32(m_data, &offset); + } + if (flags & SSH_FILEXFER_ATTR_EXTENDED) { + const quint32 count = SshPacketParser::asUint32(m_data, &offset); + for (quint32 i = 0; i < count; ++i) { + SshPacketParser::asString(m_data, &offset); + SshPacketParser::asString(m_data, &offset); + } + } + return attributes; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h b/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h new file mode 100644 index 00000000000..5a5b8d42fed --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h @@ -0,0 +1,111 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPINCOMINGPACKET_P_H +#define SFTPINCOMINGPACKET_P_H + +#include "sftppacket_p.h" + +namespace Core { +namespace Internal { + +struct SftpHandleResponse { + quint32 requestId; + QByteArray handle; +}; + +struct SftpStatusResponse { + quint32 requestId; + SftpStatusCode status; + QString errorString; + QByteArray language; +}; + +struct SftpFileAttributes { + bool sizePresent; + bool timesPresent; + bool uidAndGidPresent; + bool permissionsPresent; + quint64 size; + quint32 uid; + quint32 gid; + quint32 permissions; + quint32 atime; + quint32 mtime; +}; + +struct SftpFile { + QString fileName; + QString longName; // Not present in later RFCs, so we don't expose this to the user. + SftpFileAttributes attributes; +}; + +struct SftpNameResponse { + quint32 requestId; + QList files; +}; + +struct SftpDataResponse { + quint32 requestId; + QByteArray data; +}; + +struct SftpAttrsResponse { + quint32 requestId; + SftpFileAttributes attrs; +}; + +class SftpIncomingPacket : public AbstractSftpPacket +{ +public: + SftpIncomingPacket(); + + void consumeData(QByteArray &data); + void clear(); + bool isComplete() const; + quint32 extractServerVersion() const; + SftpHandleResponse asHandleResponse() const; + SftpStatusResponse asStatusResponse() const; + SftpNameResponse asNameResponse() const; + SftpDataResponse asDataResponse() const; + SftpAttrsResponse asAttrsResponse() const; + +private: + void moveFirstBytes(QByteArray &target, QByteArray &source, int n); + + SftpFileAttributes asFileAttributes(quint32 &offset) const; + SftpFile asFile(quint32 &offset) const; + + quint32 m_length; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPINCOMINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sftpoperation.cpp b/src/plugins/coreplugin/ssh/sftpoperation.cpp new file mode 100644 index 00000000000..8acb126db1f --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoperation.cpp @@ -0,0 +1,176 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpoperation_p.h" + +#include "sftpoutgoingpacket_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +AbstractSftpOperation::AbstractSftpOperation(SftpJobId jobId) : jobId(jobId) +{ +} + +AbstractSftpOperation::~AbstractSftpOperation() { } + + +SftpMakeDir::SftpMakeDir(SftpJobId jobId, const QString &path) + : AbstractSftpOperation(jobId), remoteDir(path) +{ +} + +SftpOutgoingPacket &SftpMakeDir::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateMkDir(remoteDir, jobId); +} + + +SftpRmDir::SftpRmDir(SftpJobId, const QString &path) + : AbstractSftpOperation(jobId), remoteDir(path) +{ +} + +SftpOutgoingPacket &SftpRmDir::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRmDir(remoteDir, jobId); +} + + +SftpRm::SftpRm(SftpJobId jobId, const QString &path) + : AbstractSftpOperation(jobId), remoteFile(path) {} + +SftpOutgoingPacket &SftpRm::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRm(remoteFile, jobId); +} + + +SftpRename::SftpRename(SftpJobId jobId, const QString &oldPath, + const QString &newPath) + : AbstractSftpOperation(jobId), oldPath(oldPath), newPath(newPath) +{ +} + +SftpOutgoingPacket &SftpRename::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRename(oldPath, newPath, jobId); +} + + +AbstractSftpOperationWithHandle::AbstractSftpOperationWithHandle(SftpJobId jobId, + const QString &remotePath) + : AbstractSftpOperation(jobId), + remotePath(remotePath), state(Inactive), hasError(false) +{ +} + +AbstractSftpOperationWithHandle::~AbstractSftpOperationWithHandle() { } + + +SftpListDir::SftpListDir(SftpJobId jobId, const QString &path) + : AbstractSftpOperationWithHandle(jobId, path) +{ +} + +SftpOutgoingPacket &SftpListDir::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenDir(remotePath, jobId); +} + + +SftpCreateFile::SftpCreateFile(SftpJobId jobId, const QString &path, + SftpOverwriteMode mode) + : AbstractSftpOperationWithHandle(jobId, path), mode(mode) +{ +} + +SftpOutgoingPacket & SftpCreateFile::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForWriting(remotePath, mode, jobId); +} + + +const int AbstractSftpTransfer::MaxInFlightCount = 10; // Experimentally found to be enough. + +AbstractSftpTransfer::AbstractSftpTransfer(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile) + : AbstractSftpOperationWithHandle(jobId, remotePath), + localFile(localFile), fileSize(0), offset(0), inFlightCount(0), + statRequested(false) +{ +} + +void AbstractSftpTransfer::calculateInFlightCount(quint32 chunkSize) +{ + if (fileSize == 0) { + inFlightCount = 1; + } else { + inFlightCount = fileSize / chunkSize; + if (fileSize % chunkSize) + ++inFlightCount; + if (inFlightCount > MaxInFlightCount) + inFlightCount = MaxInFlightCount; + } +} + + +SftpDownload::SftpDownload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile) + : AbstractSftpTransfer(jobId, remotePath, localFile), eofId(SftpInvalidJob) +{ +} + +SftpOutgoingPacket &SftpDownload::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForReading(remotePath, jobId); +} + + +SftpUpload::SftpUpload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile, SftpOverwriteMode mode) + : AbstractSftpTransfer(jobId, remotePath, localFile), mode(mode) +{ + fileSize = localFile->size(); +} + +SftpOutgoingPacket &SftpUpload::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForWriting(remotePath, mode, jobId); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpoperation_p.h b/src/plugins/coreplugin/ssh/sftpoperation_p.h new file mode 100644 index 00000000000..65987813322 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoperation_p.h @@ -0,0 +1,193 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPOPERATION_P_H +#define SFTPOPERATION_P_H + +#include "sftpdefs.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QFile; +QT_END_NAMESPACE + +namespace Core { +namespace Internal { + +class SftpOutgoingPacket; + +struct AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + enum Type { + ListDir, MakeDir, RmDir, Rm, Rename, CreateFile, Download, Upload + }; + + AbstractSftpOperation(SftpJobId jobId); + virtual ~AbstractSftpOperation(); + virtual Type type() const=0; + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet)=0; + + const SftpJobId jobId; + +private: + AbstractSftpOperation(const AbstractSftpOperation &); + AbstractSftpOperation &operator=(const AbstractSftpOperation &); +}; + +struct SftpMakeDir : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpMakeDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return MakeDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteDir; +}; + +struct SftpRmDir : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRmDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return RmDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteDir; +}; + +struct SftpRm : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRm(SftpJobId jobId, const QString &path); + virtual Type type() const { return Rm; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteFile; +}; + +struct SftpRename : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRename(SftpJobId jobId, const QString &oldPath, const QString &newPath); + virtual Type type() const { return Rename; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString oldPath; + const QString newPath; +}; + + +struct AbstractSftpOperationWithHandle : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + enum State { Inactive, OpenRequested, Open, CloseRequested }; + + AbstractSftpOperationWithHandle(SftpJobId jobId, const QString &remotePath); + ~AbstractSftpOperationWithHandle(); + + const QString remotePath; + QByteArray remoteHandle; + State state; + bool hasError; +}; + + +struct SftpListDir : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + SftpListDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return ListDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); +}; + + +struct SftpCreateFile : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + SftpCreateFile(SftpJobId jobId, const QString &path, SftpOverwriteMode mode); + virtual Type type() const { return CreateFile; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const SftpOverwriteMode mode; +}; + +struct AbstractSftpTransfer : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + AbstractSftpTransfer(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile); + void calculateInFlightCount(quint32 chunkSize); + + static const int MaxInFlightCount; + + const QSharedPointer localFile; + quint64 fileSize; + quint64 offset; + int inFlightCount; + bool statRequested; +}; + +struct SftpDownload : public AbstractSftpTransfer +{ + typedef QSharedPointer Ptr; + SftpDownload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile); + virtual Type type() const { return Download; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + QMap offsets; + SftpJobId eofId; +}; + +struct SftpUpload : public AbstractSftpTransfer +{ + typedef QSharedPointer Ptr; + + SftpUpload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile, SftpOverwriteMode mode); + virtual Type type() const { return Upload; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + SftpOverwriteMode mode; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPOPERATION_P_H diff --git a/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp b/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp new file mode 100644 index 00000000000..57fd85467e0 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp @@ -0,0 +1,202 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpoutgoingpacket_p.h" + +#include "sshpacket_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { + const quint32 DefaultAttributes = 0; + const quint32 SSH_FXF_READ = 0x00000001; + const quint32 SSH_FXF_WRITE = 0x00000002; + const quint32 SSH_FXF_APPEND = 0x00000004; + const quint32 SSH_FXF_CREAT = 0x00000008; + const quint32 SSH_FXF_TRUNC = 0x00000010; + const quint32 SSH_FXF_EXCL = 0x00000020; +} + +SftpOutgoingPacket::SftpOutgoingPacket() +{ +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateInit(quint32 version) +{ + return init(SSH_FXP_INIT, 0).appendInt(version).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_OPENDIR, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateReadDir(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_READDIR, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateCloseHandle(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_CLOSE, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateMkDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_MKDIR, requestId).appendString(path) + .appendInt(DefaultAttributes).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRmDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_RMDIR, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRm(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_REMOVE, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRename(const QString &oldPath, + const QString &newPath, quint32 requestId) +{ + return init(SSH_FXP_RENAME, requestId).appendString(oldPath) + .appendString(newPath).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFileForWriting(const QString &path, + SftpOverwriteMode mode, quint32 requestId) +{ + return generateOpenFile(path, Write, mode, requestId); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFileForReading(const QString &path, + quint32 requestId) +{ + // Note: Overwrite mode is irrelevant and will be ignored. + return generateOpenFile(path, Read, SftpSkipExisting, requestId); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateReadFile(const QByteArray &handle, + quint64 offset, quint32 length, quint32 requestId) +{ + return init(SSH_FXP_READ, requestId).appendString(handle).appendInt64(offset) + .appendInt(length).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateFstat(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_FSTAT, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateWriteFile(const QByteArray &handle, + quint64 offset, const QByteArray &data, quint32 requestId) +{ + return init(SSH_FXP_WRITE, requestId).appendString(handle) + .appendInt64(offset).appendString(data).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFile(const QString &path, + OpenType openType, SftpOverwriteMode mode, quint32 requestId) +{ + quint32 pFlags; + switch (openType) { + case Read: + pFlags = SSH_FXF_READ; + break; + case Write: + pFlags = SSH_FXF_WRITE | SSH_FXF_CREAT; + switch (mode) { + case SftpOverwriteExisting: pFlags |= SSH_FXF_TRUNC; break; + case SftpAppendToExisting: pFlags |= SSH_FXF_APPEND; break; + case SftpSkipExisting: pFlags |= SSH_FXF_EXCL; break; + } + break; + } + return init(SSH_FXP_OPEN, requestId).appendString(path).appendInt(pFlags) + .appendInt(DefaultAttributes).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::init(SftpPacketType type, + quint32 requestId) +{ + m_data.resize(TypeOffset + 1); + m_data[TypeOffset] = type; + if (type != SSH_FXP_INIT) { + appendInt(requestId); +#ifdef CREATOR_SSH_DEBUG + qDebug("Generating SFTP packet of type %d with request id %u", type, + requestId); +#endif + } + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendInt(quint32 val) +{ + m_data.append(AbstractSshPacket::encodeInt(val)); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendInt64(quint64 value) +{ + m_data.append(AbstractSshPacket::encodeInt(value)); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendString(const QString &string) +{ + m_data.append(AbstractSshPacket::encodeString(string.toUtf8())); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendString(const QByteArray &string) +{ + m_data += AbstractSshPacket::encodeString(string); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::finalize() +{ + AbstractSshPacket::setLengthField(m_data); + return *this; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h b/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h new file mode 100644 index 00000000000..4f456e87542 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h @@ -0,0 +1,83 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPOUTGOINGPACKET_P_H +#define SFTPOUTGOINGPACKET_P_H + +#include "sftppacket_p.h" +#include "sftpdefs.h" + +namespace Core { +namespace Internal { + +class SftpOutgoingPacket : public AbstractSftpPacket +{ +public: + SftpOutgoingPacket(); + SftpOutgoingPacket &generateInit(quint32 version); + SftpOutgoingPacket &generateOpenDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateReadDir(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateCloseHandle(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateMkDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRmDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRm(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRename(const QString &oldPath, + const QString &newPath, quint32 requestId); + SftpOutgoingPacket &generateOpenFileForWriting(const QString &path, + SftpOverwriteMode mode, quint32 requestId); + SftpOutgoingPacket &generateOpenFileForReading(const QString &path, + quint32 requestId); + SftpOutgoingPacket &generateReadFile(const QByteArray &handle, + quint64 offset, quint32 length, quint32 requestId); + SftpOutgoingPacket &generateFstat(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateWriteFile(const QByteArray &handle, + quint64 offset, const QByteArray &data, quint32 requestId); + +private: + static QByteArray encodeString(const QString &string); + + enum OpenType { Read, Write }; + SftpOutgoingPacket &generateOpenFile(const QString &path, OpenType openType, + SftpOverwriteMode mode, quint32 requestId); + + SftpOutgoingPacket &init(SftpPacketType type, quint32 requestId); + SftpOutgoingPacket &appendInt(quint32 value); + SftpOutgoingPacket &appendInt64(quint64 value); + SftpOutgoingPacket &appendString(const QString &string); + SftpOutgoingPacket &appendString(const QByteArray &string); + SftpOutgoingPacket &finalize(); +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPOUTGOINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sftppacket.cpp b/src/plugins/coreplugin/ssh/sftppacket.cpp new file mode 100644 index 00000000000..0064bf39faf --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftppacket.cpp @@ -0,0 +1,54 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftppacket_p.h" + +#include "sshpacketparser_p.h" + +namespace Core { +namespace Internal { + +const quint32 AbstractSftpPacket::MaxDataSize = 32768; +const quint32 AbstractSftpPacket::MaxPacketSize = 34000; +const int AbstractSftpPacket::TypeOffset = 4; +const int AbstractSftpPacket::RequestIdOffset = TypeOffset + 1; +const int AbstractSftpPacket::PayloadOffset = RequestIdOffset + 4; + + +AbstractSftpPacket::AbstractSftpPacket() +{ +} + +quint32 AbstractSftpPacket::requestId() const +{ + return SshPacketParser::asUint32(m_data, RequestIdOffset); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftppacket_p.h b/src/plugins/coreplugin/ssh/sftppacket_p.h new file mode 100644 index 00000000000..aae1a15a97b --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftppacket_p.h @@ -0,0 +1,108 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPPACKET_P_H +#define SFTPPACKET_P_H + +#include +#include +#include + +namespace Core { +namespace Internal { + +enum SftpPacketType { + SSH_FXP_INIT = 1, + SSH_FXP_VERSION = 2, + SSH_FXP_OPEN = 3, + SSH_FXP_CLOSE = 4, + SSH_FXP_READ = 5, + SSH_FXP_WRITE = 6, + SSH_FXP_LSTAT = 7, + SSH_FXP_FSTAT = 8, + SSH_FXP_SETSTAT = 9, + SSH_FXP_FSETSTAT = 10, + SSH_FXP_OPENDIR = 11, + SSH_FXP_READDIR = 12, + SSH_FXP_REMOVE = 13, + SSH_FXP_MKDIR = 14, + SSH_FXP_RMDIR = 15, + SSH_FXP_REALPATH = 16, + SSH_FXP_STAT = 17, + SSH_FXP_RENAME = 18, + SSH_FXP_READLINK = 19, + SSH_FXP_SYMLINK = 20, // Removed from later protocol versions. Try not to use. + + SSH_FXP_STATUS = 101, + SSH_FXP_HANDLE = 102, + SSH_FXP_DATA = 103, + SSH_FXP_NAME = 104, + SSH_FXP_ATTRS = 105, + + SSH_FXP_EXTENDED = 200, + SSH_FXP_EXTENDED_REPLY = 201 +}; + +enum SftpStatusCode { + SSH_FX_OK = 0, + SSH_FX_EOF = 1, + SSH_FX_NO_SUCH_FILE = 2, + SSH_FX_PERMISSION_DENIED = 3, + SSH_FX_FAILURE = 4, + SSH_FX_BAD_MESSAGE = 5, + SSH_FX_NO_CONNECTION = 6, + SSH_FX_CONNECTION_LOST = 7, + SSH_FX_OP_UNSUPPORTED = 8 +}; + +class AbstractSftpPacket +{ +public: + AbstractSftpPacket(); + quint32 requestId() const; + const QByteArray &rawData() const { return m_data; } + SftpPacketType type() const { return static_cast(m_data.at(TypeOffset)); } + + static const quint32 MaxDataSize; // "Pure" data size per read/writepacket. + static const quint32 MaxPacketSize; + +protected: + quint32 dataSize() const { return static_cast(m_data.size()); } + + static const int TypeOffset; + static const int RequestIdOffset; + static const int PayloadOffset; + + QByteArray m_data; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshbotanconversions_p.h b/src/plugins/coreplugin/ssh/sshbotanconversions_p.h new file mode 100644 index 00000000000..05829779423 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshbotanconversions_p.h @@ -0,0 +1,97 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BYTEARRAYCONVERSIONS_P_H +#define BYTEARRAYCONVERSIONS_P_H + +#include "sshcapabilities_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +inline const Botan::byte *convertByteArray(const QByteArray &a) +{ + return reinterpret_cast(a.constData()); +} + +inline Botan::byte *convertByteArray(QByteArray &a) +{ + return reinterpret_cast(a.data()); +} + +inline QByteArray convertByteArray(const Botan::SecureVector &v) +{ + return QByteArray(reinterpret_cast(v.begin()), v.size()); +} + +inline const char *botanKeyExchangeAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::DiffieHellmanGroup1Sha1 + || rfcAlgoName == SshCapabilities::DiffieHellmanGroup14Sha1); + return rfcAlgoName == SshCapabilities::DiffieHellmanGroup1Sha1 + ? "modp/ietf/1024" : "modp/ietf/2048"; +} + +inline const char *botanCryptAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::CryptAlgo3Des + || rfcAlgoName == SshCapabilities::CryptAlgoAes128); + return rfcAlgoName == SshCapabilities::CryptAlgo3Des + ? "TripleDES" : "AES-128"; +} + +inline const char *botanEmsaAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::PubKeyDss + || rfcAlgoName == SshCapabilities::PubKeyRsa); + return rfcAlgoName == SshCapabilities::PubKeyDss + ? "EMSA1(SHA-1)" : "EMSA3(SHA-1)"; +} + +inline const char *botanSha1Name() { return "SHA-1"; } + +inline const char *botanHMacAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); + return botanSha1Name(); +} + +inline quint32 botanHMacKeyLen(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); + return 20; +} + +} // namespace Internal +} // namespace Core + +#endif // BYTEARRAYCONVERSIONS_P_H diff --git a/src/plugins/coreplugin/ssh/sshcapabilities.cpp b/src/plugins/coreplugin/ssh/sshcapabilities.cpp new file mode 100644 index 00000000000..56db394206a --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcapabilities.cpp @@ -0,0 +1,103 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshcapabilities_p.h" + +#include "sshexception_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +namespace { + QByteArray listAsByteArray(const QList &list) + { + QByteArray array; + foreach(const QByteArray &elem, list) + array += elem + ','; + if (!array.isEmpty()) + array.remove(array.count() - 1, 1); + return array; + } +} // anonymous namspace + +const QByteArray SshCapabilities::DiffieHellmanGroup1Sha1("diffie-hellman-group1-sha1"); +const QByteArray SshCapabilities::DiffieHellmanGroup14Sha1("diffie-hellman-group14-sha1"); +const QList SshCapabilities::KeyExchangeMethods + = QList() << SshCapabilities::DiffieHellmanGroup1Sha1 + << SshCapabilities::DiffieHellmanGroup14Sha1; + +const QByteArray SshCapabilities::PubKeyDss("ssh-dss"); +const QByteArray SshCapabilities::PubKeyRsa("ssh-rsa"); +const QList SshCapabilities::PublicKeyAlgorithms + = QList() << SshCapabilities::PubKeyRsa + << SshCapabilities::PubKeyDss; + +const QByteArray SshCapabilities::CryptAlgo3Des("3des-cbc"); +const QByteArray SshCapabilities::CryptAlgoAes128("aes128-cbc"); +const QList SshCapabilities::EncryptionAlgorithms + = QList() << SshCapabilities::CryptAlgoAes128 + << SshCapabilities::CryptAlgo3Des; + +const QByteArray SshCapabilities::HMacSha1("hmac-sha1"); +const QByteArray SshCapabilities::HMacSha196("hmac-sha1-96"); +const QList SshCapabilities::MacAlgorithms + = QList() /* << SshCapabilities::HMacSha196 */ + << SshCapabilities::HMacSha1; + +const QList SshCapabilities::CompressionAlgorithms + = QList() << "none"; + +const QByteArray SshCapabilities::SshConnectionService("ssh-connection"); + +const QByteArray SshCapabilities::PublicKeyAuthMethod("publickey"); +const QByteArray SshCapabilities::PasswordAuthMethod("password"); + + +QByteArray SshCapabilities::findBestMatch(const QList &myCapabilities, + const QList &serverCapabilities) +{ + foreach (const QByteArray &myCapability, myCapabilities) { + if (serverCapabilities.contains(myCapability)) + return myCapability; + } + + throw SshServerException(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Server and client capabilities don't match.", + QCoreApplication::translate("SshConnection", + "Server and client capabilities don't match. " + "Client list was: %1.\nServer list was %2.") + .arg(listAsByteArray(myCapabilities).data()) + .arg(listAsByteArray(serverCapabilities).data())); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshcapabilities_p.h b/src/plugins/coreplugin/ssh/sshcapabilities_p.h new file mode 100644 index 00000000000..7c58c830f56 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcapabilities_p.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef CAPABILITIES_P_H +#define CAPABILITIES_P_H + +#include +#include + +namespace Core { +namespace Internal { + +class SshCapabilities +{ +public: + static const QByteArray DiffieHellmanGroup1Sha1; + static const QByteArray DiffieHellmanGroup14Sha1; + static const QList KeyExchangeMethods; + + static const QByteArray PubKeyDss; + static const QByteArray PubKeyRsa; + static const QList PublicKeyAlgorithms; + + static const QByteArray CryptAlgo3Des; + static const QByteArray CryptAlgoAes128; + static const QList EncryptionAlgorithms; + + static const QByteArray HMacSha1; + static const QByteArray HMacSha196; + static const QList MacAlgorithms; + + static const QList CompressionAlgorithms; + + static const QByteArray SshConnectionService; + + static const QByteArray PublicKeyAuthMethod; + static const QByteArray PasswordAuthMethod; + + static QByteArray findBestMatch(const QList &myCapabilities, + const QList &serverCapabilities); +}; + +} // namespace Internal +} // namespace Core + +#endif // CAPABILITIES_P_H diff --git a/src/plugins/coreplugin/ssh/sshchannel.cpp b/src/plugins/coreplugin/ssh/sshchannel.cpp new file mode 100644 index 00000000000..6e1b9c43f52 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannel.cpp @@ -0,0 +1,244 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshchannel_p.h" + +#include "sshincomingpacket_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { + const quint32 MinMaxPacketSize = 32768; + const quint32 MaxPacketSize = 16 * 1024 * 1024; + const quint32 InitialWindowSize = MaxPacketSize; + const quint32 NoChannel = 0xffffffffu; +} // anonymous namespace + +AbstractSshChannel::AbstractSshChannel(quint32 channelId, + SshSendFacility &sendFacility) + : m_sendFacility(sendFacility), m_localChannel(channelId), + m_remoteChannel(NoChannel), m_localWindowSize(InitialWindowSize), + m_remoteWindowSize(0), m_state(Inactive) +{ +} + +AbstractSshChannel::~AbstractSshChannel() +{ + +} + +void AbstractSshChannel::setChannelState(ChannelState state) +{ + m_state = state; + if (state == Closed) + closeHook(); +} + +void AbstractSshChannel::requestSessionStart() +{ + // Note: We are just being paranoid here about the Botan exceptions, + // which are extremely unlikely to happen, because if there was a problem + // with our cryptography stuff, it would have hit us before, on + // establishing the connection. + try { + m_sendFacility.sendSessionPacket(m_localChannel, InitialWindowSize, + MaxPacketSize); + setChannelState(SessionRequested); + } catch (Botan::Exception &e) { + m_errorString = QString::fromAscii(e.what()); + closeChannel(); + } +} + +void AbstractSshChannel::sendData(const QByteArray &data) +{ + try { + m_sendBuffer += data; + flushSendBuffer(); + } catch (Botan::Exception &e) { + m_errorString = QString::fromAscii(e.what()); + closeChannel(); + } +} + +void AbstractSshChannel::handleWindowAdjust(quint32 bytesToAdd) +{ + checkChannelActive(); + + const quint64 newValue = m_remoteWindowSize + bytesToAdd; + if (newValue > 0xffffffffu) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Illegal window size requested."); + } + + m_remoteWindowSize = newValue; + flushSendBuffer(); +} + +void AbstractSshChannel::flushSendBuffer() +{ + const quint32 bytesToSend + = qMin(m_remoteWindowSize, m_sendBuffer.size()); + if (bytesToSend > 0) { + const QByteArray &data = m_sendBuffer.left(bytesToSend); + m_sendFacility.sendChannelDataPacket(m_remoteChannel, data); + m_sendBuffer.remove(0, bytesToSend); + m_remoteWindowSize -= bytesToSend; + } +} + +void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId, + quint32 remoteWindowSize, quint32 remoteMaxPacketSize) +{ + if (m_state != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + + if (remoteMaxPacketSize < MinMaxPacketSize) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Maximum packet size too low."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("Channel opened. remote channel id: %u, remote window size: %u, " + "remote max packet size: %u", + remoteChannelId, remoteWindowSize, remoteMaxPacketSize); +#endif + m_remoteChannel = remoteChannelId; + m_remoteWindowSize = remoteWindowSize; + m_remoteMaxPacketSize = remoteMaxPacketSize; + setChannelState(SessionEstablished); + handleOpenSuccessInternal(); +} + +void AbstractSshChannel::handleOpenFailure(const QString &reason) +{ + if (m_state != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("Channel open request failed for channel %u", m_localChannel); +#endif + m_errorString = reason; + handleOpenFailureInternal(); +} + +void AbstractSshChannel::handleChannelEof() +{ + if (m_state == Inactive || m_state == Closed) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_EOF message."); + } + m_localWindowSize = 0; +} + +void AbstractSshChannel::handleChannelClose() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Receiving CLOSE for channel %u", m_localChannel); +#endif + if (channelState() == Inactive || channelState() == Closed) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_CLOSE message."); + } + closeChannel(); + setChannelState(Closed); +} + +void AbstractSshChannel::handleChannelData(const QByteArray &data) +{ + const int bytesToDeliver = handleChannelOrExtendedChannelData(data); + handleChannelDataInternal(bytesToDeliver == data.size() + ? data : data.left(bytesToDeliver)); +} + +void AbstractSshChannel::handleChannelExtendedData(quint32 type, const QByteArray &data) +{ + const int bytesToDeliver = handleChannelOrExtendedChannelData(data); + handleChannelExtendedDataInternal(type, bytesToDeliver == data.size() + ? data : data.left(bytesToDeliver)); +} + +void AbstractSshChannel::handleChannelRequest(const SshIncomingPacket &packet) +{ + qWarning("Ignoring unknown request type '%s'", + packet.extractChannelRequestType().data()); +} + +int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data) +{ + checkChannelActive(); + + const int bytesToDeliver = qMin(data.size(), maxDataSize()); + if (bytesToDeliver != data.size()) + qWarning("Misbehaving server does not respect local window, clipping."); + + m_localWindowSize -= bytesToDeliver; + if (m_localWindowSize < MaxPacketSize) { + m_localWindowSize += MaxPacketSize; + m_sendFacility.sendWindowAdjustPacket(m_remoteChannel, + MaxPacketSize); + } + return bytesToDeliver; +} + +void AbstractSshChannel::closeChannel() +{ + if (m_state != CloseRequested && m_state != Closed) { + if (m_state == Inactive) { + setChannelState(Closed); + } else { + setChannelState(CloseRequested); + m_sendFacility.sendChannelEofPacket(m_remoteChannel); + m_sendFacility.sendChannelClosePacket(m_remoteChannel); + } + } +} + +void AbstractSshChannel::checkChannelActive() +{ + if (channelState() == Inactive || channelState() == Closed) + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Channel not open."); +} + +quint32 AbstractSshChannel::maxDataSize() const +{ + return qMin(m_localWindowSize, MaxPacketSize); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshchannel_p.h b/src/plugins/coreplugin/ssh/sshchannel_p.h new file mode 100644 index 00000000000..993357d8713 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannel_p.h @@ -0,0 +1,111 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCHANNEL_P_H +#define SSHCHANNEL_P_H + +#include +#include + +namespace Core { +namespace Internal { + +class SshIncomingPacket; +class SshSendFacility; + +class AbstractSshChannel +{ +public: + enum ChannelState { + Inactive, SessionRequested, SessionEstablished, CloseRequested, Closed + }; + + ChannelState channelState() const { return m_state; } + void setChannelState(ChannelState state); + + void setError(const QString &error) { m_errorString = error; } + QString errorString() const { return m_errorString; } + + quint32 localChannelId() const { return m_localChannel; } + quint32 remoteChannel() const { return m_remoteChannel; } + + virtual void handleChannelSuccess()=0; + virtual void handleChannelFailure()=0; + virtual void handleChannelRequest(const SshIncomingPacket &packet); + + virtual void closeHook()=0; + + void handleOpenSuccess(quint32 remoteChannelId, quint32 remoteWindowSize, + quint32 remoteMaxPacketSize); + void handleOpenFailure(const QString &reason); + void handleWindowAdjust(quint32 bytesToAdd); + void handleChannelEof(); + void handleChannelClose(); + void handleChannelData(const QByteArray &data); + void handleChannelExtendedData(quint32 type, const QByteArray &data); + + void requestSessionStart(); + void sendData(const QByteArray &data); + void closeChannel(); + + virtual ~AbstractSshChannel(); + +protected: + AbstractSshChannel(quint32 channelId, SshSendFacility &sendFacility); + + quint32 maxDataSize() const; + void checkChannelActive(); + + SshSendFacility &m_sendFacility; + +private: + virtual void handleOpenSuccessInternal()=0; + virtual void handleOpenFailureInternal()=0; + virtual void handleChannelDataInternal(const QByteArray &data)=0; + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data)=0; + + void setState(ChannelState newState); + void flushSendBuffer(); + int handleChannelOrExtendedChannelData(const QByteArray &data); + + const quint32 m_localChannel; + quint32 m_remoteChannel; + quint32 m_localWindowSize; + quint32 m_remoteWindowSize; + quint32 m_remoteMaxPacketSize; + ChannelState m_state; + QByteArray m_sendBuffer; + QString m_errorString; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCHANNEL_P_H diff --git a/src/plugins/coreplugin/ssh/sshchannelmanager.cpp b/src/plugins/coreplugin/ssh/sshchannelmanager.cpp new file mode 100644 index 00000000000..c7d31136971 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannelmanager.cpp @@ -0,0 +1,188 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshchannelmanager_p.h" + +#include "sftpchannel.h" +#include "sftpchannel_p.h" +#include "sshincomingpacket_p.h" +#include "sshremoteprocess.h" +#include "sshremoteprocess_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { +namespace Internal { + +SshChannelManager::SshChannelManager(SshSendFacility &sendFacility) + : m_sendFacility(sendFacility), m_nextLocalChannelId(0) +{ +} + +SshChannelManager::~SshChannelManager() {} + +void SshChannelManager::handleChannelRequest(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel()) + ->handleChannelRequest(packet); +} + +void SshChannelManager::handleChannelOpen(const SshIncomingPacket &) +{ + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server tried to open channel on client."); +} + +void SshChannelManager::handleChannelOpenFailure(const SshIncomingPacket &packet) +{ + const SshChannelOpenFailure &failure = packet.extractChannelOpenFailure(); + ChannelIterator it = lookupChannelAsIterator(failure.localChannel); + try { + it.value()->handleOpenFailure(failure.reasonString); + } catch (SshServerException &e) { + removeChannel(it); + throw e; + } + removeChannel(it); +} + +void SshChannelManager::handleChannelOpenConfirmation(const SshIncomingPacket &packet) +{ + const SshChannelOpenConfirmation &confirmation + = packet.extractChannelOpenConfirmation(); + lookupChannel(confirmation.localChannel)->handleOpenSuccess(confirmation.remoteChannel, + confirmation.remoteWindowSize, confirmation.remoteMaxPacketSize); +} + +void SshChannelManager::handleChannelSuccess(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel())->handleChannelSuccess(); +} + +void SshChannelManager::handleChannelFailure(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel())->handleChannelFailure(); +} + +void SshChannelManager::handleChannelWindowAdjust(const SshIncomingPacket &packet) +{ + const SshChannelWindowAdjust adjust = packet.extractWindowAdjust(); + lookupChannel(adjust.localChannel)->handleWindowAdjust(adjust.bytesToAdd); +} + +void SshChannelManager::handleChannelData(const SshIncomingPacket &packet) +{ + const SshChannelData &data = packet.extractChannelData(); + lookupChannel(data.localChannel)->handleChannelData(data.data); +} + +void SshChannelManager::handleChannelExtendedData(const SshIncomingPacket &packet) +{ + const SshChannelExtendedData &data = packet.extractChannelExtendedData(); + lookupChannel(data.localChannel)->handleChannelExtendedData(data.type, data.data); +} + +void SshChannelManager::handleChannelEof(const SshIncomingPacket &packet) +{ + AbstractSshChannel * const channel + = lookupChannel(packet.extractRecipientChannel(), true); + if (channel) + channel->handleChannelEof(); +} + +void SshChannelManager::handleChannelClose(const SshIncomingPacket &packet) +{ + const quint32 channelId = packet.extractRecipientChannel(); + + ChannelIterator it = lookupChannelAsIterator(channelId, true); + if (it != m_channels.end()) { + it.value()->handleChannelClose(); + removeChannel(it); + } +} + +SshChannelManager::ChannelIterator SshChannelManager::lookupChannelAsIterator(quint32 channelId, + bool allowNotFound) +{ + ChannelIterator it = m_channels.find(channelId); + if (it == m_channels.end() && !allowNotFound) { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid channel id.", + SSH_TR("Invalid channel id %1").arg(channelId)); + } + return it; +} + +AbstractSshChannel *SshChannelManager::lookupChannel(quint32 channelId, + bool allowNotFound) +{ + ChannelIterator it = lookupChannelAsIterator(channelId, allowNotFound); + return it == m_channels.end() ? 0 : it.value(); +} + +Core::SshRemoteProcess::Ptr SshChannelManager::createRemoteProcess(const QByteArray &command) +{ + SshRemoteProcess::Ptr proc(new SshRemoteProcess(command, m_nextLocalChannelId++, m_sendFacility)); + insertChannel(proc->d, proc); + return proc; +} + +Core::SftpChannel::Ptr SshChannelManager::createSftpChannel() +{ + SftpChannel::Ptr sftp(new SftpChannel(m_nextLocalChannelId++, m_sendFacility)); + insertChannel(sftp->d, sftp); + return sftp; +} + +void SshChannelManager::insertChannel(AbstractSshChannel *priv, + const QSharedPointer &pub) +{ + m_channels.insert(priv->localChannelId(), priv); + m_sessions.insert(priv, pub); +} + +void SshChannelManager::closeAllChannels() +{ + for (ChannelIterator it = m_channels.begin(); it != m_channels.end(); ++it) + it.value()->closeChannel(); + m_channels.clear(); + m_sessions.clear(); +} + +void SshChannelManager::removeChannel(ChannelIterator it) +{ + Q_ASSERT(it != m_channels.end() && "Unexpected channel lookup failure."); + const int removeCount = m_sessions.remove(it.value()); + Q_ASSERT(removeCount == 1 && "Session for channel not found."); + m_channels.erase(it); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshchannelmanager_p.h b/src/plugins/coreplugin/ssh/sshchannelmanager_p.h new file mode 100644 index 00000000000..fe62c009241 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannelmanager_p.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCHANNELLAYER_P_H +#define SSHCHANNELLAYER_P_H + +#include +#include + +namespace Core { + +class SftpChannel; +class SshRemoteProcess; + +namespace Internal { + +class AbstractSshChannel; +class SshIncomingPacket; +class SshSendFacility; + +class SshChannelManager +{ +public: + SshChannelManager(SshSendFacility &sendFacility); + ~SshChannelManager(); + + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); + void closeAllChannels(); + + void handleChannelRequest(const SshIncomingPacket &packet); + void handleChannelOpen(const SshIncomingPacket &packet); + void handleChannelOpenFailure(const SshIncomingPacket &packet); + void handleChannelOpenConfirmation(const SshIncomingPacket &packet); + void handleChannelSuccess(const SshIncomingPacket &packet); + void handleChannelFailure(const SshIncomingPacket &packet); + void handleChannelWindowAdjust(const SshIncomingPacket &packet); + void handleChannelData(const SshIncomingPacket &packet); + void handleChannelExtendedData(const SshIncomingPacket &packet); + void handleChannelEof(const SshIncomingPacket &packet); + void handleChannelClose(const SshIncomingPacket &packet); + +private: + typedef QHash::Iterator ChannelIterator; + + ChannelIterator lookupChannelAsIterator(quint32 channelId, + bool allowNotFound = false); + AbstractSshChannel *lookupChannel(quint32 channelId, + bool allowNotFound = false); + void removeChannel(ChannelIterator it); + void insertChannel(AbstractSshChannel *priv, + const QSharedPointer &pub); + + SshSendFacility &m_sendFacility; + QHash m_channels; + QHash > m_sessions; + quint32 m_nextLocalChannelId; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCHANNELLAYER_P_H diff --git a/src/plugins/coreplugin/ssh/sshconnection.cpp b/src/plugins/coreplugin/ssh/sshconnection.cpp index 7433bbebd8d..fbf63d76705 100644 --- a/src/plugins/coreplugin/ssh/sshconnection.cpp +++ b/src/plugins/coreplugin/ssh/sshconnection.cpp @@ -1,19 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of Qt Creator. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -21,471 +22,540 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ #include "sshconnection.h" +#include "sshconnection_p.h" -#include "ne7sshobject.h" +#include "sftpchannel.h" +#include "sshcapabilities_p.h" +#include "sshchannelmanager_p.h" +#include "sshcryptofacility_p.h" +#include "sshexception_p.h" +#include "sshkeyexchange_p.h" -#include -#include -#include +#include +#include + +#include #include -#include -#include - -#include - -#include +#include namespace Core { namespace { + const QByteArray ClientId("SSH-2.0-QtCreator\r\n"); -class GenericSshConnection -{ - Q_DECLARE_TR_FUNCTIONS(GenericSshConnection) -public: - GenericSshConnection(const SshServerInfo &server) - : ssh(Internal::Ne7SshObject::instance()->get()), - m_server(server), - m_channel(-1) - { } + bool staticInitializationsDone = false; + QMutex staticInitMutex; - ~GenericSshConnection() + void doStaticInitializationsIfNecessary() { - quit(); - } - - bool start(bool shell, void (*callbackFunc)(void *), void *callbackArg) - { - Q_ASSERT(m_channel == -1); - - try { - const QString *authString; - int (ne7ssh::*connFunc)(const char *, int, const char *, - const char *, bool, int, void (*)(void *), void *); - if (m_server.authType == SshServerInfo::AuthByPwd) { - authString = &m_server.pwd; - connFunc = &ne7ssh::connectWithPassword; - } else { - authString = &m_server.privateKeyFile; - connFunc = &ne7ssh::connectWithKey; + if (!staticInitializationsDone) { + staticInitMutex.lock(); + if (!staticInitializationsDone) { + Botan::LibraryInitializer::initialize("thread_safe=true"); + qRegisterMetaType("SshError"); + staticInitializationsDone = true; } - m_channel = (ssh.data()->*connFunc)(m_server.host.toLatin1(), - m_server.port, m_server.uname.toAscii(), authString->toLatin1(), - shell, m_server.timeout, callbackFunc, callbackArg); - if (m_channel == -1) { - setError(tr("Could not connect to host."), false); - return false; - } - } catch (const std::exception &e) { - // Should in theory not be necessary, but Net7 leaks Botan exceptions. - setError(tr("Error in cryptography backend: %1") - .arg(QLatin1String(e.what())), false); - return false; - } - - return true; - } - - void quit() - { - const int channel = m_channel; - if (channel != -1) { - m_channel = -1; - if (!ssh->close(channel)) - qWarning("%s: close() failed.", Q_FUNC_INFO); + staticInitMutex.unlock(); } } - - bool isConnected() const { return channel() != -1; } - bool hasError() const { return !m_error.isEmpty(); } - QString error() const { return m_error; } - int channel() const { return m_channel; } - QString lastNe7Error() { return ssh->errors()->pop(channel()); } - const SshServerInfo &server() { return m_server; } - - void setError(const QString error, bool appendNe7ErrMsg) - { - m_error = error; - if (appendNe7ErrMsg) - m_error += QLatin1String(": ") + lastNe7Error(); - } - - QSharedPointer ssh; -private: - const SshServerInfo m_server; - QString m_error; - int m_channel; -}; - -char *alloc(size_t n) -{ - return new char[n]; } -} // anonymous namespace +// TODO: Mechanism for checking the host key. First connection to host: save, later: compare + +SshConnection::Ptr SshConnection::create() +{ + doStaticInitializationsIfNecessary(); + return Ptr(new SshConnection); +} + +SshConnection::SshConnection() : d(new Internal::SshConnectionPrivate(this)) +{ + connect(d, SIGNAL(connected()), this, SIGNAL(connected()), + Qt::QueuedConnection); + connect(d, SIGNAL(dataAvailable(QString)), this, + SIGNAL(dataAvailable(QString)), Qt::QueuedConnection); + connect(d, SIGNAL(disconnected()), this, SIGNAL(disconnected()), + Qt::QueuedConnection); + connect(d, SIGNAL(error(SshError)), this, SIGNAL(error(SshError)), + Qt::QueuedConnection); +} + +void SshConnection::connectToHost(const SshConnectionParameters &serverInfo) +{ + d->connectToHost(serverInfo); +} + +void SshConnection::disconnectFromHost() +{ + d->closeConnection(Internal::SSH_DISCONNECT_BY_APPLICATION, SshNoError, "", + QString()); +} + +SshConnection::State SshConnection::state() const +{ + switch (d->state()) { + case Internal::SocketUnconnected: + return Unconnected; + case Internal::ConnectionEstablished: + return Connected; + default: + return Connecting; + } +} + +SshError SshConnection::errorState() const +{ + return d->error(); +} + +QString SshConnection::errorString() const +{ + return d->errorString(); +} + +SshConnectionParameters SshConnection::connectionParameters() const +{ + return d->m_connParams; +} + +SshConnection::~SshConnection() +{ + disconnect(); + disconnectFromHost(); + delete d; +} + +QSharedPointer SshConnection::createRemoteProcess(const QByteArray &command) +{ + return state() == Connected + ? d->createRemoteProcess(command) : QSharedPointer(); +} + +QSharedPointer SshConnection::createSftpChannel() +{ + return state() == Connected + ? d->createSftpChannel() : QSharedPointer(); +} + namespace Internal { -struct InteractiveSshConnectionPrivate +SshConnectionPrivate::SshConnectionPrivate(SshConnection *conn) + : m_socket(new QTcpSocket(this)), m_state(SocketUnconnected), + m_sendFacility(m_socket), + m_channelManager(new SshChannelManager(m_sendFacility)), + m_error(SshNoError), m_ignoreNextPacket(false), m_conn(conn) { - InteractiveSshConnectionPrivate(const SshServerInfo &server) - : conn(server), outputReader(0) {} + setupPacketHandlers(); + connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout())); +} - GenericSshConnection conn; - ConnectionOutputReader *outputReader; - QByteArray remoteOutput; - QMutex mutex; - QWaitCondition waitCond; -}; - -struct NonInteractiveSshConnectionPrivate +SshConnectionPrivate::~SshConnectionPrivate() { - NonInteractiveSshConnectionPrivate(const SshServerInfo &server) - : conn(server) {} + disconnect(); +} - GenericSshConnection conn; - Ne7SftpSubsystem sftp; -}; - -class ConnectionOutputReader : public QThread +void SshConnectionPrivate::setupPacketHandlers() { -public: - ConnectionOutputReader(InteractiveSshConnection *parent) - : QThread(parent), m_conn(parent), m_stopRequested(false), - m_dataAvailable(false) - {} + typedef SshConnectionPrivate This; - ~ConnectionOutputReader() - { - stop(); - wait(); + setupPacketHandler(SSH_MSG_KEXINIT, StateList() << SocketConnected, + &This::handleKeyExchangeInitPacket); + setupPacketHandler(SSH_MSG_KEXDH_REPLY, StateList() << KeyExchangeStarted, + &This::handleKeyExchangeReplyPacket); + + setupPacketHandler(SSH_MSG_NEWKEYS, StateList() << KeyExchangeSuccess, + &This::handleNewKeysPacket); + setupPacketHandler(SSH_MSG_SERVICE_ACCEPT, + StateList() << UserAuthServiceRequested, + &This::handleServiceAcceptPacket); + setupPacketHandler(SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, + StateList() << UserAuthRequested, &This::handlePasswordExpiredPacket); + setupPacketHandler(SSH_MSG_GLOBAL_REQUEST, + StateList() << ConnectionEstablished, &This::handleGlobalRequest); + + const StateList authReqList = StateList() << UserAuthRequested; + setupPacketHandler(SSH_MSG_USERAUTH_BANNER, authReqList, + &This::handleUserAuthBannerPacket); + setupPacketHandler(SSH_MSG_USERAUTH_SUCCESS, authReqList, + &This::handleUserAuthSuccessPacket); + setupPacketHandler(SSH_MSG_USERAUTH_FAILURE, authReqList, + &This::handleUserAuthFailurePacket); + + const StateList connectedList + = StateList() << ConnectionEstablished; + setupPacketHandler(SSH_MSG_CHANNEL_REQUEST, connectedList, + &This::handleChannelRequest); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN, connectedList, + &This::handleChannelOpen); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN_FAILURE, connectedList, + &This::handleChannelOpenFailure); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN_CONFIRMATION, connectedList, + &This::handleChannelOpenConfirmation); + setupPacketHandler(SSH_MSG_CHANNEL_SUCCESS, connectedList, + &This::handleChannelSuccess); + setupPacketHandler(SSH_MSG_CHANNEL_FAILURE, connectedList, + &This::handleChannelFailure); + setupPacketHandler(SSH_MSG_CHANNEL_WINDOW_ADJUST, connectedList, + &This::handleChannelWindowAdjust); + setupPacketHandler(SSH_MSG_CHANNEL_DATA, connectedList, + &This::handleChannelData); + setupPacketHandler(SSH_MSG_CHANNEL_EXTENDED_DATA, connectedList, + &This::handleChannelExtendedData); + + const StateList connectedOrClosedList + = StateList() << SocketUnconnected << ConnectionEstablished; + setupPacketHandler(SSH_MSG_CHANNEL_EOF, connectedOrClosedList, + &This::handleChannelEof); + setupPacketHandler(SSH_MSG_CHANNEL_CLOSE, connectedOrClosedList, + &This::handleChannelClose); + + setupPacketHandler(SSH_MSG_DISCONNECT, StateList() << SocketConnected + << KeyExchangeStarted << KeyExchangeSuccess + << UserAuthServiceRequested << UserAuthRequested + << ConnectionEstablished, &This::handleDisconnect); +} + +void SshConnectionPrivate::setupPacketHandler(SshPacketType type, + const SshConnectionPrivate::StateList &states, + SshConnectionPrivate::PacketHandler handler) +{ + m_packetHandlers.insert(type, HandlerInStates(states, handler)); +} + +void SshConnectionPrivate::handleSocketConnected() +{ + m_state = SocketConnected; + sendData(ClientId); +} + +void SshConnectionPrivate::handleIncomingData() +{ + if (m_state == SocketUnconnected) + return; // For stuff queued in the event loop after we've called closeConnection(); + + try { + m_incomingData += m_socket->readAll(); +#ifdef CREATOR_SSH_DEBUG + qDebug("state = %d, remote data size = %d", m_state, + m_incomingData.count()); +#endif + if (m_state == SocketConnected) + handleServerId(); + handlePackets(); + } catch (SshServerException &e) { + closeConnection(e.error, SshProtocolError, e.errorStringServer, + tr("SSH Protocol error: %1").arg(e.errorStringUser)); + } catch (SshClientException &e) { + closeConnection(SSH_DISCONNECT_BY_APPLICATION, e.error, "", + e.errorString); + } catch (Botan::Exception &e) { + closeConnection(SSH_DISCONNECT_BY_APPLICATION, SshInternalError, "", + tr("Botan exception: %1").arg(e.what())); + } +} + +void SshConnectionPrivate::handleServerId() +{ + const int idOffset = m_incomingData.indexOf("SSH-"); + if (idOffset == -1) + return; + m_incomingData.remove(0, idOffset); + if (m_incomingData.size() < 7) + return; + const QByteArray &version = m_incomingData.mid(4, 3); + if (version != "2.0") { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, + "Invalid protocol version.", + tr("Invalid protocol version: Expected '2.0', got '%1'.") + .arg(SshPacketParser::asUserString(version))); + } + const int endOffset = m_incomingData.indexOf("\r\n"); + if (endOffset == -1) + return; + if (m_incomingData.at(7) != '-') { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid server id.", tr("Invalid server id '%1'.") + .arg(SshPacketParser::asUserString(m_incomingData))); } - void stop() - { - m_mutex.lock(); - m_stopRequested = true; - m_waitCond.wakeOne(); - m_mutex.unlock(); + m_keyExchange.reset(new SshKeyExchange(m_sendFacility)); + m_keyExchange->sendKexInitPacket(m_incomingData.left(endOffset)); + m_incomingData.remove(0, endOffset + 2); +} + +void SshConnectionPrivate::handlePackets() +{ + m_incomingPacket.consumeData(m_incomingData); + while (m_incomingPacket.isComplete()) { + handleCurrentPacket(); + m_incomingPacket.clear(); + m_incomingPacket.consumeData(m_incomingData); + } +} + +void SshConnectionPrivate::handleCurrentPacket() +{ + Q_ASSERT(m_incomingPacket.isComplete()); + Q_ASSERT(m_state == KeyExchangeStarted || !m_ignoreNextPacket); + + if (m_ignoreNextPacket) { + m_ignoreNextPacket = false; + return; } - void dataAvailable() - { - m_mutex.lock(); - m_dataAvailable = true; - m_waitCond.wakeOne(); - m_mutex.unlock(); + QHash::ConstIterator it + = m_packetHandlers.find(m_incomingPacket.type()); + if (it == m_packetHandlers.end()) { + m_sendFacility.sendMsgUnimplementedPacket(m_incomingPacket.serverSeqNr()); + return; } + if (!it.value().first.contains(m_state)) { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected packet.", tr("Unexpected packet of type %1.") + .arg(m_incomingPacket.type())); + } + (this->*it.value().second)(); +} -private: - virtual void run() - { - while (true) { - m_mutex.lock(); - if (m_stopRequested) { - m_mutex.unlock(); - return; - } - const int channel = m_conn->d->conn.channel(); - if (!m_dataAvailable || channel == -1) - m_waitCond.wait(&m_mutex); - m_dataAvailable = false; - m_mutex.unlock(); - QScopedPointer > - output(m_conn->d->conn.ssh->readAndReset(channel, alloc)); - if (output) { - m_conn->d->mutex.lock(); - m_conn->d->remoteOutput += output.data(); - emit m_conn->remoteOutputAvailable(); - m_conn->d->mutex.unlock(); - } +void SshConnectionPrivate::handleKeyExchangeInitPacket() +{ + // If the server sends a guessed packet, the guess must be wrong, + // because the algorithms we support requires us to initiate the + // key exchange. + if (m_keyExchange->sendDhInitPacket(m_incomingPacket)) + m_ignoreNextPacket = true; + m_state = KeyExchangeStarted; +} + +void SshConnectionPrivate::handleKeyExchangeReplyPacket() +{ + m_keyExchange->sendNewKeysPacket(m_incomingPacket, + ClientId.left(ClientId.size() - 2)); + m_sendFacility.recreateKeys(*m_keyExchange); + m_state = KeyExchangeSuccess; +} + +void SshConnectionPrivate::handleNewKeysPacket() +{ + m_incomingPacket.recreateKeys(*m_keyExchange); + m_keyExchange.reset(); + m_sendFacility.sendUserAuthServiceRequestPacket(); + m_state = UserAuthServiceRequested; +} + +void SshConnectionPrivate::handleServiceAcceptPacket() +{ + if (m_connParams.authType == SshConnectionParameters::AuthByPwd) { + m_sendFacility.sendUserAuthByPwdRequestPacket(m_connParams.uname.toUtf8(), + SshCapabilities::SshConnectionService, m_connParams.pwd.toUtf8()); + } else { + QFile privKeyFile(m_connParams.privateKeyFile); + bool couldOpen = privKeyFile.open(QIODevice::ReadOnly); + QByteArray contents; + if (couldOpen) + contents = privKeyFile.readAll(); + if (!couldOpen || privKeyFile.error() != QFile::NoError) { + throw SshClientException(SshKeyFileError, + tr("Could not read private key file: %1") + .arg(privKeyFile.errorString())); } + + m_sendFacility.createAuthenticationKey(contents); + m_sendFacility.sendUserAuthByKeyRequestPacket(m_connParams.uname.toUtf8(), + SshCapabilities::SshConnectionService); + } + m_state = UserAuthRequested; +} + +void SshConnectionPrivate::handlePasswordExpiredPacket() +{ + if (m_connParams.authType == SshConnectionParameters::AuthByKey) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Got SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, but did not use password."); } - InteractiveSshConnection *m_conn; - bool m_stopRequested; - bool m_dataAvailable; - QMutex m_mutex; - QWaitCondition m_waitCond; -}; + throw SshClientException(SshAuthenticationError, tr("Password expired.")); +} + +void SshConnectionPrivate::handleUserAuthBannerPacket() +{ + emit dataAvailable(m_incomingPacket.extractUserAuthBanner().message); +} + +void SshConnectionPrivate::handleGlobalRequest() +{ + m_sendFacility.sendRequestFailurePacket(); +} + +void SshConnectionPrivate::handleUserAuthSuccessPacket() +{ + m_state = ConnectionEstablished; + m_timeoutTimer.stop(); + emit connected(); +} + +void SshConnectionPrivate::handleUserAuthFailurePacket() +{ + const QString errorMsg = m_connParams.authType == SshConnectionParameters::AuthByPwd + ? tr("Server rejected password.") : tr("Server rejected key."); + throw SshClientException(SshAuthenticationError, errorMsg); +} +void SshConnectionPrivate::handleDebugPacket() +{ + const SshDebug &msg = m_incomingPacket.extractDebug(); + if (msg.display) + emit dataAvailable(msg.message); +} + +void SshConnectionPrivate::handleChannelRequest() +{ + m_channelManager->handleChannelRequest(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpen() +{ + m_channelManager->handleChannelOpen(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpenFailure() +{ + m_channelManager->handleChannelOpenFailure(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpenConfirmation() +{ + m_channelManager->handleChannelOpenConfirmation(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelSuccess() +{ + m_channelManager->handleChannelSuccess(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelFailure() +{ + m_channelManager->handleChannelFailure(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelWindowAdjust() +{ + m_channelManager->handleChannelWindowAdjust(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelData() +{ + m_channelManager->handleChannelData(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelExtendedData() +{ + m_channelManager->handleChannelExtendedData(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelEof() +{ + m_channelManager->handleChannelEof(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelClose() +{ + m_channelManager->handleChannelClose(m_incomingPacket); +} + +void SshConnectionPrivate::handleDisconnect() +{ + const SshDisconnect msg = m_incomingPacket.extractDisconnect(); + throw SshServerException(SSH_DISCONNECT_CONNECTION_LOST, + "", tr("Server closed connection: %1").arg(msg.description)); +} + +void SshConnectionPrivate::sendData(const QByteArray &data) +{ + m_socket->write(data); +} + +void SshConnectionPrivate::handleSocketDisconnected() +{ + closeConnection(SSH_DISCONNECT_CONNECTION_LOST, SshClosedByServerError, + "Connection closed unexpectedly.", + tr("Connection closed unexpectedly.")); +} + +void SshConnectionPrivate::handleSocketError() +{ + if (m_error == SshNoError) { + closeConnection(SSH_DISCONNECT_CONNECTION_LOST, SshSocketError, + "Network error", m_socket->errorString()); + } +} + +void SshConnectionPrivate::handleTimeout() +{ + if (m_state != ConnectionEstablished) + closeConnection(SSH_DISCONNECT_BY_APPLICATION, SshTimeoutError, "", + tr("Connection timed out.")); +} + +void SshConnectionPrivate::connectToHost(const SshConnectionParameters &serverInfo) +{ + m_incomingData.clear(); + m_incomingPacket.reset(); + m_sendFacility.reset(); + m_error = SshNoError; + m_ignoreNextPacket = false; + m_errorString.clear(); + connect(m_socket, SIGNAL(connected()), this, SLOT(handleSocketConnected())); + connect(m_socket, SIGNAL(readyRead()), this, SLOT(handleIncomingData())); + connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(handleSocketError())); + connect(m_socket, SIGNAL(disconnected()), this, + SLOT(handleSocketDisconnected())); + this->m_connParams = serverInfo; + m_state = SocketConnecting; + m_timeoutTimer.start(m_connParams.timeout * 1000); + m_socket->connectToHost(serverInfo.host, serverInfo.port); +} + +void SshConnectionPrivate::closeConnection(SshErrorCode sshError, + SshError userError, const QByteArray &serverErrorString, + const QString &userErrorString) +{ + // Prevent endless loops by recursive exceptions. + if (m_state == SocketUnconnected || m_error != SshNoError) + return; + + m_error = userError; + m_errorString = userErrorString; + m_timeoutTimer.stop(); + disconnect(m_socket, 0, this, 0); + try { + m_channelManager->closeAllChannels(); + m_sendFacility.sendDisconnectPacket(sshError, serverErrorString); + } catch (Botan::Exception &) {} // Nothing sensible to be done here. + if (m_error != SshNoError) + emit error(userError); + if (m_state == ConnectionEstablished) + emit disconnected(); + m_socket->disconnectFromHost(); + m_state = SocketUnconnected; +} + +QSharedPointer SshConnectionPrivate::createRemoteProcess(const QByteArray &command) +{ + return m_channelManager->createRemoteProcess(command); +} + +QSharedPointer SshConnectionPrivate::createSftpChannel() +{ + return m_channelManager->createSftpChannel(); +} } // namespace Internal - - -namespace { - -void wakeupReader(void *opaqueReader) -{ - static_cast(opaqueReader)->dataAvailable(); -} - -} // Anonymous namespace - - -InteractiveSshConnection::InteractiveSshConnection(const SshServerInfo &server) - : d(new Internal::InteractiveSshConnectionPrivate(server)) -{ - d->outputReader = new Internal::ConnectionOutputReader(this); -} - -InteractiveSshConnection::~InteractiveSshConnection() -{ - d->conn.ssh->send("exit\n", d->conn.channel()); - quit(); - delete d; -} - -bool InteractiveSshConnection::start() -{ - if (isConnected()) - return true; - - if (!d->conn.start(true, wakeupReader, d->outputReader)) - return false; - - d->outputReader->start(); - return true; -} - -bool InteractiveSshConnection::sendInput(const QByteArray &input) -{ - if (!d->conn.ssh->send(input.data(), d->conn.channel())) { - d->conn.setError(tr("Error sending input"), true); - return false; - } - return true; -} - -void InteractiveSshConnection::quit() -{ - d->mutex.lock(); - d->waitCond.wakeOne(); - d->mutex.unlock(); - d->outputReader->stop(); - d->conn.quit(); -} - -QByteArray InteractiveSshConnection::waitForRemoteOutput(int msecs) -{ - d->mutex.lock(); - if (d->remoteOutput.isEmpty()) - d->waitCond.wait(&d->mutex, msecs == -1 ? ULONG_MAX : msecs); - const QByteArray remoteOutput = d->remoteOutput; - d->remoteOutput.clear(); - d->mutex.unlock(); - return remoteOutput; -} - - -InteractiveSshConnection::Ptr InteractiveSshConnection::create(const SshServerInfo &server) -{ - return Ptr(new InteractiveSshConnection(server)); -} - -bool InteractiveSshConnection::isConnected() const -{ - return d->conn.isConnected(); -} - -bool InteractiveSshConnection::hasError() const -{ - return d->conn.hasError(); -} - -QString InteractiveSshConnection::error() const -{ - return d->conn.error(); -} - - -namespace { - -class FileMgr -{ -public: - FileMgr(const QString &filePath, const char *mode) - : m_file(fopen(filePath.toLatin1().data(), mode)) {} - ~FileMgr() { if (m_file) fclose(m_file); } - FILE *file() const { return m_file; } -private: - FILE * const m_file; -}; - -} // Anonymous namespace - -SftpConnection::SftpConnection(const SshServerInfo &server) - : d(new Internal::NonInteractiveSshConnectionPrivate(server)) -{ } - -SftpConnection::~SftpConnection() -{ - quit(); - delete d; -} - -bool SftpConnection::start() -{ - if (isConnected()) - return true; - if (!d->conn.start(false, 0, 0)) - return false; - if (!d->conn.ssh->initSftp(d->sftp, d->conn.channel()) - || !d->sftp.setTimeout(d->conn.server().timeout)) { - d->conn.setError(tr("Error setting up SFTP subsystem"), true); - quit(); - return false; - } - return true; -} - -bool SftpConnection::transferFiles(const QList &transferList) -{ - for (int i = 0; i < transferList.count(); ++i) { - const SftpTransferInfo &transfer = transferList.at(i); - bool success; - if (transfer.type == SftpTransferInfo::Upload) { - success = upload(transfer.localFilePath, transfer.remoteFilePath); - } else { - success = download(transfer.remoteFilePath, transfer.localFilePath); - } - if (!success) - return false; - } - - return true; -} - -bool SftpConnection::upload(const QString &localFilePath, - const QByteArray &remoteFilePath) -{ - FileMgr fileMgr(localFilePath, "rb"); - if (!fileMgr.file()) { - d->conn.setError(tr("Could not open file '%1'").arg(localFilePath), - false); - return false; - } - - if (!d->sftp.put(fileMgr.file(), remoteFilePath.data())) { - d->conn.setError(tr("Could not uplodad file '%1'") - .arg(localFilePath), true); - return false; - } - - emit fileCopied(localFilePath); - return true; -} - -bool SftpConnection::download(const QByteArray &remoteFilePath, - const QString &localFilePath) -{ - FileMgr fileMgr(localFilePath, "wb"); - if (!fileMgr.file()) { - d->conn.setError(tr("Could not open file '%1'").arg(localFilePath), - false); - return false; - } - - if (!d->sftp.get(remoteFilePath.data(), fileMgr.file())) { - d->conn.setError(tr("Could not copy remote file '%1' to local file '%2'") - .arg(remoteFilePath, localFilePath), false); - return false; - } - - emit fileCopied(remoteFilePath); - return true; -} - -bool SftpConnection::createRemoteDir(const QByteArray &remoteDir) -{ - if (!d->sftp.mkdir(remoteDir.data())) { - d->conn.setError(tr("Could not create remote directory"), true); - return false; - } - return true; -} - -bool SftpConnection::removeRemoteDir(const QByteArray &remoteDir) -{ - if (!d->sftp.rmdir(remoteDir.data())) { - d->conn.setError(tr("Could not remove remote directory"), true); - return false; - } - return true; -} - -QByteArray SftpConnection::listRemoteDirContents(const QByteArray &remoteDir, - bool withAttributes, bool &ok) -{ - const char * const buffer = d->sftp.ls(remoteDir.data(), withAttributes); - if (!buffer) { - d->conn.setError(tr("Could not get remote directory contents"), true); - ok = false; - return QByteArray(); - } - ok = true; - return QByteArray(buffer); -} - -bool SftpConnection::removeRemoteFile(const QByteArray &remoteFile) -{ - if (!d->sftp.rm(remoteFile.data())) { - d->conn.setError(tr("Could not remove remote file"), true); - return false; - } - return true; -} - -bool SftpConnection::changeRemoteWorkingDir(const QByteArray &newRemoteDir) -{ - if (!d->sftp.cd(newRemoteDir.data())) { - d->conn.setError(tr("Could not change remote working directory"), true); - return false; - } - return true; -} - -void SftpConnection::quit() -{ - d->conn.quit(); -} - -bool SftpConnection::isConnected() const -{ - return d->conn.isConnected(); -} - -bool SftpConnection::hasError() const -{ - return d->conn.hasError(); -} - -QString SftpConnection::error() const -{ - return d->conn.error(); -} - -SftpConnection::Ptr SftpConnection::create(const SshServerInfo &server) -{ - return Ptr(new SftpConnection(server)); -} - } // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshconnection.h b/src/plugins/coreplugin/ssh/sshconnection.h index 8c7b59f594b..e7f73995a4a 100644 --- a/src/plugins/coreplugin/ssh/sshconnection.h +++ b/src/plugins/coreplugin/ssh/sshconnection.h @@ -1,19 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of Qt Creator. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage +** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -21,27 +22,16 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ #ifndef SSHCONNECTION_H #define SSHCONNECTION_H +#include "ssherrors.h" + #include #include @@ -50,14 +40,14 @@ #include namespace Core { +class SftpChannel; +class SshRemoteProcess; namespace Internal { - struct InteractiveSshConnectionPrivate; - struct NonInteractiveSshConnectionPrivate; - class ConnectionOutputReader; -} +class SshConnectionPrivate; +} // namespace Internal -struct CORE_EXPORT SshServerInfo +struct CORE_EXPORT SshConnectionParameters { QString host; QString uname; @@ -69,85 +59,44 @@ struct CORE_EXPORT SshServerInfo }; -class CORE_EXPORT InteractiveSshConnection : public QObject +/* + * This class provides an SSH connection, implementing protocol version 2.0 + * It can spawn channels for remote execution and SFTP operations (version 3). + * It operates asynchronously (non-blocking) and is not thread-safe. + */ +class CORE_EXPORT SshConnection : public QObject { Q_OBJECT - Q_DISABLE_COPY(InteractiveSshConnection) - friend class Internal::ConnectionOutputReader; + Q_DISABLE_COPY(SshConnection) public: - typedef QSharedPointer Ptr; + enum State { Unconnected, Connecting, Connected }; + typedef QSharedPointer Ptr; - static Ptr create(const SshServerInfo &server); + static Ptr create(); - bool start(); - void quit(); - bool isConnected() const; - bool sendInput(const QByteArray &input); // Should normally end in newline. - QByteArray waitForRemoteOutput(int msecs = -1); - bool hasError() const; - QString error() const; - ~InteractiveSshConnection(); + void connectToHost(const SshConnectionParameters &serverInfo); + void disconnectFromHost(); + State state() const; + SshError errorState() const; + QString errorString() const; + SshConnectionParameters connectionParameters() const; + ~SshConnection(); + + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); signals: - void remoteOutputAvailable(); + void connected(); + void disconnected(); + void dataAvailable(const QString &message); + void error(SshError); private: - InteractiveSshConnection(const SshServerInfo &server); + SshConnection(); - struct Internal::InteractiveSshConnectionPrivate *d; + Internal::SshConnectionPrivate *d; }; - -struct CORE_EXPORT SftpTransferInfo -{ - enum Type { Upload, Download }; - - SftpTransferInfo(const QString &localFilePath, - const QByteArray &remoteFilePath, Type type) - : localFilePath(localFilePath), - remoteFilePath(remoteFilePath), - type(type) - { - } - - QString localFilePath; - QByteArray remoteFilePath; - Type type; -}; - -class CORE_EXPORT SftpConnection : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(SftpConnection) -public: - typedef QSharedPointer Ptr; - - static Ptr create(const SshServerInfo &server); - bool start(); - void quit(); - bool isConnected() const; - bool hasError() const; - QString error() const; - bool upload(const QString &localFilePath, const QByteArray &remoteFilePath); - bool download(const QByteArray &remoteFilePath, const QString &localFilePath); - bool transferFiles(const QList &transferList); - bool createRemoteDir(const QByteArray &remoteDir); - bool removeRemoteDir(const QByteArray &remoteDir); - bool removeRemoteFile(const QByteArray &remoteFile); - bool changeRemoteWorkingDir(const QByteArray &newRemoteDir); - QByteArray listRemoteDirContents(const QByteArray &remoteDir, - bool withAttributes, bool &ok); - ~SftpConnection(); - -signals: - void fileCopied(const QString &filePath); - -private: - SftpConnection(const SshServerInfo &server); - - Internal::NonInteractiveSshConnectionPrivate *d; -}; - -} // namespace Core +} // namespace Internal #endif // SSHCONNECTION_H diff --git a/src/plugins/coreplugin/ssh/sshconnection_p.h b/src/plugins/coreplugin/ssh/sshconnection_p.h new file mode 100644 index 00000000000..c20ccf78b52 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshconnection_p.h @@ -0,0 +1,157 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCONNECTION_P_H +#define SSHCONNECTION_P_H + +#include "sshconnection.h" +#include "sshexception_p.h" +#include "sshincomingpacket_p.h" +#include "sshremoteprocess.h" +#include "sshsendfacility_p.h" + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QTcpSocket; +QT_END_NAMESPACE + +namespace Botan { class Exception; } + +namespace Core { +class SftpChannel; + +namespace Internal { +class SshChannelManager; + +// NOTE: When you add stuff here, don't forget to update m_packetHandlers. +enum SshStateInternal { + SocketUnconnected, // initial and after disconnect + SocketConnecting, // After connectToHost() + SocketConnected, // After socket's connected() signal + KeyExchangeStarted, // After server's KEXINIT message + KeyExchangeSuccess, // After server's DH_REPLY message + UserAuthServiceRequested, + UserAuthRequested, + + ConnectionEstablished // After service has been started + // ... +}; + +class SshConnectionPrivate : public QObject +{ + Q_OBJECT + friend class Core::SshConnection; +public: + SshConnectionPrivate(SshConnection *conn); + ~SshConnectionPrivate(); + + void connectToHost(const SshConnectionParameters &serverInfo); + void closeConnection(SshErrorCode sshError, SshError userError, + const QByteArray &serverErrorString, const QString &userErrorString); + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); + SshStateInternal state() const { return m_state; } + SshError error() const { return m_error; } + QString errorString() const { return m_errorString; } + +signals: + void connected(); + void disconnected(); + void dataAvailable(const QString &message); + void error(SshError); + +private: + Q_SLOT void handleSocketConnected(); + Q_SLOT void handleIncomingData(); + Q_SLOT void handleSocketError(); + Q_SLOT void handleSocketDisconnected(); + Q_SLOT void handleTimeout(); + + void handleServerId(); + void handlePackets(); + void handleCurrentPacket(); + void handleKeyExchangeInitPacket(); + void handleKeyExchangeReplyPacket(); + void handleNewKeysPacket(); + void handleServiceAcceptPacket(); + void handlePasswordExpiredPacket(); + void handleUserAuthSuccessPacket(); + void handleUserAuthFailurePacket(); + void handleUserAuthBannerPacket(); + void handleGlobalRequest(); + void handleDebugPacket(); + void handleChannelRequest(); + void handleChannelOpen(); + void handleChannelOpenFailure(); + void handleChannelOpenConfirmation(); + void handleChannelSuccess(); + void handleChannelFailure(); + void handleChannelWindowAdjust(); + void handleChannelData(); + void handleChannelExtendedData(); + void handleChannelEof(); + void handleChannelClose(); + void handleDisconnect(); + + void sendData(const QByteArray &data); + + typedef void (SshConnectionPrivate::*PacketHandler)(); + typedef QList StateList; + void setupPacketHandlers(); + void setupPacketHandler(SshPacketType type, const StateList &states, + PacketHandler handler); + + typedef QPair HandlerInStates; + QHash m_packetHandlers; + + QTcpSocket *m_socket; + SshStateInternal m_state; + SshIncomingPacket m_incomingPacket; + SshSendFacility m_sendFacility; + QScopedPointer m_channelManager; + SshConnectionParameters m_connParams; + QByteArray m_incomingData; + SshError m_error; + QString m_errorString; + QScopedPointer m_keyExchange; + QTimer m_timeoutTimer; + bool m_ignoreNextPacket; + SshConnection *m_conn; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCONNECTION_P_H diff --git a/src/plugins/coreplugin/ssh/sshcryptofacility.cpp b/src/plugins/coreplugin/ssh/sshcryptofacility.cpp new file mode 100644 index 00000000000..fd2fe320444 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcryptofacility.cpp @@ -0,0 +1,369 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshcryptofacility_p.h" + +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshexception_p.h" +#include "sshkeyexchange_p.h" +#include "sshpacket_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +using namespace Botan; + +namespace Core { +namespace Internal { + +SshAbstractCryptoFacility::SshAbstractCryptoFacility() + : m_cipherBlockSize(0), m_macLength(0) +{ +} + +SshAbstractCryptoFacility::~SshAbstractCryptoFacility() {} + +void SshAbstractCryptoFacility::clearKeys() +{ + m_cipherBlockSize = 0; + m_macLength = 0; + m_sessionId.clear(); + m_pipe.reset(0); + m_hMac.reset(0); +} + +void SshAbstractCryptoFacility::recreateKeys(const SshKeyExchange &kex) +{ + checkInvariant(); + + if (m_sessionId.isEmpty()) + m_sessionId = kex.h(); + Algorithm_Factory &af = global_state().algorithm_factory(); + const std::string &cryptAlgo = botanCryptAlgoName(cryptAlgoName(kex)); + BlockCipher * const cipher = af.prototype_block_cipher(cryptAlgo)->clone(); + + m_cipherBlockSize = cipher->BLOCK_SIZE; + const QByteArray ivData = generateHash(kex, ivChar(), m_cipherBlockSize); + const InitializationVector iv(convertByteArray(ivData), m_cipherBlockSize); + + const quint32 keySize = max_keylength_of(cryptAlgo); + const QByteArray cryptKeyData = generateHash(kex, keyChar(), keySize); + SymmetricKey cryptKey(convertByteArray(cryptKeyData), keySize); + + BlockCipherMode * const cipherMode + = makeCipherMode(cipher, new Null_Padding, iv, cryptKey); + m_pipe.reset(new Pipe(cipherMode)); + + m_macLength = botanHMacKeyLen(hMacAlgoName(kex)); + const QByteArray hMacKeyData = generateHash(kex, macChar(), macLength()); + SymmetricKey hMacKey(convertByteArray(hMacKeyData), macLength()); + const HashFunction * const hMacProto + = af.prototype_hash_function(botanHMacAlgoName(hMacAlgoName(kex))); + m_hMac.reset(new HMAC(hMacProto->clone())); + m_hMac->set_key(hMacKey); +} + +void SshAbstractCryptoFacility::convert(QByteArray &data, quint32 offset, + quint32 dataSize) const +{ + Q_ASSERT(offset + dataSize <= static_cast(data.size())); + checkInvariant(); + + // Session id empty => No key exchange has happened yet. + if (dataSize == 0 || m_sessionId.isEmpty()) + return; + + if (dataSize % cipherBlockSize() != 0) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid packet size"); + } + m_pipe->process_msg(reinterpret_cast(data.constData()) + offset, + dataSize); + quint32 bytesRead = m_pipe->read(reinterpret_cast(data.data()) + offset, + dataSize, m_pipe->message_count() - 1); // Can't use Pipe::LAST_MESSAGE because of a VC bug. + Q_ASSERT(bytesRead == dataSize); +} + +QByteArray SshAbstractCryptoFacility::generateMac(const QByteArray &data, + quint32 dataSize) const +{ + return m_sessionId.isEmpty() + ? QByteArray() + : convertByteArray(m_hMac->process(reinterpret_cast(data.constData()), + dataSize)); +} + +QByteArray SshAbstractCryptoFacility::generateHash(const SshKeyExchange &kex, + char c, quint32 length) +{ + const QByteArray &k = kex.k(); + const QByteArray &h = kex.h(); + QByteArray data(k); + data.append(h).append(c).append(m_sessionId); + SecureVector key + = kex.hash()->process(convertByteArray(data), data.size()); + while (key.size() < length) { + SecureVector tmpKey; + tmpKey.append(convertByteArray(k), k.size()); + tmpKey.append(convertByteArray(h), h.size()); + tmpKey.append(key); + key.append(kex.hash()->process(tmpKey)); + } + return QByteArray(reinterpret_cast(key.begin()), length); +} + +void SshAbstractCryptoFacility::checkInvariant() const +{ + Q_ASSERT(m_sessionId.isEmpty() == !m_pipe); +} + + +const QByteArray SshEncryptionFacility::PrivKeyFileStartLineRsa("-----BEGIN RSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileStartLineDsa("-----BEGIN DSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileEndLineRsa("-----END RSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileEndLineDsa("-----END DSA PRIVATE KEY-----"); + +QByteArray SshEncryptionFacility::cryptAlgoName(const SshKeyExchange &kex) const +{ + return kex.encryptionAlgo(); +} + +QByteArray SshEncryptionFacility::hMacAlgoName(const SshKeyExchange &kex) const +{ + return kex.hMacAlgoClientToServer(); +} + +BlockCipherMode *SshEncryptionFacility::makeCipherMode(BlockCipher *cipher, + BlockCipherModePaddingMethod *paddingMethod, const InitializationVector &iv, + const SymmetricKey &key) +{ + return new CBC_Encryption(cipher, paddingMethod, key, iv); +} + +void SshEncryptionFacility::encrypt(QByteArray &data) const +{ + convert(data, 0, data.size()); +} + +void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFileContents) +{ + if (privKeyFileContents == m_cachedPrivKeyContents) + return; + +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: Key not cached, reading", Q_FUNC_INFO); +#endif + QList pubKeyParams; + QList allKeyParams; + try { + createAuthenticationKeyFromPKCS8(privKeyFileContents, pubKeyParams, + allKeyParams); + } catch (Botan::Exception &) { + createAuthenticationKeyFromOpenSSL(privKeyFileContents, pubKeyParams, + allKeyParams); + } + + foreach (const BigInt &b, allKeyParams) { + if (b.is_zero()) { + throw SshClientException(SshKeyFileError, + SSH_TR("Decoding of private key file failed.")); + } + } + + m_authPubKeyBlob = AbstractSshPacket::encodeString(m_authKeyAlgoName); + foreach (const BigInt &b, pubKeyParams) + m_authPubKeyBlob += AbstractSshPacket::encodeMpInt(b); + m_cachedPrivKeyContents = privKeyFileContents; +} + +void SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams) +{ + Pipe pipe; + pipe.process_msg(convertByteArray(privKeyFileContents), + privKeyFileContents.size()); + Private_Key * const key = PKCS8::load_key(pipe, m_rng); + if (DSA_PrivateKey * const dsaKey = dynamic_cast(key)) { + m_authKey.reset(dsaKey); + pubKeyParams << dsaKey->group_p() << dsaKey->group_q() + << dsaKey->group_g() << dsaKey->get_y(); + allKeyParams << pubKeyParams << dsaKey->get_x(); + } else if (RSA_PrivateKey * const rsaKey = dynamic_cast(key)) { + m_authKey.reset(rsaKey); + pubKeyParams << rsaKey->get_e() << rsaKey->get_n(); + allKeyParams << pubKeyParams << rsaKey->get_p() << rsaKey->get_q() + << rsaKey->get_d(); + } else { + throw Botan::Exception(); + } +} + +void SshEncryptionFacility::createAuthenticationKeyFromOpenSSL(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams) +{ + bool syntaxOk = true; + QList lines = privKeyFileContents.split('\n'); + while (lines.last().isEmpty()) + lines.removeLast(); + if (lines.count() < 3) { + syntaxOk = false; + } else if (lines.first() == PrivKeyFileStartLineRsa) { + if (lines.last() != PrivKeyFileEndLineRsa) + syntaxOk =false; + else + m_authKeyAlgoName = SshCapabilities::PubKeyRsa; + } else if (lines.first() == PrivKeyFileStartLineDsa) { + if (lines.last() != PrivKeyFileEndLineDsa) + syntaxOk = false; + else + m_authKeyAlgoName = SshCapabilities::PubKeyDss; + } else { + syntaxOk = false; + } + if (!syntaxOk) { + throw SshClientException(SshKeyFileError, + SSH_TR("Private key file has unexpected format.")); + } + + QByteArray privateKeyBlob; + for (int i = 1; i < lines.size() - 1; ++i) + privateKeyBlob += lines.at(i); + privateKeyBlob = QByteArray::fromBase64(privateKeyBlob); + + BER_Decoder decoder(convertByteArray(privateKeyBlob), + privateKeyBlob.size()); + BER_Decoder sequence = decoder.start_cons(SEQUENCE); + quint32 version; + sequence.decode (version); + if (version != 0) { + throw SshClientException(SshKeyFileError, + SSH_TR("Private key encoding has version %1, expected 0.") + .arg(version)); + } + + if (m_authKeyAlgoName == SshCapabilities::PubKeyDss) { + BigInt p, q, g, y, x; + sequence.decode (p).decode (q).decode (g).decode (y).decode (x); + DSA_PrivateKey * const dsaKey + = new DSA_PrivateKey(m_rng, DL_Group(p, q, g), x); + m_authKey.reset(dsaKey); + pubKeyParams << p << q << g << y; + allKeyParams << pubKeyParams << x; + } else { + BigInt p, q, e, d, n; + sequence.decode (n).decode (e).decode (d).decode (p).decode (q); + RSA_PrivateKey * const rsaKey + = new RSA_PrivateKey (m_rng, p, q, e, d, n); + m_authKey.reset(rsaKey); + pubKeyParams << e << n; + allKeyParams << pubKeyParams << p << q << d; + } + + sequence.discard_remaining(); + sequence.verify_end(); +} + +QByteArray SshEncryptionFacility::authenticationAlgorithmName() const +{ + Q_ASSERT(m_authKey); + return m_authKeyAlgoName; +} + +QByteArray SshEncryptionFacility::authenticationKeySignature(const QByteArray &data) const +{ + Q_ASSERT(m_authKey); + + QScopedPointer signer(get_pk_signer (*m_authKey, + botanEmsaAlgoName(m_authKeyAlgoName))); + QByteArray dataToSign = AbstractSshPacket::encodeString(sessionId()) + data; + QByteArray signature + = convertByteArray(signer->sign_message(convertByteArray(dataToSign), + dataToSign.size(), m_rng)); + return AbstractSshPacket::encodeString(m_authKeyAlgoName) + + AbstractSshPacket::encodeString(signature); +} + +QByteArray SshEncryptionFacility::getRandomNumbers(int count) const +{ + QByteArray data; + data.resize(count); + m_rng.randomize(convertByteArray(data), count); + return data; +} + +SshEncryptionFacility::~SshEncryptionFacility() {} + + +QByteArray SshDecryptionFacility::cryptAlgoName(const SshKeyExchange &kex) const +{ + return kex.decryptionAlgo(); +} + +QByteArray SshDecryptionFacility::hMacAlgoName(const SshKeyExchange &kex) const +{ + return kex.hMacAlgoServerToClient(); +} + +BlockCipherMode *SshDecryptionFacility::makeCipherMode(BlockCipher *cipher, + BlockCipherModePaddingMethod *paddingMethod, const InitializationVector &iv, + const SymmetricKey &key) +{ + return new CBC_Decryption(cipher, paddingMethod, key, iv); +} + +void SshDecryptionFacility::decrypt(QByteArray &data, quint32 offset, + quint32 dataSize) const +{ + convert(data, offset, dataSize); +#ifdef CREATOR_SSH_DEBUG + qDebug("Decrypted data:"); + const char * const start = data.constData() + offset; + const char * const end = start + dataSize; + for (const char *c = start; c < end; ++c) + qDebug() << "'" << *c << "' (0x" << (static_cast(*c) & 0xff) << ")"; +#endif +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshcryptofacility_p.h b/src/plugins/coreplugin/ssh/sshcryptofacility_p.h new file mode 100644 index 00000000000..f60e6d4b8de --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcryptofacility_p.h @@ -0,0 +1,154 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHABSTRACTCRYPTOFACILITY_P_H +#define SSHABSTRACTCRYPTOFACILITY_P_H + +#include +#include + +#include +#include + +namespace Botan { + class BigInt; + class BlockCipher; + class BlockCipherMode; + class BlockCipherModePaddingMethod; + class HashFunction; + class HMAC; + class Pipe; + class PK_Signing_Key; +} + +namespace Core { +namespace Internal { + +class SshKeyExchange; + +class SshAbstractCryptoFacility +{ +public: + virtual ~SshAbstractCryptoFacility(); + + void clearKeys(); + void recreateKeys(const SshKeyExchange &kex); + QByteArray generateMac(const QByteArray &data, quint32 dataSize) const; + quint32 cipherBlockSize() const { return m_cipherBlockSize; } + quint32 macLength() const { return m_macLength; } + +protected: + SshAbstractCryptoFacility(); + void convert(QByteArray &data, quint32 offset, quint32 dataSize) const; + QByteArray sessionId() const { return m_sessionId; } + +private: + SshAbstractCryptoFacility(const SshAbstractCryptoFacility &); + SshAbstractCryptoFacility &operator=(const SshAbstractCryptoFacility &); + + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const=0; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const=0; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, + const Botan::SymmetricKey &key)=0; + virtual char ivChar() const=0; + virtual char keyChar() const=0; + virtual char macChar() const=0; + + QByteArray generateHash(const SshKeyExchange &kex, char c, quint32 length); + void checkInvariant() const; + + QByteArray m_sessionId; + QScopedPointer m_pipe; + QScopedPointer m_hMac; + quint32 m_cipherBlockSize; + quint32 m_macLength; +}; + +class SshEncryptionFacility : public SshAbstractCryptoFacility +{ +public: + void encrypt(QByteArray &data) const; + + void createAuthenticationKey(const QByteArray &privKeyFileContents); + QByteArray authenticationAlgorithmName() const; + QByteArray authenticationPublicKey() const { return m_authPubKeyBlob; } + QByteArray authenticationKeySignature(const QByteArray &data) const; + QByteArray getRandomNumbers(int count) const; + + ~SshEncryptionFacility(); + +private: + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, const Botan::SymmetricKey &key); + virtual char ivChar() const { return 'A'; } + virtual char keyChar() const { return 'C'; } + virtual char macChar() const { return 'E'; } + + void createAuthenticationKeyFromPKCS8(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams); + void createAuthenticationKeyFromOpenSSL(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams); + + static const QByteArray PrivKeyFileStartLineRsa; + static const QByteArray PrivKeyFileStartLineDsa; + static const QByteArray PrivKeyFileEndLineRsa; + static const QByteArray PrivKeyFileEndLineDsa; + + QByteArray m_authKeyAlgoName; + QByteArray m_authPubKeyBlob; + QByteArray m_cachedPrivKeyContents; + QScopedPointer m_authKey; + mutable Botan::AutoSeeded_RNG m_rng; +}; + +class SshDecryptionFacility : public SshAbstractCryptoFacility +{ +public: + void decrypt(QByteArray &data, quint32 offset, quint32 dataSize) const; + +private: + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, const Botan::SymmetricKey &key); + virtual char ivChar() const { return 'B'; } + virtual char keyChar() const { return 'D'; } + virtual char macChar() const { return 'F'; } +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHABSTRACTCRYPTOFACILITY_P_H diff --git a/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp b/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp new file mode 100644 index 00000000000..d35075bf77f --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp @@ -0,0 +1,165 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshdelayedsignal_p.h" + +#include "sftpchannel_p.h" +#include "sshremoteprocess_p.h" + +#include + +namespace Core { +namespace Internal { + +SshDelayedSignal::SshDelayedSignal(const QWeakPointer &checkObject) + : m_checkObject(checkObject) +{ + QTimer::singleShot(0, this, SLOT(handleTimeout())); +} + +void SshDelayedSignal::handleTimeout() +{ + if (!m_checkObject.isNull()) + emitSignal(); + deleteLater(); +} + + +SftpDelayedSignal::SftpDelayedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SshDelayedSignal(checkObject), m_privChannel(privChannel) {} + + +SftpInitializationFailedSignal::SftpInitializationFailedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, const QString &reason) + : SftpDelayedSignal(privChannel, checkObject), m_reason(reason) {} + +void SftpInitializationFailedSignal::emitSignal() +{ + m_privChannel->emitInitializationFailedSignal(m_reason); +} + + +SftpInitializedSignal::SftpInitializedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SftpDelayedSignal(privChannel, checkObject) {} + +void SftpInitializedSignal::emitSignal() +{ + m_privChannel->emitInitialized(); +} + + +SftpJobFinishedSignal::SftpJobFinishedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &error) + : SftpDelayedSignal(privChannel, checkObject), m_jobId(jobId), m_error(error) +{ +} + +void SftpJobFinishedSignal::emitSignal() +{ + m_privChannel->emitJobFinished(m_jobId, m_error); +} + + +SftpDataAvailableSignal::SftpDataAvailableSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &data) + : SftpDelayedSignal(privChannel, checkObject), m_jobId(jobId), m_data(data) {} + +void SftpDataAvailableSignal::emitSignal() +{ + m_privChannel->emitDataAvailable(m_jobId, m_data); +} + + +SftpClosedSignal::SftpClosedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SftpDelayedSignal(privChannel, checkObject) {} + +void SftpClosedSignal::emitSignal() +{ + m_privChannel->emitClosed(); +} + + +SshRemoteProcessDelayedSignal::SshRemoteProcessDelayedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject) + : SshDelayedSignal(checkObject), m_privChannel(privChannel) {} + + +SshRemoteProcessStartedSignal::SshRemoteProcessStartedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject) + : SshRemoteProcessDelayedSignal(privChannel, checkObject) {} + +void SshRemoteProcessStartedSignal::emitSignal() +{ + m_privChannel->emitStartedSignal(); +} + + +SshRemoteProcessOutputAvailableSignal::SshRemoteProcessOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), m_output(output) +{ +} + +void SshRemoteProcessOutputAvailableSignal::emitSignal() +{ + m_privChannel->emitOutputAvailableSignal(m_output); +} + + +SshRemoteProcessErrorOutputAvailableSignal::SshRemoteProcessErrorOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), m_output(output) +{ +} + +void SshRemoteProcessErrorOutputAvailableSignal::emitSignal() +{ + m_privChannel->emitErrorOutputAvailableSignal(m_output); +} + + +SshRemoteProcessClosedSignal::SshRemoteProcessClosedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, int exitStatus) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), + m_exitStatus(exitStatus) +{ +} + +void SshRemoteProcessClosedSignal::emitSignal() +{ + m_privChannel->emitClosedSignal(m_exitStatus); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h b/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h new file mode 100644 index 00000000000..09163fb6861 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h @@ -0,0 +1,190 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHDELAYEDSIGNAL_P_H +#define SSHDELAYEDSIGNAL_P_H + +#include "sftpdefs.h" + +#include +#include +#include + +namespace Core { +namespace Internal { +class SftpChannelPrivate; +class SshRemoteProcessPrivate; + +class SshDelayedSignal : public QObject +{ + Q_OBJECT +public: + SshDelayedSignal(const QWeakPointer &checkObject); + +private: + Q_SLOT void handleTimeout(); + virtual void emitSignal()=0; + + const QWeakPointer m_checkObject; +}; + + +class SftpDelayedSignal : public SshDelayedSignal +{ +public: + SftpDelayedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +protected: + SftpChannelPrivate * const m_privChannel; +}; + +class SftpInitializationFailedSignal : public SftpDelayedSignal +{ +public: + SftpInitializationFailedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, const QString &reason); + +private: + virtual void emitSignal(); + + const QString m_reason; +}; + +class SftpInitializedSignal : public SftpDelayedSignal +{ +public: + SftpInitializedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + +class SftpJobFinishedSignal : public SftpDelayedSignal +{ +public: + SftpJobFinishedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &error); + +private: + virtual void emitSignal(); + + const SftpJobId m_jobId; + const QString m_error; +}; + +class SftpDataAvailableSignal : public SftpDelayedSignal +{ +public: + SftpDataAvailableSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &data); + +private: + virtual void emitSignal(); + + const SftpJobId m_jobId; + const QString m_data; +}; + +class SftpClosedSignal : public SftpDelayedSignal +{ +public: + SftpClosedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + + +class SshRemoteProcessDelayedSignal : public SshDelayedSignal +{ +public: + SshRemoteProcessDelayedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject); + +protected: + SshRemoteProcessPrivate * const m_privChannel; +}; + +class SshRemoteProcessStartedSignal : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessStartedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + +class SshRemoteProcessOutputAvailableSignal + : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output); + +private: + virtual void emitSignal(); + + const QByteArray m_output; +}; + +class SshRemoteProcessErrorOutputAvailableSignal + : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessErrorOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output); + +private: + virtual void emitSignal(); + + const QByteArray m_output; +}; + +class SshRemoteProcessClosedSignal : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessClosedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, int exitStatus); + +private: + virtual void emitSignal(); + + const int m_exitStatus; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHDELAYEDSIGNAL_P_H diff --git a/src/plugins/coreplugin/ssh/ssherrors.h b/src/plugins/coreplugin/ssh/ssherrors.h new file mode 100644 index 00000000000..01587edfc53 --- /dev/null +++ b/src/plugins/coreplugin/ssh/ssherrors.h @@ -0,0 +1,43 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHERRORS_P_H +#define SSHERRORS_P_H + +namespace Core { + +enum SshError { + SshNoError, SshSocketError, SshTimeoutError, SshProtocolError, + SshHostKeyError, SshKeyFileError, SshAuthenticationError, + SshClosedByServerError, SshInternalError +}; + +} // namespace Core + +#endif // SSHERRORS_P_H diff --git a/src/plugins/coreplugin/ssh/sshexception_p.h b/src/plugins/coreplugin/ssh/sshexception_p.h new file mode 100644 index 00000000000..6812fabc49e --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshexception_p.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHEXCEPTION_P_H +#define SSHEXCEPTION_P_H + +#include "ssherrors.h" + +#include +#include +#include + +namespace Core { +namespace Internal { + +enum SshErrorCode { + SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1, + SSH_DISCONNECT_PROTOCOL_ERROR = 2, + SSH_DISCONNECT_KEY_EXCHANGE_FAILED = 3, + SSH_DISCONNECT_RESERVED = 4, + SSH_DISCONNECT_MAC_ERROR = 5, + SSH_DISCONNECT_COMPRESSION_ERROR = 6, + SSH_DISCONNECT_SERVICE_NOT_AVAILABLE = 7, + SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8, + SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9, + SSH_DISCONNECT_CONNECTION_LOST = 10, + SSH_DISCONNECT_BY_APPLICATION = 11, + SSH_DISCONNECT_TOO_MANY_CONNECTIONS = 12, + SSH_DISCONNECT_AUTH_CANCELLED_BY_USER = 13, + SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14, + SSH_DISCONNECT_ILLEGAL_USER_NAME = 15 +}; + +#define SSH_TR(string) QCoreApplication::translate("SshConnection", string) + +#define SSH_SERVER_EXCEPTION(error, errorString) \ + SshServerException((error), (errorString), SSH_TR(errorString)) + +struct SshServerException +{ + SshServerException(SshErrorCode error, const QByteArray &errorStringServer, + const QString &errorStringUser) + : error(error), errorStringServer(errorStringServer), + errorStringUser(errorStringUser) {} + + const SshErrorCode error; + const QByteArray errorStringServer; + const QString errorStringUser; +}; + +struct SshClientException +{ + SshClientException(SshError error, const QString &errorString) + : error(error), errorString(errorString) {} + + const SshError error; + const QString errorString; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHEXCEPTION_P_H diff --git a/src/plugins/coreplugin/ssh/sshincomingpacket.cpp b/src/plugins/coreplugin/ssh/sshincomingpacket.cpp new file mode 100644 index 00000000000..fdc274bbbdb --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshincomingpacket.cpp @@ -0,0 +1,442 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshincomingpacket_p.h" + +#include "sshcapabilities_p.h" + +namespace Core { +namespace Internal { + +const QByteArray SshIncomingPacket::ExitStatusType("exit-status"); +const QByteArray SshIncomingPacket::ExitSignalType("exit-signal"); + +SshIncomingPacket::SshIncomingPacket() : m_serverSeqNr(0) { } + +quint32 SshIncomingPacket::cipherBlockSize() const +{ + return qMax(m_decrypter.cipherBlockSize(), 8U); +} + +quint32 SshIncomingPacket::macLength() const +{ + return m_decrypter.macLength(); +} + +void SshIncomingPacket::recreateKeys(const SshKeyExchange &keyExchange) +{ + m_decrypter.recreateKeys(keyExchange); +} + +void SshIncomingPacket::reset() +{ + clear(); + m_serverSeqNr = 0; + m_decrypter.clearKeys(); +} + +void SshIncomingPacket::consumeData(QByteArray &newData) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: current data size = %d, new data size = %d", + Q_FUNC_INFO, m_data.size(), newData.size()); +#endif + + if (isComplete() || newData.isEmpty()) + return; + + /* + * Until we have reached the minimum packet size, we cannot decrypt the + * length field. + */ + const quint32 minSize = minPacketSize(); + if (currentDataSize() < minSize) { + const int bytesToTake + = qMin(minSize - currentDataSize(), newData.size()); + moveFirstBytes(m_data, newData, bytesToTake); +#ifdef CREATOR_SSH_DEBUG + qDebug("Took %d bytes from new data", bytesToTake); +#endif + if (currentDataSize() < minSize) + return; + } + + const int bytesToTake + = qMin(length() + 4 + macLength() - currentDataSize(), + newData.size()); + moveFirstBytes(m_data, newData, bytesToTake); +#ifdef CREATOR_SSH_DEBUG + qDebug("Took %d bytes from new data", bytesToTake); +#endif + if (isComplete()) { +#ifdef CREATOR_SSH_DEBUG + qDebug("Message complete. Overall size: %u, payload size: %u", + m_data.size(), m_length - paddingLength() - 1); +#endif + decrypt(); + ++m_serverSeqNr; + } +} + +void SshIncomingPacket::decrypt() +{ + Q_ASSERT(isComplete()); + const quint32 netDataLength = length() + 4; + m_decrypter.decrypt(m_data, cipherBlockSize(), + netDataLength - cipherBlockSize()); + const QByteArray &mac = m_data.mid(netDataLength, macLength()); + if (mac != generateMac(m_decrypter, m_serverSeqNr)) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_MAC_ERROR, + "Message authentication failed."); + } +} + +void SshIncomingPacket::moveFirstBytes(QByteArray &target, QByteArray &source, + int n) +{ + target.append(source.left(n)); + source.remove(0, n); +} + +SshKeyExchangeInit SshIncomingPacket::extractKeyExchangeInitData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_KEXINIT); + + SshKeyExchangeInit exchangeData; + try { + quint32 offset = TypeOffset + 1; + std::memcpy(exchangeData.cookie, &m_data.constData()[offset], + sizeof exchangeData.cookie); + offset += sizeof exchangeData.cookie; + exchangeData.keyAlgorithms + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.serverHostKeyAlgorithms + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.encryptionAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.encryptionAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.macAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.macAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.compressionAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.compressionAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.languagesClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.languagesServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.firstKexPacketFollows + = SshPacketParser::asBool(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Key exchange failed: Server sent invalid SSH_MSG_KEXINIT packet."); + } + return exchangeData; +} + +SshKeyExchangeReply SshIncomingPacket::extractKeyExchangeReply(const QByteArray &pubKeyAlgo) const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_KEXDH_REPLY); + + try { + SshKeyExchangeReply replyData; + quint32 offset = TypeOffset + 1; + const quint32 k_sLength + = SshPacketParser::asUint32(m_data, &offset); + if (offset + k_sLength > currentDataSize()) + throw SshPacketParseException(); + replyData.k_s = m_data.mid(offset - 4, k_sLength + 4); + if (SshPacketParser::asString(m_data, &offset) != pubKeyAlgo) + throw SshPacketParseException(); + + // DSS: p and q, RSA: e and n + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + + // g and y + if (pubKeyAlgo == SshCapabilities::PubKeyDss) { + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + } + + replyData.f = SshPacketParser::asBigInt(m_data, &offset); + offset += 4; + if (SshPacketParser::asString(m_data, &offset) != pubKeyAlgo) + throw SshPacketParseException(); + replyData.signatureBlob = SshPacketParser::asString(m_data, &offset); + return replyData; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Key exchange failed: " + "Server sent invalid SSH_MSG_KEXDH_REPLY packet."); + } +} + +SshDisconnect SshIncomingPacket::extractDisconnect() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_DISCONNECT); + + SshDisconnect msg; + try { + quint32 offset = TypeOffset + 1; + msg.reasonCode = SshPacketParser::asUint32(m_data, &offset); + msg.description = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_DISCONNECT."); + } + + return msg; +} + +SshUserAuthBanner SshIncomingPacket::extractUserAuthBanner() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_USERAUTH_BANNER); + + try { + SshUserAuthBanner msg; + quint32 offset = TypeOffset + 1; + msg.message = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + return msg; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_USERAUTH_BANNER."); + } +} + +SshDebug SshIncomingPacket::extractDebug() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_DEBUG); + + try { + SshDebug msg; + quint32 offset = TypeOffset + 1; + msg.display = SshPacketParser::asBool(m_data, &offset); + msg.message = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + return msg; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_USERAUTH_BANNER."); + } +} + +SshChannelOpenFailure SshIncomingPacket::extractChannelOpenFailure() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_OPEN_FAILURE); + + SshChannelOpenFailure openFailure; + try { + quint32 offset = TypeOffset + 1; + openFailure.localChannel = SshPacketParser::asUint32(m_data, &offset); + openFailure.reasonCode = SshPacketParser::asUint32(m_data, &offset); + openFailure.reasonString = SshPacketParser::asString(m_data, &offset); + openFailure.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + return openFailure; +} + +SshChannelOpenConfirmation SshIncomingPacket::extractChannelOpenConfirmation() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_OPEN_CONFIRMATION); + + SshChannelOpenConfirmation confirmation; + try { + quint32 offset = TypeOffset + 1; + confirmation.localChannel = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteChannel = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteWindowSize = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteMaxPacketSize = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + return confirmation; +} + +SshChannelWindowAdjust SshIncomingPacket::extractWindowAdjust() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_WINDOW_ADJUST); + + SshChannelWindowAdjust adjust; + try { + quint32 offset = TypeOffset + 1; + adjust.localChannel = SshPacketParser::asUint32(m_data, &offset); + adjust.bytesToAdd = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_WINDOW_ADJUST packet."); + } + return adjust; +} + +SshChannelData SshIncomingPacket::extractChannelData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_DATA); + + SshChannelData data; + try { + quint32 offset = TypeOffset + 1; + data.localChannel = SshPacketParser::asUint32(m_data, &offset); + data.data = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_DATA packet."); + } + return data; +} + +SshChannelExtendedData SshIncomingPacket::extractChannelExtendedData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_EXTENDED_DATA); + + SshChannelExtendedData data; + try { + quint32 offset = TypeOffset + 1; + data.localChannel = SshPacketParser::asUint32(m_data, &offset); + data.type = SshPacketParser::asUint32(m_data, &offset); + data.data = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_EXTENDED_DATA packet."); + } + return data; +} + +SshChannelExitStatus SshIncomingPacket::extractChannelExitStatus() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + SshChannelExitStatus exitStatus; + try { + quint32 offset = TypeOffset + 1; + exitStatus.localChannel = SshPacketParser::asUint32(m_data, &offset); + const QByteArray &type = SshPacketParser::asString(m_data, &offset); + Q_ASSERT(type == ExitStatusType); + if (SshPacketParser::asBool(m_data, &offset)) + throw SshPacketParseException(); + exitStatus.exitStatus = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid exit-status packet."); + } + return exitStatus; +} + +SshChannelExitSignal SshIncomingPacket::extractChannelExitSignal() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + SshChannelExitSignal exitSignal; + try { + quint32 offset = TypeOffset + 1; + exitSignal.localChannel = SshPacketParser::asUint32(m_data, &offset); + const QByteArray &type = SshPacketParser::asString(m_data, &offset); + Q_ASSERT(type == ExitSignalType); + if (SshPacketParser::asBool(m_data, &offset)) + throw SshPacketParseException(); + exitSignal.signal = SshPacketParser::asString(m_data, &offset); + exitSignal.coreDumped = SshPacketParser::asBool(m_data, &offset); + exitSignal.error = SshPacketParser::asUserString(m_data, &offset); + exitSignal.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid exit-signal packet."); + } + return exitSignal; +} + +quint32 SshIncomingPacket::extractRecipientChannel() const +{ + Q_ASSERT(isComplete()); + + try { + quint32 offset = TypeOffset + 1; + return SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid packet."); + } +} + +QByteArray SshIncomingPacket::extractChannelRequestType() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + try { + quint32 offset = TypeOffset + 1; + SshPacketParser::asUint32(m_data, &offset); + return SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_REQUEST packet."); + } +} + +void SshIncomingPacket::calculateLength() const +{ + Q_ASSERT(currentDataSize() >= minPacketSize()); +#ifdef CREATOR_SSH_DEBUG + qDebug("Length field before decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, + m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff); +#endif + m_decrypter.decrypt(m_data, 0, cipherBlockSize()); +#ifdef CREATOR_SSH_DEBUG + qDebug("Length field after decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff); + qDebug("message type = %d", m_data.at(TypeOffset)); +#endif + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); +#ifdef CREATOR_SSH_DEBUG + qDebug("decrypted length is %u", m_length); +#endif +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshincomingpacket_p.h b/src/plugins/coreplugin/ssh/sshincomingpacket_p.h new file mode 100644 index 00000000000..9b10c8f7998 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshincomingpacket_p.h @@ -0,0 +1,186 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHINCOMINGPACKET_P_H +#define SSHINCOMINGPACKET_P_H + +#include "sshpacket_p.h" + +#include "sshcryptofacility_p.h" +#include "sshpacketparser_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +class SshKeyExchange; + +struct SshKeyExchangeInit +{ + char cookie[16]; + SshNameList keyAlgorithms; + SshNameList serverHostKeyAlgorithms; + SshNameList encryptionAlgorithmsClientToServer; + SshNameList encryptionAlgorithmsServerToClient; + SshNameList macAlgorithmsClientToServer; + SshNameList macAlgorithmsServerToClient; + SshNameList compressionAlgorithmsClientToServer; + SshNameList compressionAlgorithmsServerToClient; + SshNameList languagesClientToServer; + SshNameList languagesServerToClient; + bool firstKexPacketFollows; +}; + +struct SshKeyExchangeReply +{ + QByteArray k_s; + QList parameters; // DSS: p, q, g, y. RSA: e, n. + Botan::BigInt f; + QByteArray signatureBlob; +}; + +struct SshDisconnect +{ + quint32 reasonCode; + QString description; + QByteArray language; +}; + +struct SshUserAuthBanner +{ + QString message; + QByteArray language; +}; + +struct SshDebug +{ + bool display; + QString message; + QByteArray language; +}; + +struct SshChannelOpenFailure +{ + quint32 localChannel; + quint32 reasonCode; + QString reasonString; + QByteArray language; +}; + +struct SshChannelOpenConfirmation +{ + quint32 localChannel; + quint32 remoteChannel; + quint32 remoteWindowSize; + quint32 remoteMaxPacketSize; +}; + +struct SshChannelWindowAdjust +{ + quint32 localChannel; + quint32 bytesToAdd; +}; + +struct SshChannelData +{ + quint32 localChannel; + QByteArray data; +}; + +struct SshChannelExtendedData +{ + quint32 localChannel; + quint32 type; + QByteArray data; +}; + +struct SshChannelExitStatus +{ + quint32 localChannel; + quint32 exitStatus; +}; + +struct SshChannelExitSignal +{ + quint32 localChannel; + QByteArray signal; + bool coreDumped; + QString error; + QByteArray language; +}; + + +class SshIncomingPacket : public AbstractSshPacket +{ +public: + SshIncomingPacket(); + + void consumeData(QByteArray &data); + void recreateKeys(const SshKeyExchange &keyExchange); + void reset(); + + SshKeyExchangeInit extractKeyExchangeInitData() const; + SshKeyExchangeReply extractKeyExchangeReply(const QByteArray &pubKeyAlgo) const; + SshDisconnect extractDisconnect() const; + SshUserAuthBanner extractUserAuthBanner() const; + SshDebug extractDebug() const; + + SshChannelOpenFailure extractChannelOpenFailure() const; + SshChannelOpenConfirmation extractChannelOpenConfirmation() const; + SshChannelWindowAdjust extractWindowAdjust() const; + SshChannelData extractChannelData() const; + SshChannelExtendedData extractChannelExtendedData() const; + SshChannelExitStatus extractChannelExitStatus() const; + SshChannelExitSignal extractChannelExitSignal() const; + quint32 extractRecipientChannel() const; + QByteArray extractChannelRequestType() const; + + quint32 serverSeqNr() const { return m_serverSeqNr; } + + static const QByteArray ExitStatusType; + static const QByteArray ExitSignalType; + +private: + virtual quint32 cipherBlockSize() const; + virtual quint32 macLength() const; + virtual void calculateLength() const; + + void decrypt(); + void moveFirstBytes(QByteArray &target, QByteArray &source, int n); + + quint32 m_serverSeqNr; + SshDecryptionFacility m_decrypter; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHINCOMINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshkeyexchange.cpp b/src/plugins/coreplugin/ssh/sshkeyexchange.cpp new file mode 100644 index 00000000000..7875d2ecd07 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshkeyexchange.cpp @@ -0,0 +1,197 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshkeyexchange_p.h" + +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshsendfacility_p.h" +#include "sshexception_p.h" +#include "sshincomingpacket_p.h" + +#include +#include +#include +#include +#include + +#include + +using namespace Botan; + +namespace Core { +namespace Internal { + +namespace { + + // For debugging + void printNameList(const char *listName, const SshNameList &list) + { +#ifdef CREATOR_SSH_DEBUG + qDebug("%s:", listName); + foreach (const QByteArray &name, list.names) + qDebug("%s", name.constData()); +#else + Q_UNUSED(listName); + Q_UNUSED(list); +#endif + } +} // anonymous namespace + +SshKeyExchange::SshKeyExchange(SshSendFacility &sendFacility) + : m_sendFacility(sendFacility) +{ +} + +SshKeyExchange::~SshKeyExchange() {} + +void SshKeyExchange::sendKexInitPacket(const QByteArray &serverId) +{ + m_serverId = serverId; + const AbstractSshPacket::Payload &payload + = m_sendFacility.sendKeyExchangeInitPacket(); + m_clientKexInitPayload = QByteArray(payload.data, payload.size); +} + +bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("server requests key exchange"); +#endif + serverKexInit.printRawBytes(); + SshKeyExchangeInit kexInitParams + = serverKexInit.extractKeyExchangeInitData(); + + printNameList("Key Algorithms", kexInitParams.keyAlgorithms); + printNameList("Server Host Key Algorithms", kexInitParams.serverHostKeyAlgorithms); + printNameList("Encryption algorithms client to server", kexInitParams.encryptionAlgorithmsClientToServer); + printNameList("Encryption algorithms server to client", kexInitParams.encryptionAlgorithmsServerToClient); + printNameList("MAC algorithms client to server", kexInitParams.macAlgorithmsClientToServer); + printNameList("MAC algorithms server to client", kexInitParams.macAlgorithmsServerToClient); + printNameList("Compression algorithms client to server", kexInitParams.compressionAlgorithmsClientToServer); + printNameList("Compression algorithms client to server", kexInitParams.compressionAlgorithmsClientToServer); + printNameList("Languages client to server", kexInitParams.languagesClientToServer); + printNameList("Languages server to client", kexInitParams.languagesServerToClient); +#ifdef CREATOR_SSH_DEBUG + qDebug("First packet follows: %d", kexInitParams.firstKexPacketFollows); +#endif + + const QByteArray &keyAlgo + = SshCapabilities::findBestMatch(SshCapabilities::KeyExchangeMethods, + kexInitParams.keyAlgorithms.names); + m_serverHostKeyAlgo + = SshCapabilities::findBestMatch(SshCapabilities::PublicKeyAlgorithms, + kexInitParams.serverHostKeyAlgorithms.names); + m_encryptionAlgo + = SshCapabilities::findBestMatch(SshCapabilities::EncryptionAlgorithms, + kexInitParams.encryptionAlgorithmsClientToServer.names); + m_decryptionAlgo + = SshCapabilities::findBestMatch(SshCapabilities::EncryptionAlgorithms, + kexInitParams.encryptionAlgorithmsServerToClient.names); + m_c2sHMacAlgo + = SshCapabilities::findBestMatch(SshCapabilities::MacAlgorithms, + kexInitParams.macAlgorithmsClientToServer.names); + m_s2cHMacAlgo + = SshCapabilities::findBestMatch(SshCapabilities::MacAlgorithms, + kexInitParams.macAlgorithmsServerToClient.names); + SshCapabilities::findBestMatch(SshCapabilities::CompressionAlgorithms, + kexInitParams.compressionAlgorithmsClientToServer.names); + SshCapabilities::findBestMatch(SshCapabilities::CompressionAlgorithms, + kexInitParams.compressionAlgorithmsServerToClient.names); + + AutoSeeded_RNG rng; + m_dhKey.reset(new DH_PrivateKey(rng, + DL_Group(botanKeyExchangeAlgoName(keyAlgo)))); + + const AbstractSshPacket::Payload &payload = serverKexInit.payLoad(); + m_serverKexInitPayload = QByteArray(payload.data, payload.size); + m_sendFacility.sendKeyDhInitPacket(m_dhKey->get_y()); + return kexInitParams.firstKexPacketFollows; +} + +void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply, + const QByteArray &clientId) +{ + const SshKeyExchangeReply &reply + = dhReply.extractKeyExchangeReply(m_serverHostKeyAlgo); + if (reply.f <= 0 || reply.f >= m_dhKey->group_p()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Server sent invalid f."); + } + + QByteArray concatenatedData = AbstractSshPacket::encodeString(clientId); + concatenatedData += AbstractSshPacket::encodeString(m_serverId); + concatenatedData += AbstractSshPacket::encodeString(m_clientKexInitPayload); + concatenatedData += AbstractSshPacket::encodeString(m_serverKexInitPayload); + concatenatedData += reply.k_s; + concatenatedData += AbstractSshPacket::encodeMpInt(m_dhKey->get_y()); + concatenatedData += AbstractSshPacket::encodeMpInt(reply.f); + SymmetricKey k = m_dhKey->derive_key(reply.f); + m_k = AbstractSshPacket::encodeMpInt(BigInt(k.begin(), k.length())); + concatenatedData += m_k; + + m_hash.reset(get_hash(botanSha1Name())); + const SecureVector &hashResult + = m_hash->process(convertByteArray(concatenatedData), + concatenatedData.size()); + m_h = convertByteArray(hashResult); + + QScopedPointer sigKey; + QScopedPointer verifier; + if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) { + const DL_Group group(reply.parameters.at(0), reply.parameters.at(1), + reply.parameters.at(2)); + DSA_PublicKey * const dsaKey + = new DSA_PublicKey(group, reply.parameters.at(3)); + sigKey.reset(dsaKey); + verifier.reset(get_pk_verifier(*dsaKey, + botanEmsaAlgoName(SshCapabilities::PubKeyDss))); + } else if (m_serverHostKeyAlgo == SshCapabilities::PubKeyRsa) { + RSA_PublicKey * const rsaKey + = new RSA_PublicKey(reply.parameters.at(1), reply.parameters.at(0)); + sigKey.reset(rsaKey); + verifier.reset(get_pk_verifier(*rsaKey, + botanEmsaAlgoName(SshCapabilities::PubKeyRsa))); + } else { + Q_ASSERT(!"Impossible: Neither DSS nor RSA!"); + } + const byte * const botanH = convertByteArray(m_h); + const Botan::byte * const botanSig + = convertByteArray(reply.signatureBlob); + if (!verifier->verify_message(botanH, m_h.size(), botanSig, + reply.signatureBlob.size())) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Invalid signature in SSH_MSG_KEXDH_REPLY packet."); + } + + m_sendFacility.sendNewKeysPacket(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshkeyexchange_p.h b/src/plugins/coreplugin/ssh/sshkeyexchange_p.h new file mode 100644 index 00000000000..076f5bedd6e --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshkeyexchange_p.h @@ -0,0 +1,87 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHKEYEXCHANGE_P_H +#define SSHKEYEXCHANGE_P_H + +#include + +#include +#include + +namespace Botan { class HashFunction; } + +namespace Core { +namespace Internal { + +class SshSendFacility; +class SshIncomingPacket; + +class SshKeyExchange +{ +public: + SshKeyExchange(SshSendFacility &sendFacility); + ~SshKeyExchange(); + + void sendKexInitPacket(const QByteArray &serverId); + + // Returns true <=> the server sends a guessed package. + bool sendDhInitPacket(const SshIncomingPacket &serverKexInit); + + void sendNewKeysPacket(const SshIncomingPacket &dhReply, + const QByteArray &clientId); + + QByteArray k() const { return m_k; } + QByteArray h() const { return m_h; } + Botan::HashFunction *hash() const { return m_hash.data(); } + QByteArray encryptionAlgo() const { return m_encryptionAlgo; } + QByteArray decryptionAlgo() const { return m_decryptionAlgo; } + QByteArray hMacAlgoClientToServer() const { return m_c2sHMacAlgo; } + QByteArray hMacAlgoServerToClient() const { return m_s2cHMacAlgo; } + +private: + QByteArray m_serverId; + QByteArray m_clientKexInitPayload; + QByteArray m_serverKexInitPayload; + QScopedPointer m_dhKey; + QByteArray m_k; + QByteArray m_h; + QByteArray m_serverHostKeyAlgo; + QByteArray m_encryptionAlgo; + QByteArray m_decryptionAlgo; + QByteArray m_c2sHMacAlgo; + QByteArray m_s2cHMacAlgo; + QScopedPointer m_hash; + SshSendFacility &m_sendFacility; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHKEYEXCHANGE_P_H diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp index 17a63886e31..976d0094c78 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp @@ -1,55 +1,138 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "sshkeygenerator.h" -#include "ne7sshobject.h" +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshpacket_p.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include namespace Core { -SshKeyGenerator::SshKeyGenerator() +using namespace Botan; +using namespace Internal; + +SshKeyGenerator::SshKeyGenerator() { } + +bool SshKeyGenerator::generateKeys(KeyType type, PrivateKeyFormat format, + int keySize) { + try { + AutoSeeded_RNG rng; + KeyPtr key; + if (type == Rsa) + key = KeyPtr(new RSA_PrivateKey(rng, keySize)); + else + key = KeyPtr(new DSA_PrivateKey(rng, DL_Group(rng, DL_Group::Strong, + keySize))); + return format == Pkcs8 + ? generatePkcs8Keys(key) : generateOpenSslKeys(key, type); + } catch (Botan::Exception &e) { + m_error = tr("Error generating key: %1").arg(e.what()); + return false; + } } -bool SshKeyGenerator::generateKeys(KeyType type, const QString &id, int keySize) +bool SshKeyGenerator::generatePkcs8Keys(const KeyPtr &key) { - QTemporaryFile tmpPubKeyFile; - QTemporaryFile tmpPrivKeyFile; - if (!tmpPubKeyFile.open() || !tmpPrivKeyFile.open()) { - m_error = tr("Error creating temporary files."); - return false; + generatePkcs8Key(key, false); + generatePkcs8Key(key, true); + return true; +} + +void SshKeyGenerator::generatePkcs8Key(const KeyPtr &key, bool privateKey) +{ + Pipe pipe; + pipe.start_msg(); + QByteArray *keyData; + if (privateKey) { + PKCS8::encode(*key, pipe); + keyData = &m_privateKey; + } else { + X509::encode(*key, pipe); + keyData = &m_publicKey; } - tmpPubKeyFile.setAutoRemove(false); - tmpPubKeyFile.close(); - tmpPrivKeyFile.close(); - const char * const typeStr = type == Rsa ? "rsa" : "dsa"; - Internal::Ne7SshObject::Ptr ne7Object - = Internal::Ne7SshObject::instance()->get(); - if (!ne7Object->generateKeyPair(typeStr, id.toUtf8(), - tmpPrivKeyFile.fileName().toUtf8(), - tmpPubKeyFile.fileName().toUtf8(), keySize)) { - // TODO: Race condition on pop() call. Perhaps not use Net7 errors? Or hack API - m_error = tr("Error generating keys: %1") - .arg(ne7Object->errors()->pop()); - return false; + pipe.end_msg(); + keyData->resize(pipe.remaining(pipe.message_count() - 1)); + pipe.read(convertByteArray(*keyData), keyData->size(), + pipe.message_count() - 1); +} + +bool SshKeyGenerator::generateOpenSslKeys(const KeyPtr &key, KeyType type) +{ + QList publicParams; + QList allParams; + QByteArray keyId; + if (type == Rsa) { + const QSharedPointer rsaKey + = key.dynamicCast(); + publicParams << rsaKey->get_e() << rsaKey->get_n(); + allParams << rsaKey->get_n() << rsaKey->get_e() << rsaKey->get_d() + << rsaKey->get_p() << rsaKey->get_q(); + keyId = SshCapabilities::PubKeyRsa; + } else { + const QSharedPointer dsaKey + = key.dynamicCast(); + publicParams << dsaKey->group_p() << dsaKey->group_q() + << dsaKey->group_g() << dsaKey->get_y(); + allParams << publicParams << dsaKey->get_x(); + keyId = SshCapabilities::PubKeyDss; } - if (!tmpPubKeyFile.open() || !tmpPrivKeyFile.open()) { - m_error = tr("Error reading temporary files."); - return false; - } + QByteArray publicKeyBlob = AbstractSshPacket::encodeString(keyId); + foreach (const BigInt &b, publicParams) + publicKeyBlob += AbstractSshPacket::encodeMpInt(b); + publicKeyBlob = publicKeyBlob.toBase64(); + const QByteArray id = "QtCreator/" + + QDateTime::currentDateTime().toString(Qt::ISODate).toUtf8(); + m_publicKey = keyId + ' ' + publicKeyBlob + ' ' + id; - m_publicKey = tmpPubKeyFile.readAll(); - m_privateKey = tmpPrivKeyFile.readAll(); - if (tmpPubKeyFile.error() != QFile::NoError - || tmpPrivKeyFile.error() != QFile::NoError) { - m_error = tr("Error reading temporary files."); - return false; - } - - m_type = type; + DER_Encoder encoder; + encoder.start_cons(SEQUENCE).encode (0U); + foreach (const BigInt &b, allParams) + encoder.encode(b); + encoder.end_cons(); + const char * const label + = type == Rsa ? "RSA PRIVATE KEY" : "DSA PRIVATE KEY"; + m_privateKey + = QByteArray(PEM_Code::encode (encoder.get_contents(), label).c_str()); return true; } diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.h b/src/plugins/coreplugin/ssh/sshkeygenerator.h index a68237e576f..ada06150a04 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.h +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.h @@ -1,10 +1,43 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef SSHKEYGENERATOR_H #define SSHKEYGENERATOR_H #include #include -#include +#include + +namespace Botan { + class Private_Key; +} namespace Core { @@ -13,19 +46,28 @@ class CORE_EXPORT SshKeyGenerator Q_DECLARE_TR_FUNCTIONS(SshKeyGenerator) public: enum KeyType { Rsa, Dsa }; + enum PrivateKeyFormat { Pkcs8, OpenSsl }; SshKeyGenerator(); - bool generateKeys(KeyType type, const QString &id, int keySize); + bool generateKeys(KeyType type, PrivateKeyFormat format, int keySize); QString error() const { return m_error; } - QString privateKey() const { return m_privateKey; } - QString publicKey() const { return m_publicKey; } + QByteArray privateKey() const { return m_privateKey; } + QByteArray publicKey() const { return m_publicKey; } KeyType type() const { return m_type; } + PrivateKeyFormat format() const { return m_format; } private: + typedef QSharedPointer KeyPtr; + + bool generatePkcs8Keys(const KeyPtr &key); + void generatePkcs8Key(const KeyPtr &key, bool privateKey); + bool generateOpenSslKeys(const KeyPtr &key, KeyType type); + QString m_error; - QString m_publicKey; - QString m_privateKey; + QByteArray m_publicKey; + QByteArray m_privateKey; KeyType m_type; + PrivateKeyFormat m_format; }; } // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp b/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp new file mode 100644 index 00000000000..c6cf99443d4 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp @@ -0,0 +1,284 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshoutgoingpacket_p.h" + +#include "sshcapabilities_p.h" +#include "sshcryptofacility_p.h" + +#include + +namespace Core { +namespace Internal { + +SshOutgoingPacket::SshOutgoingPacket(const SshEncryptionFacility &encrypter, + const quint32 &seqNr) : m_encrypter(encrypter), m_seqNr(seqNr) +{ +} + +quint32 SshOutgoingPacket::cipherBlockSize() const +{ + return qMax(m_encrypter.cipherBlockSize(), 4U); +} + +quint32 SshOutgoingPacket::macLength() const +{ + return m_encrypter.macLength(); +} + +void SshOutgoingPacket::generateKeyExchangeInitPacket() +{ + const QByteArray &supportedkeyExchangeMethods + = encodeNameList(SshCapabilities::KeyExchangeMethods); + const QByteArray &supportedPublicKeyAlgorithms + = encodeNameList(SshCapabilities::PublicKeyAlgorithms); + const QByteArray &supportedEncryptionAlgorithms + = encodeNameList(SshCapabilities::EncryptionAlgorithms); + const QByteArray &supportedMacAlgorithms + = encodeNameList(SshCapabilities::MacAlgorithms); + const QByteArray &supportedCompressionAlgorithms + = encodeNameList(SshCapabilities::CompressionAlgorithms); + const QByteArray &supportedLanguages = encodeNameList(QList()); + + init(SSH_MSG_KEXINIT); + m_data += m_encrypter.getRandomNumbers(16); + m_data.append(supportedkeyExchangeMethods); + m_data.append(supportedPublicKeyAlgorithms); + m_data.append(supportedEncryptionAlgorithms) + .append(supportedEncryptionAlgorithms); + m_data.append(supportedMacAlgorithms).append(supportedMacAlgorithms); + m_data.append(supportedCompressionAlgorithms) + .append(supportedCompressionAlgorithms); + m_data.append(supportedLanguages).append(supportedLanguages); + appendBool(false); // No guessed packet. + m_data.append(QByteArray(4, 0)); // Reserved. + finalize(); +} + +void SshOutgoingPacket::generateKeyDhInitPacket(const Botan::BigInt &e) +{ + init(SSH_MSG_KEXDH_INIT).appendMpInt(e).finalize(); +} + +void SshOutgoingPacket::generateNewKeysPacket() +{ + init(SSH_MSG_NEWKEYS).finalize(); +} + +void SshOutgoingPacket::generateUserAuthServiceRequestPacket() +{ + generateServiceRequest("ssh-userauth"); +} + +void SshOutgoingPacket::generateServiceRequest(const QByteArray &service) +{ + init(SSH_MSG_SERVICE_REQUEST).appendString(service).finalize(); +} + +void SshOutgoingPacket::generateUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd) +{ + init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service) + .appendString("password").appendBool(false).appendString(pwd) + .finalize(); +} + +void SshOutgoingPacket::generateUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service) +{ + init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service) + .appendString("publickey").appendBool(true) + .appendString(m_encrypter.authenticationAlgorithmName()) + .appendString(m_encrypter.authenticationPublicKey()); + const QByteArray &dataToSign = m_data.mid(PayloadOffset); + appendString(m_encrypter.authenticationKeySignature(dataToSign)); + finalize(); +} + +void SshOutgoingPacket::generateRequestFailurePacket() +{ + init(SSH_MSG_REQUEST_FAILURE).finalize(); +} + +void SshOutgoingPacket::generateSessionPacket(quint32 channelId, + quint32 windowSize, quint32 maxPacketSize) +{ + init(SSH_MSG_CHANNEL_OPEN).appendString("session").appendInt(channelId) + .appendInt(windowSize).appendInt(maxPacketSize).finalize(); +} + +void SshOutgoingPacket::generateEnvPacket(quint32 remoteChannel, + const QByteArray &var, const QByteArray &value) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel).appendString("env") + .appendBool(false).appendString(var).appendString(value); +} + +void SshOutgoingPacket::generateExecPacket(quint32 remoteChannel, + const QByteArray &command) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel).appendString("exec") + .appendBool(true).appendString(command).finalize(); +} + +void SshOutgoingPacket::generateSftpPacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel) + .appendString("subsystem").appendBool(true).appendString("sftp") + .finalize(); +} + +void SshOutgoingPacket::generateWindowAdjustPacket(quint32 remoteChannel, + quint32 bytesToAdd) +{ + init(SSH_MSG_CHANNEL_WINDOW_ADJUST).appendInt(remoteChannel) + .appendInt(bytesToAdd).finalize(); +} + +void SshOutgoingPacket::generateChannelDataPacket(quint32 remoteChannel, + const QByteArray &data) +{ + init(SSH_MSG_CHANNEL_DATA).appendInt(remoteChannel).appendString(data) + .finalize(); +} + +void SshOutgoingPacket::generateChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel) + .appendString("signal").appendBool(false).appendString(signalName) + .finalize(); +} + +void SshOutgoingPacket::generateChannelEofPacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_EOF).appendInt(remoteChannel).finalize(); +} + +void SshOutgoingPacket::generateChannelClosePacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_CLOSE).appendInt(remoteChannel).finalize(); +} + +void SshOutgoingPacket::generateDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString) +{ + init(SSH_MSG_DISCONNECT).appendInt(reason).appendString(reasonString) + .appendString(QByteArray()).finalize(); +} + +void SshOutgoingPacket::generateMsgUnimplementedPacket(quint32 serverSeqNr) +{ + init(SSH_MSG_UNIMPLEMENTED).appendInt(serverSeqNr).finalize(); +} + +SshOutgoingPacket &SshOutgoingPacket::appendInt(quint32 val) +{ + m_data.append(encodeInt(val)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendMpInt(const Botan::BigInt &number) +{ + m_data.append(encodeMpInt(number)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendBool(bool b) +{ + m_data += static_cast(b); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendString(const QByteArray &string) +{ + m_data.append(encodeString(string)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::init(SshPacketType type) +{ + m_data.resize(TypeOffset + 1); + m_data[TypeOffset] = type; + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::setPadding() +{ + m_data += m_encrypter.getRandomNumbers(MinPaddingLength); + int padLength = MinPaddingLength; + const int divisor = sizeDivisor(); + const int mod = m_data.size() % divisor; + padLength += divisor - mod; + m_data += m_encrypter.getRandomNumbers(padLength - MinPaddingLength); + m_data[PaddingLengthOffset] = padLength; + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::encrypt() +{ + const QByteArray &mac + = generateMac(m_encrypter, m_seqNr); + m_encrypter.encrypt(m_data); + m_data += mac; + return *this; +} + +void SshOutgoingPacket::finalize() +{ + setPadding(); + setLengthField(m_data); + m_length = m_data.size() - 4; +#ifdef CREATOR_SSH_DEBUG + qDebug("Encrypting packet of type %u", m_data.at(TypeOffset)); +#endif + encrypt(); + Q_ASSERT(isComplete()); +} + +int SshOutgoingPacket::sizeDivisor() const +{ + return qMax(cipherBlockSize(), 8U); +} + +QByteArray SshOutgoingPacket::encodeNameList(const QList &list) +{ + QByteArray data; + data.resize(4); + for (int i = 0; i < list.count(); ++i) { + if (i > 0) + data.append(','); + data.append(list.at(i)); + } + AbstractSshPacket::setLengthField(data); + return data; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h b/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h new file mode 100644 index 00000000000..eb9c2f520d6 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h @@ -0,0 +1,98 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHOUTGOINGPACKET_P_H +#define SSHOUTGOINGPACKET_P_H + +#include "sshpacket_p.h" + +namespace Core { +namespace Internal { + +class SshEncryptionFacility; + +class SshOutgoingPacket : public AbstractSshPacket +{ +public: + SshOutgoingPacket(const SshEncryptionFacility &encrypter, + const quint32 &seqNr); + + void generateKeyExchangeInitPacket(); + void generateKeyDhInitPacket(const Botan::BigInt &e); + void generateNewKeysPacket(); + void generateDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString); + void generateMsgUnimplementedPacket(quint32 serverSeqNr); + void generateUserAuthServiceRequestPacket(); + void generateUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd); + void generateUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service); + void generateRequestFailurePacket(); + void generateSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize); + void generateEnvPacket(quint32 remoteChannel, const QByteArray &var, + const QByteArray &value); + void generateExecPacket(quint32 remoteChannel, const QByteArray &command); + void generateSftpPacket(quint32 remoteChannel); + void generateWindowAdjustPacket(quint32 remoteChannel, quint32 bytesToAdd); + void generateChannelDataPacket(quint32 remoteChannel, + const QByteArray &data); + void generateChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName); + void generateChannelEofPacket(quint32 remoteChannel); + void generateChannelClosePacket(quint32 remoteChannel); + +private: + virtual quint32 cipherBlockSize() const; + virtual quint32 macLength() const; + + static QByteArray encodeNameList(const QList &list); + + void generateServiceRequest(const QByteArray &service); + + SshOutgoingPacket &init(SshPacketType type); + SshOutgoingPacket &setPadding(); + SshOutgoingPacket &encrypt(); + void finalize(); + + SshOutgoingPacket &appendInt(quint32 val); + SshOutgoingPacket &appendString(const QByteArray &string); + SshOutgoingPacket &appendMpInt(const Botan::BigInt &number); + SshOutgoingPacket &appendBool(bool b); + int sizeDivisor() const; + + const SshEncryptionFacility &m_encrypter; + const quint32 &m_seqNr; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHOUTGOINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshpacket.cpp b/src/plugins/coreplugin/ssh/sshpacket.cpp new file mode 100644 index 00000000000..ff705093554 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacket.cpp @@ -0,0 +1,167 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshpacket_p.h" + +#include "sshcapabilities_p.h" +#include "sshcryptofacility_p.h" +#include "sshexception_p.h" +#include "sshpacketparser_p.h" + +#include + +#include + +namespace Core { +namespace Internal { + +const quint32 AbstractSshPacket::PaddingLengthOffset = 4; +const quint32 AbstractSshPacket::PayloadOffset = PaddingLengthOffset + 1; +const quint32 AbstractSshPacket::TypeOffset = PayloadOffset; +const quint32 AbstractSshPacket::MinPaddingLength = 4; + +namespace { + + void printByteArray(const QByteArray &data) + { +#ifdef CREATOR_SSH_DEBUG + for (int i = 0; i < data.count(); ++i) + qDebug() << std::hex << (static_cast(data[i]) & 0xff) << " "; +#else + Q_UNUSED(data); +#endif + } +} // anonymous namespace + + +AbstractSshPacket::AbstractSshPacket() : m_length(0) { } +AbstractSshPacket::~AbstractSshPacket() {} + +bool AbstractSshPacket::isComplete() const +{ + if (currentDataSize() < minPacketSize()) + return false; + Q_ASSERT(4 + length() + macLength() >= currentDataSize()); + return 4 + length() + macLength() == currentDataSize(); +} + +void AbstractSshPacket::clear() +{ + m_data.clear(); + m_length = 0; +} + +SshPacketType AbstractSshPacket::type() const +{ + Q_ASSERT(isComplete()); + return static_cast(m_data.at(TypeOffset)); +} + +AbstractSshPacket::Payload AbstractSshPacket::payLoad() const +{ + Payload p; + p.data = m_data.constData() + PayloadOffset; + p.size = length() - paddingLength() - 1; + return p; +} + +void AbstractSshPacket::printRawBytes() const +{ + printByteArray(m_data); +} + +QByteArray AbstractSshPacket::encodeString(const QByteArray &string) +{ + QByteArray data; + data.resize(4); + data += string; + setLengthField(data); + return data; +} + +QByteArray AbstractSshPacket::encodeMpInt(const Botan::BigInt &number) +{ + if (number.is_zero()) + return QByteArray(4, 0); + + int stringLength = number.bytes(); + const bool positiveAndMsbSet = number.sign() == Botan::BigInt::Positive + && (number.byte_at(stringLength - 1) & 0x80); + if (positiveAndMsbSet) + ++stringLength; + QByteArray data; + data.resize(4 + stringLength); + int pos = 4; + if (positiveAndMsbSet) + data[pos++] = '\0'; + number.binary_encode(reinterpret_cast(data.data()) + pos); + setLengthField(data); + return data; +} + +int AbstractSshPacket::paddingLength() const +{ + return m_data[PaddingLengthOffset]; +} + +quint32 AbstractSshPacket::length() const +{ + //Q_ASSERT(currentDataSize() >= minPacketSize()); + if (m_length == 0) + calculateLength(); + return m_length; +} + +void AbstractSshPacket::calculateLength() const +{ + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); +} + +QByteArray AbstractSshPacket::generateMac(const SshAbstractCryptoFacility &crypt, + quint32 seqNr) const +{ + const quint32 seqNrBe = qToBigEndian(seqNr); + QByteArray data(reinterpret_cast(&seqNrBe), sizeof seqNrBe); + data += QByteArray(m_data.constData(), length() + 4); + return crypt.generateMac(data, data.size()); +} + +quint32 AbstractSshPacket::minPacketSize() const +{ + return qMax(cipherBlockSize(), 16) + macLength(); +} + +void AbstractSshPacket::setLengthField(QByteArray &data) +{ + const quint32 length = qToBigEndian(data.size() - 4); + data.replace(0, 4, reinterpret_cast(&length), 4); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshpacket_p.h b/src/plugins/coreplugin/ssh/sshpacket_p.h new file mode 100644 index 00000000000..7120f001fd5 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacket_p.h @@ -0,0 +1,137 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHPACKET_P_H +#define SSHPACKET_P_H + +#include "sshexception_p.h" + +#include +#include +#include + +#include + +namespace Core { +namespace Internal { + +enum SshPacketType { + SSH_MSG_DISCONNECT = 1, + SSH_MSG_IGNORE = 2, + SSH_MSG_UNIMPLEMENTED = 3, + SSH_MSG_DEBUG = 4, + SSH_MSG_SERVICE_REQUEST = 5, + SSH_MSG_SERVICE_ACCEPT = 6, + + SSH_MSG_KEXINIT = 20, + SSH_MSG_NEWKEYS = 21, + SSH_MSG_KEXDH_INIT = 30, + SSH_MSG_KEXDH_REPLY = 31, + + SSH_MSG_USERAUTH_REQUEST = 50, + SSH_MSG_USERAUTH_FAILURE = 51, + SSH_MSG_USERAUTH_SUCCESS = 52, + SSH_MSG_USERAUTH_BANNER = 53, + SSH_MSG_USERAUTH_PK_OK = 60, + SSH_MSG_USERAUTH_PASSWD_CHANGEREQ = 60, + + SSH_MSG_GLOBAL_REQUEST = 80, + SSH_MSG_REQUEST_SUCCESS = 81, + SSH_MSG_REQUEST_FAILURE = 82, + + SSH_MSG_CHANNEL_OPEN = 90, + SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91, + SSH_MSG_CHANNEL_OPEN_FAILURE = 92, + SSH_MSG_CHANNEL_WINDOW_ADJUST = 93, + SSH_MSG_CHANNEL_DATA = 94, + SSH_MSG_CHANNEL_EXTENDED_DATA = 95, + SSH_MSG_CHANNEL_EOF = 96, + SSH_MSG_CHANNEL_CLOSE = 97, + SSH_MSG_CHANNEL_REQUEST = 98, + SSH_MSG_CHANNEL_SUCCESS = 99, + SSH_MSG_CHANNEL_FAILURE = 100, +}; + +enum SshExtendedDataType { SSH_EXTENDED_DATA_STDERR = 1 }; + +class SshAbstractCryptoFacility; + +class AbstractSshPacket +{ +public: + virtual ~AbstractSshPacket(); + + void clear(); + bool isComplete() const; + SshPacketType type() const; + + static QByteArray encodeString(const QByteArray &string); + static QByteArray encodeMpInt(const Botan::BigInt &number); + template static QByteArray encodeInt(T value) + { + const T valMsb = qToBigEndian(value); + return QByteArray(reinterpret_cast(&valMsb), sizeof valMsb); + } + + static void setLengthField(QByteArray &data); + + void printRawBytes() const; // For Debugging. + + const QByteArray &rawData() const { return m_data; } + + struct Payload { const char *data; quint32 size; }; + Payload payLoad() const; + +protected: + AbstractSshPacket(); + + virtual quint32 cipherBlockSize() const=0; + virtual quint32 macLength() const=0; + virtual void calculateLength() const; + + quint32 length() const; + int paddingLength() const; + quint32 minPacketSize() const; + quint32 currentDataSize() const { return m_data.size(); } + QByteArray generateMac(const SshAbstractCryptoFacility &crypt, + quint32 seqNr) const; + + static const quint32 PaddingLengthOffset; + static const quint32 PayloadOffset; + static const quint32 TypeOffset; + static const quint32 MinPaddingLength; + + mutable QByteArray m_data; + mutable quint32 m_length; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshpacketparser.cpp b/src/plugins/coreplugin/ssh/sshpacketparser.cpp new file mode 100644 index 00000000000..2f339c03d92 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacketparser.cpp @@ -0,0 +1,153 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshpacketparser_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { quint32 size(const QByteArray &data) { return data.size(); } } + +QString SshPacketParser::asUserString(const QByteArray &rawString) +{ + QByteArray filteredString; + filteredString.resize(rawString.size()); + for (int i = 0; i < rawString.size(); ++i) { + const char c = rawString.at(i); + filteredString[i] + = std::isprint(c) || c == '\n' || c == '\r' || c == '\t' ? c : '?'; + } + return QString::fromUtf8(filteredString); +} + +bool SshPacketParser::asBool(const QByteArray &data, quint32 offset) +{ + if (size(data) <= offset) + throw SshPacketParseException(); + return data.at(offset); +} + +bool SshPacketParser::asBool(const QByteArray &data, quint32 *offset) +{ + bool b = asBool(data, *offset); + ++(*offset); + return b; +} + + +quint32 SshPacketParser::asUint32(const QByteArray &data, quint32 offset) +{ + if (size(data) < offset + 4) + throw SshPacketParseException(); + const quint32 value = ((data.at(offset) & 0xff) << 24) + + ((data.at(offset + 1) & 0xff) << 16) + + ((data.at(offset + 2) & 0xff) << 8) + (data.at(offset + 3) & 0xff); + return value; +} + +quint32 SshPacketParser::asUint32(const QByteArray &data, quint32 *offset) +{ + const quint32 v = asUint32(data, *offset); + *offset += 4; + return v; +} + +quint64 SshPacketParser::asUint64(const QByteArray &data, quint32 offset) +{ + if (size(data) < offset + 8) + throw SshPacketParseException(); + const quint64 value = (static_cast(data.at(offset) & 0xff) << 56) + + (static_cast(data.at(offset + 1) & 0xff) << 48) + + (static_cast(data.at(offset + 2) & 0xff) << 40) + + (static_cast(data.at(offset + 3) & 0xff) << 32) + + ((data.at(offset + 4) & 0xff) << 24) + + ((data.at(offset + 5) & 0xff) << 16) + + ((data.at(offset + 6) & 0xff) << 8) + + (data.at(offset + 7) & 0xff); + return value; +} + +quint64 SshPacketParser::asUint64(const QByteArray &data, quint32 *offset) +{ + const quint64 val = asUint64(data, *offset); + *offset += 8; + return val; +} + +QByteArray SshPacketParser::asString(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + if (size(data) < *offset + length) + throw SshPacketParseException(); + const QByteArray &string = data.mid(*offset, length); + *offset += length; + return string; +} + +QString SshPacketParser::asUserString(const QByteArray &data, quint32 *offset) +{ + return asUserString(asString(data, offset)); +} + +SshNameList SshPacketParser::asNameList(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + const int listEndPos = *offset + length; + if (data.size() < listEndPos) + throw SshPacketParseException(); + SshNameList names(length + 4); + int nextNameOffset = *offset; + int nextCommaOffset = data.indexOf(',', nextNameOffset); + while (nextNameOffset > 0 && nextNameOffset < listEndPos) { + const int stringEndPos = nextCommaOffset == -1 + || nextCommaOffset > listEndPos ? listEndPos : nextCommaOffset; + names.names << QByteArray(data.constData() + nextNameOffset, + stringEndPos - nextNameOffset); + nextNameOffset = nextCommaOffset + 1; + nextCommaOffset = data.indexOf(',', nextNameOffset); + } + *offset += length; + return names; +} + +Botan::BigInt SshPacketParser::asBigInt(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + if (length == 0) + return Botan::BigInt(); + const Botan::byte *numberStart + = reinterpret_cast(data.constData() + *offset); + *offset += length; + return Botan::BigInt::decode(numberStart, length); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshpacketparser_p.h b/src/plugins/coreplugin/ssh/sshpacketparser_p.h new file mode 100644 index 00000000000..253f256b7be --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacketparser_p.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHPACKETPARSER_P_H +#define SSHPACKETPARSER_P_H + +#include + +#include +#include +#include + +namespace Core { +namespace Internal { + +struct SshNameList +{ + SshNameList() : originalLength(0) {} + SshNameList(quint32 originalLength) : originalLength(originalLength) {} + quint32 originalLength; + QList names; +}; + +class SshPacketParseException { }; + +// This class's functions try to read a byte array at a certain offset +// as the respective chunk of data as specified in the SSH RFCs. +// If they succeed, they update the offset, so they can easily +// be called in succession by client code. +// For convenience, some have also versions that don't update the offset, +// so they can be called with rvalues if the new value is not needed. +// If they fail, they throw an SshPacketParseException. +class SshPacketParser +{ +public: + static bool asBool(const QByteArray &data, quint32 offset); + static bool asBool(const QByteArray &data, quint32 *offset); + static quint16 asUint16(const QByteArray &data, quint32 offset); + static quint16 asUint16(const QByteArray &data, quint32 *offset); + static quint64 asUint64(const QByteArray &data, quint32 offset); + static quint64 asUint64(const QByteArray &data, quint32 *offset); + static quint32 asUint32(const QByteArray &data, quint32 offset); + static quint32 asUint32(const QByteArray &data, quint32 *offset); + static QByteArray asString(const QByteArray &data, quint32 *offset); + static QString asUserString(const QByteArray &data, quint32 *offset); + static SshNameList asNameList(const QByteArray &data, quint32 *offset); + static Botan::BigInt asBigInt(const QByteArray &data, quint32 *offset); + + static QString asUserString(const QByteArray &rawString); +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHPACKETPARSER_P_H diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess.cpp b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp new file mode 100644 index 00000000000..c9566e9aca9 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp @@ -0,0 +1,270 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshremoteprocess.h" +#include "sshremoteprocess_p.h" + +#include "sshdelayedsignal_p.h" +#include "sshincomingpacket_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { + +const QByteArray SshRemoteProcess::AbrtSignal("ABRT"); +const QByteArray SshRemoteProcess::AlrmSignal("ALRM"); +const QByteArray SshRemoteProcess::FpeSignal("FPE"); +const QByteArray SshRemoteProcess::HupSignal("HUP"); +const QByteArray SshRemoteProcess::IllSignal("ILL"); +const QByteArray SshRemoteProcess::IntSignal("INT"); +const QByteArray SshRemoteProcess::KillSignal("KILL"); +const QByteArray SshRemoteProcess::PipeSignal("PIPE"); +const QByteArray SshRemoteProcess::QuitSignal("QUIT"); +const QByteArray SshRemoteProcess::SegvSignal("SEGV"); +const QByteArray SshRemoteProcess::TermSignal("TERM"); +const QByteArray SshRemoteProcess::Usr1Signal("USR1"); +const QByteArray SshRemoteProcess::Usr2Signal("USR2"); + +SshRemoteProcess::SshRemoteProcess(const QByteArray &command, quint32 channelId, + Internal::SshSendFacility &sendFacility) + : d(new Internal::SshRemoteProcessPrivate(command, channelId, sendFacility, this)) +{ +} + +SshRemoteProcess::~SshRemoteProcess() +{ + Q_ASSERT(d->channelState() == Internal::SshRemoteProcessPrivate::Inactive + || d->channelState() == Internal::SshRemoteProcessPrivate::CloseRequested + || d->channelState() == Internal::SshRemoteProcessPrivate::Closed); + delete d; +} + +void SshRemoteProcess::addToEnvironment(const QByteArray &var, const QByteArray &value) +{ + if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) + d->m_env << qMakePair(var, value); // Cached locally and sent on start() +} + +void SshRemoteProcess::start() +{ + if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) { +#ifdef CREATOR_SSH_DEBUG + qDebug("process start requested, channel id = %u", d->localChannelId()); +#endif + d->requestSessionStart(); + } +} + +void SshRemoteProcess::sendSignal(const QByteArray &signal) +{ + try { + if (isRunning()) + d->m_sendFacility.sendChannelSignalPacket(d->remoteChannel(), + signal); + } catch (Botan::Exception &e) { + d->setError(QString::fromAscii(e.what())); + d->closeChannel(); + } +} + +void SshRemoteProcess::closeChannel() +{ + d->closeChannel(); +} + +void SshRemoteProcess::sendInput(const QByteArray &data) +{ + if (isRunning()) + d->sendData(data); +} + +bool SshRemoteProcess::isRunning() const +{ + return d->m_procState == Internal::SshRemoteProcessPrivate::Running; +} + +QString SshRemoteProcess::errorString() const { return d->errorString(); } + +int SshRemoteProcess::exitCode() const { return d->m_exitCode; } + +QByteArray SshRemoteProcess::exitSignal() const { return d->m_signal; } + +namespace Internal { + +SshRemoteProcessPrivate::SshRemoteProcessPrivate(const QByteArray &command, + quint32 channelId, SshSendFacility &sendFacility, SshRemoteProcess *proc) + : AbstractSshChannel(channelId, sendFacility), m_procState(NotYetStarted), + m_wasRunning(false), m_exitCode(0), m_command(command), m_proc(proc) +{ +} + +void SshRemoteProcessPrivate::setProcState(ProcessState newState) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("channel: old state = %d,new state = %d", m_procState, newState); +#endif + m_procState = newState; + if (newState == StartFailed) { + createClosedSignal(SshRemoteProcess::FailedToStart); + } else if (newState == Running) { + m_wasRunning = true; + createStartedSignal(); + } +} + +void SshRemoteProcessPrivate::closeHook() +{ + if (m_wasRunning) { + if (!m_signal.isEmpty()) + createClosedSignal(SshRemoteProcess::KilledBySignal); + else + createClosedSignal(SshRemoteProcess::ExitedNormally); + } +} + +void SshRemoteProcessPrivate::handleOpenSuccessInternal() +{ + foreach (const EnvVar &envVar, m_env) { + m_sendFacility.sendEnvPacket(remoteChannel(), envVar.first, + envVar.second); + } + + m_sendFacility.sendExecPacket(remoteChannel(), m_command); + setProcState(ExecRequested); +} + +void SshRemoteProcessPrivate::handleOpenFailureInternal() +{ + setProcState(StartFailed); +} + +void SshRemoteProcessPrivate::handleChannelSuccess() +{ + if (m_procState != ExecRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_SUCCESS message."); + } + setProcState(Running); +} + +void SshRemoteProcessPrivate::handleChannelFailure() +{ + if (m_procState != ExecRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_FAILURE message."); + } + + setProcState(StartFailed); + closeChannel(); +} + +void SshRemoteProcessPrivate::handleChannelDataInternal(const QByteArray &data) +{ + createOutputAvailableSignal(data); +} + +void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data) +{ + if (type != SSH_EXTENDED_DATA_STDERR) + qWarning("Unknown extended data type %u", type); + else + createErrorOutputAvailableSignal(data); +} + +void SshRemoteProcessPrivate::handleChannelRequest(const SshIncomingPacket &packet) +{ + checkChannelActive(); + const QByteArray &requestType = packet.extractChannelRequestType(); + if (requestType == SshIncomingPacket::ExitStatusType) { + const SshChannelExitStatus status = packet.extractChannelExitStatus(); +#ifdef CREATOR_SSH_DEBUG + qDebug("Process exiting with exit code %d", status.exitStatus); +#endif + m_exitCode = status.exitStatus; + m_procState = Exited; + } else if (requestType == SshIncomingPacket::ExitSignalType) { + const SshChannelExitSignal &signal = packet.extractChannelExitSignal(); +#ifdef CREATOR_SSH_DEBUG + qDebug("Exit due to signal %s", signal.signal.data()); +#endif + setError(signal.error); + m_signal = signal.signal; + m_procState = Exited; + } else { + qWarning("Ignoring unknown request type '%s'", requestType.data()); + } +} + +void SshRemoteProcessPrivate::createStartedSignal() +{ + new SshRemoteProcessStartedSignal(this, QWeakPointer(m_proc)); +} + +void SshRemoteProcessPrivate::emitStartedSignal() +{ + emit m_proc->started(); +} + +void SshRemoteProcessPrivate::createOutputAvailableSignal(const QByteArray &output) +{ + new SshRemoteProcessOutputAvailableSignal(this, + QWeakPointer(m_proc), output); +} + +void SshRemoteProcessPrivate::emitOutputAvailableSignal(const QByteArray &output) +{ + emit m_proc->outputAvailable(output); +} + +void SshRemoteProcessPrivate::createErrorOutputAvailableSignal(const QByteArray &output) +{ + new SshRemoteProcessErrorOutputAvailableSignal(this, + QWeakPointer(m_proc), output); +} + +void SshRemoteProcessPrivate::emitErrorOutputAvailableSignal(const QByteArray &output) +{ + emit m_proc->errorOutputAvailable(output); +} + +void SshRemoteProcessPrivate::createClosedSignal(int exitStatus) +{ + new SshRemoteProcessClosedSignal(this, + QWeakPointer(m_proc), exitStatus); +} + +void SshRemoteProcessPrivate::emitClosedSignal(int exitStatus) +{ + emit m_proc->closed(exitStatus); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess.h b/src/plugins/coreplugin/ssh/sshremoteprocess.h new file mode 100644 index 00000000000..941894990f6 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess.h @@ -0,0 +1,130 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHREMOTECOMMAND_H +#define SSHREMOTECOMMAND_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +QT_END_NAMESPACE + +namespace Core { +namespace Internal { +class SshChannelManager; +class SshRemoteProcessPrivate; +class SshSendFacility; +} // namespace Internal + + +/* + * This class implements an SSH channel for running a remote process. + * Objects are created via SshConnection::createRemoteProcess. + * The process is started via the start() member function. + * A closeChannel() function is provided, but rarely useful, because + * a) when the process ends, the channel is closed automatically, and + * b) closing a channel will not necessarily kill the remote process. + * Therefore, the only sensible use case for calling closeChannel() is to + * get rid of an SshRemoteProces object before the process is actually started. + * Note that the process does not have a terminal, so you can't use it + * for applications that require one. + */ +class CORE_EXPORT SshRemoteProcess : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(SshRemoteProcess) + + friend class Internal::SshChannelManager; + friend class Internal::SshRemoteProcessPrivate; + +public: + typedef QSharedPointer Ptr; + enum ExitStatus { FailedToStart, KilledBySignal, ExitedNormally }; + + static const QByteArray AbrtSignal; + static const QByteArray AlrmSignal; + static const QByteArray FpeSignal; + static const QByteArray HupSignal; + static const QByteArray IllSignal; + static const QByteArray IntSignal; + static const QByteArray KillSignal; + static const QByteArray PipeSignal; + static const QByteArray QuitSignal; + static const QByteArray SegvSignal; + static const QByteArray TermSignal; + static const QByteArray Usr1Signal; + static const QByteArray Usr2Signal; + + ~SshRemoteProcess(); + + /* + * Note that this is of limited value in practice, because servers are + * usually configured to ignore such requests for security reasons. + */ + void addToEnvironment(const QByteArray &var, const QByteArray &value); + + void start(); + void closeChannel(); + + bool isRunning() const; + QString errorString() const; + int exitCode() const; + QByteArray exitSignal() const; + + // Note: This is ignored by the OpenSSH server. + void sendSignal(const QByteArray &signal); + void kill() { sendSignal(KillSignal); } + + void sendInput(const QByteArray &data); // Should usually have a trailing newline. + +signals: + void started(); + void outputAvailable(const QByteArray &output); + void errorOutputAvailable(const QByteArray &output); + + /* + * Parameter is of type ExitStatus, but we use int because of + * signal/slot awkwardness (full namespace required). + */ + void closed(int exitStatus); + +private: + SshRemoteProcess(const QByteArray &command, quint32 channelId, + Internal::SshSendFacility &sendFacility); + + Internal::SshRemoteProcessPrivate *d; +}; + +} // namespace Core + +#endif // SSHREMOTECOMMAND_H diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess_p.h b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h new file mode 100644 index 00000000000..951ca247310 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h @@ -0,0 +1,96 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHREMOTEPROCESS_P_H +#define SSHREMOTEPROCESS_P_H + +#include "sshchannel_p.h" + +#include +#include + +namespace Core { +class SshRemoteProcess; + +namespace Internal { +class SshSendFacility; + +class SshRemoteProcessPrivate : public AbstractSshChannel +{ + friend class Core::SshRemoteProcess; +public: + enum ProcessState { + NotYetStarted, ExecRequested, StartFailed,Running, Exited + }; + + virtual void handleChannelSuccess(); + virtual void handleChannelFailure(); + + virtual void closeHook(); + + void emitStartedSignal(); + void emitOutputAvailableSignal(const QByteArray &output); + void emitErrorOutputAvailableSignal(const QByteArray &output); + void emitClosedSignal(int exitStatus); + +private: + SshRemoteProcessPrivate(const QByteArray &command, quint32 channelId, + SshSendFacility &sendFacility, SshRemoteProcess *proc); + + virtual void handleOpenSuccessInternal(); + virtual void handleOpenFailureInternal(); + virtual void handleChannelDataInternal(const QByteArray &data); + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data); + virtual void handleChannelRequest(const SshIncomingPacket &packet); + + void setProcState(ProcessState newState); + + void createStartedSignal(); + void createOutputAvailableSignal(const QByteArray &output); + void createErrorOutputAvailableSignal(const QByteArray &output); + void createClosedSignal(int exitStatus); + + ProcessState m_procState; + bool m_wasRunning; + QByteArray m_signal; + int m_exitCode; + + const QByteArray m_command; + + typedef QPair EnvVar; + QList m_env; + + SshRemoteProcess *m_proc; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHREMOTEPROCESS_P_H diff --git a/src/plugins/coreplugin/ssh/sshsendfacility.cpp b/src/plugins/coreplugin/ssh/sshsendfacility.cpp new file mode 100644 index 00000000000..3c793af24d7 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshsendfacility.cpp @@ -0,0 +1,191 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshsendfacility_p.h" + +#include "sshkeyexchange_p.h" +#include "sshoutgoingpacket_p.h" + +#include + +namespace Core { +namespace Internal { + +SshSendFacility::SshSendFacility(QTcpSocket *socket) + : m_clientSeqNr(0), m_socket(socket), + m_outgoingPacket(m_encrypter, m_clientSeqNr) +{ +} + +void SshSendFacility::sendPacket() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Sending packet, client seq nr is %u", m_clientSeqNr); +#endif + m_socket->write(m_outgoingPacket.rawData()); + ++m_clientSeqNr; +} + +void SshSendFacility::reset() +{ + m_clientSeqNr = 0; + m_encrypter.clearKeys(); +} + +void SshSendFacility::recreateKeys(const SshKeyExchange &keyExchange) +{ + m_encrypter.recreateKeys(keyExchange); +} + +void SshSendFacility::createAuthenticationKey(const QByteArray &privKeyFileContents) +{ + m_encrypter.createAuthenticationKey(privKeyFileContents); +} + +SshOutgoingPacket::Payload SshSendFacility::sendKeyExchangeInitPacket() +{ + m_outgoingPacket.generateKeyExchangeInitPacket(); + sendPacket(); + return m_outgoingPacket.payLoad(); +} + +void SshSendFacility::sendKeyDhInitPacket(const Botan::BigInt &e) +{ + m_outgoingPacket.generateKeyDhInitPacket(e); + sendPacket(); +} + +void SshSendFacility::sendNewKeysPacket() +{ + m_outgoingPacket.generateNewKeysPacket(); + sendPacket(); +} + +void SshSendFacility::sendDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString) +{ + m_outgoingPacket.generateDisconnectPacket(reason, reasonString); + sendPacket(); + } + +void SshSendFacility::sendMsgUnimplementedPacket(quint32 serverSeqNr) +{ + m_outgoingPacket.generateMsgUnimplementedPacket(serverSeqNr); + sendPacket(); +} + +void SshSendFacility::sendUserAuthServiceRequestPacket() +{ + m_outgoingPacket.generateUserAuthServiceRequestPacket(); + sendPacket(); +} + +void SshSendFacility::sendUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd) +{ + m_outgoingPacket.generateUserAuthByPwdRequestPacket(user, service, pwd); + sendPacket(); + } + +void SshSendFacility::sendUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service) +{ + m_outgoingPacket.generateUserAuthByKeyRequestPacket(user, service); + sendPacket(); +} + +void SshSendFacility::sendRequestFailurePacket() +{ + m_outgoingPacket.generateRequestFailurePacket(); + sendPacket(); +} + +void SshSendFacility::sendSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize) +{ + m_outgoingPacket.generateSessionPacket(channelId, windowSize, + maxPacketSize); + sendPacket(); +} + +void SshSendFacility::sendEnvPacket(quint32 remoteChannel, + const QByteArray &var, const QByteArray &value) +{ + m_outgoingPacket.generateEnvPacket(remoteChannel, var, value); + sendPacket(); +} + +void SshSendFacility::sendExecPacket(quint32 remoteChannel, + const QByteArray &command) +{ + m_outgoingPacket.generateExecPacket(remoteChannel, command); + sendPacket(); +} + +void SshSendFacility::sendSftpPacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateSftpPacket(remoteChannel); + sendPacket(); +} + +void SshSendFacility::sendWindowAdjustPacket(quint32 remoteChannel, + quint32 bytesToAdd) +{ + m_outgoingPacket.generateWindowAdjustPacket(remoteChannel, bytesToAdd); + sendPacket(); +} + +void SshSendFacility::sendChannelDataPacket(quint32 remoteChannel, + const QByteArray &data) +{ + m_outgoingPacket.generateChannelDataPacket(remoteChannel, data); + sendPacket(); +} + +void SshSendFacility::sendChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName) +{ + m_outgoingPacket.generateChannelSignalPacket(remoteChannel, signalName); + sendPacket(); +} + +void SshSendFacility::sendChannelEofPacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateChannelEofPacket(remoteChannel); + sendPacket(); +} + +void SshSendFacility::sendChannelClosePacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateChannelClosePacket(remoteChannel); + sendPacket(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshsendfacility_p.h b/src/plugins/coreplugin/ssh/sshsendfacility_p.h new file mode 100644 index 00000000000..6f1cdf76f38 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshsendfacility_p.h @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCONNECTIONOUTSTATE_P_H +#define SSHCONNECTIONOUTSTATE_P_H + +#include "sshcryptofacility_p.h" +#include "sshoutgoingpacket_p.h" + +QT_BEGIN_NAMESPACE +class QTcpSocket; +QT_END_NAMESPACE + + +namespace Core { +namespace Internal { +class SshKeyExchange; + +class SshSendFacility +{ +public: + SshSendFacility(QTcpSocket *socket); + void reset(); + void recreateKeys(const SshKeyExchange &keyExchange); + void createAuthenticationKey(const QByteArray &privKeyFileContents); + + SshOutgoingPacket::Payload sendKeyExchangeInitPacket(); + void sendKeyDhInitPacket(const Botan::BigInt &e); + void sendNewKeysPacket(); + void sendDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString); + void sendMsgUnimplementedPacket(quint32 serverSeqNr); + void sendUserAuthServiceRequestPacket(); + void sendUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd); + void sendUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service); + void sendRequestFailurePacket(); + void sendSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize); + void sendEnvPacket(quint32 remoteChannel, const QByteArray &var, + const QByteArray &value); + void sendExecPacket(quint32 remoteChannel, const QByteArray &command); + void sendSftpPacket(quint32 remoteChannel); + void sendWindowAdjustPacket(quint32 remoteChannel, quint32 bytesToAdd); + void sendChannelDataPacket(quint32 remoteChannel, const QByteArray &data); + void sendChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName); + void sendChannelEofPacket(quint32 remoteChannel); + void sendChannelClosePacket(quint32 remoteChannel); + +private: + void sendPacket(); + + quint32 m_clientSeqNr; + SshEncryptionFacility m_encrypter; + QTcpSocket *m_socket; + SshOutgoingPacket m_outgoingPacket; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCONNECTIONOUTSTATE_P_H diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 626f1f1b3a6..0756b1b77dc 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -144,7 +144,7 @@ void CodepasterPlugin::extensionsInitialized() { } -void CodepasterPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown() { // Delete temporary, fetched files foreach(const QString &fetchedSnippet, m_fetchedSnippets) { @@ -152,6 +152,7 @@ void CodepasterPlugin::aboutToShutdown() if (file.exists()) file.remove(); } + return SynchronousShutdown; } void CodepasterPlugin::postEditor() diff --git a/src/plugins/cpaster/cpasterplugin.h b/src/plugins/cpaster/cpasterplugin.h index b75158b0c9a..6dcc8a902b6 100644 --- a/src/plugins/cpaster/cpasterplugin.h +++ b/src/plugins/cpaster/cpasterplugin.h @@ -55,7 +55,7 @@ public: virtual bool initialize(const QStringList &arguments, QString *error_message); virtual void extensionsInitialized(); - virtual void aboutToShutdown(); + virtual ShutdownFlag aboutToShutdown(); public slots: void postEditor(); diff --git a/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp similarity index 87% rename from src/plugins/cppeditor/cppcheckundefinedsymbols.cpp rename to src/plugins/cppeditor/cppchecksymbols.cpp index 0e16c51bb8f..0e9af30b392 100644 --- a/src/plugins/cppeditor/cppcheckundefinedsymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -27,7 +27,7 @@ ** **************************************************************************/ -#include "cppcheckundefinedsymbols.h" +#include "cppchecksymbols.h" #include #include @@ -117,8 +117,8 @@ protected: return; } else if (const QualifiedNameId *q = name->asQualifiedNameId()) { - for (unsigned i = 0; i < q->nameCount(); ++i) - addType(q->nameAt(i)); + addType(q->base()); + addType(q->name()); } else if (name->isNameId() || name->isTemplateNameId()) { addType(name->identifier()); @@ -255,13 +255,13 @@ protected: } // end of anonymous namespace -CheckUndefinedSymbols::Future CheckUndefinedSymbols::go(Document::Ptr doc, const LookupContext &context) +CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &context) { Q_ASSERT(doc); - return (new CheckUndefinedSymbols(doc, context))->start(); + return (new CheckSymbols(doc, context))->start(); } -CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context) +CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context) : ASTVisitor(doc->translationUnit()), _doc(doc), _context(context) { _fileName = doc->fileName(); @@ -270,10 +270,10 @@ CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupCont _scopes = collectTypes.scopes(); } -CheckUndefinedSymbols::~CheckUndefinedSymbols() +CheckSymbols::~CheckSymbols() { } -void CheckUndefinedSymbols::run() +void CheckSymbols::run() { if (! isCanceled()) runFunctor(); @@ -281,7 +281,7 @@ void CheckUndefinedSymbols::run() reportFinished(); } -void CheckUndefinedSymbols::runFunctor() +void CheckSymbols::runFunctor() { _diagnosticMessages.clear(); @@ -291,14 +291,14 @@ void CheckUndefinedSymbols::runFunctor() } } -bool CheckUndefinedSymbols::warning(unsigned line, unsigned column, const QString &text, unsigned length) +bool CheckSymbols::warning(unsigned line, unsigned column, const QString &text, unsigned length) { Document::DiagnosticMessage m(Document::DiagnosticMessage::Warning, _fileName, line, column, text, length); _diagnosticMessages.append(m); return false; } -bool CheckUndefinedSymbols::warning(AST *ast, const QString &text) +bool CheckSymbols::warning(AST *ast, const QString &text) { const Token &firstToken = tokenAt(ast->firstToken()); const Token &lastToken = tokenAt(ast->lastToken() - 1); @@ -311,7 +311,7 @@ bool CheckUndefinedSymbols::warning(AST *ast, const QString &text) return false; } -bool CheckUndefinedSymbols::preVisit(AST *) +bool CheckSymbols::preVisit(AST *) { if (isCanceled()) return false; @@ -319,7 +319,7 @@ bool CheckUndefinedSymbols::preVisit(AST *) return true; } -bool CheckUndefinedSymbols::visit(NamespaceAST *ast) +bool CheckSymbols::visit(NamespaceAST *ast) { if (ast->identifier_token) { const Token &tok = tokenAt(ast->identifier_token); @@ -334,22 +334,22 @@ bool CheckUndefinedSymbols::visit(NamespaceAST *ast) return true; } -bool CheckUndefinedSymbols::visit(UsingDirectiveAST *) +bool CheckSymbols::visit(UsingDirectiveAST *) { return true; } -bool CheckUndefinedSymbols::visit(SimpleDeclarationAST *) +bool CheckSymbols::visit(SimpleDeclarationAST *) { return true; } -bool CheckUndefinedSymbols::visit(NamedTypeSpecifierAST *) +bool CheckSymbols::visit(NamedTypeSpecifierAST *) { return true; } -void CheckUndefinedSymbols::checkNamespace(NameAST *name) +void CheckSymbols::checkNamespace(NameAST *name) { if (! name) return; @@ -369,9 +369,9 @@ void CheckUndefinedSymbols::checkNamespace(NameAST *name) warning(line, column, QCoreApplication::translate("CheckUndefinedSymbols", "Expected a namespace-name"), length); } -void CheckUndefinedSymbols::checkName(NameAST *ast) +void CheckSymbols::checkName(NameAST *ast) { - if (ast->name) { + if (ast && ast->name) { if (const Identifier *ident = ast->name->identifier()) { const QByteArray id = QByteArray::fromRawData(ident->chars(), ident->size()); if (_potentialTypes.contains(id)) { @@ -383,25 +383,25 @@ void CheckUndefinedSymbols::checkName(NameAST *ast) } } -bool CheckUndefinedSymbols::visit(SimpleNameAST *ast) +bool CheckSymbols::visit(SimpleNameAST *ast) { checkName(ast); return true; } -bool CheckUndefinedSymbols::visit(TemplateIdAST *ast) +bool CheckSymbols::visit(TemplateIdAST *ast) { checkName(ast); return true; } -bool CheckUndefinedSymbols::visit(DestructorNameAST *ast) +bool CheckSymbols::visit(DestructorNameAST *ast) { checkName(ast); return true; } -bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast) +bool CheckSymbols::visit(QualifiedNameAST *ast) { if (ast->name) { Scope *scope = findScope(ast); @@ -439,7 +439,7 @@ bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast) return false; } -bool CheckUndefinedSymbols::visit(TypenameTypeParameterAST *ast) +bool CheckSymbols::visit(TypenameTypeParameterAST *ast) { if (ast->name && ast->name->name) { if (const Identifier *templId = ast->name->name->identifier()) { @@ -454,24 +454,24 @@ bool CheckUndefinedSymbols::visit(TypenameTypeParameterAST *ast) return true; } -bool CheckUndefinedSymbols::visit(TemplateTypeParameterAST *ast) +bool CheckSymbols::visit(TemplateTypeParameterAST *ast) { checkName(ast->name); return true; } -bool CheckUndefinedSymbols::visit(TemplateDeclarationAST *ast) +bool CheckSymbols::visit(TemplateDeclarationAST *ast) { _templateDeclarationStack.append(ast); return true; } -void CheckUndefinedSymbols::endVisit(TemplateDeclarationAST *) +void CheckSymbols::endVisit(TemplateDeclarationAST *) { _templateDeclarationStack.takeFirst(); } -void CheckUndefinedSymbols::addTypeUsage(const Use &use) +void CheckSymbols::addTypeUsage(const Use &use) { _typeUsages.append(use); @@ -479,7 +479,7 @@ void CheckUndefinedSymbols::addTypeUsage(const Use &use) flush(); } -void CheckUndefinedSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast) +void CheckSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast) { if (! b) return; @@ -500,7 +500,7 @@ void CheckUndefinedSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast) //qDebug() << "added use" << oo(ast->name) << line << column << length; } -void CheckUndefinedSymbols::addTypeUsage(const QList &candidates, NameAST *ast) +void CheckSymbols::addTypeUsage(const QList &candidates, NameAST *ast) { unsigned startToken = ast->firstToken(); if (DestructorNameAST *dtor = ast->asDestructorName()) @@ -530,7 +530,7 @@ void CheckUndefinedSymbols::addTypeUsage(const QList &candidates, Name } } -unsigned CheckUndefinedSymbols::startOfTemplateDeclaration(TemplateDeclarationAST *ast) const +unsigned CheckSymbols::startOfTemplateDeclaration(TemplateDeclarationAST *ast) const { if (ast->declaration) { if (TemplateDeclarationAST *templ = ast->declaration->asTemplateDeclaration()) @@ -542,7 +542,7 @@ unsigned CheckUndefinedSymbols::startOfTemplateDeclaration(TemplateDeclarationAS return ast->firstToken(); } -Scope *CheckUndefinedSymbols::findScope(AST *ast) const +Scope *CheckSymbols::findScope(AST *ast) const { Scope *scope = 0; @@ -561,7 +561,7 @@ Scope *CheckUndefinedSymbols::findScope(AST *ast) const return scope; } -void CheckUndefinedSymbols::flush() +void CheckSymbols::flush() { if (_typeUsages.isEmpty()) return; diff --git a/src/plugins/cppeditor/cppcheckundefinedsymbols.h b/src/plugins/cppeditor/cppchecksymbols.h similarity index 83% rename from src/plugins/cppeditor/cppcheckundefinedsymbols.h rename to src/plugins/cppeditor/cppchecksymbols.h index 4dbc0b52f3c..1e5d74c1b32 100644 --- a/src/plugins/cppeditor/cppcheckundefinedsymbols.h +++ b/src/plugins/cppeditor/cppchecksymbols.h @@ -27,8 +27,8 @@ ** **************************************************************************/ -#ifndef CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H -#define CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H +#ifndef CPLUSPLUS_CHECKSYMBOLS_H +#define CPLUSPLUS_CHECKSYMBOLS_H #include "cppsemanticinfo.h" @@ -41,12 +41,12 @@ namespace CPlusPlus { -class CheckUndefinedSymbols: +class CheckSymbols: protected ASTVisitor, public QtConcurrent::RunFunctionTaskBase { public: - virtual ~CheckUndefinedSymbols(); + virtual ~CheckSymbols(); typedef CppEditor::Internal::SemanticInfo::Use Use; @@ -56,11 +56,27 @@ public: typedef QFuture Future; static Future go(Document::Ptr doc, const LookupContext &context); + static QMap > chunks(const QFuture &future, int from, int to) + { + QMap > chunks; + + for (int i = from; i < to; ++i) { + const Use use = future.resultAt(i); + if (! use.line) + continue; // skip it, it's an invalid use. + + const int blockNumber = use.line - 1; + chunks[blockNumber].append(use); + } + + return chunks; + } + protected: using ASTVisitor::visit; using ASTVisitor::endVisit; - CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context); + CheckSymbols(Document::Ptr doc, const LookupContext &context); bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0); bool warning(AST *ast, const QString &text); @@ -107,4 +123,4 @@ private: } // end of namespace CPlusPlus -#endif // CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H +#endif // CPLUSPLUS_CHECKSYMBOLS_H diff --git a/src/plugins/cppeditor/cppdeclfromdef.cpp b/src/plugins/cppeditor/cppdeclfromdef.cpp new file mode 100644 index 00000000000..23a11d7a500 --- /dev/null +++ b/src/plugins/cppeditor/cppdeclfromdef.cpp @@ -0,0 +1,250 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "cppdeclfromdef.h" + +#include //### remove +#include //###remove + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace CPlusPlus; +using namespace CppEditor::Internal; +using namespace CppTools; + +using CppEditor::CppRefactoringChanges; + +namespace { + +class InsertionPointFinder: public ASTVisitor +{ +public: + InsertionPointFinder(Document::Ptr doc, const QString &className) + : ASTVisitor(doc->translationUnit()) + , _doc(doc) + , _className(className) + {} + + void operator()(int *line, int *column) + { + if (!line && !column) + return; + _line = 0; + _column = 0; + + AST *ast = translationUnit()->ast(); + accept(ast); + + if (line) + *line = _line - 1; + if (column) + *column = _column - 1; + } + +protected: + using ASTVisitor::visit; + + bool visit(ClassSpecifierAST *ast) + { + if (!ast->symbol || _className != QLatin1String(ast->symbol->identifier()->chars())) + return true; + + unsigned currentVisibility = (tokenKind(ast->classkey_token) == T_CLASS) ? T_PUBLIC : T_PRIVATE; + unsigned insertBefore = 0; + + for (DeclarationListAST *iter = ast->member_specifier_list; iter; iter = iter->next) { + DeclarationAST *decl = iter->value; + if (AccessDeclarationAST *xsDecl = decl->asAccessDeclaration()) { + const unsigned token = xsDecl->access_specifier_token; + const int kind = tokenKind(token); + if (kind == T_PUBLIC) { + currentVisibility = T_PUBLIC; + } else if (kind == T_PROTECTED) { + if (currentVisibility == T_PUBLIC) { + insertBefore = token; + break; + } else { + currentVisibility = T_PROTECTED; + } + } else if (kind == T_PRIVATE) { + if (currentVisibility == T_PUBLIC + || currentVisibility == T_PROTECTED) { + insertBefore = token; + break; + } else { + currentVisibility = T_PRIVATE; + } + } + } + } + + if (!insertBefore) + insertBefore = ast->rbrace_token; + + getTokenStartPosition(insertBefore, &_line, &_column); + + return false; + } + +private: + Document::Ptr _doc; + QString _className; + + unsigned _line; + unsigned _column; +}; + +QString prettyMinimalType(const FullySpecifiedType &ty, + const LookupContext &context, + Scope *source, + ClassOrNamespace *target) +{ + Overview oo; + + if (const NamedType *namedTy = ty->asNamedType()) + return oo.prettyTypeWithName(ty, context.minimalName(namedTy->name(), + source, + target), + context.control().data()); + else + return oo(ty); +} + +} // anonymous namespace + +DeclFromDef::DeclFromDef(TextEditor::BaseTextEditor *editor) + : CppQuickFixOperation(editor) +{} + +QString DeclFromDef::description() const +{ + return QCoreApplication::tr("Create Declaration from Definition", "DeclFromDef"); +} + +int DeclFromDef::match(const QList &path) +{ + m_targetFileName.clear(); + m_targetSymbolName.clear(); + m_decl.clear(); + + FunctionDefinitionAST *funDef = 0; + int idx = 0; + for (; idx < path.size(); ++idx) { + AST *node = path.at(idx); + if (FunctionDefinitionAST *candidate = node->asFunctionDefinition()) { + if (!funDef) + funDef = candidate; + } else if (node->asClassSpecifier()) { + return -1; + } + } + + if (!funDef || !funDef->symbol) + return -1; + + Function *method = funDef->symbol; + LookupContext context(document(), snapshot()); + + if (ClassOrNamespace *targetBinding = context.lookupParent(method)) { + foreach (Symbol *s, targetBinding->symbols()) { + if (Class *clazz = s->asClass()) { + m_targetFileName = QLatin1String(clazz->fileName()); + m_targetSymbolName = QLatin1String(clazz->identifier()->chars()); + + m_decl = generateDeclaration(method, targetBinding); + + return idx; + } // ### TODO: support insertion into namespaces + } + } + + return -1; +} + +void DeclFromDef::createChanges() +{ + CppRefactoringChanges *changes = refactoringChanges(); + + Document::Ptr targetDoc = changes->document(m_targetFileName); + InsertionPointFinder findInsertionPoint(targetDoc, m_targetSymbolName); + int line = 0, column = 0; + findInsertionPoint(&line, &column); + + int targetPosition1 = changes->positionInFile(m_targetFileName, line, column); + int targetPosition2 = changes->positionInFile(m_targetFileName, line + 1, 0) - 1; + + Utils::ChangeSet target; + target.insert(targetPosition1, m_decl); + changes->changeFile(m_targetFileName, target); + + changes->reindent(m_targetFileName, + Utils::ChangeSet::Range(targetPosition1, targetPosition2)); + + changes->openEditor(m_targetFileName, line, column); +} + +QString DeclFromDef::generateDeclaration(Function *method, ClassOrNamespace *targetBinding) +{ + LookupContext context(document(), snapshot()); + Overview oo; + QString decl; + + decl.append(prettyMinimalType(method->returnType(), + context, + method->scope(), + targetBinding)); + + decl.append(QLatin1Char(' ')); + decl.append(QLatin1String(method->name()->identifier()->chars())); + decl.append(QLatin1Char('(')); + for (unsigned argIdx = 0; argIdx < method->argumentCount(); ++argIdx) { + if (argIdx > 0) + decl.append(QLatin1String(", ")); + Argument *arg = method->argumentAt(argIdx)->asArgument(); + decl.append(prettyMinimalType(arg->type(), + context, + method->members(), + targetBinding)); + decl.append(QLatin1Char(' ')); + decl.append(oo(arg->name())); + } + decl.append(QLatin1String(");\n\n")); + + return decl; +} diff --git a/src/plugins/cppeditor/cppdeclfromdef.h b/src/plugins/cppeditor/cppdeclfromdef.h new file mode 100644 index 00000000000..8cbebc9271b --- /dev/null +++ b/src/plugins/cppeditor/cppdeclfromdef.h @@ -0,0 +1,67 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef CPPDECLFROMDEF_H +#define CPPDECLFROMDEF_H + +#include "cppquickfix.h" + +#include + +namespace CPlusPlus { +class ClassOrNamespace; +} // namespace CPlusPlus + +namespace CppEditor { +namespace Internal { + +class DeclFromDef: public CppQuickFixOperation +{ +public: + DeclFromDef(TextEditor::BaseTextEditor *editor); + + virtual int match(const QList &path); + virtual QString description() const; + virtual void createChanges(); + +protected: + virtual QString generateDeclaration(CPlusPlus::Function *method, + CPlusPlus::ClassOrNamespace *targetBinding); + +private: + QString m_targetFileName; + QString m_targetSymbolName; + QString m_decl; +}; + + +} // namespace Internal +} // namespace CppEditor + +#endif // CPPDECLFROMDEF_H diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index cc4238013a0..adef080f35f 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -31,10 +31,8 @@ #include "cppeditorconstants.h" #include "cppplugin.h" #include "cpphighlighter.h" -#include "cppcheckundefinedsymbols.h" - +#include "cppchecksymbols.h" #include "cppquickfix.h" -#include #include #include @@ -57,6 +55,7 @@ #include #include +#include #include #include #include @@ -97,7 +96,7 @@ #include enum { - UPDATE_METHOD_BOX_INTERVAL = 150, + UPDATE_OUTLINE_INTERVAL = 150, UPDATE_USES_INTERVAL = 300 }; @@ -129,47 +128,6 @@ static QList createSelections(QTextDocument *document return selections; } -static QList createSelections(QTextDocument *document, - const QList &msgs, - const QTextCharFormat &format) -{ - QList selections; - - QTextBlock currentBlock = document->firstBlock(); - unsigned currentLine = 1; - - foreach (const SemanticInfo::Use &use, msgs) { - QTextCursor cursor(document); - - if (currentLine != use.line) { - int delta = use.line - currentLine; - - if (delta >= 0) { - while (delta--) - currentBlock = currentBlock.next(); - } else { - currentBlock = document->findBlockByNumber(use.line - 1); - } - - currentLine = use.line; - } - - const int pos = currentBlock.position() + use.column - 1; - if (pos < 0) - continue; - - cursor.setPosition(pos); - cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, use.length); - - QTextEdit::ExtraSelection sel; - sel.cursor = cursor; - sel.format = format; - selections.append(sel); - } - - return selections; -} - namespace { class OverviewTreeView : public QTreeView @@ -189,6 +147,32 @@ public: } }; +class OverviewProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + OverviewProxyModel(CPlusPlus::OverviewModel *sourceModel, QObject *parent) : + QSortFilterProxyModel(parent), + m_sourceModel(sourceModel) + { + setSourceModel(m_sourceModel); + } + + bool filterAcceptsRow(int sourceRow,const QModelIndex &sourceParent) const + { + // ignore generated symbols, e.g. by macro expansion (Q_OBJECT) + const QModelIndex sourceIndex = m_sourceModel->index(sourceRow, 0, sourceParent); + CPlusPlus::Symbol *symbol = m_sourceModel->symbolFromIndex(sourceIndex); + if (symbol && symbol->isGenerated()) + return false; + + return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); + } +private: + CPlusPlus::OverviewModel *m_sourceModel; +}; + + class FindLocalUses: protected ASTVisitor { Scope *_functionScope; @@ -509,7 +493,7 @@ protected: { const Name *name = function->name(); if (const QualifiedNameId *q = name->asQualifiedNameId()) - name = q->unqualifiedNameId(); + name = q->name(); if (_declarationName->isEqualTo(name)) _functions->append(function); @@ -617,8 +601,10 @@ CPPEditor::CPPEditor(QWidget *parent) this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr))); } - m_highlighteRevision = 0; - connect(&m_highlightWatcher, SIGNAL(finished()), SLOT(highlightTypeUsages())); + m_highlightRevision = 0; + m_nextHighlightBlockNumber = 0; + connect(&m_highlightWatcher, SIGNAL(resultsReadyAt(int,int)), SLOT(highlightTypeUsages(int,int))); + connect(&m_highlightWatcher, SIGNAL(finished()), SLOT(finishTypeUsages())); } CPPEditor::~CPPEditor() @@ -638,51 +624,55 @@ TextEditor::BaseTextEditorEditable *CPPEditor::createEditableInterface() void CPPEditor::createToolBar(CPPEditorEditable *editable) { - m_methodCombo = new QComboBox; - m_methodCombo->setMinimumContentsLength(22); + m_outlineCombo = new QComboBox; + m_outlineCombo->setMinimumContentsLength(22); // Make the combo box prefer to expand - QSizePolicy policy = m_methodCombo->sizePolicy(); + QSizePolicy policy = m_outlineCombo->sizePolicy(); policy.setHorizontalPolicy(QSizePolicy::Expanding); - m_methodCombo->setSizePolicy(policy); + m_outlineCombo->setSizePolicy(policy); - QTreeView *methodView = new OverviewTreeView; - methodView->header()->hide(); - methodView->setItemsExpandable(false); - m_methodCombo->setView(methodView); - m_methodCombo->setMaxVisibleItems(20); + QTreeView *outlineView = new OverviewTreeView; + outlineView->header()->hide(); + outlineView->setItemsExpandable(false); + m_outlineCombo->setView(outlineView); + m_outlineCombo->setMaxVisibleItems(20); - m_overviewModel = new OverviewModel(this); - m_proxyModel = new QSortFilterProxyModel(this); - m_proxyModel->setSourceModel(m_overviewModel); - if (CppPlugin::instance()->sortedMethodOverview()) + m_outlineModel = new OverviewModel(this); + m_proxyModel = new OverviewProxyModel(m_outlineModel, this); + if (CppPlugin::instance()->sortedOutline()) m_proxyModel->sort(0, Qt::AscendingOrder); else - m_proxyModel->sort(-1, Qt::AscendingOrder); // don't sort yet, but set column for sortedMethodOverview() + m_proxyModel->sort(-1, Qt::AscendingOrder); // don't sort yet, but set column for sortedOutline() m_proxyModel->setDynamicSortFilter(true); m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - m_methodCombo->setModel(m_proxyModel); + m_outlineCombo->setModel(m_proxyModel); - m_methodCombo->setContextMenuPolicy(Qt::ActionsContextMenu); - m_sortAction = new QAction(tr("Sort alphabetically"), m_methodCombo); + m_outlineCombo->setContextMenuPolicy(Qt::ActionsContextMenu); + m_sortAction = new QAction(tr("Sort Alphabetically"), m_outlineCombo); m_sortAction->setCheckable(true); - m_sortAction->setChecked(sortedMethodOverview()); - connect(m_sortAction, SIGNAL(toggled(bool)), CppPlugin::instance(), SLOT(setSortedMethodOverview(bool))); - m_methodCombo->addAction(m_sortAction); + m_sortAction->setChecked(sortedOutline()); + connect(m_sortAction, SIGNAL(toggled(bool)), CppPlugin::instance(), SLOT(setSortedOutline(bool))); + m_outlineCombo->addAction(m_sortAction); - m_updateMethodBoxTimer = new QTimer(this); - m_updateMethodBoxTimer->setSingleShot(true); - m_updateMethodBoxTimer->setInterval(UPDATE_METHOD_BOX_INTERVAL); - connect(m_updateMethodBoxTimer, SIGNAL(timeout()), this, SLOT(updateMethodBoxIndexNow())); + m_updateOutlineTimer = new QTimer(this); + m_updateOutlineTimer->setSingleShot(true); + m_updateOutlineTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + connect(m_updateOutlineTimer, SIGNAL(timeout()), this, SLOT(updateOutlineNow())); + + m_updateOutlineIndexTimer = new QTimer(this); + m_updateOutlineIndexTimer->setSingleShot(true); + m_updateOutlineIndexTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + connect(m_updateOutlineIndexTimer, SIGNAL(timeout()), this, SLOT(updateOutlineIndexNow())); m_updateUsesTimer = new QTimer(this); m_updateUsesTimer->setSingleShot(true); m_updateUsesTimer->setInterval(UPDATE_USES_INTERVAL); connect(m_updateUsesTimer, SIGNAL(timeout()), this, SLOT(updateUsesNow())); - connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int))); - connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex())); - connect(m_methodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMethodBoxToolTip())); + connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateOutlineIndex())); + connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip())); connect(document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onContentsChanged(int,int,int))); connect(file(), SIGNAL(changed()), this, SLOT(updateFileName())); @@ -698,7 +688,7 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable) QToolBar *toolBar = static_cast(editable->toolBar()); QList actions = toolBar->actions(); QWidget *w = toolBar->widgetForAction(actions.first()); - static_cast(w->layout())->insertWidget(0, m_methodCombo, 1); + static_cast(w->layout())->insertWidget(0, m_outlineCombo, 1); } void CPPEditor::paste() @@ -806,10 +796,7 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc) m_semanticHighlighter->rehighlight(source); } - m_overviewModel->rebuild(doc); - OverviewTreeView *treeView = static_cast(m_methodCombo->view()); - treeView->sync(); - updateMethodBoxIndexNow(); + m_updateOutlineTimer->start(); } const Macro *CPPEditor::findCanonicalMacro(const QTextCursor &cursor, Document::Ptr doc) const @@ -985,19 +972,19 @@ void CPPEditor::onContentsChanged(int position, int charsRemoved, int charsAdded void CPPEditor::updateFileName() { } -void CPPEditor::jumpToMethod(int) +void CPPEditor::jumpToOutlineElement(int) { - QModelIndex index = m_proxyModel->mapToSource(m_methodCombo->view()->currentIndex()); - Symbol *symbol = m_overviewModel->symbolFromIndex(index); + QModelIndex index = m_proxyModel->mapToSource(m_outlineCombo->view()->currentIndex()); + Symbol *symbol = m_outlineModel->symbolFromIndex(index); if (! symbol) return; openCppEditorAt(linkToSymbol(symbol)); } -void CPPEditor::setSortedMethodOverview(bool sort) +void CPPEditor::setSortedOutline(bool sort) { - if (sort != sortedMethodOverview()) { + if (sort != sortedOutline()) { if (sort) m_proxyModel->sort(0, Qt::AscendingOrder); else @@ -1005,18 +992,38 @@ void CPPEditor::setSortedMethodOverview(bool sort) bool block = m_sortAction->blockSignals(true); m_sortAction->setChecked(m_proxyModel->sortColumn() == 0); m_sortAction->blockSignals(block); - updateMethodBoxIndexNow(); + updateOutlineIndexNow(); } } -bool CPPEditor::sortedMethodOverview() const +bool CPPEditor::sortedOutline() const { return (m_proxyModel->sortColumn() == 0); } -void CPPEditor::updateMethodBoxIndex() +void CPPEditor::updateOutlineNow() { - m_updateMethodBoxTimer->start(); + const Snapshot snapshot = m_modelManager->snapshot(); + Document::Ptr document = snapshot.document(file()->fileName()); + + if (!document) + return; + + if (document->editorRevision() != editorRevision()) { + m_updateOutlineTimer->start(); + return; + } + + m_outlineModel->rebuild(document); + + OverviewTreeView *treeView = static_cast(m_outlineCombo->view()); + treeView->sync(); + updateOutlineIndexNow(); +} + +void CPPEditor::updateOutlineIndex() +{ + m_updateOutlineIndexTimer->start(); } void CPPEditor::highlightUses(const QList &uses, @@ -1055,49 +1062,46 @@ void CPPEditor::highlightUses(const QList &uses, } } -void CPPEditor::updateMethodBoxIndexNow() +void CPPEditor::updateOutlineIndexNow() { - if (! m_overviewModel->document()) + if (!m_outlineModel->document()) return; - if (m_overviewModel->document()->editorRevision() != editorRevision()) { - m_updateMethodBoxTimer->start(); + if (m_outlineModel->document()->editorRevision() != editorRevision()) { + m_updateOutlineIndexTimer->start(); return; } - m_updateMethodBoxTimer->stop(); + m_updateOutlineIndexTimer->stop(); - int line = 0, column = 0; - convertPosition(position(), &line, &column); + m_outlineModelIndex = QModelIndex(); //invalidate + QModelIndex comboIndex = outlineModelIndex(); - QModelIndex lastIndex; - const int rc = m_overviewModel->rowCount(); - for (int row = 0; row < rc; ++row) { - const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex()); - Symbol *symbol = m_overviewModel->symbolFromIndex(index); - if (symbol && symbol->line() > unsigned(line)) - break; - lastIndex = index; - } + if (comboIndex.isValid()) { + bool blocked = m_outlineCombo->blockSignals(true); - if (lastIndex.isValid()) { - bool blocked = m_methodCombo->blockSignals(true); - m_methodCombo->setCurrentIndex(m_proxyModel->mapFromSource(lastIndex).row()); - updateMethodBoxToolTip(); - (void) m_methodCombo->blockSignals(blocked); + // There is no direct way to select a non-root item + m_outlineCombo->setRootModelIndex(m_proxyModel->mapFromSource(comboIndex.parent())); + m_outlineCombo->setCurrentIndex(m_proxyModel->mapFromSource(comboIndex).row()); + m_outlineCombo->setRootModelIndex(QModelIndex()); + + updateOutlineToolTip(); + + m_outlineCombo->blockSignals(blocked); } } -void CPPEditor::updateMethodBoxToolTip() +void CPPEditor::updateOutlineToolTip() { - m_methodCombo->setToolTip(m_methodCombo->currentText()); + m_outlineCombo->setToolTip(m_outlineCombo->currentText()); } void CPPEditor::updateUses() { + if (editorRevision() != m_highlightRevision) + m_highlighter.cancel(); m_updateUsesTimer->start(); - m_highlighter.cancel(); } void CPPEditor::updateUsesNow() @@ -1108,18 +1112,76 @@ void CPPEditor::updateUsesNow() semanticRehighlight(); } -void CPPEditor::highlightTypeUsages() +void CPPEditor::highlightTypeUsages(int from, int to) { - if (editorRevision() != m_highlighteRevision) + if (editorRevision() != m_highlightRevision) return; // outdated else if (m_highlighter.isCanceled()) return; // aborted - const QList typeUsages = m_highlighter.results(); - setExtraSelections(TypeSelection, createSelections(document(), typeUsages, m_typeFormat)); + CppHighlighter *highlighter = qobject_cast(baseTextDocument()->syntaxHighlighter()); + Q_ASSERT(highlighter); + QTextDocument *doc = document(); + + if (m_nextHighlightBlockNumber >= doc->blockCount()) + return; + + QMap > chunks = CheckSymbols::chunks(m_highlighter, from, to); + Q_ASSERT(!chunks.isEmpty()); + QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber); + + QMapIterator > it(chunks); + while (b.isValid() && it.hasNext()) { + it.next(); + const int blockNumber = it.key(); + Q_ASSERT(blockNumber < doc->blockCount()); + + while (m_nextHighlightBlockNumber < blockNumber) { + highlighter->setExtraAdditionalFormats(b, QList()); + b = b.next(); + ++m_nextHighlightBlockNumber; + } + + QList formats; + foreach (const SemanticInfo::Use &use, it.value()) { + QTextLayout::FormatRange formatRange; + formatRange.format = m_typeFormat; + formatRange.start = use.column - 1; + formatRange.length = use.length; + formats.append(formatRange); + } + highlighter->setExtraAdditionalFormats(b, formats); + b = b.next(); + ++m_nextHighlightBlockNumber; + } } +void CPPEditor::finishTypeUsages() +{ + if (editorRevision() != m_highlightRevision) + return; // outdated + + else if (m_highlighter.isCanceled()) + return; // aborted + + CppHighlighter *highlighter = qobject_cast(baseTextDocument()->syntaxHighlighter()); + Q_ASSERT(highlighter); + QTextDocument *doc = document(); + + if (m_nextHighlightBlockNumber >= doc->blockCount()) + return; + + QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber); + + while (b.isValid()) { + highlighter->setExtraAdditionalFormats(b, QList()); + b = b.next(); + ++m_nextHighlightBlockNumber; + } +} + + void CPPEditor::switchDeclarationDefinition() { if (! m_modelManager) @@ -1417,6 +1479,23 @@ SemanticInfo CPPEditor::semanticInfo() const return m_lastSemanticInfo; } +CPlusPlus::OverviewModel *CPPEditor::outlineModel() const +{ + return m_outlineModel; +} + +QModelIndex CPPEditor::outlineModelIndex() +{ + if (!m_outlineModelIndex.isValid()) { + int line = 0, column = 0; + convertPosition(position(), &line, &column); + m_outlineModelIndex = indexForPosition(line, column); + emit outlineModelIndexChanged(m_outlineModelIndex); + } + + return m_outlineModelIndex; +} + bool CPPEditor::isElectricCharacter(QChar ch) const { if (ch == QLatin1Char('{') || @@ -1897,9 +1976,10 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) if (semanticInfo.doc) { LookupContext context(semanticInfo.doc, semanticInfo.snapshot); - CheckUndefinedSymbols::Future f = CheckUndefinedSymbols::go(semanticInfo.doc, context); + CheckSymbols::Future f = CheckSymbols::go(semanticInfo.doc, context); m_highlighter = f; - m_highlighteRevision = semanticInfo.revision; + m_highlightRevision = semanticInfo.revision; + m_nextHighlightBlockNumber = 0; m_highlightWatcher.setFuture(m_highlighter); } @@ -1910,6 +1990,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) #endif } + setExtraSelections(UnusedSymbolSelection, unusedSelections); if (! m_renameSelections.isEmpty()) @@ -2161,3 +2242,26 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) return semanticInfo; } + +QModelIndex CPPEditor::indexForPosition(int line, int column, const QModelIndex &rootIndex) const +{ + QModelIndex lastIndex = rootIndex; + + const int rowCount = m_outlineModel->rowCount(rootIndex); + for (int row = 0; row < rowCount; ++row) { + const QModelIndex index = m_outlineModel->index(row, 0, rootIndex); + Symbol *symbol = m_outlineModel->symbolFromIndex(index); + if (symbol && symbol->line() > unsigned(line)) + break; + lastIndex = index; + } + + if (lastIndex != rootIndex) { + // recurse + lastIndex = indexForPosition(line, column, lastIndex); + } + + return lastIndex; +} + +#include "cppeditor.moc" diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 488bcfd9e27..738a9775866 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -42,6 +42,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE class QComboBox; @@ -166,6 +167,9 @@ public: bool isOutdated() const; SemanticInfo semanticInfo() const; + CPlusPlus::OverviewModel *outlineModel() const; + QModelIndex outlineModelIndex(); + virtual void paste(); // reimplemented from BaseTextEditor virtual void cut(); // reimplemented from BaseTextEditor @@ -176,10 +180,13 @@ public: void setObjCEnabled(bool onoff); bool isObjCEnabled() const; +Q_SIGNALS: + void outlineModelIndexChanged(const QModelIndex &index); + public Q_SLOTS: virtual void setFontSettings(const TextEditor::FontSettings &); virtual void setTabSettings(const TextEditor::TabSettings &); - void setSortedMethodOverview(bool sort); + void setSortedOutline(bool sort); void switchDeclarationDefinition(); void jumpToDefinition(); void renameSymbolUnderCursor(); @@ -214,10 +221,11 @@ protected: private Q_SLOTS: void updateFileName(); - void jumpToMethod(int index); - void updateMethodBoxIndex(); - void updateMethodBoxIndexNow(); - void updateMethodBoxToolTip(); + void jumpToOutlineElement(int index); + void updateOutlineNow(); + void updateOutlineIndex(); + void updateOutlineIndexNow(); + void updateOutlineToolTip(); void updateUses(); void updateUsesNow(); void onDocumentUpdated(CPlusPlus::Document::Ptr doc); @@ -225,7 +233,8 @@ private Q_SLOTS: void semanticRehighlight(); void updateSemanticInfo(const CppEditor::Internal::SemanticInfo &semanticInfo); - void highlightTypeUsages(); + void highlightTypeUsages(int from, int to); + void finishTypeUsages(); void performQuickFix(int index); @@ -234,7 +243,7 @@ private: void setShowWarningMessage(bool showWarningMessage); void markSymbols(CPlusPlus::Symbol *canonicalSymbol, const SemanticInfo &info); - bool sortedMethodOverview() const; + bool sortedOutline() const; CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol, const CPlusPlus::Snapshot &snapshot); virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar); virtual void indent(QTextDocument *doc, const QTextCursor &cursor, QChar typedChar); @@ -258,15 +267,19 @@ private: bool openLink(const Link &link) { return openCppEditorAt(link); } bool openCppEditorAt(const Link &); + QModelIndex indexForPosition(int line, int column, const QModelIndex &rootIndex = QModelIndex()) const; + static Link linkToSymbol(CPlusPlus::Symbol *symbol); CppTools::CppModelManagerInterface *m_modelManager; - QComboBox *m_methodCombo; - CPlusPlus::OverviewModel *m_overviewModel; + QComboBox *m_outlineCombo; + CPlusPlus::OverviewModel *m_outlineModel; + QModelIndex m_outlineModelIndex; QSortFilterProxyModel *m_proxyModel; QAction *m_sortAction; - QTimer *m_updateMethodBoxTimer; + QTimer *m_updateOutlineTimer; + QTimer *m_updateOutlineIndexTimer; QTimer *m_updateUsesTimer; QTextCharFormat m_occurrencesFormat; QTextCharFormat m_occurrencesUnusedFormat; @@ -288,7 +301,8 @@ private: QFuture m_highlighter; QFutureWatcher m_highlightWatcher; - unsigned m_highlighteRevision; // the editor revision that requested the highlight + unsigned m_highlightRevision; // the editor revision that requested the highlight + int m_nextHighlightBlockNumber; }; diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro index 49306644a2d..4b017f64fee 100644 --- a/src/plugins/cppeditor/cppeditor.pro +++ b/src/plugins/cppeditor/cppeditor.pro @@ -17,9 +17,10 @@ HEADERS += cppplugin.h \ cppclasswizard.h \ cppquickfix.h \ cpprefactoringchanges.h \ - cppcheckundefinedsymbols.h \ + cppchecksymbols.h \ cppsemanticinfo.h \ - cppoutline.h + cppoutline.h \ + cppdeclfromdef.h SOURCES += cppplugin.cpp \ cppeditor.cpp \ @@ -29,9 +30,10 @@ SOURCES += cppplugin.cpp \ cppclasswizard.cpp \ cppquickfix.cpp \ cpprefactoringchanges.cpp \ - cppcheckundefinedsymbols.cpp \ + cppchecksymbols.cpp \ cppsemanticinfo.cpp \ - cppoutline.cpp + cppoutline.cpp \ + cppdeclfromdef.cpp RESOURCES += cppeditor.qrc diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 321025058e3..c98c35dcdc7 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -42,7 +42,7 @@ using namespace TextEditor; using namespace CPlusPlus; CppHighlighter::CppHighlighter(QTextDocument *document) : - QSyntaxHighlighter(document) + TextEditor::SyntaxHighlighter(document) { } diff --git a/src/plugins/cppeditor/cpphighlighter.h b/src/plugins/cppeditor/cpphighlighter.h index 9d7c0496fc5..d8fe769371a 100644 --- a/src/plugins/cppeditor/cpphighlighter.h +++ b/src/plugins/cppeditor/cpphighlighter.h @@ -31,16 +31,17 @@ #define CPPHIGHLIGHTER_H #include "cppeditorenums.h" -#include +#include #include #include namespace CppEditor { + namespace Internal { class CPPEditor; -class CppHighlighter : public QSyntaxHighlighter +class CppHighlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 8115032b1e1..5c84e868412 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -29,7 +29,6 @@ #include "cpphoverhandler.h" #include "cppeditor.h" -#include "cppplugin.h" #include #include @@ -39,48 +38,69 @@ #include #include #include +#include #include +#include -#include #include -#include -#include -#include #include #include #include #include #include #include -#include +#include +#include -#include #include #include -#include #include #include -#include using namespace CppEditor::Internal; using namespace CPlusPlus; using namespace Core; +namespace { + QString removeQualificationIfAny(const QString &name) { + int index = name.lastIndexOf(QLatin1Char(':')); + if (index == -1) + return name; + else + return name.right(name.length() - index - 1); + } + + void moveCursorToEndOfQualifiedName(QTextCursor *tc) { + QTextDocument *doc = tc->document(); + if (!doc) + return; + + while (true) { + const QChar &ch = doc->characterAt(tc->position()); + if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) + tc->movePosition(QTextCursor::NextCharacter); + else if (ch == QLatin1Char(':') && + doc->characterAt(tc->position() + 1) == QLatin1Char(':')) + tc->movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, 2); + else + break; + } + } +} + CppHoverHandler::CppHoverHandler(QObject *parent) - : QObject(parent) + : QObject(parent), m_modelManager(0), m_matchingHelpCandidate(-1) { - m_modelManager = ExtensionSystem::PluginManager::instance()->getObject(); + m_modelManager = + ExtensionSystem::PluginManager::instance()->getObject(); + + m_htmlDocExtractor.setLengthReference(1000, true); // Listen for editor opened events in order to connect to tooltip/helpid requests connect(ICore::instance()->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), this, SLOT(editorOpened(Core::IEditor *))); } -void CppHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int pos) -{ - updateHelpIdAndTooltip(editor, pos); -} - void CppHoverHandler::editorOpened(IEditor *editor) { CPPEditorEditable *cppEditor = qobject_cast(editor); @@ -94,22 +114,59 @@ void CppHoverHandler::editorOpened(IEditor *editor) this, SLOT(updateContextHelpId(TextEditor::ITextEditor*, int))); } +void CppHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int pos) +{ + if (!editor) + return; + + // If the tooltip is visible and there is a help match, this match is used to update the help + // id. Otherwise, the identification process happens. + if (!QToolTip::isVisible() || m_matchingHelpCandidate == -1) + identifyMatch(editor, pos); + + if (m_matchingHelpCandidate != -1) + editor->setContextHelpId(m_helpCandidates.at(m_matchingHelpCandidate).m_helpId); + else + editor->setContextHelpId(QString()); +} + void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos) { if (!editor) return; - ICore *core = ICore::instance(); - const int dbgcontext = core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_DEBUGMODE); + editor->setContextHelpId(QString()); - if (core->hasContext(dbgcontext)) + ICore *core = ICore::instance(); + const int dbgContext = + core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_DEBUGMODE); + if (core->hasContext(dbgContext)) return; - updateHelpIdAndTooltip(editor, pos); + identifyMatch(editor, pos); - if (m_toolTip.isEmpty()) + if (m_toolTip.isEmpty()) { QToolTip::hideText(); - else { + } else { + if (m_matchingHelpCandidate != -1) { + QString contents; + TextEditor::BaseTextEditor *baseEditor = baseTextEditor(editor); + if (baseEditor && baseEditor->displaySettings().m_integrateDocsIntoTooltips) + contents = getDocContents(); + if (!contents.isEmpty()) { + m_toolTip = contents; + } else { + m_toolTip = Qt::escape(m_toolTip); + m_toolTip.prepend(QLatin1String("")); + m_toolTip.append(QLatin1String("")); + } + + m_toolTip = QString(QLatin1String("" + "" + "" + "
    %1
    ")).arg(m_toolTip); + } + const QPoint pnt = point - QPoint(0, #ifdef Q_WS_WIN 24 @@ -122,210 +179,241 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint } } -static QString buildHelpId(Symbol *symbol, const Name *declarationName) +void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos) { - Scope *scope = 0; - - if (symbol) { - scope = symbol->scope(); - declarationName = symbol->name(); - } - - if (! declarationName) - return QString(); - - Overview overview; - overview.setShowArgumentNames(false); - overview.setShowReturnTypes(false); - - QStringList qualifiedNames; - qualifiedNames.prepend(overview.prettyName(declarationName)); - - for (; scope; scope = scope->enclosingScope()) { - Symbol *owner = scope->owner(); - - if (owner && owner->name() && ! scope->isEnumScope()) { - const Name *name = owner->name(); - const Identifier *id = 0; - - if (const NameId *nameId = name->asNameId()) - id = nameId->identifier(); - - else if (const TemplateNameId *nameId = name->asTemplateNameId()) - id = nameId->identifier(); - - if (id) - qualifiedNames.prepend(QString::fromLatin1(id->chars(), id->size())); - } - } - - return qualifiedNames.join(QLatin1String("::")); -} - -void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos) -{ - m_helpId.clear(); - m_toolTip.clear(); + resetMatchings(); if (!m_modelManager) return; - TextEditor::BaseTextEditor *edit = qobject_cast(editor->widget()); - if (!edit) + const Snapshot &snapshot = m_modelManager->snapshot(); + Document::Ptr doc = snapshot.document(editor->file()->fileName()); + if (!doc) return; - const Snapshot snapshot = m_modelManager->snapshot(); - const QString fileName = editor->file()->fileName(); - Document::Ptr doc = snapshot.document(fileName); - if (!doc) - return; // nothing to do + int line = 0; + int column = 0; + editor->convertPosition(pos, &line, &column); - QString formatTooltip = edit->extraSelectionTooltip(pos); - QTextCursor tc(edit->document()); - tc.setPosition(pos); + if (!matchDiagnosticMessage(doc, line) && + !matchIncludeFile(doc, line) && + !matchMacroInUse(doc, pos)) { - const unsigned lineNumber = tc.block().blockNumber() + 1; + TextEditor::BaseTextEditor *baseEditor = baseTextEditor(editor); + if (!baseEditor) + return; - // Find the last symbol up to the cursor position - int line = 0, column = 0; - editor->convertPosition(tc.position(), &line, &column); - Scope *scope = doc->scopeAt(line, column); - - TypeOfExpression typeOfExpression; - typeOfExpression.init(doc, snapshot); - - // We only want to show F1 if the tooltip matches the help id - bool showF1 = true; - - foreach (const Document::DiagnosticMessage &m, doc->diagnosticMessages()) { - if (m.line() == lineNumber) { - m_toolTip = m.text(); - showF1 = false; - break; + bool extraSelectionTooltip = false; + if (!baseEditor->extraSelectionTooltip(pos).isEmpty()) { + m_toolTip = baseEditor->extraSelectionTooltip(pos); + extraSelectionTooltip = true; } - } - QMap helpLinks; - if (m_toolTip.isEmpty()) { - foreach (const Document::Include &incl, doc->includes()) { - if (incl.line() == lineNumber) { - m_toolTip = QDir::toNativeSeparators(incl.fileName()); - m_helpId = QFileInfo(incl.fileName()).fileName(); - helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId); - break; - } - } - } - - if (m_helpId.isEmpty()) { - // Move to the end of a qualified name - bool stop = false; - while (!stop) { - const QChar ch = editor->characterAt(tc.position()); - if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) - tc.setPosition(tc.position() + 1); - else if (ch == QLatin1Char(':') && editor->characterAt(tc.position() + 1) == QLatin1Char(':')) { - tc.setPosition(tc.position() + 2); - } else { - stop = true; - } - } + QTextCursor tc(baseEditor->document()); + tc.setPosition(pos); + moveCursorToEndOfQualifiedName(&tc); // Fetch the expression's code ExpressionUnderCursor expressionUnderCursor; - const QString expression = expressionUnderCursor(tc); + const QString &expression = expressionUnderCursor(tc); + Scope *scope = doc->scopeAt(line, column); - const QList types = typeOfExpression(expression, scope); + TypeOfExpression typeOfExpression; + typeOfExpression.init(doc, snapshot); + const QList &lookupItems = typeOfExpression(expression, scope); + if (lookupItems.isEmpty()) + return; + const LookupItem &lookupItem = lookupItems.first(); // ### TODO: select the best candidate. + handleLookupItemMatch(lookupItem, !extraSelectionTooltip); + } - if (!types.isEmpty()) { - Overview overview; - overview.setShowArgumentNames(true); - overview.setShowReturnTypes(true); - overview.setShowFullyQualifiedNamed(true); + evaluateHelpCandidates(); +} - const LookupItem result = types.first(); // ### TODO: select the best candidate. - FullySpecifiedType symbolTy = result.type(); // result of `type of expression'. - Symbol *declaration = result.declaration(); // lookup symbol - const Name *declarationName = declaration ? declaration->name() : 0; +bool CppHoverHandler::matchDiagnosticMessage(const CPlusPlus::Document::Ptr &document, + unsigned line) +{ + foreach (const Document::DiagnosticMessage &m, document->diagnosticMessages()) { + if (m.line() == line) { + m_toolTip = m.text(); + return true; + } + } + return false; +} - if (declaration && declaration->scope() - && declaration->scope()->isClassScope()) { - Class *enclosingClass = declaration->scope()->owner()->asClass(); - if (const Identifier *id = enclosingClass->identifier()) { - if (id->isEqualTo(declaration->identifier())) - declaration = enclosingClass; - } - } +bool CppHoverHandler::matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line) +{ + foreach (const Document::Include &includeFile, document->includes()) { + if (includeFile.line() == line) { + m_toolTip = QDir::toNativeSeparators(includeFile.fileName()); + const QString &fileName = QFileInfo(includeFile.fileName()).fileName(); + m_helpCandidates.append(HelpCandidate(fileName, fileName, HelpCandidate::Include)); + return true; + } + } + return false; +} - m_helpId = buildHelpId(declaration, declarationName); - - if (m_toolTip.isEmpty()) { - Symbol *symbol = declaration; - - if (declaration) - symbol = declaration; - - if (symbol && symbol == declaration && symbol->isClass()) { - m_toolTip = m_helpId; - - } else if (declaration && (declaration->isDeclaration() || declaration->isArgument())) { - m_toolTip = overview.prettyType(symbolTy, buildHelpId(declaration, declaration->name())); - - } else if (symbolTy->isClassType() || symbolTy->isEnumType() || - symbolTy->isForwardClassDeclarationType()) { - m_toolTip = m_helpId; - - } else { - m_toolTip = overview.prettyType(symbolTy, m_helpId); - - } - } - - // Some docs don't contain the namespace in the documentation pages, for instance - // there is QtMobility::QContactManager but the help page is for QContactManager. - // To show their help anyway, try stripping scopes until we find something. - const QString startHelpId = m_helpId; - while (!m_helpId.isEmpty()) { - helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId); - if (!helpLinks.isEmpty()) - break; - - int coloncolonIndex = m_helpId.indexOf(QLatin1String("::")); - if (coloncolonIndex == -1) { - m_helpId = startHelpId; - break; - } - - m_helpId.remove(0, coloncolonIndex + 2); +bool CppHoverHandler::matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos) +{ + foreach (const Document::MacroUse &use, document->macroUses()) { + if (use.contains(pos)) { + const unsigned begin = use.begin(); + const QString &name = use.macro().name(); + if (pos < begin + name.length()) { + m_toolTip = use.macro().toString(); + m_helpCandidates.append(HelpCandidate(name, name, HelpCandidate::Macro)); + return true; } } } + return false; +} - if (m_toolTip.isEmpty()) { - foreach (const Document::MacroUse &use, doc->macroUses()) { - if (use.contains(pos)) { - const Macro m = use.macro(); - m_toolTip = m.toString(); - m_helpId = m.name(); - break; +void CppHoverHandler::handleLookupItemMatch(const LookupItem &lookupItem, const bool assignTooltip) +{ + Symbol *matchingDeclaration = lookupItem.declaration(); + FullySpecifiedType matchingType = lookupItem.type(); + + Overview overview; + overview.setShowArgumentNames(true); + overview.setShowReturnTypes(true); + overview.setShowFullyQualifiedNamed(true); + + if (!matchingDeclaration && assignTooltip) { + m_toolTip = overview.prettyType(matchingType, QString()); + } else { + QString qualifiedName; + if (matchingDeclaration->enclosingSymbol()->isClass() || + matchingDeclaration->enclosingSymbol()->isNamespace() || + matchingDeclaration->enclosingSymbol()->isEnum()) { + const QList &names = + LookupContext::fullyQualifiedName(matchingDeclaration); + const int size = names.size(); + for (int i = 0; i < size; ++i) { + qualifiedName.append(overview.prettyName(names.at(i))); + if (i < size - 1) + qualifiedName.append(QLatin1String("::")); + } + } else { + qualifiedName.append(overview.prettyName(matchingDeclaration->name())); + } + + if (assignTooltip) { + if (matchingDeclaration->isClass() || + matchingDeclaration->isNamespace() || + matchingDeclaration->isForwardClassDeclaration() || + matchingDeclaration->isEnum()) { + m_toolTip = qualifiedName; + } else { + m_toolTip = overview.prettyType(matchingType, qualifiedName); } } - } - if (!formatTooltip.isEmpty()) - m_toolTip = formatTooltip; - - if (!m_helpId.isEmpty() && !helpLinks.isEmpty()) { - if (showF1) { - // we need the original width without escape sequences - const int width = QFontMetrics(QToolTip::font()).width(m_toolTip); - m_toolTip = QString(QLatin1String("" - "
    %1
    ")) - .arg(Qt::escape(m_toolTip)).arg(width); + HelpCandidate::Category helpCategory; + if (matchingDeclaration->isNamespace() || + matchingDeclaration->isClass() || + matchingDeclaration->isForwardClassDeclaration()) { + helpCategory = HelpCandidate::ClassOrNamespace; + } else if (matchingDeclaration->isEnum()) { + helpCategory = HelpCandidate::Enum; + } else if (matchingDeclaration->isTypedef()) { + helpCategory = HelpCandidate::Typedef; + } else if (matchingDeclaration->isStatic() && !matchingDeclaration->isFunction()) { + helpCategory = HelpCandidate::Var; + } else { + helpCategory = HelpCandidate::Function; } - editor->setContextHelpId(m_helpId); - } else if (!m_toolTip.isEmpty() && Qt::mightBeRichText(m_toolTip)) { - m_toolTip = QString(QLatin1String("%1")).arg(Qt::escape(m_toolTip)); + + // Help identifiers are simply the name with no signature, arguments or return type. + // They might or might not include a qualification. This is why two candidates are + // created. + overview.setShowArgumentNames(false); + overview.setShowReturnTypes(false); + overview.setShowFunctionSignatures(false); + overview.setShowFullyQualifiedNamed(false); + const QString &simpleName = overview.prettyName(matchingDeclaration->name()); + overview.setShowFunctionSignatures(true); + const QString &specifierId = overview.prettyType(matchingType, simpleName); + + m_helpCandidates.append(HelpCandidate(simpleName, specifierId, helpCategory)); + m_helpCandidates.append(HelpCandidate(qualifiedName, specifierId, helpCategory)); } } + +void CppHoverHandler::evaluateHelpCandidates() +{ + for (int i = 0; i < m_helpCandidates.size(); ++i) { + if (helpIdExists(m_helpCandidates.at(i).m_helpId)) { + m_matchingHelpCandidate = i; + return; + } + } +} + +bool CppHoverHandler::helpIdExists(const QString &helpId) const +{ + QMap helpLinks = Core::HelpManager::instance()->linksForIdentifier(helpId); + if (!helpLinks.isEmpty()) + return true; + return false; +} + +QString CppHoverHandler::getDocContents() +{ + Q_ASSERT(m_matchingHelpCandidate >= 0); + + QString contents; + const HelpCandidate &help = m_helpCandidates.at(m_matchingHelpCandidate); + QMap helpLinks = + Core::HelpManager::instance()->linksForIdentifier(help.m_helpId); + foreach (const QUrl &url, helpLinks) { + // The help id might or might not be qualified. But anchors and marks are not qualified. + const QString &name = removeQualificationIfAny(help.m_helpId); + const QByteArray &html = Core::HelpManager::instance()->fileData(url); + switch (help.m_category) { + case HelpCandidate::Include: + contents = m_htmlDocExtractor.getClassOrNamespaceBrief(html, name); + break; + case HelpCandidate::ClassOrNamespace: + contents = m_htmlDocExtractor.getClassOrNamespaceDescription(html, name); + break; + case HelpCandidate::Function: + contents = + m_htmlDocExtractor.getFunctionDescription(html, help.m_markId, name); + break; + case HelpCandidate::Enum: + contents = m_htmlDocExtractor.getEnumDescription(html, name); + break; + case HelpCandidate::Typedef: + contents = m_htmlDocExtractor.getTypedefDescription(html, name); + break; + case HelpCandidate::Var: + contents = m_htmlDocExtractor.getVarDescription(html, name); + break; + case HelpCandidate::Macro: + contents = m_htmlDocExtractor.getMacroDescription(html, help.m_markId, name); + break; + default: + break; + } + + if (!contents.isEmpty()) + break; + } + return contents; +} + +void CppHoverHandler::resetMatchings() +{ + m_matchingHelpCandidate = -1; + m_helpCandidates.clear(); + m_toolTip.clear(); +} + +TextEditor::BaseTextEditor *CppHoverHandler::baseTextEditor(TextEditor::ITextEditor *editor) +{ + return qobject_cast(editor->widget()); +} diff --git a/src/plugins/cppeditor/cpphoverhandler.h b/src/plugins/cppeditor/cpphoverhandler.h index 311b8292236..84c58733d48 100644 --- a/src/plugins/cppeditor/cpphoverhandler.h +++ b/src/plugins/cppeditor/cpphoverhandler.h @@ -30,12 +30,21 @@ #ifndef CPPHOVERHANDLER_H #define CPPHOVERHANDLER_H +#include + #include +#include + +#include QT_BEGIN_NAMESPACE class QPoint; QT_END_NAMESPACE +namespace CPlusPlus { +class LookupItem; +} + namespace Core { class IEditor; } @@ -46,6 +55,7 @@ class CppModelManagerInterface; namespace TextEditor { class ITextEditor; +class BaseTextEditor; } namespace CppEditor { @@ -54,7 +64,6 @@ namespace Internal { class CppHoverHandler : public QObject { Q_OBJECT - public: CppHoverHandler(QObject *parent = 0); @@ -66,11 +75,45 @@ private slots: void editorOpened(Core::IEditor *editor); private: - void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos); + struct HelpCandidate + { + enum Category { + ClassOrNamespace, + Enum, + Typedef, + Var, + Macro, + Include, + Function + }; + + HelpCandidate(const QString &helpId, const QString &markId, Category category) : + m_helpId(helpId), m_markId(markId), m_category(category) + {} + QString m_helpId; + QString m_markId; + Category m_category; + }; + + void resetMatchings(); + void identifyMatch(TextEditor::ITextEditor *editor, int pos); + bool matchDiagnosticMessage(const CPlusPlus::Document::Ptr &document, unsigned line); + bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line); + bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos); + void handleLookupItemMatch(const CPlusPlus::LookupItem &lookupItem, + const bool assignTooltip); + + void evaluateHelpCandidates(); + bool helpIdExists(const QString &helpId) const; + QString getDocContents(); + + static TextEditor::BaseTextEditor *baseTextEditor(TextEditor::ITextEditor *editor); CppTools::CppModelManagerInterface *m_modelManager; - QString m_helpId; + int m_matchingHelpCandidate; + QList m_helpCandidates; QString m_toolTip; + Utils::HtmlDocExtractor m_htmlDocExtractor; }; } // namespace Internal diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index b6ee497c516..146b060ae68 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -4,10 +4,12 @@ #include #include +#include #include -#include #include +#include +#include using namespace CppEditor::Internal; @@ -29,9 +31,11 @@ CppOutlineTreeView::CppOutlineTreeView(QWidget *parent) : setExpandsOnDoubleClick(false); } -CppOutlineFilterModel::CppOutlineFilterModel(QObject *parent) : - QSortFilterProxyModel(parent) +CppOutlineFilterModel::CppOutlineFilterModel(CPlusPlus::OverviewModel *sourceModel, QObject *parent) : + QSortFilterProxyModel(parent), + m_sourceModel(sourceModel) { + setSourceModel(m_sourceModel); } bool CppOutlineFilterModel::filterAcceptsRow(int sourceRow, @@ -41,6 +45,12 @@ bool CppOutlineFilterModel::filterAcceptsRow(int sourceRow, if (!sourceParent.isValid() && sourceRow == 0) { return false; } + // ignore generated symbols, e.g. by macro expansion (Q_OBJECT) + const QModelIndex sourceIndex = m_sourceModel->index(sourceRow, 0, sourceParent); + CPlusPlus::Symbol *symbol = m_sourceModel->symbolFromIndex(sourceIndex); + if (symbol && symbol->isGenerated()) + return false; + return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } @@ -49,8 +59,8 @@ CppOutlineWidget::CppOutlineWidget(CPPEditor *editor) : TextEditor::IOutlineWidget(), m_editor(editor), m_treeView(new CppOutlineTreeView(this)), - m_model(new CPlusPlus::OverviewModel(this)), - m_proxyModel(new CppOutlineFilterModel(this)), + m_model(m_editor->outlineModel()), + m_proxyModel(new CppOutlineFilterModel(m_model, this)), m_enableCursorSync(true), m_blockCursorSync(false) { @@ -60,20 +70,13 @@ CppOutlineWidget::CppOutlineWidget(CPPEditor *editor) : layout->addWidget(m_treeView); setLayout(layout); - m_proxyModel->setSourceModel(m_model); m_treeView->setModel(m_proxyModel); - CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface::instance(); + connect(m_model, SIGNAL(modelReset()), this, SLOT(modelUpdated())); + modelUpdated(); - connect(modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), - this, SLOT(updateOutline(CPlusPlus::Document::Ptr))); - - if (modelManager->snapshot().contains(editor->file()->fileName())) { - updateOutline(modelManager->snapshot().document(editor->file()->fileName())); - } - - connect(m_editor, SIGNAL(cursorPositionChanged()), - this, SLOT(updateSelectionInTree())); + connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)), + this, SLOT(updateSelectionInTree(QModelIndex))); connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateSelectionInText(QItemSelection))); } @@ -82,32 +85,19 @@ void CppOutlineWidget::setCursorSynchronization(bool syncWithCursor) { m_enableCursorSync = syncWithCursor; if (m_enableCursorSync) - updateSelectionInTree(); + updateSelectionInTree(m_editor->outlineModelIndex()); } -void CppOutlineWidget::updateOutline(CPlusPlus::Document::Ptr document) +void CppOutlineWidget::modelUpdated() { - m_document = document; - if (document && m_editor - && (document->fileName() == m_editor->file()->fileName()) - && (document->editorRevision() == m_editor->editorRevision())) { - if (debug) - qDebug() << "CppOutline - rebuilding model"; - m_model->rebuild(document); - m_treeView->expandAll(); - updateSelectionInTree(); - } + m_treeView->expandAll(); } -void CppOutlineWidget::updateSelectionInTree() +void CppOutlineWidget::updateSelectionInTree(const QModelIndex &index) { if (!syncCursor()) return; - int line = m_editor->textCursor().blockNumber(); - int column = m_editor->textCursor().columnNumber(); - - QModelIndex index = indexForPosition(QModelIndex(), line, column); QModelIndex proxyIndex = m_proxyModel->mapFromSource(index); m_blockCursorSync = true; @@ -115,6 +105,7 @@ void CppOutlineWidget::updateSelectionInTree() qDebug() << "CppOutline - updating selection due to cursor move"; m_treeView->selectionModel()->select(proxyIndex, QItemSelectionModel::ClearAndSelect); + m_treeView->scrollTo(proxyIndex); m_blockCursorSync = false; } @@ -129,69 +120,21 @@ void CppOutlineWidget::updateSelectionInText(const QItemSelection &selection) CPlusPlus::Symbol *symbol = m_model->symbolFromIndex(index); if (symbol) { m_blockCursorSync = true; - unsigned line, column; - m_document->translationUnit()->getPosition(symbol->startOffset(), &line, &column); if (debug) - qDebug() << "CppOutline - moving cursor to" << line << column - 1; + qDebug() << "CppOutline - moving cursor to" << symbol->line() << symbol->column() - 1; + + Core::EditorManager *editorManager = Core::EditorManager::instance(); + editorManager->cutForwardNavigationHistory(); + editorManager->addCurrentPositionToNavigationHistory(); // line has to be 1 based, column 0 based! - m_editor->gotoLine(line, column - 1); + m_editor->gotoLine(symbol->line(), symbol->column() - 1); m_blockCursorSync = false; } } } -QModelIndex CppOutlineWidget::indexForPosition(const QModelIndex &rootIndex, int line, int column) -{ - QModelIndex result = rootIndex; - - const int rowCount = m_model->rowCount(rootIndex); - for (int row = 0; row < rowCount; ++row) { - QModelIndex index = m_model->index(row, 0, rootIndex); - CPlusPlus::Symbol *symbol = m_model->symbolFromIndex(index); - if (symbol && positionInsideSymbol(line, column, symbol)) { - // recurse to children - result = indexForPosition(index, line, column); - } - } - - return result; -} - -bool CppOutlineWidget::positionInsideSymbol(unsigned cursorLine, unsigned cursorColumn, CPlusPlus::Symbol *symbol) const -{ - if (!m_document) - return false; - CPlusPlus::TranslationUnit *translationUnit = m_document->translationUnit(); - - unsigned symbolStartLine = -1; - unsigned symbolStartColumn = -1; - - translationUnit->getPosition(symbol->startOffset(), &symbolStartLine, &symbolStartColumn); - - // normalize to 0 based - --symbolStartLine; - --symbolStartColumn; - - if (symbolStartLine < cursorLine - || (symbolStartLine == cursorLine && symbolStartColumn <= cursorColumn)) { - unsigned symbolEndLine = -1; - unsigned symbolEndColumn = -1; - translationUnit->getPosition(symbol->endOffset(), &symbolEndLine, &symbolEndColumn); - - // normalize to 0 based - --symbolEndLine; - --symbolEndColumn; - - if (symbolEndLine > cursorLine - || (symbolEndLine == cursorLine && symbolEndColumn >= cursorColumn)) { - return true; - } - } - return false; -} - bool CppOutlineWidget::syncCursor() { return m_enableCursorSync && !m_blockCursorSync; diff --git a/src/plugins/cppeditor/cppoutline.h b/src/plugins/cppeditor/cppoutline.h index 96443811cc0..3eea8b3c65f 100644 --- a/src/plugins/cppeditor/cppoutline.h +++ b/src/plugins/cppeditor/cppoutline.h @@ -22,10 +22,12 @@ class CppOutlineFilterModel : public QSortFilterProxyModel { Q_OBJECT public: - CppOutlineFilterModel(QObject *parent); + CppOutlineFilterModel(CPlusPlus::OverviewModel *sourceModel, QObject *parent); // QSortFilterProxyModel bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +private: + CPlusPlus::OverviewModel *m_sourceModel; }; class CppOutlineWidget : public TextEditor::IOutlineWidget @@ -38,13 +40,11 @@ public: virtual void setCursorSynchronization(bool syncWithCursor); private slots: - void updateOutline(CPlusPlus::Document::Ptr document); - void updateSelectionInTree(); + void modelUpdated(); + void updateSelectionInTree(const QModelIndex &index); void updateSelectionInText(const QItemSelection &selection); private: - QModelIndex indexForPosition(const QModelIndex &rootIndex, int line, int column); - bool positionInsideSymbol(unsigned cursorLine, unsigned cursorColumn, CPlusPlus::Symbol *symbol) const; bool syncCursor(); private: @@ -52,7 +52,6 @@ private: CppOutlineTreeView *m_treeView; CPlusPlus::OverviewModel *m_model; CppOutlineFilterModel *m_proxyModel; - CPlusPlus::Document::Ptr m_document; bool m_enableCursorSync; bool m_blockCursorSync; diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index c1dfeff08ca..2b9e980f827 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -135,7 +135,7 @@ CppPlugin *CppPlugin::m_instance = 0; CppPlugin::CppPlugin() : m_actionHandler(0), - m_sortedMethodOverview(false), + m_sortedOutline(false), m_renameSymbolUnderCursorAction(0), m_findUsagesAction(0), m_updateCodeModelAction(0) @@ -176,19 +176,19 @@ void CppPlugin::initializeEditor(CPPEditor *editor) this, SLOT(quickFix(TextEditor::ITextEditable*))); // method combo box sorting - connect(this, SIGNAL(methodOverviewSortingChanged(bool)), - editor, SLOT(setSortedMethodOverview(bool))); + connect(this, SIGNAL(outlineSortingChanged(bool)), + editor, SLOT(setSortedOutline(bool))); } -void CppPlugin::setSortedMethodOverview(bool sorted) +void CppPlugin::setSortedOutline(bool sorted) { - m_sortedMethodOverview = sorted; - emit methodOverviewSortingChanged(sorted); + m_sortedOutline = sorted; + emit outlineSortingChanged(sorted); } -bool CppPlugin::sortedMethodOverview() const +bool CppPlugin::sortedOutline() const { - return m_sortedMethodOverview; + return m_sortedOutline; } CppQuickFixCollector *CppPlugin::quickFixCollector() const @@ -308,21 +308,22 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess void CppPlugin::readSettings() { - m_sortedMethodOverview = Core::ICore::instance()->settings()->value("CppTools/SortedMethodOverview", false).toBool(); + m_sortedOutline = Core::ICore::instance()->settings()->value("CppTools/SortedMethodOverview", false).toBool(); } void CppPlugin::writeSettings() { - Core::ICore::instance()->settings()->setValue("CppTools/SortedMethodOverview", m_sortedMethodOverview); + Core::ICore::instance()->settings()->setValue("CppTools/SortedMethodOverview", m_sortedOutline); } void CppPlugin::extensionsInitialized() { } -void CppPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag CppPlugin::aboutToShutdown() { writeSettings(); + return SynchronousShutdown; } void CppPlugin::switchDeclarationDefinition() diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h index c7d4b82c3cd..517da5c2f95 100644 --- a/src/plugins/cppeditor/cppplugin.h +++ b/src/plugins/cppeditor/cppplugin.h @@ -60,20 +60,20 @@ public: bool initialize(const QStringList &arguments, QString *error_message = 0); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); // Connect editor to settings changed signals. void initializeEditor(CPPEditor *editor); - bool sortedMethodOverview() const; + bool sortedOutline() const; CppQuickFixCollector *quickFixCollector() const; signals: - void methodOverviewSortingChanged(bool sort); + void outlineSortingChanged(bool sort); public slots: - void setSortedMethodOverview(bool sorted); + void setSortedOutline(bool sorted); private slots: void switchDeclarationDefinition(); @@ -93,7 +93,7 @@ private: static CppPlugin *m_instance; TextEditor::TextEditorActionHandler *m_actionHandler; - bool m_sortedMethodOverview; + bool m_sortedOutline; QAction *m_renameSymbolUnderCursorAction; QAction *m_findUsagesAction; QAction *m_updateCodeModelAction; diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp index 29dc9ed1b6e..b717d632541 100644 --- a/src/plugins/cppeditor/cppquickfix.cpp +++ b/src/plugins/cppeditor/cppquickfix.cpp @@ -29,11 +29,13 @@ #include "cppquickfix.h" #include "cppeditor.h" +#include "cppdeclfromdef.h" #include #include #include #include +#include #include #include @@ -929,7 +931,7 @@ public: // We need to do a QCA::translate, so we need a context. // Use fully qualified class name: Overview oo; - foreach (const Name *n, LookupContext::fullyQualifiedName(function)) { + foreach (const Name *n, LookupContext::path(function)) { if (!m_context.isEmpty()) m_context.append(QLatin1String("::")); m_context.append(oo.prettyName(n)); @@ -1217,6 +1219,135 @@ public: }; +/* + Adds missing case statements for "switch (enumVariable)" +*/ +class CompleteSwitchCaseStatement: public CppQuickFixOperation +{ +public: + CompleteSwitchCaseStatement(TextEditor::BaseTextEditor *editor) + : CppQuickFixOperation(editor) + {} + + virtual QString description() const + { + return QApplication::translate("CppTools::QuickFix", "Complete Switch Statement"); + } + + virtual int match(const QList &path) + { + if (path.isEmpty()) + return -1; // nothing to do + + // look for switch statement + for (int depth = path.size()-1; depth >= 0; --depth) { + AST *ast = path.at(depth); + SwitchStatementAST *switchStatement = ast->asSwitchStatement(); + if (switchStatement) { + if (!isCursorOn(switchStatement->switch_token) || !switchStatement->statement) + return -1; + compoundStatement = switchStatement->statement->asCompoundStatement(); + if (!compoundStatement) // we ignore pathologic case "switch (t) case A: ;" + return -1; + // look if the condition's type is an enum + if (Enum *e = conditionEnum(switchStatement)) { + // check the possible enum values + values.clear(); + Overview prettyPrint; + for (unsigned i = 0; i < e->memberCount(); ++i) { + if (Declaration *decl = e->memberAt(i)->asDeclaration()) { + values << prettyPrint(decl->name()); + } + } + // Get the used values + CaseStatementCollector caseValues(document()->translationUnit()); + QStringList usedValues = caseValues(switchStatement); + // save the values that would be added + foreach (const QString &usedValue, usedValues) + values.removeAll(usedValue); + if (values.isEmpty()) + return -1; + return depth; + } + return -1; + } + } + + return -1; + } + + virtual void createChanges() + { + ChangeSet changes; + int start = endOf(compoundStatement->lbrace_token); + changes.insert(start, QLatin1String("\ncase ") + + values.join(QLatin1String(":\nbreak;\ncase ")) + + QLatin1String(":\nbreak;")); + refactoringChanges()->changeFile(fileName(), changes); + refactoringChanges()->reindent(fileName(), range(compoundStatement)); + } + +protected: + Enum *conditionEnum(SwitchStatementAST *statement) + { + Block *block = statement->symbol; + Scope *scope = document()->scopeAt(block->line(), block->column()); + TypeOfExpression typeOfExpression; + typeOfExpression.init(document(), snapshot()); + const QList results = typeOfExpression(statement->condition, + document(), + scope); + foreach (LookupItem result, results) { + FullySpecifiedType fst = result.type(); + if (Enum *e = result.declaration()->type()->asEnumType()) + return e; + if (NamedType *namedType = fst->asNamedType()) { + QList candidates = + typeOfExpression.context().lookup(namedType->name(), scope); + foreach (Symbol *candidate, candidates) { + if (Enum *e = candidate->asEnum()) { + return e; + } + } + } + } + return 0; + } + class CaseStatementCollector : public ASTVisitor + { + public: + CaseStatementCollector(TranslationUnit *unit) : ASTVisitor(unit) {} + QStringList operator ()(AST *ast) + { + values.clear(); + foundCaseStatementLevel = false; + accept(ast); + return values; + } + + bool preVisit(AST *ast) { + if (CaseStatementAST *cs = ast->asCaseStatement()) { + foundCaseStatementLevel = true; + if (SimpleNameAST *sm = cs->expression->asSimpleName()) { + Overview prettyPrint; + values << prettyPrint(sm->name); + } + return true; + } else if (foundCaseStatementLevel) { + return false; + } + return true; + } + + bool foundCaseStatementLevel; + QStringList values; + }; + +protected: + CompoundStatementAST *compoundStatement; + QStringList values; +}; + } // end of anonymous namespace @@ -1415,6 +1546,8 @@ QList CppQuickFixFactory::quickFixOperations QSharedPointer convertNumericToHex(new ConvertNumericToHex(editor)); QSharedPointer convertNumericToOctal(new ConvertNumericToOctal(editor)); QSharedPointer convertNumericToDecimal(new ConvertNumericToDecimal(editor)); + QSharedPointer completeSwitchCaseStatement(new CompleteSwitchCaseStatement(editor)); + QSharedPointer declFromDef(new DeclFromDef(editor)); quickFixOperations.append(rewriteLogicalAndOp); quickFixOperations.append(splitIfStatementOp); @@ -1429,6 +1562,11 @@ QList CppQuickFixFactory::quickFixOperations quickFixOperations.append(convertNumericToHex); quickFixOperations.append(convertNumericToOctal); quickFixOperations.append(convertNumericToDecimal); + quickFixOperations.append(completeSwitchCaseStatement); + +#if 0 + quickFixOperations.append(declFromDef); +#endif if (editor->mimeType() == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE) quickFixOperations.append(wrapCString); diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 733671fa515..3f90f644c05 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -200,7 +200,7 @@ protected: { _item = newCompletionItem(name); } virtual void visit(const QualifiedNameId *name) - { _item = newCompletionItem(name->unqualifiedNameId()); } + { _item = newCompletionItem(name->name()); } }; struct CompleteFunctionDeclaration @@ -1723,7 +1723,33 @@ QList CppCodeCompletion::getCompletions() return completionItems; } -void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) +bool CppCodeCompletion::typedCharCompletes(const TextEditor::CompletionItem &item, QChar typedChar) +{ + if (item.data.canConvert()) // snippet + return false; + + if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) + return typedChar == QLatin1Char('(') + || typedChar == QLatin1Char(','); + + if (m_completionOperator == T_STRING_LITERAL || m_completionOperator == T_ANGLE_STRING_LITERAL) + return typedChar == QLatin1Char('/') + && item.text.endsWith(QLatin1Char('/')); + + if (item.data.value()) + return typedChar == QLatin1Char(':') + || typedChar == QLatin1Char(';') + || typedChar == QLatin1Char('.') + || typedChar == QLatin1Char(',') + || typedChar == QLatin1Char('('); + + if (item.data.canConvert()) + return typedChar == QLatin1Char('('); + + return false; +} + +void CppCodeCompletion::complete(const TextEditor::CompletionItem &item, QChar typedChar) { Symbol *symbol = 0; @@ -1749,10 +1775,15 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) { toInsert = item.text; extraChars += QLatin1Char(')'); + + if (typedChar == QLatin1Char('(')) // Eat the opening parenthesis + typedChar = QChar(); } else if (m_completionOperator == T_STRING_LITERAL || m_completionOperator == T_ANGLE_STRING_LITERAL) { toInsert = item.text; if (!toInsert.endsWith(QLatin1Char('/'))) extraChars += QLatin1Char((m_completionOperator == T_ANGLE_STRING_LITERAL) ? '>' : '"'); + else if (typedChar == QLatin1Char('/')) // Eat the slash + typedChar = QChar(); } else { toInsert = item.text; @@ -1768,7 +1799,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) if (! function->hasReturnType() && (function->identity() && !function->identity()->isDestructorNameId())) { // Don't insert any magic, since the user might have just wanted to select the class - } else if (function->templateParameterCount() != 0) { + } else if (function->templateParameterCount() != 0 && typedChar != QLatin1Char('(')) { // If there are no arguments, then we need the template specification if (function->argumentCount() == 0) { extraChars += QLatin1Char('<'); @@ -1777,32 +1808,50 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) if (completionSettings().m_spaceAfterFunctionName) extraChars += QLatin1Char(' '); extraChars += QLatin1Char('('); + if (typedChar == QLatin1Char('(')) + typedChar = QChar(); // If the function doesn't return anything, automatically place the semicolon, // unless we're doing a scope completion (then it might be function definition). - bool endWithSemicolon = function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON; + const QChar characterAtCursor = m_editor->characterAt(m_editor->position()); + bool endWithSemicolon = typedChar == QLatin1Char(';') + || (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON); + const QChar semicolon = typedChar.isNull() ? QLatin1Char(';') : typedChar; + + if (endWithSemicolon && characterAtCursor == semicolon) { + endWithSemicolon = false; + typedChar = QChar(); + } // If the function takes no arguments, automatically place the closing parenthesis if (item.duplicateCount == 0 && ! function->hasArguments()) { extraChars += QLatin1Char(')'); - if (endWithSemicolon) - extraChars += QLatin1Char(';'); + if (endWithSemicolon) { + extraChars += semicolon; + typedChar = QChar(); + } } else if (autoParenthesesEnabled) { const QChar lookAhead = m_editor->characterAt(m_editor->position() + 1); if (MatchingText::shouldInsertMatchingText(lookAhead)) { extraChars += QLatin1Char(')'); --cursorOffset; if (endWithSemicolon) { - extraChars += QLatin1Char(';'); + extraChars += semicolon; --cursorOffset; + typedChar = QChar(); } } + // TODO: When an opening parenthesis exists, the "semicolon" should really be + // inserted after the matching closing parenthesis. } } } } if (autoInsertBrackets && item.data.canConvert()) { + if (typedChar == QLatin1Char('(')) + typedChar = QChar(); + // everything from the closing parenthesis on are extra chars, to // make sure an auto-inserted ")" gets replaced by ") const" if necessary int closingParen = toInsert.lastIndexOf(QLatin1Char(')')); @@ -1811,6 +1860,13 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) } } + // Append an unhandled typed character, adjusting cursor offset when it had been adjusted before + if (!typedChar.isNull()) { + extraChars += typedChar; + if (cursorOffset != 0) + --cursorOffset; + } + // Avoid inserting characters that are already there for (int i = 0; i < extraChars.length(); ++i) { const QChar a = extraChars.at(i); @@ -1836,7 +1892,7 @@ bool CppCodeCompletion::partiallyComplete(const QList *completions); - void complete(const TextEditor::CompletionItem &item); + bool typedCharCompletes(const TextEditor::CompletionItem &item, QChar typedChar); + void complete(const TextEditor::CompletionItem &item, QChar typedChar); bool partiallyComplete(const QList &completionItems); void cleanup(); diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 45c79e783ec..75fe53fda81 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "cppcodeformatter.h" #include @@ -828,7 +857,7 @@ int CodeFormatter::tokenizeBlock(const QTextBlock &block, bool *endedJoined) *endedJoined = tokenize.endedJoined(); const int lexerState = tokenize.state(); - TextBlockUserData::setLexerState(block, lexerState); + BaseTextDocumentLayout::setLexerState(block, lexerState); return lexerState; } @@ -913,12 +942,12 @@ bool QtStyleCodeFormatter::loadBlockData(const QTextBlock &block, BlockData *dat void QtStyleCodeFormatter::saveLexerState(QTextBlock *block, int state) const { - TextBlockUserData::setLexerState(*block, state); + BaseTextDocumentLayout::setLexerState(*block, state); } int QtStyleCodeFormatter::loadLexerState(const QTextBlock &block) const { - return TextBlockUserData::lexerState(block); + return BaseTextDocumentLayout::lexerState(block); } void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedIndentDepth) const diff --git a/src/plugins/cpptools/cppcodeformatter.h b/src/plugins/cpptools/cppcodeformatter.h index bc615586fed..fb3db4997fc 100644 --- a/src/plugins/cpptools/cppcodeformatter.h +++ b/src/plugins/cpptools/cppcodeformatter.h @@ -1,3 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef CPPCODEFORMATTER_H #define CPPCODEFORMATTER_H diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 194b4ed7909..d785bf1097b 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -148,7 +148,7 @@ public: CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelManager) : QObject(modelManager), _modelManager(modelManager), - _resultWindow(ExtensionSystem::PluginManager::instance()->getObject()) + _resultWindow(Find::SearchResultWindow::instance()) { m_watcher.setPendingResultsLimit(1); connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index dcff150363d..9b84e8012ba 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -160,8 +160,9 @@ void CppToolsPlugin::extensionsInitialized() m_modelManager->setHeaderSuffixes(mimeType.suffixes()); } -void CppToolsPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown() { + return SynchronousShutdown; } void CppToolsPlugin::switchHeaderSource() diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h index 97e95b017fa..532662b2aec 100644 --- a/src/plugins/cpptools/cpptoolsplugin.h +++ b/src/plugins/cpptools/cpptoolsplugin.h @@ -65,7 +65,7 @@ public: bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); CppModelManager *cppModelManager() { return m_modelManager; } QString correspondingHeaderOrSource(const QString &fileName) const; diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp index f66700bf30f..99c2616489d 100644 --- a/src/plugins/cpptools/searchsymbols.cpp +++ b/src/plugins/cpptools/searchsymbols.cpp @@ -96,10 +96,9 @@ bool SearchSymbols::visit(Function *symbol) QString extraScope; if (const Name *name = symbol->name()) { - if (const QualifiedNameId *nameId = name->asQualifiedNameId()) { - if (nameId->nameCount() > 1) { - extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2)); - } + if (const QualifiedNameId *q = name->asQualifiedNameId()) { + if (q->base()) + extraScope = overview.prettyName(q->base()); } } QString fullScope = _scope; diff --git a/src/plugins/debugger/cdb/breakpoint.cpp b/src/plugins/debugger/cdb/breakpoint.cpp index 49a6550990e..3f2525920c7 100644 --- a/src/plugins/debugger/cdb/breakpoint.cpp +++ b/src/plugins/debugger/cdb/breakpoint.cpp @@ -257,9 +257,9 @@ static bool mapDeviceToDriveLetter(QString *s) for (const TCHAR *driveLetter = driveLetters; *driveLetter; driveLetter++) { szDrive[0] = *driveLetter; // Look up each device name if (QueryDosDevice(szDrive, driveName, MAX_PATH)) { - const QString deviceName = QString::fromUtf16(driveName); + const QString deviceName = QString::fromWCharArray(driveName); if (s->startsWith(deviceName)) { - s->replace(0, deviceName.size(), QString::fromUtf16(szDrive)); + s->replace(0, deviceName.size(), QString::fromWCharArray(szDrive)); return true; } } @@ -275,7 +275,7 @@ static bool mapDeviceToDriveLetter(QString *s) static inline QString normalizeFileNameCaseHelper(const QString &f) { - HANDLE hFile = CreateFile(f.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + HANDLE hFile = CreateFile((const wchar_t*)f.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) return f; // Get the file size. We need a non-empty file to map it. @@ -305,7 +305,7 @@ static inline QString normalizeFileNameCaseHelper(const QString &f) pszFilename[0] = 0; // Get a file name of the form "/Device/HarddiskVolume1/file.cpp" if (GetMappedFileName (GetCurrentProcess(), pMem, pszFilename, MAX_PATH)) { - rc = QString::fromUtf16(pszFilename); + rc = QString::fromWCharArray(pszFilename); if (!mapDeviceToDriveLetter(&rc)) rc.clear(); } diff --git a/src/plugins/debugger/cdb/coreengine.cpp b/src/plugins/debugger/cdb/coreengine.cpp index 324d470831f..c84b7b92642 100644 --- a/src/plugins/debugger/cdb/coreengine.cpp +++ b/src/plugins/debugger/cdb/coreengine.cpp @@ -296,7 +296,7 @@ bool CoreEngine::init(const QString &dllEnginePath, QString *errorMessage) *errorMessage = msgComFailed("GetImagePathWide", hr); return false; } - m_baseImagePath = QString::fromUtf16(buf); + m_baseImagePath = QString::fromWCharArray(buf); hr = lib.debugCreate( __uuidof(IDebugRegisters2), reinterpret_cast(&m_cif.debugRegisters)); if (FAILED(hr)) { @@ -447,7 +447,7 @@ bool CoreEngine::startDebuggerWithExecutable(const QString &workingDirectory, PCWSTR workingDirC = 0; const QString workingDirN = workingDirectory.isEmpty() ? QString() : QDir::toNativeSeparators(workingDirectory); if (!workingDirN.isEmpty()) - workingDirC = workingDirN.utf16(); + workingDirC = (PCWSTR)workingDirN.utf16(); hr = m_cif.debugClient->CreateProcess2Wide(NULL, reinterpret_cast(const_cast(cmd.utf16())), &dbgopts, sizeof(dbgopts), @@ -820,7 +820,7 @@ quint64 CoreEngine::getSourceLineAddress(const QString &file, { ULONG64 rc = 0; const HRESULT hr = m_cif.debugSymbols->GetOffsetByLineWide(line, - const_cast(file.utf16()), + (wchar_t*)(file.utf16()), &rc); if (FAILED(hr)) { *errorMessage = QString::fromLatin1("Unable to determine address of %1:%2 : %3"). @@ -830,6 +830,11 @@ quint64 CoreEngine::getSourceLineAddress(const QString &file, return rc; } +void CoreEngine::outputVersion() +{ + m_cif.debugControl->OutputVersionInformation(DEBUG_OUTCTL_ALL_CLIENTS); +} + bool CoreEngine::autoDetectPath(QString *outPath, QStringList *checkedDirectories /* = 0 */) { @@ -978,10 +983,10 @@ static void formatEventFilter(CIDebugControl *ctl, unsigned long start, unsigned HRESULT hr = ctl->GetEventFilterTextWide(i, buffer, bufSize, 0); if (SUCCEEDED(hr)) { ULONG size; - str << "- #" << i << " \"" << QString::fromUtf16(buffer) << '"'; + str << "- #" << i << " \"" << QString::fromWCharArray(buffer) << '"'; hr = ctl->GetEventFilterCommandWide(i, buffer, bufSize, &size); if (SUCCEEDED(hr) && size > 1) - str << " command: '" << QString::fromUtf16(buffer) << '\''; + str << " command: '" << QString::fromWCharArray(buffer) << '\''; if (isException) { DEBUG_EXCEPTION_FILTER_PARAMETERS exceptionParameters; hr = ctl->GetExceptionFilterParameters(1, 0, i, &exceptionParameters); @@ -996,7 +1001,7 @@ static void formatEventFilter(CIDebugControl *ctl, unsigned long start, unsigned if (exceptionParameters.SecondCommandSize) { hr = ctl->GetExceptionFilterSecondCommandWide(i, buffer, bufSize, 0); if (SUCCEEDED(hr)) - str << " 2nd-command '" << QString::fromUtf16(buffer) << '\''; + str << " 2nd-command '" << QString::fromWCharArray(buffer) << '\''; } } } // isException diff --git a/src/plugins/debugger/cdb/coreengine.h b/src/plugins/debugger/cdb/coreengine.h index c73fc7e72da..c6e25e9cede 100644 --- a/src/plugins/debugger/cdb/coreengine.h +++ b/src/plugins/debugger/cdb/coreengine.h @@ -168,6 +168,9 @@ signals: // feature of the engine. void modulesLoaded(); +public slots: + void outputVersion(); + protected: virtual void timerEvent(QTimerEvent* te); diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index 7ce93ba1c96..2e6ded73730 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -74,6 +75,8 @@ namespace Internal { it handles communication between the engine and the bineditor. */ +namespace { const int DataRange = 1024 * 1024; } + MemoryViewAgent::MemoryViewAgent(DebuggerEngine *engine, quint64 addr) : QObject(engine), m_engine(engine) { @@ -113,11 +116,15 @@ void MemoryViewAgent::createBinEditor(quint64 addr) connect(editor->widget(), SIGNAL(newRangeRequested(Core::IEditor *, quint64)), this, SLOT(provideNewRange(Core::IEditor*,quint64))); + connect(editor->widget(), SIGNAL(startOfFileRequested(Core::IEditor *)), + this, SLOT(handleStartOfFileRequested(Core::IEditor*))); + connect(editor->widget(), SIGNAL(endOfFileRequested(Core::IEditor *)), + this, SLOT(handleEndOfFileRequested(Core::IEditor*))); m_editors << editor; editorManager->activateEditor(editor); QMetaObject::invokeMethod(editor->widget(), "setNewWindowRequestAllowed"); QMetaObject::invokeMethod(editor->widget(), "setLazyData", - Q_ARG(quint64, addr), Q_ARG(int, 1024 * 1024), Q_ARG(int, BinBlockSize)); + Q_ARG(quint64, addr), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize)); } else { DebuggerPlugin::instance()->showMessageBox(QMessageBox::Warning, tr("No memory viewer available"), @@ -147,10 +154,26 @@ void MemoryViewAgent::addLazyData(QObject *editorToken, quint64 addr, void MemoryViewAgent::provideNewRange(Core::IEditor *editor, quint64 address) { QMetaObject::invokeMethod(editor->widget(), "setLazyData", - Q_ARG(quint64, address), Q_ARG(int, 1024 * 1024), + Q_ARG(quint64, address), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize)); } +// Since we are not dealing with files, we take these signals to mean +// "move to start/end of range". This seems to make more sense than +// jumping to the start or end of the address space, respectively. +void MemoryViewAgent::handleStartOfFileRequested(Core::IEditor *editor) +{ + QMetaObject::invokeMethod(editor->widget(), + "setCursorPosition", Q_ARG(int, 0)); +} + +void MemoryViewAgent::handleEndOfFileRequested(Core::IEditor *editor) +{ + QMetaObject::invokeMethod(editor->widget(), + "setCursorPosition", Q_ARG(int, DataRange - 1)); +} + + /////////////////////////////////////////////////////////////////////// // diff --git a/src/plugins/debugger/debuggeragents.h b/src/plugins/debugger/debuggeragents.h index 85eab2f353d..396b06fad57 100644 --- a/src/plugins/debugger/debuggeragents.h +++ b/src/plugins/debugger/debuggeragents.h @@ -63,6 +63,8 @@ private: Q_SLOT void createBinEditor(quint64 startAddr); Q_SLOT void fetchLazyData(Core::IEditor *, quint64 block, bool sync); Q_SLOT void provideNewRange(Core::IEditor *editor, quint64 address); + Q_SLOT void handleStartOfFileRequested(Core::IEditor *editor); + Q_SLOT void handleEndOfFileRequested(Core::IEditor *editor); QList > m_editors; QPointer m_engine; diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 3795f73688a..b0ced81a84c 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -207,6 +207,8 @@ void AttachCoreDialog::setCoreFile(const QString &fileName) // /////////////////////////////////////////////////////////////////////// +#ifndef Q_OS_WIN + static bool isUnixProcessId(const QString &procname) { for (int i = 0; i != procname.size(); ++i) @@ -288,6 +290,7 @@ static QList unixProcessList() } return rc; } +#endif // Q_OS_WIN static QList processList() { diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 0f7ba095238..c542087c251 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -87,7 +87,7 @@ public: QString dumperLibrary; QStringList dumperLibraryLocations; - Core::SshServerInfo sshserver; + Core::SshConnectionParameters connParams; DebuggerStartMode startMode; }; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 7e847eab484..c1b2a7fbcbb 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2480,13 +2480,14 @@ void DebuggerPlugin::clearCppCodeModelSnapshot() d->m_codeModelSnapshot = CPlusPlus::Snapshot(); } -void DebuggerPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown() { writeSettings(); if (d->m_uiSwitcher) d->m_uiSwitcher->aboutToShutdown(); //if (d->m_engine) // d->m_engine->shutdown(); + return SynchronousShutdown; } void DebuggerPlugin::showMessage(const QString &msg, int channel, int timeout) diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index d3fadff4c6c..b183c3c855f 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -121,7 +121,7 @@ private: friend class Internal::DebuggerListener ; bool initialize(const QStringList &arguments, QString *errorMessage); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); void extensionsInitialized(); void remoteCommand(const QStringList &options, const QStringList &arguments); diff --git a/src/plugins/debugger/gdb/remotegdbprocess.cpp b/src/plugins/debugger/gdb/remotegdbprocess.cpp index fb7e2d02817..7288f44c7b8 100644 --- a/src/plugins/debugger/gdb/remotegdbprocess.cpp +++ b/src/plugins/debugger/gdb/remotegdbprocess.cpp @@ -33,14 +33,15 @@ #include +using namespace Core; + namespace Debugger { namespace Internal { -RemoteGdbProcess::RemoteGdbProcess(const Core::SshServerInfo &server, +RemoteGdbProcess::RemoteGdbProcess(const Core::SshConnectionParameters &connParams, RemotePlainGdbAdapter *adapter, QObject *parent) - : AbstractGdbProcess(parent), m_serverInfo(server), m_adapter(adapter) + : AbstractGdbProcess(parent), m_connParams(connParams), m_adapter(adapter) { - } QByteArray RemoteGdbProcess::readAllStandardOutput() @@ -59,68 +60,122 @@ QByteArray RemoteGdbProcess::readAllStandardError() void RemoteGdbProcess::start(const QString &cmd, const QStringList &args) { - m_gdbConn = Core::InteractiveSshConnection::create(m_serverInfo); - m_appOutputConn = Core::InteractiveSshConnection::create(m_serverInfo); - m_errOutputConn = Core::InteractiveSshConnection::create(m_serverInfo); m_command = cmd; m_cmdArgs = args; - m_errOutputConn->start(); - m_appOutputConn->start(); - m_gdbConn->start(); - } + m_gdbStarted = false; + m_error.clear(); + m_conn = SshConnection::create(); + connect(m_conn.data(), SIGNAL(connected()), this, SLOT(handleConnected())); + connect(m_conn.data(), SIGNAL(error(SshError)), this, + SLOT(handleConnectionError())); + m_conn->connectToHost(m_connParams); +} + +void RemoteGdbProcess::handleConnected() +{ + m_fifoCreator = m_conn->createRemoteProcess( "rm -f " + + AppOutputFile + " && mkfifo " + AppOutputFile); + connect(m_fifoCreator.data(), SIGNAL(closed(int)), this, + SLOT(handleFifoCreationFinished(int))); + m_fifoCreator->start(); +} + +void RemoteGdbProcess::handleConnectionError() +{ + emitErrorExit(tr("Connection could not be established.")); +} + +void RemoteGdbProcess::handleFifoCreationFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) { + emitErrorExit(tr("Could not create FIFO.")); + } else { + m_appOutputReader = m_conn->createRemoteProcess("cat " + AppOutputFile); + connect(m_appOutputReader.data(), SIGNAL(started()), this, + SLOT(handleAppOutputReaderStarted())); + connect(m_appOutputReader.data(), SIGNAL(closed(int)), this, + SLOT(handleAppOutputReaderFinished(int))); + m_appOutputReader->start(); + } +} + +void RemoteGdbProcess::handleAppOutputReaderStarted() +{ + connect(m_appOutputReader.data(), SIGNAL(outputAvailable(QByteArray)), + this, SLOT(handleAppOutput(QByteArray))); + QByteArray cmdLine = "DISPLAY=:0.0 " + m_command.toUtf8() + ' ' + + m_cmdArgs.join(QLatin1String(" ")).toUtf8() + + " -tty=" + AppOutputFile; + if (!m_wd.isEmpty()) + cmdLine.prepend("cd " + m_wd.toUtf8() + " && "); + m_gdbProc = m_conn->createRemoteProcess(cmdLine); + connect(m_gdbProc.data(), SIGNAL(started()), this, + SLOT(handleGdbStarted())); + connect(m_gdbProc.data(), SIGNAL(closed(int)), this, + SLOT(handleGdbFinished(int))); + connect(m_gdbProc.data(), SIGNAL(outputAvailable(QByteArray)), this, + SLOT(handleGdbOutput(QByteArray))); + connect(m_gdbProc.data(), SIGNAL(errorOutputAvailable(QByteArray)), this, + SLOT(handleErrOutput(QByteArray))); + m_gdbProc->start(); +} + +void RemoteGdbProcess::handleAppOutputReaderFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) + emitErrorExit(tr("Application output reader unexpectedly finished.")); +} + +void RemoteGdbProcess::handleGdbStarted() +{ + m_gdbStarted = true; +} + +void RemoteGdbProcess::handleGdbFinished(int exitStatus) +{ + switch (exitStatus) { + case SshRemoteProcess::FailedToStart: + emitErrorExit(tr("Remote gdb failed to start.")); + break; + case SshRemoteProcess::KilledBySignal: + emitErrorExit(tr("Remote gdb crashed.")); + break; + case SshRemoteProcess::ExitedNormally: + emit finished(m_gdbProc->exitCode(), QProcess::NormalExit); + break; + } + disconnect(m_conn.data(), 0, this, 0); + m_gdbProc = SshRemoteProcess::Ptr(); + m_appOutputReader = SshRemoteProcess::Ptr(); + m_conn->disconnectFromHost(); +} bool RemoteGdbProcess::waitForStarted() { - if (!waitForInputReady(m_appOutputConn)) - return false; - if (!sendAndWaitForEcho(m_appOutputConn, readerCmdLine(AppOutputFile))) - return false; - if (!waitForInputReady(m_errOutputConn)) - return false; - if (!sendAndWaitForEcho(m_errOutputConn, readerCmdLine(ErrOutputFile))) - return false; - if (!waitForInputReady(m_gdbConn)) - return false; - connect(m_appOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleAppOutput())); - connect(m_errOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleErrOutput())); - connect(m_gdbConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleGdbOutput())); - m_gdbStarted = false; - m_gdbCmdLine = "stty -echo && DISPLAY=:0.0 " + m_command.toUtf8() + ' ' - + m_cmdArgs.join(QLatin1String(" ")).toUtf8() - + " -tty=" + AppOutputFile + " 2>" + ErrOutputFile + '\n'; - if (!m_wd.isEmpty()) - m_gdbCmdLine.prepend("cd " + m_wd.toUtf8() + " && "); - if (sendInput(m_gdbCmdLine) != m_gdbCmdLine.count()) - return false; - - return true; + return m_error.isEmpty(); } qint64 RemoteGdbProcess::write(const QByteArray &data) { - if (!m_gdbStarted || !m_inputToSend.isEmpty() || !m_lastSeqNr.isEmpty()) { + if (!m_gdbStarted || !m_inputToSend.isEmpty() || !m_lastSeqNr.isEmpty()) m_inputToSend.enqueue(data); - return data.size(); - } else { - return sendInput(data); - } + else + sendInput(data); + return data.size(); } void RemoteGdbProcess::kill() { - stopReaders(); - Core::InteractiveSshConnection::Ptr controlConn - = Core::InteractiveSshConnection::create(m_serverInfo); - if (!controlConn->hasError()) { - if (controlConn->start()) - controlConn->sendInput("pkill -x gdb\r\n"); - } + SshRemoteProcess::Ptr killProc + = m_conn->createRemoteProcess("pkill -SIGKILL -x gdb"); + killProc->start(); +} - m_gdbConn->quit(); - emit finished(0, QProcess::CrashExit); +void RemoteGdbProcess::interruptInferior() +{ + SshRemoteProcess::Ptr intProc + = m_conn->createRemoteProcess("pkill -x -SIGINT gdb"); + intProc->start(); } QProcess::ProcessState RemoteGdbProcess::state() const @@ -130,35 +185,19 @@ QProcess::ProcessState RemoteGdbProcess::state() const QString RemoteGdbProcess::errorString() const { - return m_gdbConn ? m_gdbConn->error() : QString(); + return m_error; } -void RemoteGdbProcess::handleGdbOutput() +void RemoteGdbProcess::handleGdbOutput(const QByteArray &output) { - m_currentGdbOutput - += removeCarriageReturn(m_gdbConn->waitForRemoteOutput(0)); + // TODO: Carriage return removal still necessary? + m_currentGdbOutput += removeCarriageReturn(output); #if 0 qDebug("%s: complete unread output is '%s'", Q_FUNC_INFO, m_currentGdbOutput.data()); #endif - if (checkForGdbExit(m_currentGdbOutput)) { - m_currentGdbOutput.clear(); - return; - } - if (!m_currentGdbOutput.endsWith('\n')) return; - if (!m_gdbStarted) { - const int index = m_currentGdbOutput.indexOf(m_gdbCmdLine); - if (index != -1) - m_currentGdbOutput.remove(index, m_gdbCmdLine.size()); - // Note: We can't guarantee that we will match the command line, - // because the remote terminal sometimes inserts control characters. - // Otherwise we could set m_gdbStarted here. - } - - m_gdbStarted = true; - if (m_currentGdbOutput.contains(m_lastSeqNr + '^')) m_lastSeqNr.clear(); @@ -187,7 +226,7 @@ QProcessEnvironment RemoteGdbProcess::processEnvironment() const void RemoteGdbProcess::setProcessEnvironment(const QProcessEnvironment & /* env */) { - // TODO: Do something. + // TODO: Do something. (if remote process exists: set, otherwise queue) } void RemoteGdbProcess::setEnvironment(const QStringList & /* env */) @@ -211,48 +250,27 @@ int RemoteGdbProcess::findAnchor(const QByteArray &data) const return -1; } -qint64 RemoteGdbProcess::sendInput(const QByteArray &data) +void RemoteGdbProcess::sendInput(const QByteArray &data) { int pos; for (pos = 0; pos < data.size(); ++pos) if (!isdigit(data.at(pos))) break; m_lastSeqNr = data.left(pos); - return m_gdbConn->sendInput(data) ? data.size() : 0; + m_gdbProc->sendInput(data); } -void RemoteGdbProcess::handleAppOutput() +void RemoteGdbProcess::handleAppOutput(const QByteArray &output) { - m_adapter->handleApplicationOutput(m_appOutputConn->waitForRemoteOutput(0)); + m_adapter->handleApplicationOutput(output); } -void RemoteGdbProcess::handleErrOutput() +void RemoteGdbProcess::handleErrOutput(const QByteArray &output) { - m_errorOutput += m_errOutputConn->waitForRemoteOutput(0); + m_errorOutput += output; emit readyReadStandardError(); } -void RemoteGdbProcess::stopReaders() -{ - if (m_appOutputConn) { - disconnect(m_appOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleAppOutput())); - m_appOutputConn->sendInput(CtrlC); - m_appOutputConn->quit(); - } - if (m_errOutputConn) { - disconnect(m_errOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleErrOutput())); - m_errOutputConn->sendInput(CtrlC); - m_errOutputConn->quit(); - } -} - -QByteArray RemoteGdbProcess::readerCmdLine(const QByteArray &file) -{ - return "rm -f " + file + " && mkfifo " + file + " && cat " + file + "\r\n"; -} - QByteArray RemoteGdbProcess::removeCarriageReturn(const QByteArray &data) { QByteArray output; @@ -264,48 +282,16 @@ QByteArray RemoteGdbProcess::removeCarriageReturn(const QByteArray &data) return output; } -bool RemoteGdbProcess::checkForGdbExit(QByteArray &output) +void RemoteGdbProcess::emitErrorExit(const QString &error) { - const QByteArray exitString("^exit"); - const int exitPos = output.indexOf(exitString); - if (exitPos == -1) - return false; - - emit finished(0, QProcess::NormalExit); - disconnect(m_gdbConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleGdbOutput())); - output.remove(exitPos + exitString.size(), output.size()); - stopReaders(); - return true; -} - -bool RemoteGdbProcess::waitForInputReady(Core::InteractiveSshConnection::Ptr &conn) -{ - if (conn->waitForRemoteOutput(m_serverInfo.timeout).isEmpty()) - return false; - while (!conn->waitForRemoteOutput(100).isEmpty()) - ; - return true; -} - -bool RemoteGdbProcess::sendAndWaitForEcho(Core::InteractiveSshConnection::Ptr &conn, - const QByteArray &cmdLine) -{ - conn->sendInput(cmdLine); - QByteArray allOutput; - while (!allOutput.endsWith(cmdLine)) { - const QByteArray curOutput = conn->waitForRemoteOutput(100); - if (curOutput.isEmpty()) - return false; - allOutput += curOutput; + if (m_error.isEmpty()) { + m_error = error; + emit finished(-1, QProcess::CrashExit); } - return true; } - const QByteArray RemoteGdbProcess::CtrlC = QByteArray(1, 0x3); const QByteArray RemoteGdbProcess::AppOutputFile("app_output"); -const QByteArray RemoteGdbProcess::ErrOutputFile("err_output"); } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/gdb/remotegdbprocess.h b/src/plugins/debugger/gdb/remotegdbprocess.h index 1008b334da7..9a9679b6952 100644 --- a/src/plugins/debugger/gdb/remotegdbprocess.h +++ b/src/plugins/debugger/gdb/remotegdbprocess.h @@ -33,6 +33,7 @@ #include "abstractgdbprocess.h" #include +#include #include #include @@ -46,7 +47,7 @@ class RemoteGdbProcess : public AbstractGdbProcess { Q_OBJECT public: - RemoteGdbProcess(const Core::SshServerInfo &server, + RemoteGdbProcess(const Core::SshConnectionParameters &server, RemotePlainGdbAdapter *adapter, QObject *parent = 0); virtual QByteArray readAllStandardOutput(); @@ -65,32 +66,37 @@ public: virtual void setEnvironment(const QStringList &env); virtual void setWorkingDirectory(const QString &dir); + void interruptInferior(); + static const QByteArray CtrlC; private slots: - void handleGdbOutput(); - void handleAppOutput(); - void handleErrOutput(); + void handleConnected(); + void handleConnectionError(); + void handleFifoCreationFinished(int exitStatus); + void handleAppOutputReaderStarted(); + void handleAppOutputReaderFinished(int exitStatus); + void handleGdbStarted(); + void handleGdbFinished(int exitStatus); + void handleGdbOutput(const QByteArray &output); + void handleAppOutput(const QByteArray &output); + void handleErrOutput(const QByteArray &output); private: static QByteArray readerCmdLine(const QByteArray &file); int findAnchor(const QByteArray &data) const; - qint64 sendInput(const QByteArray &data); - void stopReaders(); + void sendInput(const QByteArray &data); QByteArray removeCarriageReturn(const QByteArray &data); - bool checkForGdbExit(QByteArray &output); - bool sendAndWaitForEcho(Core::InteractiveSshConnection::Ptr &conn, - const QByteArray &cmdLine); - bool waitForInputReady(Core::InteractiveSshConnection::Ptr &conn); + void emitErrorExit(const QString &error); static const QByteArray AppOutputFile; - static const QByteArray ErrOutputFile; - Core::SshServerInfo m_serverInfo; - Core::InteractiveSshConnection::Ptr m_gdbConn; - Core::InteractiveSshConnection::Ptr m_appOutputConn; - Core::InteractiveSshConnection::Ptr m_errOutputConn; + Core::SshConnectionParameters m_connParams; + Core::SshConnection::Ptr m_conn; + Core::SshRemoteProcess::Ptr m_gdbProc; + Core::SshRemoteProcess::Ptr m_appOutputReader; + Core::SshRemoteProcess::Ptr m_fifoCreator; QByteArray m_gdbOutput; QByteArray m_errorOutput; QString m_command; @@ -99,7 +105,7 @@ private: QQueue m_inputToSend; QByteArray m_currentGdbOutput; QByteArray m_lastSeqNr; - QByteArray m_gdbCmdLine; + QString m_error; bool m_gdbStarted; RemotePlainGdbAdapter *m_adapter; diff --git a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp index 2f519188833..88946c11360 100644 --- a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp @@ -40,7 +40,7 @@ namespace Internal { RemotePlainGdbAdapter::RemotePlainGdbAdapter(GdbEngine *engine, QObject *parent) : AbstractPlainGdbAdapter(engine, parent), - m_gdbProc(engine->startParameters().sshserver, this) + m_gdbProc(engine->startParameters().connParams, this) { } @@ -60,7 +60,7 @@ void RemotePlainGdbAdapter::startAdapter() void RemotePlainGdbAdapter::interruptInferior() { - m_gdbProc.write(RemoteGdbProcess::CtrlC); + m_gdbProc.interruptInferior(); } QByteArray RemotePlainGdbAdapter::execFilePath() const diff --git a/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp b/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp index a3b9f7624dc..f9bf949cbc6 100644 --- a/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/tcftrkgdbadapter.cpp @@ -270,6 +270,7 @@ void TcfTrkGdbAdapter::tcftrkEvent(const tcftrk::TcfTrkEvent &e) switch (e.type()) { case tcftrk::TcfTrkEvent::LocatorHello: + m_trkDevice->sendLoggingAddListenerCommand(TcfTrkCallback()); startGdb(); // Commands are only accepted after hello break; case tcftrk::TcfTrkEvent::RunControlModuleLoadSuspended: // A module was loaded @@ -311,6 +312,9 @@ void TcfTrkGdbAdapter::tcftrkEvent(const tcftrk::TcfTrkEvent &e) Symbian::RegisterCount); } break; + case tcftrk::TcfTrkEvent::LoggingWriteEvent: // TODO: Not tested yet. + showMessage(e.toString(), AppOutput); + break; default: break; } diff --git a/src/plugins/debugger/shared/sharedlibraryinjector.cpp b/src/plugins/debugger/shared/sharedlibraryinjector.cpp index c83c2a402e6..04c39071f55 100644 --- a/src/plugins/debugger/shared/sharedlibraryinjector.cpp +++ b/src/plugins/debugger/shared/sharedlibraryinjector.cpp @@ -50,7 +50,7 @@ template inline bool resolveSymbol(const char *libraryName, HMODULE libraryHandle, const char *symbolName, SymbolType *s, QString *errorMessage) { *s = 0; - FARPROC WINAPI vs = ::GetProcAddress(libraryHandle, symbolName); + FARPROC vs = ::GetProcAddress(libraryHandle, symbolName); if (vs == 0) { *errorMessage = QString::fromLatin1("Unable to resolve '%2' in '%1'.").arg(QString::fromAscii(symbolName), QString::fromAscii(libraryName)); return false; diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index be26c36f2c5..4f4c2f542d2 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -693,8 +693,8 @@ QString decodeData(const QByteArray &ba, int encoding) decodedBa[i + 1] = c; } //qDebug() << quoteUnprintableLatin1(decodedBa) << "\n\n"; - return doubleQuote + QString::fromUcs4(reinterpret_cast - (decodedBa.data()), decodedBa.size() / 4) + doubleQuote; + return doubleQuote + QString::fromUtf16(reinterpret_cast + (decodedBa.data()), decodedBa.size() / 2) + doubleQuote; } } qDebug() << "ENCODING ERROR: " << encoding; diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index f5a44b06024..d4bde7f222f 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -149,19 +149,21 @@ enum Mode enum SubMode { NoSubMode, - ChangeSubMode, // Used for c - DeleteSubMode, // Used for d - FilterSubMode, // Used for ! - IndentSubMode, // Used for = - RegisterSubMode, // Used for " - ShiftLeftSubMode, // Used for < - ShiftRightSubMode, // Used for > - TransformSubMode, // Used for ~/gu/gU - WindowSubMode, // Used for Ctrl-w - YankSubMode, // Used for y - ZSubMode, // Used for z - CapitalZSubMode, // Used for Z - ReplaceSubMode, // Used for r + ChangeSubMode, // Used for c + DeleteSubMode, // Used for d + FilterSubMode, // Used for ! + IndentSubMode, // Used for = + RegisterSubMode, // Used for " + ShiftLeftSubMode, // Used for < + ShiftRightSubMode, // Used for > + TransformSubMode, // Used for ~/gu/gU + WindowSubMode, // Used for Ctrl-w + YankSubMode, // Used for y + ZSubMode, // Used for z + CapitalZSubMode, // Used for Z + ReplaceSubMode, // Used for r + OpenSquareSubMode, // Used for [ + CloseSquareSubMode, // Used for ] }; /*! A \e SubSubMode is used for things that require one more data item @@ -232,6 +234,11 @@ struct Column int logical; // Column on screen. }; +QDebug operator<<(QDebug ts, const Column &col) +{ + return ts << "(p: " << col.physical << ", l: " << col.logical << ")"; +} + struct CursorPosition { // for jump history @@ -292,7 +299,7 @@ QDebug operator<<(QDebug ts, const Range &range) ExCommand::ExCommand(const QString &c, const QString &a, const Range &r) - : cmd(c), hasBang(false), args(a), range(r) + : cmd(c), hasBang(false), args(a), range(r), count(1) {} QDebug operator<<(QDebug ts, const ExCommand &cmd) @@ -600,12 +607,15 @@ public: EventResult handleCommandMode(const Input &); EventResult handleRegisterMode(const Input &); EventResult handleExMode(const Input &); + EventResult handleOpenSquareSubMode(const Input &); + EventResult handleCloseSquareSubMode(const Input &); EventResult handleSearchSubSubMode(const Input &); EventResult handleCommandSubSubMode(const Input &); void finishMovement(const QString &dotCommand = QString()); void finishMovement(const QString &dotCommand, int count); void resetCommandMode(); void search(const SearchData &sd); + void searchBalanced(bool forward, QChar needle, QChar other); void highlightMatches(const QString &needle); void stopIncrementalFind(); @@ -1680,6 +1690,34 @@ EventResult FakeVimHandler::Private::handleCommandSubSubMode(const Input &input) return handled; } +EventResult FakeVimHandler::Private::handleOpenSquareSubMode(const Input &input) +{ + EventResult handled = EventHandled; + m_submode = NoSubMode; + if (input.is('{')) { + searchBalanced(false, '{', '}'); + } else if (input.is('(')) { + searchBalanced(false, '(', ')'); + } else { + handled = EventUnhandled; + } + return handled; +} + +EventResult FakeVimHandler::Private::handleCloseSquareSubMode(const Input &input) +{ + EventResult handled = EventHandled; + m_submode = NoSubMode; + if (input.is('}')) { + searchBalanced(true, '}', '{'); + } else if (input.is(')')) { + searchBalanced(true, ')', '('); + } else { + handled = EventUnhandled; + } + return handled; +} + EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) { EventResult handled = EventHandled; @@ -1698,6 +1736,10 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) } } else if (m_subsubmode != NoSubSubMode) { handleCommandSubSubMode(input); + } else if (m_submode == OpenSquareSubMode) { + handled = handleOpenSquareSubMode(input); + } else if (m_submode == CloseSquareSubMode) { + handled = handleCloseSquareSubMode(input); } else if (m_submode == WindowSubMode) { emit q->windowCommandRequested(input.key()); m_submode = NoSubMode; @@ -2035,22 +2077,25 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) m_opcount = m_mvcount; m_mvcount.clear(); m_submode = DeleteSubMode; - } else if ((input.is('d') || input.is('x')) && isVisualCharMode()) { - leaveVisualMode(); - m_submode = DeleteSubMode; - finishMovement(); - } else if ((input.is('d') || input.is('x')) && isVisualLineMode()) { - leaveVisualMode(); - m_rangemode = RangeLineMode; - yankText(currentRange(), m_register); - removeText(currentRange()); - handleStartOfLine(); - } else if ((input.is('d') || input.is('x')) && isVisualBlockMode()) { - leaveVisualMode(); - m_rangemode = RangeBlockMode; - yankText(currentRange(), m_register); - removeText(currentRange()); - setPosition(qMin(position(), anchor())); + } else if ((input.is('d') || input.is('x') || input.isKey(Key_Delete)) + && isVisualMode()) { + if (isVisualCharMode()) { + leaveVisualMode(); + m_submode = DeleteSubMode; + finishMovement(); + } else if (isVisualLineMode()) { + leaveVisualMode(); + m_rangemode = RangeLineMode; + yankText(currentRange(), m_register); + removeText(currentRange()); + handleStartOfLine(); + } else if (isVisualBlockMode()) { + leaveVisualMode(); + m_rangemode = RangeBlockMode; + yankText(currentRange(), m_register); + removeText(currentRange()); + setPosition(qMin(position(), anchor())); + } } else if (input.is('D') && isNoVisualMode()) { if (atEndOfLine()) moveLeft(); @@ -2170,7 +2215,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) setCursorPosition(m_jumpListRedo.last()); m_jumpListRedo.pop_back(); } - } else if (input.is('j') || input.isKey(Key_Down)) { + } else if (input.is('j') || input.isKey(Key_Down) + || input.isControl('j') || input.isControl('n')) { m_movetype = MoveLineWise; setAnchor(); moveDown(count()); @@ -2198,7 +2244,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) } endEditBlock(); finishMovement(); - } else if (input.is('k') || input.isKey(Key_Up)) { + } else if (input.is('k') || input.isKey(Key_Up) || input.isControl('p')) { m_movetype = MoveLineWise; setAnchor(); moveUp(count()); @@ -2472,6 +2518,10 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) else if (input.is('U')) m_subsubmode = UpCaseSubSubMode; finishMovement(); + } else if (input.is('[')) { + m_submode = OpenSquareSubMode; + } else if (input.is(']')) { + m_submode = CloseSquareSubMode; } else if (input.isKey(Key_PageDown) || input.isControl('f')) { moveDown(count() * (linesOnScreen() - 2) - cursorLineOnScreen()); scrollToLine(cursorLine()); @@ -2486,6 +2536,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input) setAnchor(); moveRight(qMin(1, rightDist())); removeText(currentRange()); + if (atEndOfLine()) + moveLeft(); } else if (input.isKey(Key_BracketLeft) || input.isKey(Key_BracketRight)) { } else if (input.isControl(Key_BracketRight)) { @@ -2624,11 +2676,11 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input) if (col.logical <= ind.logical && col.logical && startsWithWhitespace(data, col.physical)) { const int ts = config(ConfigTabStop).toInt(); - const int newcol = col.logical - 1 - (col.logical - 1) % ts; - data.remove(0, col.physical); - setLineContents(line, tabExpand(newcol).append(data)); + const int newl = col.logical - 1 - (col.logical - 1) % ts; + const QString prefix = tabExpand(newl); + setLineContents(line, prefix + data.mid(col.physical)); moveToStartOfLine(); - moveRight(newcol); + moveRight(prefix.size()); m_lastInsertion.clear(); // FIXME } else { m_tc.deletePreviousChar(); @@ -2649,14 +2701,18 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input) removeAutomaticIndentation(); moveUp(count() * (linesOnScreen() - 2)); m_lastInsertion.clear(); - } else if (input.isKey(Key_Tab) && hasConfig(ConfigExpandTab)) { + } else if (input.isKey(Key_Tab)) { m_justAutoIndented = 0; - const int ts = config(ConfigTabStop).toInt(); - const int col = logicalCursorColumn(); - QString str = QString(ts - col % ts, ' '); - m_lastInsertion.append(str); - insertText(str); - setTargetColumn(); + if (hasConfig(ConfigExpandTab)) { + const int ts = config(ConfigTabStop).toInt(); + const int col = logicalCursorColumn(); + QString str = QString(ts - col % ts, ' '); + m_lastInsertion.append(str); + insertText(str); + setTargetColumn(); + } else { + insertInInsertMode(input.raw()); + } } else if (input.isControl('d')) { // remove one level of indentation from the current line int shift = config(ConfigShiftWidth).toInt(); @@ -3393,7 +3449,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &line0) if (line.startsWith(QLatin1Char('%'))) line = "1,$" + line.mid(1); - int beginLine = readLineCode(line); + const int beginLine = readLineCode(line); int endLine = -1; if (line.startsWith(',')) { line = line.mid(1); @@ -3411,6 +3467,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &line0) cmd.hasBang = arg0.endsWith('!'); if (cmd.hasBang) cmd.cmd.chop(1); + if (beginLine != -1) + cmd.count = beginLine; //qDebug() << "CMD: " << cmd; enterCommandMode(); @@ -3459,6 +3517,40 @@ static void vimPatternToQtPattern(QString *needle, QTextDocument::FindFlags *fla //qDebug() << "NEEDLE " << needle0 << needle; } +void FakeVimHandler::Private::searchBalanced(bool forward, QChar needle, QChar other) +{ + int level = 1; + int pos = m_tc.position(); + const int npos = forward ? lastPositionInDocument() : 0; + QTextDocument *doc = m_tc.document(); + while (true) { + if (forward) + ++pos; + else + --pos; + if (pos == npos) + return; + QChar c = doc->characterAt(pos); + if (c == other) + ++level; + else if (c == needle) + --level; + if (level == 0) { + const int oldLine = cursorLine() - cursorLineOnScreen(); + m_tc.setPosition(pos, MoveAnchor); + m_tc.clearSelection(); + EDITOR(setTextCursor(m_tc)); + // Making this unconditional feels better, but is not "vim like". + if (oldLine != cursorLine() - cursorLineOnScreen()) + scrollToLine(cursorLine() - linesOnScreen() / 2); + setTargetColumn(); + updateSelection(); + recordJump(); + return; + } + } +} + void FakeVimHandler::Private::search(const SearchData &sd) { if (sd.needle.isEmpty()) @@ -3613,13 +3705,13 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) if (hasConfig(ConfigStartOfLine)) targetPos = firstPositionInLine(beginLine); - int len = config(ConfigShiftWidth).toInt() * repeat; - QString indent(len, ' '); - + const int sw = config(ConfigShiftWidth).toInt(); beginEditBlock(targetPos); for (int line = beginLine; line <= endLine; ++line) { - setPosition(firstPositionInLine(line)); - m_tc.insertText(indent); + QString data = lineContents(line); + const Column col = indentation(data); + data = tabExpand(col.logical + sw * repeat) + data.mid(col.physical); + setLineContents(line, data); } endEditBlock(); @@ -4301,10 +4393,12 @@ void FakeVimHandler::Private::setLineContents(int line, const QString &contents) { QTextBlock block = m_tc.document()->findBlockByNumber(line - 1); QTextCursor tc = m_tc; - tc.setPosition(block.position()); - tc.setPosition(block.position() + block.length() - 1, KeepAnchor); + const int begin = block.position(); + const int len = block.length(); + tc.setPosition(begin); + tc.setPosition(begin + len - 1, KeepAnchor); tc.removeSelectedText(); - fixMarks(block.position(), block.length() - contents.size()); + fixMarks(begin, contents.size() + 1 - len); tc.insertText(contents); } diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index f5b0db1c040..6db23a2d460 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -60,7 +60,7 @@ struct Range struct ExCommand { - ExCommand() : hasBang(false) {} + ExCommand() : hasBang(false), count(1) {} ExCommand(const QString &cmd, const QString &args = QString(), const Range &range = Range()); @@ -68,6 +68,7 @@ struct ExCommand bool hasBang; QString args; Range range; + int count; }; class FakeVimHandler : public QObject diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 0ecdcdc4fa9..fc313bac387 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -102,8 +102,6 @@ const char * const SETTINGS_CATEGORY = "D.FakeVim"; const char * const SETTINGS_CATEGORY_FAKEVIM_ICON = ":/core/images/category_fakevim.png"; const char * const SETTINGS_ID = "A.General"; const char * const SETTINGS_EX_CMDS_ID = "B.ExCommands"; -const char * const CMD_FILE_NEXT = "FakeVim.SwitchFileNext"; -const char * const CMD_FILE_PREV = "FakeVim.SwitchFilePrev"; } // namespace Constants } // namespace FakeVim @@ -119,6 +117,7 @@ namespace FakeVim { namespace Internal { typedef QMap CommandMap; +typedef QLatin1String _; class FakeVimOptionPage : public Core::IOptionsPage { @@ -128,11 +127,12 @@ public: FakeVimOptionPage() {} // IOptionsPage - QString id() const { return QLatin1String(Constants::SETTINGS_ID); } + QString id() const { return _(Constants::SETTINGS_ID); } QString displayName() const { return tr("General"); } - QString category() const { return QLatin1String(Constants::SETTINGS_CATEGORY); } + QString category() const { return _(Constants::SETTINGS_CATEGORY); } QString displayCategory() const { return tr("FakeVim"); } - QIcon categoryIcon() const { return QIcon(QLatin1String(Constants::SETTINGS_CATEGORY_FAKEVIM_ICON)); } + QIcon categoryIcon() const + { return QIcon(_(Constants::SETTINGS_CATEGORY_FAKEVIM_ICON)); } QWidget *createPage(QWidget *parent); void apply() { m_group.apply(ICore::instance()->settings()); } @@ -238,7 +238,7 @@ void FakeVimOptionPage::setQtStyle() m_ui.checkBoxAutoIndent->setChecked(true); m_ui.checkBoxSmartIndent->setChecked(true); m_ui.checkBoxIncSearch->setChecked(true); - m_ui.lineEditBackspace->setText(QLatin1String("indent,eol,start")); + m_ui.lineEditBackspace->setText(_("indent,eol,start")); } void FakeVimOptionPage::setPlainStyle() @@ -275,7 +275,7 @@ struct CommandItem QTreeWidgetItem *m_item; }; -Q_DECLARE_METATYPE(CommandItem*); +Q_DECLARE_METATYPE(CommandItem *); namespace FakeVim { namespace Internal { @@ -288,9 +288,9 @@ public: FakeVimExCommandsPage(FakeVimPluginPrivate *q) : m_q(q) {} // IOptionsPage - QString id() const { return QLatin1String(Constants::SETTINGS_EX_CMDS_ID); } + QString id() const { return _(Constants::SETTINGS_EX_CMDS_ID); } QString displayName() const { return tr("Ex Command Mapping"); } - QString category() const { return QLatin1String(Constants::SETTINGS_CATEGORY); } + QString category() const { return _(Constants::SETTINGS_CATEGORY); } QString displayCategory() const { return tr("FakeVim"); } QIcon categoryIcon() const { return QIcon(); } // TODO: Icon for FakeVim @@ -512,9 +512,8 @@ private slots: void handleDelayedQuitAll(bool forced); void handleDelayedQuit(bool forced, Core::IEditor *editor); - void switchFile(bool previous); - void switchFileNext(); - void switchFilePrev(); + void switchToFile(int n); + int currentFile() const; signals: void delayedQuitRequested(bool forced, Core::IEditor *editor); @@ -525,6 +524,8 @@ private: FakeVimOptionPage *m_fakeVimOptionsPage; FakeVimExCommandsPage *m_fakeVimExCommandsPage; QHash m_editorToHandler; + QPointer m_editorManager; + EditorManager *editorManager() const { return m_editorManager; } void triggerAction(const QString &code); void setActionChecked(const QString &code, bool check); @@ -546,10 +547,6 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin) q = plugin; m_fakeVimOptionsPage = 0; m_fakeVimExCommandsPage = 0; - defaultExCommandMap()[Constants::CMD_FILE_NEXT] = - QRegExp("^n(ext)?!?( (.*))?$"); - defaultExCommandMap()[Constants::CMD_FILE_PREV] = - QRegExp("^(N(ext)?|prev(ious)?)!?( (.*))?$"); defaultExCommandMap()[CppTools::Constants::SWITCH_HEADER_SOURCE] = QRegExp("^A$"); defaultExCommandMap()["Coreplugin.OutputPane.previtem"] = @@ -560,7 +557,7 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin) QRegExp("^tag?$"); defaultExCommandMap()[Core::Constants::GO_BACK] = QRegExp("^pop?$"); - defaultExCommandMap()[QLatin1String("QtCreator.Locate")] = + defaultExCommandMap()[_("QtCreator.Locate")] = QRegExp("^e$"); } @@ -584,6 +581,7 @@ void FakeVimPluginPrivate::aboutToShutdown() bool FakeVimPluginPrivate::initialize() { + m_editorManager = Core::ICore::instance()->editorManager(); Core::ActionManager *actionManager = Core::ICore::instance()->actionManager(); QTC_ASSERT(actionManager, return false); @@ -607,10 +605,9 @@ bool FakeVimPluginPrivate::initialize() advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR); // EditorManager - QObject *editorManager = Core::ICore::instance()->editorManager(); - connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)), + connect(editorManager(), SIGNAL(editorAboutToClose(Core::IEditor*)), this, SLOT(editorAboutToClose(Core::IEditor*))); - connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)), + connect(editorManager(), SIGNAL(editorOpened(Core::IEditor*)), this, SLOT(editorOpened(Core::IEditor*))); connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)), @@ -618,16 +615,6 @@ bool FakeVimPluginPrivate::initialize() connect(theFakeVimSetting(ConfigReadVimRc), SIGNAL(valueChanged(QVariant)), this, SLOT(maybeReadVimRc())); - QAction *switchFileNextAction = new QAction(tr("Switch to next file"), this); - cmd = actionManager->registerAction(switchFileNextAction, Constants::CMD_FILE_NEXT, globalcontext); - cmd->setAttribute(Command::CA_Hide); - connect(switchFileNextAction, SIGNAL(triggered()), this, SLOT(switchFileNext())); - - QAction *switchFilePrevAction = new QAction(tr("Switch to previous file"), this); - cmd = actionManager->registerAction(switchFilePrevAction, Constants::CMD_FILE_PREV, globalcontext); - cmd->setAttribute(Command::CA_Hide); - connect(switchFilePrevAction, SIGNAL(triggered()), this, SLOT(switchFilePrev())); - // Delayed operations. connect(this, SIGNAL(delayedQuitRequested(bool,Core::IEditor*)), this, SLOT(handleDelayedQuit(bool,Core::IEditor*)), Qt::QueuedConnection); @@ -645,7 +632,7 @@ static const char *idKey = "Command"; void FakeVimPluginPrivate::writeSettings(QSettings *settings) { - settings->beginWriteArray(QLatin1String(exCommandMapGroup)); + settings->beginWriteArray(_(exCommandMapGroup)); int count = 0; typedef CommandMap::const_iterator Iterator; @@ -657,8 +644,8 @@ void FakeVimPluginPrivate::writeSettings(QSettings *settings) if ((defaultExCommandMap().contains(id) && defaultExCommandMap()[id] != re) || (!defaultExCommandMap().contains(id) && !re.pattern().isEmpty())) { settings->setArrayIndex(count); - settings->setValue(QLatin1String(idKey), id); - settings->setValue(QLatin1String(reKey), re.pattern()); + settings->setValue(_(idKey), id); + settings->setValue(_(reKey), re.pattern()); ++count; } } @@ -670,11 +657,11 @@ void FakeVimPluginPrivate::readSettings(QSettings *settings) { exCommandMap() = defaultExCommandMap(); - int size = settings->beginReadArray(QLatin1String(exCommandMapGroup)); + int size = settings->beginReadArray(_(exCommandMapGroup)); for (int i = 0; i < size; ++i) { settings->setArrayIndex(i); - const QString id = settings->value(QLatin1String(idKey)).toString(); - const QString re = settings->value(QLatin1String(reKey)).toString(); + const QString id = settings->value(_(idKey)).toString(); + const QString re = settings->value(_(reKey)).toString(); exCommandMap()[id] = QRegExp(re); } settings->endArray(); @@ -702,8 +689,8 @@ void FakeVimPluginPrivate::maybeReadVimRc() void FakeVimPluginPrivate::showSettingsDialog() { Core::ICore::instance()->showOptionsDialog( - QLatin1String(Constants::SETTINGS_CATEGORY), - QLatin1String(Constants::SETTINGS_ID)); + _(Constants::SETTINGS_CATEGORY), + _(Constants::SETTINGS_ID)); } void FakeVimPluginPrivate::triggerAction(const QString &code) @@ -873,15 +860,15 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value) if (Find::FindPlugin::instance()) Find::FindPlugin::instance()->setUseFakeVim(on); if (on) { - Core::EditorManager::instance()->showEditorStatusBar( - QLatin1String(Constants::MINI_BUFFER), + editorManager()->showEditorStatusBar( + _(Constants::MINI_BUFFER), "vi emulation mode. Type :q to leave. Use , Ctrl-R to trigger run.", tr("Quit FakeVim"), this, SLOT(quitFakeVim())); foreach (Core::IEditor *editor, m_editorToHandler.keys()) m_editorToHandler[editor]->setupWidget(); } else { - Core::EditorManager::instance()->hideEditorStatusBar( - QLatin1String(Constants::MINI_BUFFER)); + editorManager()->hideEditorStatusBar( + _(Constants::MINI_BUFFER)); TextEditor::TabSettings ts = TextEditor::TextEditorSettings::instance()->tabSettings(); foreach (Core::IEditor *editor, m_editorToHandler.keys()) @@ -912,7 +899,7 @@ void FakeVimPluginPrivate::checkForElectricCharacter(bool *result, QChar c) void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) { using namespace Core; - //qDebug() << "PLUGIN HANDLE: " << cmd.cmd; + //qDebug() << "PLUGIN HANDLE: " << cmd.cmd << cmd.count; *handled = false; @@ -920,8 +907,7 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) if (!handler) return; - EditorManager *editorManager = EditorManager::instance(); - QTC_ASSERT(editorManager, return); + QTC_ASSERT(editorManager(), return); *handled = true; if (cmd.cmd == "w" || cmd.cmd == "write") { @@ -980,6 +966,20 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) setActionChecked(Find::Constants::CASE_SENSITIVE, true); *handled = false; // Let the handler see it as well. } + } else if (cmd.cmd == "n" || cmd.cmd == "next") { + // :n[ext] + switchToFile(currentFile() + cmd.count); + } else if (cmd.cmd == "prev" || cmd.cmd == "previous" + || cmd.cmd == "N" || cmd.cmd == "Next") { + // :prev[ious] + switchToFile(currentFile() - cmd.count); + } else if (cmd.cmd == "bn" || cmd.cmd == "bnext") { + // :bn[ext] + switchToFile(currentFile() + cmd.count); + } else if (cmd.cmd == "bp" || cmd.cmd == "bprevious" + || cmd.cmd == "bN" || cmd.cmd == "bNext") { + // :bp[revious] + switchToFile(currentFile() - cmd.count); } else { // Check whether one of the configure commands matches. typedef CommandMap::const_iterator Iterator; @@ -1027,7 +1027,7 @@ void FakeVimPluginPrivate::moveToMatchingParenthesis(bool *moved, bool *forward, if (undoFakeEOL) cursor->movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 1); if (match == TextEditor::TextBlockUserData::NoMatch) { - // backward matching is according to the character before the cursor + // Backward matching is according to the character before the cursor. bool undoMove = false; if (!cursor->atBlockEnd()) { cursor->movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 1); @@ -1102,8 +1102,8 @@ void FakeVimPluginPrivate::quitFakeVim() void FakeVimPluginPrivate::showCommandBuffer(const QString &contents) { //qDebug() << "SHOW COMMAND BUFFER" << contents; - Core::EditorManager::instance()->showEditorStatusBar( - QLatin1String(Constants::MINI_BUFFER), contents, + editorManager()->showEditorStatusBar( + _(Constants::MINI_BUFFER), contents, tr("Quit FakeVim"), this, SLOT(quitFakeVim())); } @@ -1122,24 +1122,22 @@ void FakeVimPluginPrivate::changeSelection bt->setExtraSelections(BaseTextEditor::FakeVimSelection, selection); } -void FakeVimPluginPrivate::switchFile(bool previous) +int FakeVimPluginPrivate::currentFile() const { - Core::EditorManager *em = Core::EditorManager::instance(); - Core::OpenEditorsModel *model = em->openedEditorsModel(); + Core::OpenEditorsModel *model = editorManager()->openedEditorsModel(); IEditor *cur = Core::EditorManager::instance()->currentEditor(); - int curIdx = model->indexOf(cur).row(); - int nIdx = (curIdx + model->rowCount() + (previous ? -1 : 1)) % model->rowCount(); - em->activateEditor(model->index(nIdx, 0), 0); + return model->indexOf(cur).row(); } -void FakeVimPluginPrivate::switchFileNext() +void FakeVimPluginPrivate::switchToFile(int n) { - switchFile(false); -} - -void FakeVimPluginPrivate::switchFilePrev() -{ - switchFile(true); + Core::OpenEditorsModel *model = editorManager()->openedEditorsModel(); + int size = model->rowCount(); + QTC_ASSERT(size, return); + n = n % size; + if (n < 0) + n += size; + editorManager()->activateEditor(model->index(n, 0), 0); } CommandMap &FakeVimExCommandsPage::exCommandMap() @@ -1175,9 +1173,10 @@ bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessa return d->initialize(); } -void FakeVimPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown() { d->aboutToShutdown(); + return SynchronousShutdown; } void FakeVimPlugin::extensionsInitialized() diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h index a40bb9a9f28..b9e38375e69 100644 --- a/src/plugins/fakevim/fakevimplugin.h +++ b/src/plugins/fakevim/fakevimplugin.h @@ -50,7 +50,7 @@ public: private: // implementation of ExtensionSystem::IPlugin bool initialize(const QStringList &arguments, QString *error_message); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); void extensionsInitialized(); private: diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp index 86dd69e33c6..80e30044cee 100644 --- a/src/plugins/find/basetextfind.cpp +++ b/src/plugins/find/basetextfind.cpp @@ -153,8 +153,15 @@ IFindSupport::Result BaseTextFind::findStep(const QString &txt, IFindSupport::Fi return found ? Found : NotFound; } -bool BaseTextFind::replaceStep(const QString &before, const QString &after, - IFindSupport::FindFlags findFlags) +void BaseTextFind::replace(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags) +{ + QTextCursor cursor = replaceInternal(before, after, findFlags); + setTextCursor(cursor); +} + +QTextCursor BaseTextFind::replaceInternal(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags) { QTextCursor cursor = textCursor(); bool usesRegExp = (findFlags & IFindSupport::FindRegularExpression); @@ -169,6 +176,13 @@ bool BaseTextFind::replaceStep(const QString &before, const QString &after, if ((findFlags&IFindSupport::FindBackward) != 0) cursor.setPosition(start); } + return cursor; +} + +bool BaseTextFind::replaceStep(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags) +{ + QTextCursor cursor = replaceInternal(before, after, findFlags); return find(before, findFlags, cursor); } diff --git a/src/plugins/find/basetextfind.h b/src/plugins/find/basetextfind.h index c62f5a7282e..e2bca511271 100644 --- a/src/plugins/find/basetextfind.h +++ b/src/plugins/find/basetextfind.h @@ -60,6 +60,8 @@ public: Result findIncremental(const QString &txt, IFindSupport::FindFlags findFlags); Result findStep(const QString &txt, IFindSupport::FindFlags findFlags); + void replace(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags); bool replaceStep(const QString &before, const QString &after, IFindSupport::FindFlags findFlags); int replaceAll(const QString &before, const QString &after, @@ -76,6 +78,8 @@ private: bool find(const QString &txt, IFindSupport::FindFlags findFlags, QTextCursor start); + QTextCursor replaceInternal(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags); QTextCursor textCursor() const; void setTextCursor(const QTextCursor&); diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/find/currentdocumentfind.cpp index 18c625b547f..d378823bcba 100644 --- a/src/plugins/find/currentdocumentfind.cpp +++ b/src/plugins/find/currentdocumentfind.cpp @@ -118,6 +118,13 @@ IFindSupport::Result CurrentDocumentFind::findStep(const QString &txt, IFindSupp return m_currentFind->findStep(txt, findFlags); } +void CurrentDocumentFind::replace(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags) +{ + QTC_ASSERT(m_currentFind, return); + m_currentFind->replace(before, after, findFlags); +} + bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after, IFindSupport::FindFlags findFlags) { diff --git a/src/plugins/find/currentdocumentfind.h b/src/plugins/find/currentdocumentfind.h index f104ef5f4b1..f199854c53c 100644 --- a/src/plugins/find/currentdocumentfind.h +++ b/src/plugins/find/currentdocumentfind.h @@ -56,6 +56,8 @@ public: void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags); IFindSupport::Result findIncremental(const QString &txt, IFindSupport::FindFlags findFlags); IFindSupport::Result findStep(const QString &txt, IFindSupport::FindFlags findFlags); + void replace(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags); bool replaceStep(const QString &before, const QString &after, IFindSupport::FindFlags findFlags); int replaceAll(const QString &before, const QString &after, diff --git a/src/plugins/find/find.pro b/src/plugins/find/find.pro index bfdb979332a..d0f67a405c2 100644 --- a/src/plugins/find/find.pro +++ b/src/plugins/find/find.pro @@ -27,7 +27,8 @@ SOURCES += findtoolwindow.cpp \ searchresulttreeitems.cpp \ searchresulttreemodel.cpp \ searchresulttreeview.cpp \ - searchresultwindow.cpp + searchresultwindow.cpp \ + ifindfilter.cpp FORMS += findwidget.ui \ finddialog.ui RESOURCES += find.qrc diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp index f5d22a9128b..900020c7652 100644 --- a/src/plugins/find/findplugin.cpp +++ b/src/plugins/find/findplugin.cpp @@ -143,12 +143,13 @@ void FindPlugin::extensionsInitialized() readSettings(); } -void FindPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag FindPlugin::aboutToShutdown() { d->m_findToolBar->setVisible(false); d->m_findToolBar->setParent(0); d->m_currentDocumentFind->removeConnections(); writeSettings(); + return SynchronousShutdown; } void FindPlugin::filterChanged() @@ -208,7 +209,8 @@ void FindPlugin::setupMenu() mfindadvanced->menu()->setTitle(tr("Advanced Find")); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); - cmd = am->registerAction(d->m_openFindDialog, QLatin1String("Find.Dialog"), globalcontext); + d->m_openFindDialog->setIconText(tr("Advanced...")); + cmd = am->registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); mfindadvanced->addAction(cmd); connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter())); @@ -226,7 +228,7 @@ void FindPlugin::setupFilterMenuItems() d->m_filterActions.clear(); bool haveEnabledFilters = false; foreach (IFindFilter *filter, findInterfaces) { - QAction *action = new QAction(QLatin1String(" ") + filter->name(), this); + QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this); bool isEnabled = filter->isEnabled(); if (isEnabled) haveEnabledFilters = true; diff --git a/src/plugins/find/findplugin.h b/src/plugins/find/findplugin.h index ef0e0d73561..d643be94fca 100644 --- a/src/plugins/find/findplugin.h +++ b/src/plugins/find/findplugin.h @@ -67,7 +67,7 @@ public: // IPlugin bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); QTextDocument::FindFlags findFlags() const; void updateFindCompletion(const QString &text); diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 2dc93236832..6b0118759e7 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -71,7 +71,9 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_enterFindStringAction(0), m_findNextAction(0), m_findPreviousAction(0), + m_replaceAction(0), m_replaceNextAction(0), + m_replacePreviousAction(0), m_casesensitiveIcon(":/find/images/casesensitively.png"), m_regexpIcon(":/find/images/regexp.png"), m_wholewordsIcon(":/find/images/wholewords.png"), @@ -138,6 +140,8 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND); Core::Command *cmd; + m_ui.advancedButton->setDefaultAction(am->command(Constants::ADVANCED_FIND)->action()); + QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this); cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); @@ -168,7 +172,15 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen connect(m_findPreviousAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findPreviousButton->setDefaultAction(cmd->action()); - m_replaceNextAction = new QAction(tr("Replace && Find Next"), this); + m_replaceAction = new QAction(tr("Replace"), this); + cmd = am->registerAction(m_replaceAction, Constants::REPLACE, globalcontext); + cmd->setDefaultKeySequence(QKeySequence()); + mfind->addAction(cmd, Constants::G_FIND_ACTIONS); + connect(m_replaceAction, SIGNAL(triggered()), this, SLOT(invokeReplace())); + m_ui.replaceButton->setDefaultAction(cmd->action()); + + m_replaceNextAction = new QAction(tr("Replace && Find"), this); + m_replaceNextAction->setIconText(tr("Replace && Find")); // work around bug in Qt that kills ampersands in tool button cmd = am->registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); @@ -181,7 +193,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replacePreviousAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); - m_ui.replacePreviousButton->setDefaultAction(cmd->action()); m_replaceAllAction = new QAction(tr("Replace All"), this); cmd = am->registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); @@ -315,6 +326,7 @@ void FindToolBar::updateToolBar() m_findNextAction->setEnabled(enabled); m_findPreviousAction->setEnabled(enabled); + m_replaceAction->setEnabled(replaceEnabled); m_replaceNextAction->setEnabled(replaceEnabled); m_replacePreviousAction->setEnabled(replaceEnabled); m_replaceAllAction->setEnabled(replaceEnabled); @@ -332,9 +344,10 @@ void FindToolBar::updateToolBar() m_ui.replaceLabel->setEnabled(replaceEnabled); m_ui.replaceEdit->setVisible(replaceEnabled); m_ui.replaceLabel->setVisible(replaceEnabled); - m_ui.replacePreviousButton->setVisible(replaceEnabled); + m_ui.replaceButton->setVisible(replaceEnabled); m_ui.replaceNextButton->setVisible(replaceEnabled); m_ui.replaceAllButton->setVisible(replaceEnabled); + m_ui.advancedButton->setVisible(replaceEnabled); layout()->invalidate(); if (!replaceEnabled && enabled && replaceFocus) @@ -433,6 +446,16 @@ void FindToolBar::invokeFindIncremental() } } +void FindToolBar::invokeReplace() +{ + setFindFlag(IFindSupport::FindBackward, false); + if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) { + m_plugin->updateFindCompletion(getFindText()); + m_plugin->updateReplaceCompletion(getReplaceText()); + m_currentDocumentFind->replace(getFindText(), getReplaceText(), effectiveFindFlags()); + } +} + void FindToolBar::invokeReplaceNext() { setFindFlag(IFindSupport::FindBackward, false); diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h index ab8d8a4132f..92abe7e4750 100644 --- a/src/plugins/find/findtoolbar.h +++ b/src/plugins/find/findtoolbar.h @@ -67,6 +67,7 @@ private slots: void invokeFindNext(); void invokeFindPrevious(); void invokeFindStep(); + void invokeReplace(); void invokeReplaceNext(); void invokeReplacePrevious(); void invokeReplaceStep(); @@ -120,6 +121,7 @@ private: QAction *m_enterFindStringAction; QAction *m_findNextAction; QAction *m_findPreviousAction; + QAction *m_replaceAction; QAction *m_replaceNextAction; QAction *m_replacePreviousAction; QAction *m_replaceAllAction; diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp index 5b4bf7d35e3..63993c13cd4 100644 --- a/src/plugins/find/findtoolwindow.cpp +++ b/src/plugins/find/findtoolwindow.cpp @@ -98,7 +98,7 @@ void FindToolWindow::setFindFilters(const QList &filters) m_ui.filterList->clear(); QStringList names; foreach (IFindFilter *filter, filters) { - names << filter->name(); + names << filter->displayName(); m_configWidgets.append(filter->createConfigWidget()); } m_ui.filterList->addItems(names); diff --git a/src/plugins/find/findwidget.ui b/src/plugins/find/findwidget.ui index 0e9b1cafe7a..2457dbc6989 100644 --- a/src/plugins/find/findwidget.ui +++ b/src/plugins/find/findwidget.ui @@ -100,7 +100,7 @@ - + @@ -108,10 +108,16 @@ 3 - + Qt::NoFocus + + Replace + + + Qt::ToolButtonTextOnly + Qt::LeftArrow @@ -125,6 +131,12 @@ Qt::NoFocus + + Replace && Find + + + Qt::ToolButtonTextOnly + Qt::RightArrow @@ -136,7 +148,7 @@ - All + Replace All Qt::ToolButtonTextOnly @@ -156,6 +168,16 @@ + + + + Advanced... + + + Qt::ToolButtonTextOnly + + + diff --git a/src/plugins/find/ifindfilter.cpp b/src/plugins/find/ifindfilter.cpp new file mode 100644 index 00000000000..d2eef03065a --- /dev/null +++ b/src/plugins/find/ifindfilter.cpp @@ -0,0 +1,174 @@ +#include "ifindfilter.h" + +/*! + \class Find::IFindFilter + \brief The IFindFilter class is the base class for find implementations + that are invoked via the \gui{Edit -> Find/Replace -> Advanced Find} + dialog. + + Implementations of this class add an additional "Scope" to the Advanced + Find dialog. That can be any search that requires the user to provide + a text based search term (potentially with find flags like + searching case sensitively or using regular expressions). Existing + scopes are e.g. "All Projects" (i.e. search in all files in all projects) + and "Files on File System" where the user provides a directory and file + patterns to search. + + To make your find scope available to the user, you need to implement this + class, and register an instance of your subclass in the plugin manager. + + A common way to present the search results to the user, is to use the + shared \gui{Search Results} panel. + + If you want to implement a find filter that is doing a file based text + search, you should use Find::BaseFileFind, which already implements all + the details for this kind of search, only requiring you to provide an + iterator over the file names of the files that should be searched. + + If you want to implement a more specialized find filter, you'll need + to + \list + \o Start your search in a separate thread + \o Make this known to the Core::ProgressManager, for a progress bar + and the ability to cancel the search + \o Interface with the shared \gui{Search Results} panel, to show + the search results, handle the event that the user click on one + of the search result items, and possible handle a global replace + of all or some of the search result items. + \endlist + + Luckily QtConcurrent and the search result panel provide the frameworks + that make it relatively easy to implement, + while ensuring a common way for the user. + + The common pattern is roughly this: + + Implement the actual search within a QtConcurrent based method, i.e. + a method that takes a \c{QFutureInterface &future} + as the first parameter and the other information needed for the search + as additional parameters. It should set useful progress information + on the QFutureInterface, regularly check for \c{future.isPaused()} + and \c{future.isCanceled()}, and report the search results + (possibly in chunks) via \c{future.reportResult}. + + In the find filter's find/replaceAll method, get the shared + \gui{Search Results} window, initiate a new search and connect the + signals for handling selection of results and the replace action + (see the Find::SearchResultWindow class for details). + Start your search implementation via the corresponding QtConcurrent + methods. Add the returned QFuture object to the Core::ProgressManager. + Use a QFutureWatcher on the returned QFuture object to receive a signal + when your search implementation reports search results, and add these + to the shared \gui{Search Results} window. +*/ + +/*! + \fn IFindFilter::~IFindFilter() + \internal +*/ + +/*! + \fn QString IFindFilter::id() const + \brief Unique string identifier for this find filter. + + Usually should be something like "MyPlugin.MyFindFilter". +*/ + +/*! + \fn QString IFindFilter::displayName() const + \brief The name of the find filter/scope as presented to the user. + + This is the name that e.g. appears in the scope selection combo box. + Always return a translatable string (i.e. use tr() for the return value). +*/ + +/*! + \fn bool IFindFilter::isEnabled() const + \brief Returns if the user should be able to select this find filter + at the moment. + + This is used e.g. for the "Current Projects" scope - if the user hasn't + opened a project, the scope is disabled. + + \sa changed() +*/ + +/*! + \fn QKeySequence IFindFilter::defaultShortcut() const + \brief Returns the shortcut that can be used to open the advanced find + dialog with this filter/scope preselected. + + Usually return an empty shortcut here, the user can still choose and + assign a specific shortcut to this find scope via the preferences. +*/ + +/*! + \fn bool IFindFilter::isReplaceSupported() const + \brief Returns if the find filter supports search and replace. + + The default value is false, override this method to return true, if + your find filter supports global search and replace. +*/ + +/*! + \fn void IFindFilter::findAll(const QString &txt, QTextDocument::FindFlags findFlags) + \brief This method is called when the user selected this find scope and + initiated a search. + + You should start a thread which actually performs the search for \a txt + using the given \a findFlags + (add it to Core::ProgressManager for a progress bar!) and presents the + search results to the user (using the \gui{Search Results} output pane). + For more information see the descriptions of this class, + Core::ProgressManager, and Find::SearchResultWindow. + + \sa replaceAll() + \sa Core::ProgressManager + \sa Find::SearchResultWindow +*/ + +/*! + \fn void IFindFilter::replaceAll(const QString &txt, QTextDocument::FindFlags findFlags) + \brief Override this method if you want to support search and replace. + + This method is called when the user selected this find scope and + initiated a search and replace. + The default implementation does nothing. + + You should start a thread which actually performs the search for \a txt + using the given \a findFlags + (add it to Core::ProgressManager for a progress bar!) and presents the + search results to the user (using the \gui{Search Results} output pane). + For more information see the descriptions of this class, + Core::ProgressManager, and Find::SearchResultWindow. + + \sa findAll() + \sa Core::ProgressManager + \sa Find::SearchResultWindow +*/ + +/*! + \fn QWidget *IFindFilter::createConfigWidget() + \brief Return a widget that contains additional controls for options + for this find filter. + + The widget will be shown below the common options in the Advanced Find + dialog. It will be reparented and deleted by the find plugin. +*/ + +/*! + \fn void IFindFilter::writeSettings(QSettings *settings) + \brief Called at shutdown to write the state of the additional options + for this find filter to the \a settings. +*/ + +/*! + \fn void IFindFilter::readSettings(QSettings *settings) + \brief Called at startup to read the state of the additional options + for this find filter from the \a settings. +*/ + +/*! + \fn void IFindFilter::changed() + \brief Signals that the enabled state of this find filter has changed. +*/ diff --git a/src/plugins/find/ifindfilter.h b/src/plugins/find/ifindfilter.h index 8f7967e9337..c063b55329c 100644 --- a/src/plugins/find/ifindfilter.h +++ b/src/plugins/find/ifindfilter.h @@ -50,7 +50,7 @@ public: virtual ~IFindFilter() {} virtual QString id() const = 0; - virtual QString name() const = 0; + virtual QString displayName() const = 0; virtual bool isEnabled() const = 0; virtual QKeySequence defaultShortcut() const = 0; virtual bool isReplaceSupported() const { return false; } diff --git a/src/plugins/find/ifindsupport.h b/src/plugins/find/ifindsupport.h index 3d7900f0510..e0293474bb1 100644 --- a/src/plugins/find/ifindsupport.h +++ b/src/plugins/find/ifindsupport.h @@ -65,6 +65,8 @@ public: virtual void highlightAll(const QString &txt, FindFlags findFlags); virtual Result findIncremental(const QString &txt, FindFlags findFlags) = 0; virtual Result findStep(const QString &txt, FindFlags findFlags) = 0; + virtual void replace(const QString &before, const QString &after, + FindFlags findFlags) = 0; virtual bool replaceStep(const QString &before, const QString &after, FindFlags findFlags) = 0; virtual int replaceAll(const QString &before, const QString &after, diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index 45b69f4d753..f6566b5a776 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -160,6 +160,14 @@ namespace Internal { return IFindSupport::NotFound; } + void replace(const QString &before, const QString &after, + IFindSupport::FindFlags findFlags) + { + Q_UNUSED(before) + Q_UNUSED(after) + Q_UNUSED(findFlags) + } + bool replaceStep(const QString &before, const QString &after, IFindSupport::FindFlags findFlags) { @@ -211,8 +219,88 @@ namespace Internal { using namespace Find::Internal; +/*! + \enum Find::SearchResultWindow::SearchMode + Specifies if a search should show the replace UI or not. + + \value SearchOnly + The search doesn't support replace. + \value SearchAndReplace + The search supports replace, so show the UI for it. +*/ + +/*! + \class Find::SearchResult + \brief Reports user interaction like activation of a search result item. + + Whenever a new search is initiated via startNewSearch, an instance of this + class is returned to provide the initiator with the hooks for handling user + interaction. +*/ + +/*! + \fn void SearchResult::activated(const Find::SearchResultItem &item) + \brief Sent if the user activated (e.g. double-clicked) a search result + \a item. +*/ + +/*! + \fn void SearchResult::replaceButtonClicked(const QString &replaceText, const QList &checkedItems) + \brief Sent when the user initiated a replace, e.g. by pressing the replace + all button. + + The signal reports the text to use for replacement in \a replaceText, + and the list of search result items that were selected by the user + in \a checkedItems. + The handler of this signal should apply the replace only on the selected + items. +*/ + +/*! + \class Find::SearchResultWindow + \brief The SearchResultWindow class is the implementation of a commonly + shared \gui{Search Results} output pane. Use it to show search results + to a user. + + Whenever you want to show the user a list of search results, or want + to present UI for a global search and replace, use the single instance + of this class. + + Except for being an implementation of a output pane, the + SearchResultWindow has a few methods and one enum that allows other + plugins to show their search results and hook into the user actions for + selecting an entry and performing a global replace. + + Whenever you start a search, call startNewSearch(SearchMode) to initialize + the search result window. The parameter determines if the GUI for + replacing should be shown. + The method returns a SearchResult object that is your + hook into the signals from user interaction for this search. + When you produce search results, call addResults or addResult to add them + to the search result window. + After the search has finished call finishSearch to inform the search + result window about it. + + After that you get activated signals via your SearchResult instance when + the user selects a search result item, and, if you started the search + with the SearchAndReplace option, the replaceButtonClicked signal + when the user requests a replace. +*/ + +/*! + \fn QString SearchResultWindow::displayName() const + \internal +*/ + +SearchResultWindow *SearchResultWindow::m_instance = 0; + +/*! + \fn SearchResultWindow::SearchResultWindow() + \internal +*/ SearchResultWindow::SearchResultWindow() : d(new SearchResultWindowPrivate) { + m_instance = this; d->m_widget = new QStackedWidget; d->m_widget->setWindowTitle(displayName()); @@ -260,6 +348,10 @@ SearchResultWindow::SearchResultWindow() : d(new SearchResultWindowPrivate) setShowReplaceUI(false); } +/*! + \fn SearchResultWindow::~SearchResultWindow() + \internal +*/ SearchResultWindow::~SearchResultWindow() { writeSettings(); @@ -271,16 +363,38 @@ SearchResultWindow::~SearchResultWindow() delete d; } +/*! + \fn SearchResultWindow *SearchResultWindow::instance() + \brief Returns the single shared instance of the Search Results window. +*/ +SearchResultWindow *SearchResultWindow::instance() +{ + return m_instance; +} + +/*! + \fn void SearchResultWindow::setTextToReplace(const QString &textToReplace) + \brief Sets the value in the UI element that allows the user to type + the text that should replace text in search results to \a textToReplace. +*/ void SearchResultWindow::setTextToReplace(const QString &textToReplace) { d->m_replaceTextEdit->setText(textToReplace); } +/*! + \fn QString SearchResultWindow::textToReplace() const + \brief Returns the text that should replace the text in search results. +*/ QString SearchResultWindow::textToReplace() const { return d->m_replaceTextEdit->text(); } +/*! + \fn void SearchResultWindow::setShowReplaceUI(bool show) + \internal +*/ void SearchResultWindow::setShowReplaceUI(bool show) { d->m_searchResultTreeView->model()->setShowReplaceUI(show); @@ -290,6 +404,10 @@ void SearchResultWindow::setShowReplaceUI(bool show) d->m_isShowingReplaceUI = show; } +/*! + \fn void SearchResultWindow::handleReplaceButton() + \internal +*/ void SearchResultWindow::handleReplaceButton() { QTC_ASSERT(d->m_currentSearch, return); @@ -299,6 +417,10 @@ void SearchResultWindow::handleReplaceButton() d->m_currentSearch->replaceButtonClicked(d->m_replaceTextEdit->text(), checkedItems()); } +/*! + \fn QList SearchResultWindow::checkedItems() const + \internal +*/ QList SearchResultWindow::checkedItems() const { QList result; @@ -318,20 +440,42 @@ QList SearchResultWindow::checkedItems() const return result; } +/*! + \fn void SearchResultWindow::visibilityChanged(bool) + \internal +*/ void SearchResultWindow::visibilityChanged(bool /*visible*/) { } +/*! + \fn QWidget *SearchResultWindow::outputWidget(QWidget *) + \internal +*/ QWidget *SearchResultWindow::outputWidget(QWidget *) { return d->m_widget; } +/*! + \fn QList SearchResultWindow::toolBarWidgets() const + \internal +*/ QList SearchResultWindow::toolBarWidgets() const { return QList() << d->m_expandCollapseButton << d->m_replaceLabel << d->m_replaceTextEdit << d->m_replaceButton; } +/*! + \fn SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndReplace) + \brief Tells the search results window to start a new search. + + This will clear the contents of the previous search and initialize the UI + with regard to showing the replace UI or not (depending on the search mode + in \a searchOrSearchAndReplace). + Returns a SearchResult object that is used for signaling user interaction + with the results of this search. +*/ SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndReplace) { clearContents(); @@ -341,6 +485,11 @@ SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndRep return d->m_currentSearch; } +/*! + \fn void SearchResultWindow::finishSearch() + \brief Notifies the search result window that the current search + has finished, and the UI should reflect that. +*/ void SearchResultWindow::finishSearch() { if (d->m_items.count()) { @@ -350,6 +499,10 @@ void SearchResultWindow::finishSearch() } } +/*! + \fn void SearchResultWindow::clearContents() + \brief Clears the current contents in the search result window. +*/ void SearchResultWindow::clearContents() { d->m_replaceTextEdit->setEnabled(false); @@ -361,6 +514,10 @@ void SearchResultWindow::clearContents() navigateStateChanged(); } +/*! + \fn void SearchResultWindow::showNoMatchesFound() + \internal +*/ void SearchResultWindow::showNoMatchesFound() { d->m_replaceTextEdit->setEnabled(false); @@ -368,26 +525,47 @@ void SearchResultWindow::showNoMatchesFound() d->m_widget->setCurrentWidget(d->m_noMatchesFoundDisplay); } +/*! + \fn bool SearchResultWindow::isEmpty() const + Returns if the search result window currently doesn't show any results. +*/ bool SearchResultWindow::isEmpty() const { return (d->m_searchResultTreeView->model()->rowCount() < 1); } +/*! + \fn int SearchResultWindow::numberOfResults() const + Returns the number of search results currently shown in the search + results window. +*/ int SearchResultWindow::numberOfResults() const { return d->m_items.count(); } +/*! + \fn bool SearchResultWindow::hasFocus() + \internal +*/ bool SearchResultWindow::hasFocus() { return d->m_searchResultTreeView->hasFocus() || (d->m_isShowingReplaceUI && d->m_replaceTextEdit->hasFocus()); } +/*! + \fn bool SearchResultWindow::canFocus() + \internal +*/ bool SearchResultWindow::canFocus() { return !d->m_items.isEmpty(); } +/*! + \fn void SearchResultWindow::setFocus() + \internal +*/ void SearchResultWindow::setFocus() { if (!d->m_items.isEmpty()) { @@ -406,17 +584,37 @@ void SearchResultWindow::setFocus() } } +/*! + \fn void SearchResultWindow::setTextEditorFont(const QFont &font) + \internal +*/ void SearchResultWindow::setTextEditorFont(const QFont &font) { d->m_searchResultTreeView->setTextEditorFont(font); } +/*! + \fn void SearchResultWindow::handleJumpToSearchResult(int index, bool) + \internal +*/ void SearchResultWindow::handleJumpToSearchResult(int index, bool /* checked */) { QTC_ASSERT(d->m_currentSearch, return); d->m_currentSearch->activated(d->m_items.at(index)); } +/*! + \fn void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData) + \brief Adds a single result line to the search results. + + The \a fileName, \a lineNumber and \a rowText are shown in the result line. + \a searchTermStart and \a searchTermLength specify the region that + should be visually marked (string position and length in \a rowText). + You can attach arbitrary \a userData to the search result, which can + be used e.g. when reacting to the signals of the SearchResult for your search. + + \sa addResults() +*/ void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData) { @@ -430,6 +628,13 @@ void SearchResultWindow::addResult(const QString &fileName, int lineNumber, cons addResults(QList() << item); } +/*! + \fn void SearchResultWindow::addResults(QList &items) + \brief Adds all of the given search result \a items to the search + results window. + + \sa addResult() +*/ void SearchResultWindow::addResults(QList &items) { int index = d->m_items.size(); @@ -452,6 +657,10 @@ void SearchResultWindow::addResults(QList &items) } } +/*! + \fn void SearchResultWindow::handleExpandCollapseToolButton(bool checked) + \internal +*/ void SearchResultWindow::handleExpandCollapseToolButton(bool checked) { d->m_searchResultTreeView->setAutoExpandResults(checked); @@ -461,6 +670,10 @@ void SearchResultWindow::handleExpandCollapseToolButton(bool checked) d->m_searchResultTreeView->collapseAll(); } +/*! + \fn void SearchResultWindow::readSettings() + \internal +*/ void SearchResultWindow::readSettings() { QSettings *s = Core::ICore::instance()->settings(); @@ -471,6 +684,10 @@ void SearchResultWindow::readSettings() } } +/*! + \fn void SearchResultWindow::writeSettings() + \internal +*/ void SearchResultWindow::writeSettings() { QSettings *s = Core::ICore::instance()->settings(); @@ -481,21 +698,37 @@ void SearchResultWindow::writeSettings() } } +/*! + \fn int SearchResultWindow::priorityInStatusBar() const + \internal +*/ int SearchResultWindow::priorityInStatusBar() const { return 80; } +/*! + \fn bool SearchResultWindow::canNext() + \internal +*/ bool SearchResultWindow::canNext() { return d->m_items.count() > 0; } +/*! + \fn bool SearchResultWindow::canPrevious() + \internal +*/ bool SearchResultWindow::canPrevious() { return d->m_items.count() > 0; } +/*! + \fn void SearchResultWindow::goToNext() + \internal +*/ void SearchResultWindow::goToNext() { if (d->m_items.count() == 0) @@ -506,6 +739,11 @@ void SearchResultWindow::goToNext() d->m_searchResultTreeView->emitJumpToSearchResult(idx); } } + +/*! + \fn void SearchResultWindow::goToPrev() + \internal +*/ void SearchResultWindow::goToPrev() { if (!d->m_searchResultTreeView->model()->rowCount()) @@ -517,6 +755,10 @@ void SearchResultWindow::goToPrev() } } +/*! + \fn bool SearchResultWindow::canNavigate() + \internal +*/ bool SearchResultWindow::canNavigate() { return true; diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h index 47a80c24682..92e58cebbb5 100644 --- a/src/plugins/find/searchresultwindow.h +++ b/src/plugins/find/searchresultwindow.h @@ -82,6 +82,7 @@ public: SearchResultWindow(); virtual ~SearchResultWindow(); + static SearchResultWindow *instance(); QWidget *outputWidget(QWidget *); QList toolBarWidgets() const; @@ -129,6 +130,7 @@ private: QList checkedItems() const; Internal::SearchResultWindowPrivate *d; + static SearchResultWindow *m_instance; }; } // namespace Find diff --git a/src/plugins/find/textfindconstants.h b/src/plugins/find/textfindconstants.h index a5e56e22970..69f6a2428e7 100644 --- a/src/plugins/find/textfindconstants.h +++ b/src/plugins/find/textfindconstants.h @@ -40,11 +40,13 @@ const char * const G_FIND_FILTERS = "Find.FindMenu.Filters"; const char * const G_FIND_FLAGS = "Find.FindMenu.Flags"; const char * const G_FIND_ACTIONS = "Find.FindMenu.Actions"; +const char * const ADVANCED_FIND = "Find.Dialog"; const char * const FIND = "Find.FindReplace"; const char * const FIND_IN_DOCUMENT = "Find.FindInCurrentDocument"; const char * const FIND_NEXT = "Find.FindNext"; const char * const FIND_PREVIOUS = "Find.FindPrevious"; const char * const FIND_ALL = "Find.FindAll"; +const char * const REPLACE = "Find.Replace"; const char * const REPLACE_NEXT = "Find.ReplaceNext"; const char * const REPLACE_PREVIOUS = "Find.ReplacePrevious"; const char * const REPLACE_ALL = "Find.ReplaceAll"; diff --git a/src/plugins/help/helpfindsupport.h b/src/plugins/help/helpfindsupport.h index 4292381b17c..f317f5aa9f7 100644 --- a/src/plugins/help/helpfindsupport.h +++ b/src/plugins/help/helpfindsupport.h @@ -58,6 +58,8 @@ public: Result findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags); Result findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags); + void replace(const QString &, const QString &, + Find::IFindSupport::FindFlags ) { } bool replaceStep(const QString &, const QString &, Find::IFindSupport::FindFlags ) { return false; } int replaceAll(const QString &, const QString &, @@ -85,6 +87,8 @@ public: Result findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags); Result findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags); + void replace(const QString &, const QString &, + Find::IFindSupport::FindFlags ) { } bool replaceStep(const QString &, const QString &, Find::IFindSupport::FindFlags ) { return false; } int replaceAll(const QString &, const QString &, diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index f5259658e61..718436afbfe 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -79,6 +79,12 @@ #include +#if !defined(QT_NO_WEBKIT) +#include +#include +#include +#endif + using namespace Core::Constants; using namespace Help::Internal; @@ -332,10 +338,11 @@ void HelpPlugin::extensionsInitialized() helpManager->registerDocumentation(filesToRegister); } -void HelpPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown() { if (m_sideBar) m_sideBar->saveSettings(m_core->settings(), QLatin1String("HelpSideBar")); + return SynchronousShutdown; } void HelpPlugin::setupUi() @@ -688,13 +695,11 @@ void HelpPlugin::activateContext() } else if (m_core->modeManager()->currentMode() == m_mode) return; - QString id; - QMap links; - // Find out what to show + QMap links; if (IContext *context = m_core->currentContextObject()) { - id = context->contextHelpId(); - links = Core::HelpManager::instance()->linksForIdentifier(id); + m_idFromContext = context->contextHelpId(); + links = Core::HelpManager::instance()->linksForIdentifier(m_idFromContext); } if (HelpViewer* viewer = viewerForContextMode()) { @@ -702,16 +707,26 @@ void HelpPlugin::activateContext() // No link found or no context object viewer->setHtml(tr("No Documentation" "
    %1
    No documentation " - "available.
    ").arg(id)); + "available.").arg(m_idFromContext)); viewer->setSource(QUrl()); } else { const QUrl &source = *links.begin(); - if (viewer->source() != source) + const QUrl &oldSource = viewer->source(); + if (source != oldSource) { +#if !defined(QT_NO_WEBKIT) + viewer->stop(); +#endif viewer->setSource(source); + } viewer->setFocus(); + connect(viewer, SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + + if (source.toString().remove(source.fragment()) + == oldSource.toString().remove(oldSource.fragment())) { + highlightSearchTerms(); + } } - if (viewer != m_helpViewerForSideBar) - activateHelpMode(); } } @@ -819,6 +834,45 @@ void HelpPlugin::addBookmark() manager->showBookmarkDialog(m_centralWidget, viewer->title(), url); } +void HelpPlugin::highlightSearchTerms() +{ + if (HelpViewer* viewer = viewerForContextMode()) { + disconnect(viewer, SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + +#if !defined(QT_NO_WEBKIT) + const QString &attrValue = m_idFromContext.mid(m_idFromContext + .lastIndexOf(QChar(':')) + 1); + if (attrValue.isEmpty()) + return; + + const QWebElement &document = viewer->page()->mainFrame()->documentElement(); + const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a")); + + const QLatin1String property("background-color"); + foreach (const QWebElement &element, collection) { + const QString &name = element.attribute(QLatin1String("name")); + if (name.isEmpty()) + continue; + + if (m_oldAttrValue == name) { + QWebElement parent = element.parent(); + parent.setStyleProperty(property, m_styleProperty); + } + + if (attrValue == name) { + QWebElement parent = element.parent(); + m_styleProperty = parent.styleProperty(property, + QWebElement::InlineStyle); + parent.setStyleProperty(property, QLatin1String("yellow")); + } + } + m_oldAttrValue = attrValue; +#endif + viewer->findText(m_idFromContext, 0, false, true); + } +} + void HelpPlugin::handleHelpRequest(const QUrl &url) { if (HelpViewer::launchWithExternalApp(url)) diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index a5099db7f7d..b97b61c2b62 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -70,7 +70,7 @@ public: bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); private slots: void modeChanged(Core::IMode *mode); @@ -98,6 +98,7 @@ private slots: void updateCloseButton(); void setupHelpEngineIfNeeded(); + void highlightSearchTerms(); void handleHelpRequest(const QUrl &url); private: @@ -134,6 +135,10 @@ private: Core::MiniSplitter *m_splitter; QToolButton *m_closeButton; + + QString m_oldAttrValue; + QString m_styleProperty; + QString m_idFromContext; }; } // namespace Internal diff --git a/src/plugins/perforce/perforcesettings.cpp b/src/plugins/perforce/perforcesettings.cpp index 745f6ab1a67..7cf1f8712d3 100644 --- a/src/plugins/perforce/perforcesettings.cpp +++ b/src/plugins/perforce/perforcesettings.cpp @@ -46,6 +46,7 @@ static const char *portKeyC = "Port"; static const char *clientKeyC = "Client"; static const char *userKeyC = "User"; static const char *promptToSubmitKeyC = "PromptForSubmit"; +static const char *autoOpenKeyC = "PromptToOpen"; static const char *timeOutKeyC = "TimeOut"; static const char *logCountKeyC = "LogCount"; @@ -68,7 +69,8 @@ Settings::Settings() : logCount(defaultLogCount), defaultEnv(true), timeOutS(defaultTimeOutS), - promptToSubmit(true) + promptToSubmit(true), + autoOpen(true) { } @@ -78,7 +80,8 @@ bool Settings::equals(const Settings &rhs) const && logCount == rhs.logCount && p4Command == rhs.p4Command && p4Port == rhs.p4Port && p4Client == rhs.p4Client && p4User == rhs.p4User - && timeOutS == rhs.timeOutS && promptToSubmit == rhs.promptToSubmit; + && timeOutS == rhs.timeOutS && promptToSubmit == rhs.promptToSubmit + && autoOpen == rhs.autoOpen; }; QStringList Settings::commonP4Arguments() const @@ -115,6 +118,7 @@ void PerforceSettings::fromSettings(QSettings *settings) m_settings.timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt(); m_settings.promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool(); m_settings.logCount = settings->value(QLatin1String(logCountKeyC), int(defaultLogCount)).toInt(); + m_settings.autoOpen = settings->value(QLatin1String(autoOpenKeyC), true).toBool(); settings->endGroup(); } @@ -129,6 +133,7 @@ void PerforceSettings::toSettings(QSettings *settings) const settings->setValue(QLatin1String(timeOutKeyC), m_settings.timeOutS); settings->setValue(QLatin1String(promptToSubmitKeyC), m_settings.promptToSubmit); settings->setValue(QLatin1String(logCountKeyC), m_settings.logCount); + settings->setValue(QLatin1String(autoOpenKeyC), m_settings.autoOpen); settings->endGroup(); } @@ -180,6 +185,16 @@ void PerforceSettings::setPromptToSubmit(bool p) m_settings.promptToSubmit = p; } +bool PerforceSettings::autoOpen() const +{ + return m_settings.autoOpen; +} + +void PerforceSettings::setAutoOpen(bool b) +{ + m_settings.autoOpen = b; +} + QString PerforceSettings::topLevel() const { return m_topLevel; diff --git a/src/plugins/perforce/perforcesettings.h b/src/plugins/perforce/perforcesettings.h index 803645237fa..cdb1ee0675b 100644 --- a/src/plugins/perforce/perforcesettings.h +++ b/src/plugins/perforce/perforcesettings.h @@ -61,6 +61,7 @@ struct Settings { bool defaultEnv; int timeOutS; bool promptToSubmit; + bool autoOpen; }; inline bool operator==(const Settings &s1, const Settings &s2) { return s1.equals(s2); } @@ -122,6 +123,8 @@ public: bool defaultEnv() const; bool promptToSubmit() const; void setPromptToSubmit(bool p); + bool autoOpen() const; + void setAutoOpen(bool p); // Return basic arguments, including -d and server connection parameters. QStringList commonP4Arguments(const QString &workingDir) const; diff --git a/src/plugins/perforce/perforceversioncontrol.cpp b/src/plugins/perforce/perforceversioncontrol.cpp index 2dc414f59cd..0f0a5e81905 100644 --- a/src/plugins/perforce/perforceversioncontrol.cpp +++ b/src/plugins/perforce/perforceversioncontrol.cpp @@ -70,6 +70,14 @@ bool PerforceVersionControl::vcsOpen(const QString &fileName) return m_plugin->vcsOpen(fi.absolutePath(), fi.fileName()); } +Core::IVersionControl::SettingsFlags PerforceVersionControl::settingsFlags() const +{ + SettingsFlags rc; + if (m_plugin->settings().autoOpen()) + rc|= AutoOpen; + return rc; +}; + bool PerforceVersionControl::vcsAdd(const QString &fileName) { const QFileInfo fi(fileName); diff --git a/src/plugins/perforce/perforceversioncontrol.h b/src/plugins/perforce/perforceversioncontrol.h index 1e14cd2810f..b3a01f7a6c0 100644 --- a/src/plugins/perforce/perforceversioncontrol.h +++ b/src/plugins/perforce/perforceversioncontrol.h @@ -50,6 +50,7 @@ public: virtual bool supportsOperation(Operation operation) const; virtual bool vcsOpen(const QString &fileName); + virtual SettingsFlags settingsFlags() const; virtual bool vcsAdd(const QString &fileName); virtual bool vcsDelete(const QString &filename); virtual bool vcsMove(const QString &from, const QString &to); diff --git a/src/plugins/perforce/settingspage.cpp b/src/plugins/perforce/settingspage.cpp index 5bdfe0f5478..47fa6c9d24b 100644 --- a/src/plugins/perforce/settingspage.cpp +++ b/src/plugins/perforce/settingspage.cpp @@ -85,6 +85,7 @@ Settings SettingsPageWidget::settings() const settings.timeOutS = m_ui.timeOutSpinBox->value(); settings.logCount = m_ui.logCountSpinBox->value(); settings.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked(); + settings.autoOpen = m_ui.autoOpenCheckBox->isChecked(); return settings; } @@ -98,6 +99,7 @@ void SettingsPageWidget::setSettings(const PerforceSettings &s) m_ui.logCountSpinBox->setValue(s.logCount()); m_ui.timeOutSpinBox->setValue(s.timeOutS()); m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit()); + m_ui.autoOpenCheckBox->setChecked(s.autoOpen()); } void SettingsPageWidget::setStatusText(const QString &t) diff --git a/src/plugins/perforce/settingspage.ui b/src/plugins/perforce/settingspage.ui index 6f270415089..e62622038ba 100644 --- a/src/plugins/perforce/settingspage.ui +++ b/src/plugins/perforce/settingspage.ui @@ -2,14 +2,6 @@ Perforce::Internal::SettingsPage - - - 0 - 0 - 437 - 407 - - @@ -25,7 +17,7 @@ - + @@ -134,6 +126,13 @@ + + + + Automatically open files when editing + + + diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index abb1b90b23a..78823bda17a 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -60,7 +60,7 @@ QString AllProjectsFind::id() const return QLatin1String("All Projects"); } -QString AllProjectsFind::name() const +QString AllProjectsFind::displayName() const { return tr("All Projects"); } diff --git a/src/plugins/projectexplorer/allprojectsfind.h b/src/plugins/projectexplorer/allprojectsfind.h index 2f78757c156..d4710a7381c 100644 --- a/src/plugins/projectexplorer/allprojectsfind.h +++ b/src/plugins/projectexplorer/allprojectsfind.h @@ -51,7 +51,7 @@ public: AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); QString id() const; - QString name() const; + QString displayName() const; bool isEnabled() const; QKeySequence defaultShortcut() const; diff --git a/src/plugins/projectexplorer/buildconfigdialog.cpp b/src/plugins/projectexplorer/buildconfigdialog.cpp index 5e3a58fbe19..32e018ec458 100644 --- a/src/plugins/projectexplorer/buildconfigdialog.cpp +++ b/src/plugins/projectexplorer/buildconfigdialog.cpp @@ -31,6 +31,7 @@ #include "project.h" #include "runconfiguration.h" #include "buildconfiguration.h" +#include "target.h" #include #include diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index dc58861cab0..c94f5452cf9 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -411,27 +411,43 @@ bool BuildManager::buildQueueAppend(QList steps) return true; } -void BuildManager::buildProjects(const QList &configurations) +bool BuildManager::buildProjects(const QList &configurations) { QList steps; - foreach(BuildConfiguration *bc, configurations) { + foreach(BuildConfiguration *bc, configurations) steps.append(bc->steps(BuildStep::Build)); - // TODO: Verify that this is indeed what we want. - steps.append(bc->steps(BuildStep::Deploy)); - } bool success = buildQueueAppend(steps); if (!success) { m_outputWindow->popup(false); - return; + return false; } if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) m_outputWindow->popup(false); startBuildQueue(); + return true; } -void BuildManager::cleanProjects(const QList &configurations) +bool BuildManager::deployProjects(const QList &configurations) +{ + QList steps; + foreach(BuildConfiguration *bc, configurations) + steps.append(bc->steps(BuildStep::Deploy)); + + bool success = buildQueueAppend(steps); + if (!success) { + m_outputWindow->popup(false); + return false; + } + + if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) + m_outputWindow->popup(false); + startBuildQueue(); + return true; +} + +bool BuildManager::cleanProjects(const QList &configurations) { QList steps; foreach(BuildConfiguration *bc, configurations) @@ -440,22 +456,28 @@ void BuildManager::cleanProjects(const QList &configuratio bool success = buildQueueAppend(steps); if (!success) { m_outputWindow->popup(false); - return; + return false; } if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) m_outputWindow->popup(false); startBuildQueue(); + return true; } -void BuildManager::buildProject(BuildConfiguration *configuration) +bool BuildManager::buildProject(BuildConfiguration *configuration) { - buildProjects(QList() << configuration); + return buildProjects(QList() << configuration); } -void BuildManager::cleanProject(BuildConfiguration *configuration) +bool BuildManager::deployProject(BuildConfiguration *configuration) { - cleanProjects(QList() << configuration); + return deployProjects(QList() << configuration); +} + +bool BuildManager::cleanProject(BuildConfiguration *configuration) +{ + return cleanProjects(QList() << configuration); } void BuildManager::appendStep(BuildStep *step) diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index 45b2218d4c5..0423d9e8074 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -72,10 +72,12 @@ public: bool tasksAvailable() const; - void buildProject(BuildConfiguration *bc); - void buildProjects(const QList &configurations); - void cleanProject(BuildConfiguration *configuration); - void cleanProjects(const QList &configurations); + bool buildProject(BuildConfiguration *bc); + bool buildProjects(const QList &configurations); + bool deployProject(BuildConfiguration *bc); + bool deployProjects(const QList &configurations); + bool cleanProject(BuildConfiguration *configuration); + bool cleanProjects(const QList &configurations); bool isBuilding(Project *p); bool isBuilding(BuildStep *step); diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 95e12558ad6..6424438b7f4 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -53,14 +54,14 @@ const int MAX_LINECOUNT = 10000; CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/) { - m_textEdit = new QPlainTextEdit(); - m_textEdit->setWindowTitle(tr("Compile Output")); - m_textEdit->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); - m_textEdit->setReadOnly(true); - m_textEdit->setFrameStyle(QFrame::NoFrame); + m_outputWindow = new OutputWindow(); + m_outputWindow->setWindowTitle(tr("Compile Output")); + m_outputWindow->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); + m_outputWindow->setReadOnly(true); + Aggregation::Aggregate *agg = new Aggregation::Aggregate; - agg->add(m_textEdit); - agg->add(new Find::BaseTextFind(m_textEdit)); + agg->add(m_outputWindow); + agg->add(new Find::BaseTextFind(m_outputWindow)); qRegisterMetaType("QTextCharFormat"); @@ -76,7 +77,7 @@ CompileOutputWindow::~CompileOutputWindow() bool CompileOutputWindow::hasFocus() { - return m_textEdit->hasFocus(); + return m_outputWindow->hasFocus(); } bool CompileOutputWindow::canFocus() @@ -86,50 +87,28 @@ bool CompileOutputWindow::canFocus() void CompileOutputWindow::setFocus() { - m_textEdit->setFocus(); + m_outputWindow->setFocus(); } QWidget *CompileOutputWindow::outputWidget(QWidget *) { - return m_textEdit; + return m_outputWindow; } void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat) { - if (m_textEdit->document()->blockCount() > MAX_LINECOUNT) - return; - bool shouldScroll = (m_textEdit->verticalScrollBar()->value() == - m_textEdit->verticalScrollBar()->maximum()); - QString textWithNewline = text; - if (!textWithNewline.endsWith("\n")) - textWithNewline.append("\n"); - QTextCursor cursor = QTextCursor(m_textEdit->document()); - cursor.movePosition(QTextCursor::End); - cursor.beginEditBlock(); - cursor.insertText(textWithNewline, textCharFormat); - - if (m_textEdit->document()->blockCount() > MAX_LINECOUNT) { - QTextCharFormat tmp; - tmp.setFontWeight(QFont::Bold); - cursor.insertText(tr("Additional output omitted\n"), tmp); - } - - cursor.endEditBlock(); - - if (shouldScroll) - m_textEdit->setTextCursor(cursor); + m_outputWindow->appendText(text, textCharFormat, MAX_LINECOUNT); } void CompileOutputWindow::clearContents() { - m_textEdit->clear(); + m_outputWindow->clear(); m_taskPositions.clear(); } -void CompileOutputWindow::visibilityChanged(bool b) +void CompileOutputWindow::visibilityChanged(bool) { - if (b) - m_textEdit->verticalScrollBar()->setValue(m_textEdit->verticalScrollBar()->maximum()); + } int CompileOutputWindow::priorityInStatusBar() const @@ -164,7 +143,7 @@ bool CompileOutputWindow::canNavigate() void CompileOutputWindow::registerPositionOf(const Task &task) { - int blocknumber = m_textEdit->blockCount(); + int blocknumber = m_outputWindow->blockCount(); if (blocknumber > MAX_LINECOUNT) return; m_taskPositions.insert(task.taskId, blocknumber - 1); @@ -178,7 +157,7 @@ bool CompileOutputWindow::knowsPositionOf(const Task &task) void CompileOutputWindow::showPositionOf(const Task &task) { int position = m_taskPositions.value(task.taskId); - QTextCursor newCursor(m_textEdit->document()->findBlockByNumber(position)); + QTextCursor newCursor(m_outputWindow->document()->findBlockByNumber(position)); newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); - m_textEdit->setTextCursor(newCursor); + m_outputWindow->setTextCursor(newCursor); } diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index 2065af56a8b..5b4e7b8adb2 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -30,15 +30,14 @@ #ifndef COMPILEOUTPUTWINDOW_H #define COMPILEOUTPUTWINDOW_H +#include "outputwindow.h" #include #include -#include -#include - QT_BEGIN_NAMESPACE class QPlainTextEdit; +class QTextCharFormat; QT_END_NAMESPACE namespace ProjectExplorer { @@ -80,7 +79,7 @@ public: void showPositionOf(const Task &task); private: - QPlainTextEdit *m_textEdit; + OutputWindow *m_outputWindow; QHash m_taskPositions; ShowOutputTaskHandler * m_handler; }; diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 7256a8603b3..ef9ec44a9b5 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -60,7 +60,7 @@ QString CurrentProjectFind::id() const return QLatin1String("Current Project"); } -QString CurrentProjectFind::name() const +QString CurrentProjectFind::displayName() const { return tr("Current Project"); } diff --git a/src/plugins/projectexplorer/currentprojectfind.h b/src/plugins/projectexplorer/currentprojectfind.h index 2e98e49e1b1..5ee35a83c8d 100644 --- a/src/plugins/projectexplorer/currentprojectfind.h +++ b/src/plugins/projectexplorer/currentprojectfind.h @@ -54,7 +54,7 @@ public: CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow); QString id() const; - QString name() const; + QString displayName() const; bool isEnabled() const; QKeySequence defaultShortcut() const; diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index de2894ac8cd..43a3af6a739 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index b9c8e7e18a7..9ec1483b213 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -155,11 +155,10 @@ static inline bool createFile(Internal::CustomWizardFile cwFile, return false; } // Field replacement on contents - QString contents = QString::fromLocal8Bit(file.readAll()); - if (!contents.isEmpty() && !fm.isEmpty()) - Internal::CustomWizardContext::replaceFields(fm, &contents); + const QString contentsIn = QString::fromLocal8Bit(file.readAll()); + Core::GeneratedFile generatedFile; - generatedFile.setContents(contents); + generatedFile.setContents(Internal::CustomWizardContext::processFile(fm, contentsIn)); generatedFile.setPath(targetPath); Core::GeneratedFile::Attributes attributes = 0; if (cwFile.openEditor) diff --git a/src/plugins/projectexplorer/customwizard/customwizard.pri b/src/plugins/projectexplorer/customwizard/customwizard.pri index 61475f3ae41..ac8bf2ea260 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.pri +++ b/src/plugins/projectexplorer/customwizard/customwizard.pri @@ -1,7 +1,9 @@ INCLUDEPATH *= $$PWD HEADERS += $$PWD/customwizard.h \ $$PWD/customwizardparameters.h \ - $$PWD/customwizardpage.h + $$PWD/customwizardpage.h \ + customwizard/customwizardpreprocessor.h SOURCES += $$PWD/customwizard.cpp \ $$PWD/customwizardparameters.cpp \ - $$PWD/customwizardpage.cpp + $$PWD/customwizardpage.cpp \ + customwizard/customwizardpreprocessor.cpp diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index 487c3aef373..d821ed52037 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -28,6 +28,7 @@ **************************************************************************/ #include "customwizardparameters.h" +#include "customwizardpreprocessor.h" #include #include @@ -644,5 +645,24 @@ void CustomWizardContext::reset() mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))); } +QString CustomWizardContext::processFile(const FieldReplacementMap &fm, QString in) +{ + + if (in.isEmpty()) + return in; + + if (!fm.isEmpty()) + replaceFields(fm, &in); + + QString out; + QString errorMessage; + if (!customWizardPreprocess(in, &out, &errorMessage)) { + qWarning("Error preprocessing custom widget file: %s\nFile:\n%s", + qPrintable(errorMessage), qPrintable(in)); + return QString(); + } + return out; +} + } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.h b/src/plugins/projectexplorer/customwizard/customwizardparameters.h index e5c26abf3f4..5d92843f04e 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.h +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.h @@ -105,6 +105,7 @@ struct CustomWizardContext { // %Field:l% -> lower case replacement, 'u' upper case, // 'c' capitalize first letter. static void replaceFields(const FieldReplacementMap &fm, QString *s); + static QString processFile(const FieldReplacementMap &fm, QString in); FieldReplacementMap baseReplacements; }; diff --git a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp new file mode 100644 index 00000000000..2d0a2790419 --- /dev/null +++ b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp @@ -0,0 +1,268 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "customwizardpreprocessor.h" + +#include + +#include +#include +#include +#include + +#include +#include + +namespace ProjectExplorer { +namespace Internal { + +enum { debug = 0 }; + +// Preprocessor: Conditional section type. +enum PreprocessorSection { + IfSection, + ElsifSection, + ElseSection, + EndifSection, + OtherSection +}; + +// Preprocessor: Section stack entry containing nested '@if' section +// state. +struct PreprocessStackEntry { + PreprocessStackEntry(PreprocessorSection section = OtherSection, + bool parentEnabled = true, + bool condition = false, + bool anyIfClauseMatched = false); + + PreprocessorSection section; + bool parentEnabled; + bool condition; // Current 'if/elsif' section is enabled. + bool anyIfClauseMatched; // Determines if 'else' triggers +}; + +PreprocessStackEntry::PreprocessStackEntry(PreprocessorSection s, + bool p, bool c, bool a) : + section(s), parentEnabled(p), condition(c), anyIfClauseMatched(a) +{ +} + +// Context for preprocessing. +class PreprocessContext { +public: + PreprocessContext(); + bool process(const QString &in, QString *out, QString *errorMessage); + +private: + void reset(); + bool evaluateExpression(const QString &expression, bool *result, QString *errorMessage); + PreprocessorSection preprocessorLine(const QString & in, QString *ifExpression) const; + + mutable QRegExp m_ifPattern; + mutable QRegExp m_elsifPattern; + const QRegExp m_elsePattern; + const QRegExp m_endifPattern; + + QStack m_sectionStack; + QScriptEngine m_scriptEngine; +}; + +PreprocessContext::PreprocessContext() : + // Cut out expression for 'if/elsif ' + m_ifPattern(QLatin1String("^([\\s]*@[\\s]*if[\\s]*)(.*)$")), + m_elsifPattern(QLatin1String("^([\\s]*@[\\s]*elsif[\\s]*)(.*)$")), + m_elsePattern(QLatin1String("^[\\s]*@[\\s]*else.*$")), + m_endifPattern(QLatin1String("^[\\s]*@[\\s]*endif.*$")) +{ + QTC_ASSERT(m_ifPattern.isValid() && m_elsifPattern.isValid() + && m_elsePattern.isValid() &&m_endifPattern.isValid(), return); +} + +void PreprocessContext::reset() +{ + m_sectionStack.clear(); // Add a default, enabled section. + m_sectionStack.push(PreprocessStackEntry(OtherSection, true, true)); +} + +// Determine type of line and return enumeration, cut out +// expression for '@if/@elsif'. +PreprocessorSection PreprocessContext::preprocessorLine(const QString &in, + QString *ifExpression) const +{ + if (m_ifPattern.exactMatch(in)) { + *ifExpression = m_ifPattern.cap(2).trimmed(); + return IfSection; + } + if (m_elsifPattern.exactMatch(in)) { + *ifExpression = m_elsifPattern.cap(2).trimmed(); + return ElsifSection; + } + + ifExpression->clear(); + + if (m_elsePattern.exactMatch(in)) + return ElseSection; + if (m_endifPattern.exactMatch(in)) + return EndifSection; + return OtherSection; +} + +// Evaluate an expression within an 'if'/'elsif' to a bool via QScript +bool PreprocessContext::evaluateExpression(const QString &expression, + bool *result, + QString *errorMessage) +{ + errorMessage->clear(); + *result = false; + m_scriptEngine.clearExceptions(); + const QScriptValue value = m_scriptEngine.evaluate(expression); + if (m_scriptEngine.hasUncaughtException()) { + *errorMessage = QString::fromLatin1("Error in '%1': %2"). + arg(expression, m_scriptEngine.uncaughtException().toString()); + return false; + } + // Try to convert to bool, be that an int or whatever. + if (value.isBool()) { + *result = value.toBool(); + return true; + } + if (value.isNumber()) { + *result = !qFuzzyCompare(value.toNumber(), 0); + return true; + } + if (value.isString()) { + *result = !value.toString().isEmpty(); + return true; + } + *errorMessage = QString::fromLatin1("Cannot convert result of '%1' ('%2'to bool."). + arg(expression, value.toString()); + return false; +} + +static inline QString msgEmptyStack(int line) +{ + return QString::fromLatin1("Unmatched '@endif' at line %1.").arg(line); +} + +bool PreprocessContext::process(const QString &in, QString *out, QString *errorMessage) +{ + out->clear(); + if (in.isEmpty()) + return true; + + out->reserve(in.size()); + reset(); + + const QChar newLine = QLatin1Char('\n'); + const QStringList lines = in.split(newLine, QString::KeepEmptyParts); + const int lineCount = lines.size(); + for (int l = 0; l < lineCount; l++) { + // Check for element of the stack (be it dummy, else something is wrong). + if (m_sectionStack.isEmpty()) { + *errorMessage = msgEmptyStack(l); + return false; + } + QString expression; + bool expressionValue = false; + PreprocessStackEntry &top = m_sectionStack.back(); + + switch (preprocessorLine(lines.at(l), &expression)) { + case IfSection: + // '@If': Push new section + if (top.parentEnabled) { + if (!evaluateExpression(expression, &expressionValue, errorMessage)) { + *errorMessage = QString::fromLatin1("Error in @if at %1: %2"). + arg(l + 1).arg(*errorMessage); + return false; + } + } + if (debug) + qDebug("'%s' : expr='%s' -> %d", qPrintable(lines.at(l)), qPrintable(expression), expressionValue); + m_sectionStack.push(PreprocessStackEntry(IfSection, + top.condition, expressionValue, expressionValue)); + break; + case ElsifSection: // '@elsif': Check condition. + if (top.section != IfSection && top.section != ElsifSection) { + *errorMessage = QString::fromLatin1("No preceding @if found for @elsif at %1"). + arg(l + 1); + return false; + } + if (top.parentEnabled) { + if (!evaluateExpression(expression, &expressionValue, errorMessage)) { + *errorMessage = QString::fromLatin1("Error in @elsif at %1: %2"). + arg(l + 1).arg(*errorMessage); + return false; + } + } + if (debug) + qDebug("'%s' : expr='%s' -> %d", qPrintable(lines.at(l)), qPrintable(expression), expressionValue); + top.section = ElsifSection; + // ignore consecutive '@elsifs' once something matched + if (top.anyIfClauseMatched) { + top.condition = false; + } else { + if ( (top.condition = expressionValue) ) + top.anyIfClauseMatched = true; + } + break; + case ElseSection: // '@else': Check condition. + if (top.section != IfSection && top.section != ElsifSection) { + *errorMessage = QString::fromLatin1("No preceding @if/@elsif found for @else at %1"). + arg(l + 1); + return false; + } + expressionValue = top.parentEnabled && !top.anyIfClauseMatched; + if (debug) + qDebug("%s -> %d", qPrintable(lines.at(l)), expressionValue); + top.section = ElseSection; + top.condition = expressionValue; + break; + case EndifSection: // '@endif': Discard section. + m_sectionStack.pop(); + break; + case OtherSection: // Rest: Append according to current condition. + if (top.condition) { + out->append(lines.at(l)); + out->append(newLine); + } + break; + } // switch section + + } // for lines + return true; +} + +bool customWizardPreprocess(const QString &in, QString *out, QString *errorMessage) +{ + PreprocessContext context; + return context.process(in, out, errorMessage); +} + +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h new file mode 100644 index 00000000000..be84a04f72c --- /dev/null +++ b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef CUSTOMWIZARDPREPROCESSOR_H +#define CUSTOMWIZARDPREPROCESSOR_H + +#include + +namespace ProjectExplorer { +namespace Internal { + +/* Preprocess a string using simple syntax: \code + +Text +@if +Bla... +@elsif +Blup +@endif +\endcode + +* JavaScript-expressions must evaluate to integers or boolean, like +* '2 == 1 + 1', '"a" == "a"'. The variables of the custom wizard will be +* expanded beforem, so , "%VAR%" should be used for strings and %VAR% for integers. +*/ + +bool customWizardPreprocess(const QString &in, QString *out, QString *errorMessage); + +} // namespace Internal +} // namespace ProjectExplorer + +#endif // CUSTOMWIZARDPREPROCESSOR_H diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index 3bbc97bf283..315ed6f1da7 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -30,6 +30,7 @@ #include "miniprojecttargetselector.h" #include "buildconfigurationmodel.h" #include "runconfigurationmodel.h" +#include "target.h" #include #include diff --git a/src/plugins/projectexplorer/outputformatter.cpp b/src/plugins/projectexplorer/outputformatter.cpp index 69bb04b72ea..9cf37e31036 100644 --- a/src/plugins/projectexplorer/outputformatter.cpp +++ b/src/plugins/projectexplorer/outputformatter.cpp @@ -37,8 +37,8 @@ using namespace ProjectExplorer; using namespace TextEditor; -OutputFormatter::OutputFormatter(QObject *parent) - : QObject(parent) +OutputFormatter::OutputFormatter() + : QObject() , m_formats(0) { initFormats(); @@ -58,7 +58,6 @@ QPlainTextEdit *OutputFormatter::plainTextEdit() const void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText) { m_plainTextEdit = plainText; - setParent(m_plainTextEdit); } void OutputFormatter::appendApplicationOutput(const QString &text, bool onStdErr) @@ -83,15 +82,6 @@ void OutputFormatter::append(const QString &text, const QTextCharFormat &format) cursor.insertText(text, format); } -void OutputFormatter::mousePressEvent(QMouseEvent * /*e*/) -{} - -void OutputFormatter::mouseReleaseEvent(QMouseEvent * /*e*/) -{} - -void OutputFormatter::mouseMoveEvent(QMouseEvent * /*e*/) -{} - void OutputFormatter::initFormats() { FontSettings fs = TextEditorSettings::instance()->fontSettings(); @@ -117,3 +107,8 @@ void OutputFormatter::initFormats() m_formats[StdErrFormat].setFont(font); m_formats[StdErrFormat].setForeground(QColor(200, 0, 0)); } + +void OutputFormatter::handleLink(const QString &href) +{ + Q_UNUSED(href); +} diff --git a/src/plugins/projectexplorer/outputformatter.h b/src/plugins/projectexplorer/outputformatter.h index effff7725a0..71737a9e7c1 100644 --- a/src/plugins/projectexplorer/outputformatter.h +++ b/src/plugins/projectexplorer/outputformatter.h @@ -46,7 +46,7 @@ class PROJECTEXPLORER_EXPORT OutputFormatter: public QObject Q_OBJECT public: - OutputFormatter(QObject *parent = 0); + OutputFormatter(); virtual ~OutputFormatter(); QPlainTextEdit *plainTextEdit() const; @@ -55,9 +55,7 @@ public: virtual void appendApplicationOutput(const QString &text, bool onStdErr); virtual void appendMessage(const QString &text, bool isError); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual void mouseMoveEvent(QMouseEvent *e); + virtual void handleLink(const QString &href); protected: enum Format { diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp index 91d0cab9514..99a8d34d835 100644 --- a/src/plugins/projectexplorer/outputwindow.cpp +++ b/src/plugins/projectexplorer/outputwindow.cpp @@ -33,6 +33,7 @@ #include "projectexplorersettings.h" #include "runconfiguration.h" #include "session.h" +#include "outputformatter.h" #include #include @@ -43,6 +44,8 @@ #include #include #include +#include +#include #include #include @@ -56,6 +59,7 @@ #include #include #include +#include using namespace ProjectExplorer::Internal; using namespace ProjectExplorer; @@ -209,7 +213,7 @@ void OutputPane::createNewOutputWindow(RunControl *rc) OutputWindow *ow = static_cast(m_tabWidget->widget(i)); ow->grayOutOldContent(); ow->verticalScrollBar()->setValue(ow->verticalScrollBar()->maximum()); - ow->setFormatter(rc->createOutputFormatter(ow)); + ow->setFormatter(rc->outputFormatter()); m_outputWindows.insert(rc, ow); found = true; break; @@ -217,7 +221,9 @@ void OutputPane::createNewOutputWindow(RunControl *rc) } if (!found) { OutputWindow *ow = new OutputWindow(m_tabWidget); - ow->setFormatter(rc->createOutputFormatter(ow)); + ow->setWindowTitle(tr("Application Output Window")); + ow->setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); + ow->setFormatter(rc->outputFormatter()); Aggregation::Aggregate *agg = new Aggregation::Aggregate; agg->add(ow); agg->add(new Find::BaseTextFind(ow)); @@ -372,13 +378,14 @@ bool OutputPane::canNavigate() OutputWindow::OutputWindow(QWidget *parent) : QPlainTextEdit(parent) + , m_formatter(0) , m_enforceNewline(false) , m_scrollToBottom(false) + , m_linksActive(true) + , m_mousePressed(false) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //setCenterOnScroll(false); - setWindowTitle(tr("Application Output Window")); - setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); setFrameShape(QFrame::NoFrame); setMouseTracking(true); @@ -427,6 +434,42 @@ OutputWindow::~OutputWindow() delete m_outputWindowContext; } +void OutputWindow::mousePressEvent(QMouseEvent * e) +{ + m_mousePressed = true; + QPlainTextEdit::mousePressEvent(e); +} + + +void OutputWindow::mouseReleaseEvent(QMouseEvent *e) +{ + m_mousePressed = false; + + if (!m_linksActive) { + // Mouse was released, activate links again + m_linksActive = true; + return; + } + + const QString href = anchorAt(e->pos()); + if (m_formatter) + m_formatter->handleLink(href); + QPlainTextEdit::mousePressEvent(e); +} + +void OutputWindow::mouseMoveEvent(QMouseEvent *e) +{ + // Cursor was dragged to make a selection, deactivate links + if (m_mousePressed && textCursor().hasSelection()) + m_linksActive = false; + + if (!m_linksActive || anchorAt(e->pos()).isEmpty()) + viewport()->setCursor(Qt::IBeamCursor); + else + viewport()->setCursor(Qt::PointingHandCursor); + QPlainTextEdit::mouseMoveEvent(e); +} + OutputFormatter *OutputWindow::formatter() const { return m_formatter; @@ -514,6 +557,28 @@ void OutputWindow::appendMessage(const QString &out, bool isError) enableUndoRedo(); } +// TODO rename +void OutputWindow::appendText(const QString &text, const QTextCharFormat &format, int maxLineCount) +{ + if (document()->blockCount() > maxLineCount) + return; + const bool atBottom = isScrollbarAtBottom(); + QTextCursor cursor = QTextCursor(document()); + cursor.movePosition(QTextCursor::End); + cursor.beginEditBlock(); + cursor.insertText(doNewlineEnfocement(text), format); + + if (document()->blockCount() > maxLineCount) { + QTextCharFormat tmp; + tmp.setFontWeight(QFont::Bold); + cursor.insertText(tr("Additional output omitted\n"), tmp); + } + + cursor.endEditBlock(); + if (atBottom) + scrollToBottom(); +} + bool OutputWindow::isScrollbarAtBottom() const { return verticalScrollBar()->value() == verticalScrollBar()->maximum(); @@ -552,21 +617,3 @@ void OutputWindow::enableUndoRedo() setMaximumBlockCount(0); setUndoRedoEnabled(true); } - -void OutputWindow::mousePressEvent(QMouseEvent *e) -{ - QPlainTextEdit::mousePressEvent(e); - m_formatter->mousePressEvent(e); -} - -void OutputWindow::mouseReleaseEvent(QMouseEvent *e) -{ - QPlainTextEdit::mouseReleaseEvent(e); - m_formatter->mouseReleaseEvent(e); -} - -void OutputWindow::mouseMoveEvent(QMouseEvent *e) -{ - QPlainTextEdit::mouseMoveEvent(e); - m_formatter->mouseMoveEvent(e); -} diff --git a/src/plugins/projectexplorer/outputwindow.h b/src/plugins/projectexplorer/outputwindow.h index 0646c16f7e9..4cc3eecb031 100644 --- a/src/plugins/projectexplorer/outputwindow.h +++ b/src/plugins/projectexplorer/outputwindow.h @@ -31,12 +31,9 @@ #define OUTPUTWINDOW_H #include -#include -#include #include #include -#include #include QT_BEGIN_NAMESPACE @@ -50,8 +47,9 @@ namespace Core { } namespace ProjectExplorer { - +class OutputFormatter; class RunControl; +class Project; namespace Constants { const char * const C_APP_OUTPUT = "Application Output"; @@ -137,29 +135,38 @@ public: void appendApplicationOutput(const QString &out, bool onStdErr); void appendApplicationOutputInline(const QString &out, bool onStdErr); void appendMessage(const QString &out, bool isError); + /// appends a \p text using \p format without using formater + void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount); void grayOutOldContent(); void showEvent(QShowEvent *); -protected: - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); + void clear() + { + m_enforceNewline = false; + QPlainTextEdit::clear(); + } +protected: bool isScrollbarAtBottom() const; void scrollToBottom(); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e); + virtual void mouseMoveEvent(QMouseEvent *e); + private: void enableUndoRedo(); QString doNewlineEnfocement(const QString &out); -private: Core::BaseContext *m_outputWindowContext; OutputFormatter *m_formatter; bool m_enforceNewline; bool m_scrollToBottom; + bool m_linksActive; + bool m_mousePressed; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 01b4569cb37..f88dcabd760 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -31,7 +31,6 @@ #define PROJECT_H #include "projectexplorer_export.h" -#include "target.h" #include #include diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ad0cebcde44..aa6aa70e2b3 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -97,6 +97,7 @@ #include #include #include +#include #include #include @@ -146,6 +147,10 @@ struct ProjectExplorerPluginPrivate { Utils::ParameterAction *m_rebuildActionContextMenu; QAction *m_rebuildSessionAction; QAction *m_cleanProjectOnlyAction; + QAction *m_deployProjectOnlyAction; + Utils::ParameterAction *m_deployAction; + Utils::ParameterAction *m_deployActionContextMenu; + QAction *m_deploySessionAction; Utils::ParameterAction *m_cleanAction; Utils::ParameterAction *m_cleanActionContextMenu; QAction *m_cleanSessionAction; @@ -312,13 +317,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ProcessStepFactory *processStepFactory = new ProcessStepFactory; addAutoReleasedObject(processStepFactory); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); AllProjectsFind *allProjectsFind = new AllProjectsFind(this, - pm->getObject()); + Find::SearchResultWindow::instance()); addAutoReleasedObject(allProjectsFind); CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this, - pm->getObject()); + Find::SearchResultWindow::instance()); addAutoReleasedObject(currentProjectFind); addAutoReleasedObject(new LocalApplicationRunControlFactory); @@ -569,6 +573,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mbuild->addAction(cmd, Constants::G_BUILD_SESSION); msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); + // deploy session + d->m_deploySessionAction = new QAction(tr("Deploy All"), this); + cmd = am->registerAction(d->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext); + mbuild->addAction(cmd, Constants::G_BUILD_SESSION); + msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); + // clean session QIcon cleanIcon(Constants::ICON_CLEAN); cleanIcon.addFile(Constants::ICON_CLEAN_SMALL); @@ -594,6 +604,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd->setDefaultText(d->m_rebuildAction->text()); mbuild->addAction(cmd, Constants::G_BUILD_PROJECT); + // deploy action + d->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""), + Utils::ParameterAction::AlwaysEnabled, this); + cmd = am->registerAction(d->m_deployAction, Constants::DEPLOY, globalcontext); + cmd->setAttribute(Core::Command::CA_UpdateText); + cmd->setDefaultText(d->m_deployAction->text()); + mbuild->addAction(cmd, Constants::G_BUILD_PROJECT); + // clean action d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); @@ -618,6 +636,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd->setDefaultText(d->m_rebuildActionContextMenu->text()); mproject->addAction(cmd, Constants::G_PROJECT_BUILD); + // deploy action (context menu) + d->m_deployActionContextMenu = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""), + Utils::ParameterAction::AlwaysEnabled, this); + cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::DEPLOYCM, globalcontext); + cmd->setAttribute(Core::Command::CA_UpdateText); + cmd->setDefaultText(d->m_deployActionContextMenu->text()); + mproject->addAction(cmd, Constants::G_PROJECT_BUILD); + // clean action (context menu) d->m_cleanActionContextMenu = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); @@ -634,6 +660,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this); cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext); + // deploy without dependencies action + d->m_deployProjectOnlyAction = new QAction(tr("Deploy Without Dependencies"), this); + cmd = am->registerAction(d->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext); + // clean without dependencies action d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this); cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext); @@ -748,7 +778,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er } if (QSettings *s = core->settings()) { - d->m_projectExplorerSettings.buildBeforeRun = s->value("ProjectExplorer/Settings/BuildBeforeRun", true).toBool(); + d->m_projectExplorerSettings.buildBeforeDeploy = s->value("ProjectExplorer/Settings/BuildBeforeDeploy", true).toBool(); + d->m_projectExplorerSettings.deployBeforeRun = s->value("ProjectExplorer/Settings/DeployBeforeRun", true).toBool(); d->m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool(); d->m_projectExplorerSettings.showCompilerOutput = s->value("ProjectExplorer/Settings/ShowCompilerOutput", false).toBool(); d->m_projectExplorerSettings.cleanOldAppOutput = s->value("ProjectExplorer/Settings/CleanOldAppOutput", false).toBool(); @@ -771,6 +802,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(d->m_rebuildAction, SIGNAL(triggered()), this, SLOT(rebuildProject())); connect(d->m_rebuildActionContextMenu, SIGNAL(triggered()), this, SLOT(rebuildProjectContextMenu())); connect(d->m_rebuildSessionAction, SIGNAL(triggered()), this, SLOT(rebuildSession())); + connect(d->m_deployProjectOnlyAction, SIGNAL(triggered()), this, SLOT(deployProjectOnly())); + connect(d->m_deployAction, SIGNAL(triggered()), this, SLOT(deployProject())); + connect(d->m_deployActionContextMenu, SIGNAL(triggered()), this, SLOT(deployProjectContextMenu())); + connect(d->m_deploySessionAction, SIGNAL(triggered()), this, SLOT(deploySession())); connect(d->m_cleanProjectOnlyAction, SIGNAL(triggered()), this, SLOT(cleanProjectOnly())); connect(d->m_cleanAction, SIGNAL(triggered()), this, SLOT(cleanProject())); connect(d->m_cleanActionContextMenu, SIGNAL(triggered()), this, SLOT(cleanProjectContextMenu())); @@ -909,12 +944,13 @@ void ProjectExplorerPlugin::extensionsInitialized() d->m_buildManager->extensionsInitialized(); } -void ProjectExplorerPlugin::aboutToShutdown() +ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown() { d->m_proWindow->aboutToShutdown(); // disconnect from session d->m_session->clear(); d->m_projectsMode = 0; // d->m_proWindow->saveConfigChanges(); + return SynchronousShutdown; } void ProjectExplorerPlugin::newProject() @@ -998,7 +1034,8 @@ void ProjectExplorerPlugin::savePersistentSettings() s->setValue("ProjectExplorer/RecentProjects/FileNames", fileNames); s->setValue("ProjectExplorer/RecentProjects/DisplayNames", displayNames); - s->setValue("ProjectExplorer/Settings/BuildBeforeRun", d->m_projectExplorerSettings.buildBeforeRun); + s->setValue("ProjectExplorer/Settings/BuildBeforeDeploy", d->m_projectExplorerSettings.buildBeforeDeploy); + s->setValue("ProjectExplorer/Settings/DeployBeforeRun", d->m_projectExplorerSettings.deployBeforeRun); s->setValue("ProjectExplorer/Settings/SaveBeforeBuild", d->m_projectExplorerSettings.saveBeforeBuild); s->setValue("ProjectExplorer/Settings/ShowCompilerOutput", d->m_projectExplorerSettings.showCompilerOutput); s->setValue("ProjectExplorer/Settings/CleanOldAppOutput", d->m_projectExplorerSettings.cleanOldAppOutput); @@ -1261,7 +1298,6 @@ void ProjectExplorerPlugin::executeRunConfiguration(RunConfiguration *runConfigu RunControl *control = runControlFactory->create(runConfiguration, runMode); startRunControl(control, runMode); } - } void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QString &runMode) @@ -1362,19 +1398,18 @@ void ProjectExplorerPlugin::updateActions() if (debug) qDebug() << "ProjectExplorerPlugin::updateActions"; - Project *startupProject = session()->startupProject(); - bool enableBuildActions = startupProject - && ! (d->m_buildManager->isBuilding(startupProject)) - && hasBuildSettings(startupProject); + Project *project = startupProject(); + bool enableBuildActions = project + && ! (d->m_buildManager->isBuilding(project)) + && hasBuildSettings(project); bool enableBuildActionsContextMenu = d->m_currentProject && ! (d->m_buildManager->isBuilding(d->m_currentProject)) && hasBuildSettings(d->m_currentProject); - bool hasProjects = !d->m_session->projects().isEmpty(); bool building = d->m_buildManager->isBuilding(); - QString projectName = startupProject ? startupProject->displayName() : QString(); + QString projectName = project ? project->displayName() : QString(); QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString(); if (debug) @@ -1411,7 +1446,7 @@ void ProjectExplorerPlugin::updateActions() d->m_projectSelectorAction->setEnabled(!session()->projects().isEmpty()); d->m_projectSelectorActionMenu->setEnabled(!session()->projects().isEmpty()); - updateRunActions(); + updateDeployActions(); } // NBS TODO check projectOrder() @@ -1575,6 +1610,54 @@ void ProjectExplorerPlugin::rebuildSession() } } +void ProjectExplorerPlugin::deployProjectOnly() +{ + if (!saveModifiedFiles()) + return; + d->m_buildManager->deployProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); +} + +void ProjectExplorerPlugin::deployProject() +{ + if (!saveModifiedFiles()) + return; + + const QList &projects = d->m_session->projectOrder(session()->startupProject()); + QList configurations; + foreach (Project *pro, projects) + if (pro->activeTarget()->activeBuildConfiguration()) + configurations << pro->activeTarget()->activeBuildConfiguration(); + + d->m_buildManager->deployProjects(configurations); +} + +void ProjectExplorerPlugin::deployProjectContextMenu() +{ + if (!saveModifiedFiles()) + return; + + QList configurations; + foreach (Project *pro, d->m_session->projectOrder(d->m_currentProject)) + if (pro->activeTarget()->activeBuildConfiguration()) + configurations << pro->activeTarget()->activeBuildConfiguration(); + + d->m_buildManager->deployProjects(configurations); +} + +void ProjectExplorerPlugin::deploySession() +{ + if (!saveModifiedFiles()) + return; + + const QList & projects = d->m_session->projectOrder(); + QList configurations; + foreach (Project *pro, projects) + if (pro->activeTarget()->activeBuildConfiguration()) + configurations << pro->activeTarget()->activeBuildConfiguration(); + + d->m_buildManager->deployProjects(configurations); +} + void ProjectExplorerPlugin::cleanProjectOnly() { if (debug) @@ -1648,34 +1731,58 @@ bool ProjectExplorerPlugin::hasBuildSettings(Project *pro) return false; } +bool ProjectExplorerPlugin::hasDeploySettings(Project *pro) +{ + const QList & projects = d->m_session->projectOrder(pro); + foreach(Project *project, projects) + if (project->activeTarget()->activeBuildConfiguration() && + !project->activeTarget()->activeBuildConfiguration()->steps(BuildStep::Deploy).isEmpty()) + return true; + return false; +} + void ProjectExplorerPlugin::runProjectImpl(Project *pro, QString mode) { if (!pro) return; - if (d->m_projectExplorerSettings.buildBeforeRun && hasBuildSettings(pro)) { - if (!pro->activeTarget()->activeRunConfiguration()->isEnabled()) { - if (!showBuildConfigDialog()) - return; - } - if (saveModifiedFiles()) { - d->m_runMode = mode; - d->m_delayedRunConfiguration = pro->activeTarget()->activeRunConfiguration(); - - const QList & projects = d->m_session->projectOrder(pro); - QList configurations; - foreach(Project *project, projects) - if (project->activeTarget()->activeBuildConfiguration()) - configurations << project->activeTarget()->activeBuildConfiguration(); - d->m_buildManager->buildProjects(configurations); - - updateRunActions(); - } - } else { - // TODO this ignores RunConfiguration::isEnabled() - if (saveModifiedFiles()) - executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode); + if (!pro->activeTarget()->activeRunConfiguration()->isEnabled()) { + if (!showBuildConfigDialog()) + return; } + + if (!saveModifiedFiles()) + return; + + bool delayRun = false; + // Deploy/build first? + if (d->m_projectExplorerSettings.deployBeforeRun) { + const QList & projects = d->m_session->projectOrder(pro); + QList configurations; + foreach(Project *project, projects) + if (project->activeTarget()->activeBuildConfiguration()) + configurations << project->activeTarget()->activeBuildConfiguration(); + + if (d->m_projectExplorerSettings.buildBeforeDeploy && hasBuildSettings(pro)) { + if (!d->m_buildManager->buildProjects(configurations)) + return; + delayRun = true; + } + if (hasDeploySettings(pro)) { + if (!d->m_buildManager->deployProjects(configurations)) + return; + delayRun = true; + } + } + + // Actually run (delayed) + if (delayRun) { + d->m_runMode = mode; + d->m_delayedRunConfiguration = pro->activeTarget()->activeRunConfiguration(); + } else { + executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode); + } + updateRunActions(); } void ProjectExplorerPlugin::debugProject() @@ -1735,7 +1842,7 @@ void ProjectExplorerPlugin::startupProjectChanged() this, SLOT(updateRunActions())); disconnect(previousStartupProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(updateRunActions())); + this, SLOT(updateDeployActions())); disconnect(previousStartupProject->activeTarget()->activeRunConfiguration(), SIGNAL(isEnabledChanged(bool)), this, SLOT(updateRunActions())); @@ -1748,7 +1855,7 @@ void ProjectExplorerPlugin::startupProjectChanged() if (project) { connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(updateRunActions())); + this, SLOT(updateDeployActions())); connect(project->activeTarget(), SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), this, SLOT(updateRunActions())); @@ -1776,6 +1883,35 @@ IRunControlFactory *ProjectExplorerPlugin::findRunControlFactory(RunConfiguratio return 0; } +void ProjectExplorerPlugin::updateDeployActions() +{ + Project *project = startupProject(); + + bool enableDeployActions = project + && ! (d->m_buildManager->isBuilding(project)) + && hasDeploySettings(project); + bool enableDeployActionsContextMenu = d->m_currentProject + && ! (d->m_buildManager->isBuilding(d->m_currentProject)) + && hasDeploySettings(d->m_currentProject); + + const QString projectName = project ? project->displayName() : QString(); + const QString projectNameContextMenu = d->m_currentProject ? d->m_currentProject->displayName() : QString(); + bool hasProjects = !d->m_session->projects().isEmpty(); + bool building = d->m_buildManager->isBuilding(); + + d->m_deployAction->setParameter(projectName); + d->m_deployAction->setEnabled(enableDeployActions); + + d->m_deployActionContextMenu->setParameter(projectNameContextMenu); + d->m_deployActionContextMenu->setEnabled(enableDeployActionsContextMenu); + + d->m_deployProjectOnlyAction->setEnabled(enableDeployActions); + + d->m_deploySessionAction->setEnabled(hasProjects && !building); + + updateRunActions(); +} + void ProjectExplorerPlugin::updateRunActions() { const Project *project = startupProject(); @@ -1863,7 +1999,7 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() const QPair &s = *it; if (s.first.endsWith(QLatin1String(".qws"))) continue; - QAction *action = menu->addAction(s.first); + QAction *action = menu->addAction(Utils::withTildeHomePath(s.first)); action->setData(s.first); connect(action, SIGNAL(triggered()), this, SLOT(openRecentProject())); } diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 13491c33648..973dc53535a 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -100,7 +100,7 @@ public: //PluginInterface bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); - void aboutToShutdown(); + ShutdownFlag aboutToShutdown(); void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes); Internal::ProjectExplorerSettings projectExplorerSettings() const; @@ -140,6 +140,10 @@ private slots: void rebuildProject(); void rebuildProjectContextMenu(); void rebuildSession(); + void deployProjectOnly(); + void deployProject(); + void deployProjectContextMenu(); + void deploySession(); void cleanProjectOnly(); void cleanProject(); void cleanProjectContextMenu(); @@ -182,6 +186,7 @@ private slots: void runControlFinished(); void startupProjectChanged(); // Calls updateRunAction + void updateDeployActions(); void updateRunActions(); void loadProject(const QString &project) { openProject(project); } @@ -207,6 +212,8 @@ private: void runProjectImpl(Project *pro, QString mode); void executeRunConfiguration(RunConfiguration *, const QString &mode); bool hasBuildSettings(Project *pro); + bool hasDeploySettings(Project *pro); + bool showBuildConfigDialog(); void setCurrent(Project *project, QString filePath, Node *node); diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 5a09c20c614..e25693ca974 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -53,6 +53,10 @@ const char * const REBUILDPROJECTONLY = "ProjectExplorer.RebuildProjectOnly"; const char * const REBUILD = "ProjectExplorer.Rebuild"; const char * const REBUILDCM = "ProjectExplorer.RebuildCM"; const char * const REBUILDSESSION = "ProjectExplorer.RebuildSession"; +const char * const DEPLOYPROJECTONLY = "ProjectExplorer.DeployProjectOnly"; +const char * const DEPLOY = "ProjectExplorer.Deploy"; +const char * const DEPLOYCM = "ProjectExplorer.DeployCM"; +const char * const DEPLOYSESSION = "ProjectExplorer.DeploySession"; const char * const CLEANPROJECTONLY = "ProjectExplorer.CleanProjectOnly"; const char * const CLEAN = "ProjectExplorer.Clean"; const char * const CLEANCM = "ProjectExplorer.CleanCM"; diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index 74b6f1c3637..256f4ef2639 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -37,11 +37,11 @@ namespace Internal { struct ProjectExplorerSettings { - ProjectExplorerSettings() : buildBeforeRun(true), saveBeforeBuild(false), - showCompilerOutput(false), - cleanOldAppOutput(false), useJom(true) {} + ProjectExplorerSettings() : buildBeforeDeploy(true), deployBeforeRun(true), saveBeforeBuild(false), + showCompilerOutput(false), cleanOldAppOutput(false), useJom(true) {} - bool buildBeforeRun; + bool buildBeforeDeploy; + bool deployBeforeRun; bool saveBeforeBuild; bool showCompilerOutput; bool cleanOldAppOutput; @@ -54,7 +54,8 @@ struct ProjectExplorerSettings inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerSettings &p2) { - return p1.buildBeforeRun == p2.buildBeforeRun + return p1.buildBeforeDeploy == p2.buildBeforeDeploy + && p1.deployBeforeRun == p2.deployBeforeRun && p1.saveBeforeBuild == p2.saveBeforeBuild && p1.showCompilerOutput == p2.showCompilerOutput && p1.cleanOldAppOutput == p2.cleanOldAppOutput diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index 806b9b4570c..71f6ed60d9e 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -65,7 +65,8 @@ void ProjectExplorerSettingsWidget::setJomVisible(bool v) ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const { ProjectExplorerSettings pes; - pes.buildBeforeRun = m_ui.buildProjectBeforeRunCheckBox->isChecked(); + pes.buildBeforeDeploy = m_ui.buildProjectBeforeDeployCheckBox->isChecked(); + pes.deployBeforeRun = m_ui.deployProjectBeforeRunCheckBox->isChecked(); pes.saveBeforeBuild = m_ui.saveAllFilesCheckBox->isChecked(); pes.showCompilerOutput = m_ui.showCompileOutputCheckBox->isChecked(); pes.cleanOldAppOutput = m_ui.cleanOldAppOutputCheckBox->isChecked(); @@ -75,7 +76,8 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings &pes) const { - m_ui.buildProjectBeforeRunCheckBox->setChecked(pes.buildBeforeRun); + m_ui.buildProjectBeforeDeployCheckBox->setChecked(pes.buildBeforeDeploy); + m_ui.deployProjectBeforeRunCheckBox->setChecked(pes.deployBeforeRun); m_ui.saveAllFilesCheckBox->setChecked(pes.saveBeforeBuild); m_ui.showCompileOutputCheckBox->setChecked(pes.showCompilerOutput); m_ui.cleanOldAppOutputCheckBox->setChecked(pes.cleanOldAppOutput); diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.ui b/src/plugins/projectexplorer/projectexplorersettingspage.ui index a08005b5f3a..dc0c30526d1 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.ui +++ b/src/plugins/projectexplorer/projectexplorersettingspage.ui @@ -63,9 +63,16 @@ - + - Always build project before running + Always build project before deploying it + + + + + + + Always deploy project before running it diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index 04ad8450367..f34e85ab256 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -154,8 +154,7 @@ bool FileNode::isGenerated() const */ FolderNode::FolderNode(const QString &folderPath) : Node(FolderNodeType, folderPath), - m_displayName(QDir::toNativeSeparators(folderPath)), - m_icon(Core::FileIconProvider::instance()->icon(QFileIconProvider::Folder)) + m_displayName(QDir::toNativeSeparators(folderPath)) { } @@ -182,6 +181,9 @@ QString FolderNode::displayName() const */ QIcon FolderNode::icon() const { + // Instantiating the Icon provider is expensive. + if (m_icon.isNull()) + m_icon = Core::FileIconProvider::instance()->icon(QFileIconProvider::Folder); return m_icon; } diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 3a4511e8b54..6679b6184a4 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -147,7 +147,7 @@ private: // managed by ProjectNode friend class ProjectNode; QString m_displayName; - QIcon m_icon; + mutable QIcon m_icon; }; class PROJECTEXPLORER_EXPORT ProjectNode : public FolderNode diff --git a/src/plugins/projectexplorer/projectwelcomepagewidget.cpp b/src/plugins/projectexplorer/projectwelcomepagewidget.cpp index e75df35e9b7..9c30289eb4f 100644 --- a/src/plugins/projectexplorer/projectwelcomepagewidget.cpp +++ b/src/plugins/projectexplorer/projectwelcomepagewidget.cpp @@ -39,6 +39,8 @@ #include #include +#include + #include #include #include @@ -146,8 +148,9 @@ void ProjectWelcomePageWidget::updateWelcomePage(const WelcomePageData &welcomeP break; const QFileInfo fi(it.first); QString label = "" + it.second + - "
    " + - fm.elidedText(it.first, Qt::ElideMiddle, 250); + "
    " + + fm.elidedText(QDir::toNativeSeparators(Utils::withTildeHomePath(it.first)), + Qt::ElideMiddle, 250); ui->projTreeWidget->addItem(label, it.first, QDir::toNativeSeparators(fi.absolutePath())); } diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index d6b4e505cbe..cd1a210ca71 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index b8f9e0e01a4..b4bf4fc948b 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -30,22 +30,13 @@ #ifndef PROJECTWINDOW_H #define PROJECTWINDOW_H -#include "iprojectproperties.h" - -#include -#include -#include -#include -#include -#include #include -#include -#include QT_BEGIN_NAMESPACE class QLabel; class QGridLayout; class QMenu; +class QStackedWidget; QT_END_NAMESPACE namespace ProjectExplorer { @@ -105,7 +96,6 @@ private: QList m_tabIndexToProject; }; - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 33b59d6984a..d089ef8ecfb 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -179,6 +179,11 @@ Target *RunConfiguration::target() const return m_target; } +ProjectExplorer::OutputFormatter *RunConfiguration::createOutputFormatter() const +{ + return new OutputFormatter(); +} + IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) : QObject(parent) { @@ -218,13 +223,23 @@ IRunControlFactory::~IRunControlFactory() RunControl::RunControl(RunConfiguration *runConfiguration, QString mode) : m_runMode(mode), m_runConfiguration(runConfiguration) { - if (runConfiguration) + if (runConfiguration) { m_displayName = runConfiguration->displayName(); + m_outputFormatter = runConfiguration->createOutputFormatter(); + } + // We need to ensure that there's always a OutputFormatter + if (!m_outputFormatter) + m_outputFormatter = new OutputFormatter(); } RunControl::~RunControl() { + delete m_outputFormatter; +} +OutputFormatter *RunControl::outputFormatter() +{ + return m_outputFormatter; } QString RunControl::runMode() const @@ -242,11 +257,6 @@ bool RunControl::sameRunConfiguration(RunControl *other) return other->m_runConfiguration.data() == m_runConfiguration.data(); } -OutputFormatter *RunControl::createOutputFormatter(QObject *parent) -{ - return new OutputFormatter(parent); -} - void RunControl::bringApplicationToForeground(qint64 pid) { #ifdef Q_OS_MAC diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index f9e897e509f..c1532590f65 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -85,6 +85,8 @@ public: Target *target() const; + virtual ProjectExplorer::OutputFormatter *createOutputFormatter() const; + signals: void isEnabledChanged(bool value); @@ -169,7 +171,7 @@ public: bool sameRunConfiguration(RunControl *other); - virtual OutputFormatter *createOutputFormatter(QObject *parent = 0); + OutputFormatter *outputFormatter(); QString runMode() const; signals: @@ -189,6 +191,7 @@ private: QString m_displayName; QString m_runMode; const QWeakPointer m_runConfiguration; + OutputFormatter *m_outputFormatter; #ifdef Q_OS_MAC //these two are used to bring apps in the foreground on Mac diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.h b/src/plugins/projectexplorer/runsettingspropertiespage.h index 29eeb04b2e0..5491a2afbdf 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.h +++ b/src/plugins/projectexplorer/runsettingspropertiespage.h @@ -33,7 +33,6 @@ #include "iprojectproperties.h" #include -#include QT_BEGIN_NAMESPACE class QMenu; diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index d92128a8242..f68e3117664 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -33,8 +33,6 @@ #include "projectconfiguration.h" #include "projectexplorer_export.h" -#include -#include #include namespace ProjectExplorer { diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 69a77ae9834..8ef5beb3d93 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -43,6 +43,7 @@ #include #include #include +#include using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; diff --git a/src/plugins/projectexplorer/targetsettingspanel.h b/src/plugins/projectexplorer/targetsettingspanel.h index 6d449ec1c7d..874263b936d 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.h +++ b/src/plugins/projectexplorer/targetsettingspanel.h @@ -30,19 +30,18 @@ #ifndef TARGETSETTINGSPANEL_H #define TARGETSETTINGSPANEL_H -#include "iprojectproperties.h" - -#include #include QT_BEGIN_NAMESPACE class QAction; class QMenu; +class QStackedWidget; QT_END_NAMESPACE namespace ProjectExplorer { class Target; +class Project; namespace Internal { diff --git a/src/plugins/projectexplorer/taskhub.h b/src/plugins/projectexplorer/taskhub.h index ec27b0a3c95..1fd5a10f92a 100644 --- a/src/plugins/projectexplorer/taskhub.h +++ b/src/plugins/projectexplorer/taskhub.h @@ -31,7 +31,7 @@ #define TASKHUB_H #include "task.h" -#include "projectexplorer_export.h" + #include #include diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index b6f1f4c8fb9..d5a0f410c07 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -30,17 +30,17 @@ #ifndef TASKWINDOW_H #define TASKWINDOW_H -#include "task.h" #include -#include QT_BEGIN_NAMESPACE class QAction; class QModelIndex; +class QPoint; QT_END_NAMESPACE namespace ProjectExplorer { class TaskHub; +class Task; namespace Internal { class TaskWindowPrivate; diff --git a/src/plugins/projectexplorer/vcsannotatetaskhandler.h b/src/plugins/projectexplorer/vcsannotatetaskhandler.h index 27fa40a8042..18bfcaf6b8d 100644 --- a/src/plugins/projectexplorer/vcsannotatetaskhandler.h +++ b/src/plugins/projectexplorer/vcsannotatetaskhandler.h @@ -34,9 +34,6 @@ #include "itaskhandler.h" -#include -#include - namespace Core { class IVersionControl; } diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp index f49c6077e98..eb8b87fde54 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp @@ -32,6 +32,7 @@ #include #include "itemlibrarywidgets.h" #include "itemlibrarymodel.h" +#include "itemlibraryimageprovider.h" #include "customdraganddrop.h" #include @@ -164,6 +165,9 @@ ItemLibrary::ItemLibrary(QWidget *parent) : m_d->m_resourcesView->setModel(m_d->m_resourcesDirModel); m_d->m_resourcesView->setIconSize(m_d->m_resIconSize); + /* create image provider for loading item icons */ + m_d->m_itemsView->engine()->addImageProvider(QLatin1String("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider); + /* other widgets */ QTabBar *tabBar = new QTabBar(this); tabBar->addTab(tr("Items", "Title of library items view")); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.pri b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.pri index d4e3b0f71bd..4cd2f619cd3 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.pri +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.pri @@ -6,8 +6,8 @@ VPATH += $$PWD INCLUDEPATH += $$PWD # Input -HEADERS += itemlibrary.h customdraganddrop.h itemlibrarymodel.h itemlibrarywidgets.h -SOURCES += itemlibrary.cpp customdraganddrop.cpp itemlibrarymodel.cpp itemlibrarywidgets.cpp +HEADERS += itemlibrary.h customdraganddrop.h itemlibrarymodel.h itemlibrarywidgets.h itemlibraryimageprovider.h +SOURCES += itemlibrary.cpp customdraganddrop.cpp itemlibrarymodel.cpp itemlibrarywidgets.cpp itemlibraryimageprovider.cpp RESOURCES += itemlibrary.qrc OTHER_FILES += \ diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.cpp new file mode 100644 index 00000000000..b3bb37b146a --- /dev/null +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.cpp @@ -0,0 +1,55 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ +#include "itemlibraryimageprovider.h" + +namespace QmlDesigner { + +namespace Internal { + +ItemLibraryImageProvider::ItemLibraryImageProvider() : + QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) +{ +} + +QPixmap ItemLibraryImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) +{ + QPixmap pixmap(id); + if (size) { + size->setWidth(pixmap.width()); + size->setHeight(pixmap.height()); + } + if (requestedSize.isValid()) + return pixmap.scaled(requestedSize); + return pixmap; +} + +} + +} + diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.h new file mode 100644 index 00000000000..861e4cfd476 --- /dev/null +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryimageprovider.h @@ -0,0 +1,51 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef ITEMLIBRARYIMAGEPROVIDER_H +#define ITEMLIBRARYIMAGEPROVIDER_H + +#include + +namespace QmlDesigner { + +namespace Internal { + +class ItemLibraryImageProvider : public QDeclarativeImageProvider +{ +public: + ItemLibraryImageProvider(); + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); +}; + +} + +} + +#endif // ITEMLIBRARYIMAGEPROVIDER_H diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp index 28764e0ad94..42d8cc68894 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp @@ -176,7 +176,6 @@ ItemLibraryItemModel::ItemLibraryItemModel(QScriptEngine *scriptEngine, int item m_scriptEngine(scriptEngine), m_libId(itemLibId), m_name(itemName), - m_icon(), m_iconSize(64, 64) { QScriptValue pixmapScriptValue(m_scriptEngine->newVariant(QPixmap())); @@ -204,21 +203,19 @@ QString ItemLibraryItemModel::itemName() const return m_name; } - -void ItemLibraryItemModel::setItemIcon(const QIcon &itemIcon) +void ItemLibraryItemModel::setItemIconPath(const QString &iconPath) { - m_icon = itemIcon; + m_iconPath = iconPath; - QScriptValue pixmapScriptValue(m_scriptEngine->newVariant(m_icon.pixmap(m_iconSize))); - setProperty(QLatin1String("itemPixmap"), pixmapScriptValue); + setProperty(QLatin1String("itemLibraryIconPath"), + QString(QLatin1String("image://qmldesigner_itemlibrary/") + iconPath)); } - void ItemLibraryItemModel::setItemIconSize(const QSize &itemIconSize) { m_iconSize = itemIconSize; // qDebug() << "set icon size" << itemIconSize; - setItemIcon(m_icon); + setItemIconPath(m_iconPath); } @@ -414,12 +411,12 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo) itemModel = new ItemLibraryItemModel(m_scriptEngine.data(), itemId, entry.name()); // delayed creation of (default) icons - if (entry.icon().isNull()) - entry.setIcon(QIcon(QLatin1String(":/ItemLibrary/images/item-default-icon.png"))); + if (entry.iconPath().isEmpty()) + entry.setIconPath(QLatin1String(":/ItemLibrary/images/item-default-icon.png")); if (entry.dragIcon().isNull()) entry.setDragIcon(createDragPixmap(getWidth(entry), getHeight(entry))); - itemModel->setItemIcon(entry.icon()); + itemModel->setItemIconPath(entry.iconPath()); itemModel->setItemIconSize(m_itemIconSize); sectionModel->addSectionEntry(itemModel); m_sections.insert(itemId, sectionId); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.h index 896710f4118..5859ae61ba3 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.h @@ -84,7 +84,7 @@ public: int itemLibId() const; QString itemName() const; - void setItemIcon(const QIcon &itemIcon); + void setItemIconPath(const QString &iconPath); void setItemIconSize(const QSize &itemIconSize); bool operator<(const ItemLibraryItemModel &other) const; @@ -93,7 +93,7 @@ private: QWeakPointer m_scriptEngine; int m_libId; QString m_name; - QIcon m_icon; + QString m_iconPath; QSize m_iconSize; }; diff --git a/src/plugins/qmldesigner/components/itemlibrary/qml/ItemView.qml b/src/plugins/qmldesigner/components/itemlibrary/qml/ItemView.qml index ca3babe624d..9380c90ad9e 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/qml/ItemView.qml +++ b/src/plugins/qmldesigner/components/itemlibrary/qml/ItemView.qml @@ -96,7 +96,7 @@ Item { width: itemLibraryIconWidth // to be set in Qml context height: itemLibraryIconHeight // to be set in Qml context - pixmap: itemPixmap // to be set by model + source: itemLibraryIconPath // to be set by model } Text { diff --git a/src/plugins/qmldesigner/components/propertyeditor/contextpanetextwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/contextpanetextwidget.cpp index 7d1bf033085..09a893062e4 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/contextpanetextwidget.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/contextpanetextwidget.cpp @@ -272,14 +272,14 @@ void ContextPaneTextWidget::onHorizontalAlignmentChanged() { QString alignment; if (ui->centerHAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignHCenter"); + alignment = QLatin1String("AlignHCenter"); else if (ui->leftAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignLeft"); + alignment = QLatin1String("AlignLeft"); else if (ui->rightAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignRight"); + alignment = QLatin1String("AlignRight"); if (m_horizontalAlignment != alignment) { m_horizontalAlignment = alignment; - if (alignment == QLatin1String("Text.AlignLeft")) + if (alignment == QLatin1String("AlignLeft")) emit removeProperty(QLatin1String("horizontalAlignment")); else emit propertyChanged(QLatin1String("horizontalAlignment"), alignment); @@ -298,14 +298,14 @@ void ContextPaneTextWidget::onVerticalAlignmentChanged() { QString alignment; if (ui->centerVAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignVCenter"); + alignment = QLatin1String("AlignVCenter"); else if (ui->topAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignTop"); + alignment = QLatin1String("AlignTop"); else if (ui->bottomAlignmentButton->isChecked()) - alignment = QLatin1String("Text.AlignBottom"); + alignment = QLatin1String("AlignBottom"); if (m_verticalAlignment != alignment) { m_verticalAlignment = alignment; - if (alignment == QLatin1String("Text.AlignTop")) + if (alignment == QLatin1String("AlignTop")) emit removeProperty(QLatin1String("verticalAlignment")); else emit propertyChanged(QLatin1String("verticalAlignment"), alignment); diff --git a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.cpp index addd0dcb741..1b198005ae9 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.cpp @@ -65,7 +65,7 @@ ContextPaneWidget::~ContextPaneWidget() m_bauhausColorDialog.clear(); } -void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative) +void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2) { //uncheck all color buttons foreach (ColorButton *colorButton, findChildren()) { @@ -73,20 +73,19 @@ void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative) } resize(sizeHint()); show(); - rePosition(pos, alternative); + rePosition(pos, alternative, alternative2); raise(); } -void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative) +void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative, const QPoint &alternative2) { - if (position.y() > 0) + if ((position.x() + width()) < parentWidget()->width()) move(position); else move(alternative); - m_originalPos = pos(); - if (m_xPos > 0) - move(m_xPos, pos().y()); + if (pos().y() < 0) + move(alternative2); } void ContextPaneWidget::deactivate() @@ -178,13 +177,17 @@ void ContextPaneWidget::mouseReleaseEvent(QMouseEvent *event) void ContextPaneWidget::mouseMoveEvent(QMouseEvent * event) { if (event->buttons() && Qt::LeftButton) { - + if (pos().x() < 10 && event->pos().x() < -20) + return; if (m_oldPos != QPoint(-1, -1)) { QPoint diff = event->globalPos() - m_oldPos; - move(pos() + diff); - if (m_bauhausColorDialog) - m_bauhausColorDialog->move(m_bauhausColorDialog->pos() + diff); - m_xPos = pos().x(); + if (m_bauhausColorDialog) { + QPoint newPos = pos() + diff; + if (newPos.x() > 0 && newPos.y() > 0 && (newPos.x() + width()) < parentWidget()->width() && (newPos.y() + height()) < parentWidget()->height()) { + m_bauhausColorDialog->move(m_bauhausColorDialog->pos() + diff); + move(newPos); + } + } } else { m_opacityEffect = new QGraphicsOpacityEffect; setGraphicsEffect(m_opacityEffect); diff --git a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.h b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.h index ce600a5399e..7097d6a5e13 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.h +++ b/src/plugins/qmldesigner/components/propertyeditor/contextpanewidget.h @@ -22,8 +22,8 @@ class ContextPaneWidget : public QFrame public: explicit ContextPaneWidget(QWidget *parent = 0); ~ContextPaneWidget(); - void activate(const QPoint &pos, const QPoint &alternative); - void rePosition(const QPoint &pos, const QPoint &alternative); + void activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2); + void rePosition(const QPoint &pos, const QPoint &alternative , const QPoint &alternative3); void deactivate(); BauhausColorDialog *colorDialog(); void setProperties(QmlJS::PropertyReader *propertyReader); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri b/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri index bb98fc009e7..b2e922c5131 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri @@ -2,10 +2,12 @@ VPATH += $$PWD INCLUDEPATH += $$PWD SOURCES += stateseditorwidget.cpp \ stateseditormodel.cpp \ - stateseditorview.cpp + stateseditorview.cpp \ + stateseditorimageprovider.cpp HEADERS += stateseditorwidget.h \ stateseditormodel.h \ - stateseditorview.h + stateseditorview.h \ + stateseditorimageprovider.cpp RESOURCES += $$PWD/stateseditor.qrc OTHER_FILES +=$$PWD/stateslist.qml \ $$PWD/HorizontalScrollBar.qml diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp new file mode 100644 index 00000000000..2d08b622b7a --- /dev/null +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp @@ -0,0 +1,65 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ +#include "stateseditorimageprovider.h" +#include "stateseditorview.h" + +namespace QmlDesigner { + +namespace Internal { + +StatesEditorImageProvider::StatesEditorImageProvider(StatesEditorView *view) : + QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap), + m_view(view) +{ +} + +QPixmap StatesEditorImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) +{ + if (!m_view.isNull()) { + // discard the count number (see StatesEditorModel m_updateCounter) + QString s = id.mid(0, id.lastIndexOf(QLatin1Char('-'))); + + bool ok = false; + int state = s.toInt(&ok); + if (ok) { + QPixmap pm = m_view->renderState(state); + if (size) + *size = pm.size(); + if (requestedSize.isValid()) + return pm.scaled(requestedSize); + return pm; + } + } + return QPixmap(); +} + +} + +} + diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h new file mode 100644 index 00000000000..ae614462368 --- /dev/null +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h @@ -0,0 +1,59 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef STATESEDITORIMAGEPROVIDER_H +#define STATESEDITORIMAGEPROVIDER_H + +#include + +#include + +namespace QmlDesigner { + +namespace Internal { + +class StatesEditorView; + +class StatesEditorImageProvider : public QDeclarativeImageProvider +{ +public: + StatesEditorImageProvider(StatesEditorView *view); + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); + +private: + QWeakPointer m_view; +}; + +} + +} + +#endif // STATESEDITORIMAGEPROVIDER_H + diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 8c5b5ac4767..71e51b6d8ae 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -42,12 +42,12 @@ namespace QmlDesigner { namespace Internal { StatesEditorModel::StatesEditorModel(QObject *parent) : - QAbstractListModel(parent) + QAbstractListModel(parent), + m_updateCounter(0) { - QHash roleNames; roleNames.insert(StateNameRole, "stateName"); - roleNames.insert(StatesPixmapRole, "statePixmap"); + roleNames.insert(StateImageSourceRole, "stateImageSource"); setRoleNames(roleNames); } @@ -78,11 +78,9 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const result = m_stateNames.at(index.row()); break; } - case StatesPixmapRole: { - // TODO: Maybe cache this? - if (!m_statesView.isNull()) { - result = m_statesView->renderState(index.row()); - } + case StateImageSourceRole: { + if (!m_statesView.isNull()) + return QString("image://qmldesigner_stateseditor/%1-%2").arg(index.row()).arg(m_updateCounter); break; } } @@ -120,7 +118,10 @@ void StatesEditorModel::renameState(int i, const QString &newName) if (m_stateNames[i] != newName) { if (m_stateNames.contains(newName) || newName.isEmpty()) { - QMessageBox::warning(0, tr("Invalid state name"), newName.isEmpty()?tr("The empty string as a name is reserved for the base state."):tr("Name already used in another state")); + QMessageBox::warning(0, tr("Invalid state name"), + newName.isEmpty() ? + tr("The empty string as a name is reserved for the base state.") : + tr("Name already used in another state")); } else { m_stateNames.replace(i, newName); m_statesView->renameState(i,newName); @@ -134,6 +135,14 @@ void StatesEditorModel::updateState(int i) { Q_ASSERT(i >= 0 && i < m_stateNames.count()); + // QML images with the same URL are always cached, so this changes the URL each + // time to ensure the image is loaded from the StatesImageProvider and not the + // cache. + // TODO: only increase imageId when the scene has changed so that we can load + // from the cache instead where possible. + if (++m_updateCounter == INT_MAX) + m_updateCounter = 0; + emit dataChanged(createIndex(i, 0), createIndex(i, 0)); } diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h index 89b748ed921..36f92105e80 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h @@ -47,7 +47,7 @@ class StatesEditorModel : public QAbstractListModel enum { StateNameRole = Qt::DisplayRole, - StatesPixmapRole = Qt::UserRole + StateImageSourceRole = Qt::UserRole, }; public: @@ -71,6 +71,7 @@ signals: private: QList m_stateNames; QWeakPointer m_statesView; + int m_updateCounter; }; } // namespace Itnernal diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index 937af6e900a..689f5e7a17a 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -30,6 +30,7 @@ #include "stateseditorwidget.h" #include "stateseditormodel.h" #include "stateseditorview.h" +#include "stateseditorimageprovider.h" #include #include @@ -203,6 +204,10 @@ void StatesEditorWidget::setup(Model *model) m_d->model = model; if (m_d->statesEditorView.isNull()) m_d->statesEditorView = new Internal::StatesEditorView(m_d->statesEditorModel.data(), this); + + m_d->listView->engine()->addImageProvider( + QLatin1String("qmldesigner_stateseditor"), new Internal::StatesEditorImageProvider(m_d->statesEditorView.data())); + m_d->statesEditorModel->setStatesEditorView(m_d->statesEditorView.data()); m_d->model->attachView(m_d->statesEditorView.data()); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml index dc2b649e354..2a552c32bb4 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml +++ b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml @@ -145,7 +145,7 @@ Rectangle { anchors.bottomMargin: 9 Image { anchors.centerIn:parent - pixmap: statePixmap + source: stateImageSource Rectangle { anchors.fill:parent color:"transparent" diff --git a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h index 35286f2f0b8..5a0baeba597 100644 --- a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h +++ b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h @@ -62,6 +62,7 @@ public: QString name() const; QString typeName() const; QIcon icon() const; + QString iconPath() const; int majorVersion() const; int minorVersion() const; QString category() const; @@ -77,7 +78,7 @@ public: void setType(const QString &typeName, int majorVersion, int minorVersion); void setName(const QString &name); - void setIcon(const QIcon &icon); + void setIconPath(const QString &iconPath); void addProperty(const Property &p); void addProperty(QString &name, QString &type, QString &value); void setDragIcon(const QIcon &icon); diff --git a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp index c640c77b769..18757e8b9c7 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp @@ -46,6 +46,7 @@ public: QString category; int majorVersion; int minorVersion; + QString iconPath; QIcon icon; QIcon dragIcon; QList properties; @@ -148,6 +149,11 @@ QIcon ItemLibraryEntry::icon() const return m_data->icon; } +QString ItemLibraryEntry::iconPath() const +{ + return m_data->iconPath; +} + void ItemLibraryEntry::setName(const QString &name) { m_data->name = name; @@ -160,9 +166,9 @@ void ItemLibraryEntry::setType(const QString &typeName, int majorVersion, int mi m_data->minorVersion = minorVersion; } -void ItemLibraryEntry::setIcon(const QIcon &icon) +void ItemLibraryEntry::setIconPath(const QString &iconPath) { - m_data->icon = icon; + m_data->iconPath = iconPath; } void ItemLibraryEntry::setQml(const QString &qml) @@ -184,6 +190,7 @@ QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibrary stream << itemLibraryEntry.majorVersion(); stream << itemLibraryEntry.minorVersion(); stream << itemLibraryEntry.icon(); + stream << itemLibraryEntry.iconPath(); stream << itemLibraryEntry.category(); stream << itemLibraryEntry.dragIcon(); stream << itemLibraryEntry.m_data->properties; @@ -198,6 +205,7 @@ QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry) stream >> itemLibraryEntry.m_data->majorVersion; stream >> itemLibraryEntry.m_data->minorVersion; stream >> itemLibraryEntry.m_data->icon; + stream >> itemLibraryEntry.m_data->iconPath; stream >> itemLibraryEntry.m_data->category; stream >> itemLibraryEntry.m_data->dragIcon; stream >> itemLibraryEntry.m_data->properties; diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp index 216ba28dd37..9edf26e5389 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp @@ -205,8 +205,8 @@ void MetaInfoParser::handleNodeItemLibraryEntryElement(QXmlStreamReader &reader, entry.setName(name); QString iconPath = reader.attributes().value("icon").toString(); - if (!iconPath.isEmpty()) - entry.setIcon(QIcon(iconPath)); + if (!iconPath.isEmpty()) + entry.setIconPath(iconPath); QString category = reader.attributes().value("category").toString(); if (!category.isEmpty()) diff --git a/src/plugins/qmldesigner/designersettings.cpp b/src/plugins/qmldesigner/designersettings.cpp index fece6159743..c1f7de93422 100644 --- a/src/plugins/qmldesigner/designersettings.cpp +++ b/src/plugins/qmldesigner/designersettings.cpp @@ -52,7 +52,7 @@ void DesignerSettings::fromSettings(QSettings *settings) snapMargin = settings->value( QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), QVariant(0)).toInt(); enableContextPane = settings->value( - QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), QVariant(0)).toBool(); + QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), QVariant(1)).toBool(); settings->endGroup(); settings->endGroup(); diff --git a/src/plugins/qmldesigner/qmlcontextpane.cpp b/src/plugins/qmldesigner/qmlcontextpane.cpp index 88c65ab9a1b..ca07a3adf9c 100644 --- a/src/plugins/qmldesigner/qmlcontextpane.cpp +++ b/src/plugins/qmldesigner/qmlcontextpane.cpp @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -62,7 +65,7 @@ QmlContextPane::~QmlContextPane() m_widget.clear(); } -void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, Node *node, bool update) +void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr doc, const QmlJS::Snapshot &snapshot, AST::Node *node, bool update) { if (!Internal::BauhausPlugin::pluginInstance()->settings().enableContextPane) return; @@ -73,6 +76,15 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document: if (update && editor != m_editor) return; //do not update for different editor + LookupContext::Ptr lookupContext = LookupContext::create(doc, snapshot, QList()); + const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node); + + QStringList prototypes; + while (scopeObject) { + prototypes.append(scopeObject->className()); + scopeObject = scopeObject->prototype(lookupContext->context()); + } + setEnabled(doc->isParsedCorrectly()); m_editor = editor; contextWidget()->setParent(editor->widget()->parentWidget()); @@ -97,6 +109,24 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document: offset = objectBinding->firstSourceLocation().offset; end = objectBinding->lastSourceLocation().end(); } + + int line1; + int column1; + int line2; + int column2; + m_editor->convertPosition(offset, &line1, &column1); //get line + m_editor->convertPosition(end, &line2, &column2); //get line + + QRegion reg; + if (line1 > -1 && line2 > -1) + reg = m_editor->editor()->translatedLineRegion(line1 - 1, line2); + + QRect rect; + rect.setHeight(m_widget->height() + 10); + rect.setWidth(reg.boundingRect().width() - reg.boundingRect().left()); + rect.moveTo(reg.boundingRect().topLeft()); + reg = reg.intersect(rect); + if (name.contains("Text")) { m_node = 0; PropertyReader propertyReader(doc.data(), initializer); @@ -105,11 +135,15 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document: QPoint p1 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(editor->editor()->cursorRect(tc).topLeft()) - QPoint(0, contextWidget()->height() + 10)); tc.setPosition(end); QPoint p2 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(editor->editor()->cursorRect(tc).bottomLeft()) + QPoint(0, 10)); + QPoint offset = QPoint(10, 0); + if (reg.boundingRect().width() < 400) + offset = QPoint(400 - reg.boundingRect().width() + 10 ,0); + QPoint p3 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(reg.boundingRect().topRight()) + offset); p2.setX(p1.x()); if (!update) - contextWidget()->activate(p1 , p2); + contextWidget()->activate(p3 , p1, p2); else - contextWidget()->rePosition(p1 , p2); + contextWidget()->rePosition(p3 , p1, p2); m_blockWriting = true; contextWidget()->setType(name); contextWidget()->setProperties(&propertyReader); @@ -163,7 +197,6 @@ void QmlContextPane::setProperty(const QString &propertyName, const QVariant &va QTextCursor tc(m_editor->editor()->document()); tc.beginEditBlock(); int cursorPostion = tc.position(); - tc.beginEditBlock(); changeSet.apply(&tc); if (line > 0) { @@ -171,17 +204,16 @@ void QmlContextPane::setProperty(const QString &propertyName, const QVariant &va QmlJSIndenter indenter; indenter.setTabSize(ts.m_tabSize); indenter.setIndentSize(ts.m_indentSize); - QTextBlock start = m_editor->editor()->document()->findBlockByLineNumber(line); - QTextBlock end = m_editor->editor()->document()->findBlockByLineNumber(line); + QTextBlock start = m_editor->editor()->document()->findBlockByNumber(line); + QTextBlock end = m_editor->editor()->document()->findBlockByNumber(line); - const int indent = indenter.indentForBottomLine(m_editor->editor()->document()->begin(), end.next(), QChar::Null); - ts.indentLine(start, indent); + if (end.isValid()) { + const int indent = indenter.indentForBottomLine(m_editor->editor()->document()->begin(), end.next(), QChar::Null); + ts.indentLine(start, indent); + } } tc.endEditBlock(); tc.setPosition(cursorPostion); - - tc.endEditBlock(); - tc.setPosition(cursorPostion); } } @@ -234,8 +266,14 @@ void QmlContextPane::onPropertyRemovedAndChange(const QString &remove, const QSt if (!m_doc) return; - setProperty(change, value); + QTextCursor tc(m_editor->editor()->document()); + tc.beginEditBlock(); + removeProperty(remove); + setProperty(change, value); + + tc.endEditBlock(); + m_doc.clear(); //the document is outdated } diff --git a/src/plugins/qmldesigner/qmlcontextpane.h b/src/plugins/qmldesigner/qmlcontextpane.h index d13d7125e08..a2b799042b7 100644 --- a/src/plugins/qmldesigner/qmlcontextpane.h +++ b/src/plugins/qmldesigner/qmlcontextpane.h @@ -28,7 +28,7 @@ class QmlContextPane : public QmlJS::IContextPane public: QmlContextPane(QObject *parent = 0); ~QmlContextPane(); - void apply(TextEditor::BaseTextEditorEditable *editor, QmlJS::Document::Ptr doc, QmlJS::AST::Node *node, bool update); + void apply(TextEditor::BaseTextEditorEditable *editor, QmlJS::Document::Ptr doc, const QmlJS::Snapshot &snapshot, QmlJS::AST::Node *node, bool update); void setProperty(const QString &propertyName, const QVariant &value); void removeProperty(const QString &propertyName); void setEnabled(bool); diff --git a/src/plugins/qmldesigner/settingspage.ui b/src/plugins/qmldesigner/settingspage.ui index 48b3f50b83a..66f276ca896 100644 --- a/src/plugins/qmldesigner/settingspage.ui +++ b/src/plugins/qmldesigner/settingspage.ui @@ -101,13 +101,13 @@ - Text Editor Helper + Quick Toolbars - enable + Text Quick Toolbar diff --git a/src/plugins/qmljseditor/qmljscodecompletion.cpp b/src/plugins/qmljseditor/qmljscodecompletion.cpp index 1bd3c77a52f..5f28d8acac3 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.cpp +++ b/src/plugins/qmljseditor/qmljscodecompletion.cpp @@ -878,8 +878,19 @@ void CodeCompletion::completions(QList *completions) } } -void CodeCompletion::complete(const TextEditor::CompletionItem &item) +bool CodeCompletion::typedCharCompletes(const TextEditor::CompletionItem &item, QChar typedChar) { + if (item.data.canConvert()) // snippet + return false; + + return (item.text.endsWith(QLatin1String(": ")) && typedChar == QLatin1Char(':')) + || (item.text.endsWith(QLatin1Char('.')) && typedChar == QLatin1Char('.')); +} + +void CodeCompletion::complete(const TextEditor::CompletionItem &item, QChar typedChar) +{ + Q_UNUSED(typedChar) // Currently always included in the completion item when used + QString toInsert = item.text; if (QmlJSTextEditor *edit = qobject_cast(m_editor->widget())) { @@ -895,7 +906,7 @@ void CodeCompletion::complete(const TextEditor::CompletionItem &item) QString replacableChars; if (toInsert.endsWith(QLatin1String(": "))) replacableChars = QLatin1String(": "); - else if (toInsert.endsWith(QLatin1String("."))) + else if (toInsert.endsWith(QLatin1Char('.'))) replacableChars = QLatin1String("."); int replacedLength = 0; @@ -924,7 +935,7 @@ bool CodeCompletion::partiallyComplete(const QList & const TextEditor::CompletionItem item = completionItems.first(); if (!item.data.canConvert()) { - complete(item); + complete(item, QChar()); return true; } } diff --git a/src/plugins/qmljseditor/qmljscodecompletion.h b/src/plugins/qmljseditor/qmljscodecompletion.h index 0cae652ad2c..f435badf24d 100644 --- a/src/plugins/qmljseditor/qmljscodecompletion.h +++ b/src/plugins/qmljseditor/qmljscodecompletion.h @@ -68,7 +68,8 @@ public: virtual bool triggersCompletion(TextEditor::ITextEditable *editor); virtual int startCompletion(TextEditor::ITextEditable *editor); virtual void completions(QList *completions); - virtual void complete(const TextEditor::CompletionItem &item); + virtual bool typedCharCompletes(const TextEditor::CompletionItem &item, QChar typedChar); + virtual void complete(const TextEditor::CompletionItem &item, QChar typedChar); virtual bool partiallyComplete(const QList &completionItems); virtual QList getCompletions(); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 0f5ec780490..ea6c3741e5e 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -32,6 +32,7 @@ #include "qmljshighlighter.h" #include "qmljseditorplugin.h" #include "qmljsmodelmanager.h" +#include "qmloutlinemodel.h" #include #include @@ -49,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -69,13 +72,16 @@ #include #include +#include #include #include #include +#include enum { UPDATE_DOCUMENT_DEFAULT_INTERVAL = 50, - UPDATE_USES_DEFAULT_INTERVAL = 150 + UPDATE_USES_DEFAULT_INTERVAL = 150, + UPDATE_OUTLINE_INTERVAL = 150 // msecs after new semantic info has been arrived / cursor has moved }; using namespace QmlJS; @@ -610,7 +616,8 @@ QString QmlJSEditorEditable::preferredMode() const QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) : TextEditor::BaseTextEditor(parent), - m_methodCombo(0), + m_outlineCombo(0), + m_outlineModel(new QmlOutlineModel(this)), m_modelManager(0), m_contextPane(0) { @@ -642,13 +649,23 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) : connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument())); connect(this, SIGNAL(textChanged()), this, SLOT(updateUses())); + m_updateOutlineTimer = new QTimer(this); + m_updateOutlineTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + m_updateOutlineTimer->setSingleShot(true); + connect(m_updateOutlineTimer, SIGNAL(timeout()), this, SLOT(updateOutlineNow())); + + m_updateOutlineIndexTimer = new QTimer(this); + m_updateOutlineIndexTimer->setInterval(UPDATE_OUTLINE_INTERVAL); + m_updateOutlineIndexTimer->setSingleShot(true); + connect(m_updateOutlineIndexTimer, SIGNAL(timeout()), this, SLOT(updateOutlineIndexNow())); + baseTextDocument()->setSyntaxHighlighter(new Highlighter(document())); m_modelManager = ExtensionSystem::PluginManager::instance()->getObject(); m_contextPane = ExtensionSystem::PluginManager::instance()->getObject(); if (m_contextPane) connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged())); - m_oldCurserPosition = -1; + m_oldCursorPosition = -1; if (m_modelManager) { m_semanticHighlighter->setModelManager(m_modelManager); @@ -674,19 +691,33 @@ SemanticInfo QmlJSTextEditor::semanticInfo() const return m_semanticInfo; } -int QmlJSTextEditor::documentRevision() const +int QmlJSTextEditor::editorRevision() const { return document()->revision(); } bool QmlJSTextEditor::isOutdated() const { - if (m_semanticInfo.revision() != documentRevision()) + if (m_semanticInfo.revision() != editorRevision()) return true; return false; } +QmlOutlineModel *QmlJSTextEditor::outlineModel() const +{ + return m_outlineModel; +} + +QModelIndex QmlJSTextEditor::outlineModelIndex() +{ + if (!m_outlineModelIndex.isValid()) { + m_outlineModelIndex = indexForPosition(position()); + emit outlineModelIndexChanged(m_outlineModelIndex); + } + return m_outlineModelIndex; +} + Core::IEditor *QmlJSEditorEditable::duplicate(QWidget *parent) { QmlJSTextEditor *newEditor = new QmlJSTextEditor(parent); @@ -779,6 +810,8 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc) const SemanticHighlighter::Source source = currentSource(/*force = */ true); m_semanticHighlighter->rehighlight(source); + + m_updateOutlineTimer->start(); } else { // show parsing errors QList selections; @@ -793,33 +826,70 @@ void QmlJSTextEditor::modificationChanged(bool changed) m_modelManager->fileChangedOnDisk(file()->fileName()); } -void QmlJSTextEditor::jumpToMethod(int index) +void QmlJSTextEditor::jumpToOutlineElement(int /*index*/) { - if (index > 0 && index <= m_semanticInfo.declarations.size()) { // indexes are 1-based - Declaration d = m_semanticInfo.declarations.at(index - 1); - gotoLine(d.startLine, d.startColumn - 1); - setFocus(); - } + QModelIndex index = m_outlineCombo->view()->currentIndex(); + AST::SourceLocation location = index.data(QmlOutlineModel::SourceLocationRole).value(); + + Core::EditorManager *editorManager = Core::EditorManager::instance(); + editorManager->cutForwardNavigationHistory(); + editorManager->addCurrentPositionToNavigationHistory(); + + QTextCursor cursor = textCursor(); + cursor.setPosition(location.offset); + setTextCursor(cursor); + + setFocus(); } -void QmlJSTextEditor::updateMethodBoxIndex() +void QmlJSTextEditor::updateOutlineNow() { - int line = 0, column = 0; - convertPosition(position(), &line, &column); + const Snapshot snapshot = m_modelManager->snapshot(); + Document::Ptr document = snapshot.document(file()->fileName()); - int currentSymbolIndex = 0; + if (!document) + return; - int index = 0; - while (index < m_semanticInfo.declarations.size()) { - const Declaration &d = m_semanticInfo.declarations.at(index++); - - if (line < d.startLine) - break; - else - currentSymbolIndex = index; + if (document->editorRevision() != editorRevision()) { + m_updateOutlineTimer->start(); + return; + } + + m_outlineModel->update(document, snapshot); + + QTreeView *treeView = static_cast(m_outlineCombo->view()); + treeView->expandAll(); + + updateOutlineIndexNow(); +} + +void QmlJSTextEditor::updateOutlineIndexNow() +{ + if (m_updateOutlineTimer->isActive()) + return; // updateOutlineNow will call this function soon anyway + + if (!m_outlineModel->document()) + return; + + if (m_outlineModel->document()->editorRevision() != editorRevision()) { + m_updateOutlineIndexTimer->start(); + return; + } + + m_outlineModelIndex = QModelIndex(); // invalidate + QModelIndex comboIndex = outlineModelIndex(); + + if (comboIndex.isValid()) { + bool blocked = m_outlineCombo->blockSignals(true); + + // There is no direct way to select a non-root item + m_outlineCombo->setRootModelIndex(comboIndex.parent()); + m_outlineCombo->setCurrentIndex(comboIndex.row()); + m_outlineCombo->setRootModelIndex(QModelIndex()); + + m_outlineCombo->blockSignals(blocked); } - m_methodCombo->setCurrentIndex(currentSymbolIndex); updateUses(); } @@ -995,10 +1065,6 @@ void QmlJSTextEditor::setSelectedElement() emit selectedElementsChanged(offsets, wordAtCursor); } -void QmlJSTextEditor::updateMethodBoxToolTip() -{ -} - void QmlJSTextEditor::updateFileName() { } @@ -1122,25 +1188,33 @@ TextEditor::BaseTextEditorEditable *QmlJSTextEditor::createEditableInterface() void QmlJSTextEditor::createToolBar(QmlJSEditorEditable *editable) { - m_methodCombo = new QComboBox; - m_methodCombo->setMinimumContentsLength(22); - //m_methodCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents); + m_outlineCombo = new QComboBox; + m_outlineCombo->setMinimumContentsLength(22); + m_outlineCombo->setModel(m_outlineModel); + + QTreeView *treeView = new QTreeView; + treeView->header()->hide(); + treeView->setItemsExpandable(false); + treeView->setRootIsDecorated(false); + m_outlineCombo->setView(treeView); + treeView->expandAll(); + + //m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents); // Make the combo box prefer to expand - QSizePolicy policy = m_methodCombo->sizePolicy(); + QSizePolicy policy = m_outlineCombo->sizePolicy(); policy.setHorizontalPolicy(QSizePolicy::Expanding); - m_methodCombo->setSizePolicy(policy); + m_outlineCombo->setSizePolicy(policy); - connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int))); - connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex())); - connect(m_methodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMethodBoxToolTip())); + connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); + connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start())); connect(file(), SIGNAL(changed()), this, SLOT(updateFileName())); QToolBar *toolBar = static_cast(editable->toolBar()); QList actions = toolBar->actions(); - toolBar->insertWidget(actions.first(), m_methodCombo); + toolBar->insertWidget(actions.first(), m_outlineCombo); } TextEditor::BaseTextEditor::Link QmlJSTextEditor::findLinkAt(const QTextCursor &cursor, bool /*resolveTarget*/) @@ -1226,7 +1300,7 @@ bool QmlJSTextEditor::event(QEvent *e) switch (e->type()) { case QEvent::ShortcutOverride: if (static_cast(e)->key() == Qt::Key_Escape && m_contextPane) { - m_contextPane->apply(editableInterface(), m_semanticInfo.document, 0, false); + m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, 0, false); } break; default: @@ -1241,7 +1315,7 @@ void QmlJSTextEditor::wheelEvent(QWheelEvent *event) { BaseTextEditor::wheelEvent(event); if (m_contextPane) - m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.declaringMember(position()), true); + m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, m_semanticInfo.declaringMember(position()), true); } void QmlJSTextEditor::unCommentSelection() @@ -1473,20 +1547,11 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) FindDeclarations findDeclarations; m_semanticInfo.declarations = findDeclarations(doc->ast()); - QStringList items; - items.append(tr("