Compare commits

..
2 Commits
2013 changed files with 107211 additions and 227972 deletions
-2
View File
@@ -96,5 +96,3 @@ Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
.vscode/settings.json
.vs/
-16
View File
@@ -1,16 +0,0 @@
os:
- linux
# - osx
# - windows
dist: xenial
sudo: require
language: cpp
script:
- bash bin/clean
- bash bin/configure
# - bash bin/build
# - bash bin/run-unit-tests
# end of file
+73 -200
View File
@@ -1,209 +1,80 @@
Download latest version:
https://robomongo.org/download
Robo 3T 1.4.4 (Aug/2021)
New Features:
- Support for Standard Connection String Format (Mongo URI)
Fixes:
- Fix Welcome Tab not loading the new content issue by disable/bypass HTTP cache
Robo 3T 1.4.3 (Jan/2021)
New Features:
- macOS Big Sur support
- New Welcome Tab - embeds Chromium using QtWebEngine (Windows, macOS only)
- Database explorer section has smaller default width (#1556)
- Remember size of database explorer section
- Import keys from old version: autoExpand, lineNumbers, debugMode and shellTimeoutSec
Fixes:
- Disable unsupported SSH tab for replica set connections (#1285 #1340)
- Fix crash when new shell tab executed in server unreachable case
- Fix crash when paging used in tabbed result window (#1661)
- Fix broken F2, F3, F4 shortcuts for tabbed result view
- One time re-order limit per new connections window to prevent data loss (macOS, #1790)
- Fix previously broken IPv6 support from command line: robo3t --ipv6
Robo 3T 1.4.2 (Oct/2020)
Fixes:
- Fix broken paging in DocumentDB (#1694)
Robo 3T 1.4.1 (Sep/2020)
Fixes:
- Force light mode on macOS (#1761, #1768, #1771)
- Fix broken macOS native theme/look (#1766)
- Fix broken Windows native theme/look
Robo 3T 1.4.0 (Aug/2020)
blog.robomongo.org/robo-3t-1-4/
New Features:
- Mongo shell 4.2 upgrade
- Support for Ubuntu 20.04 and macOS 10.15 (Catalina)
- SSH: ECDSA and Ed25519 keys support on Windows & macOS (#1719, #1530, #1590)
- Manually specify visible databases (#1696, #1368, #389)
Improvements:
- Qt Upgrade (v5.12.8 - Apr/2020, Windows & macOS only)
- OpenSSL upgrade (v1.1.1f - Mar/2020, Windows & macOS only)
- libssh2 upgrade (v1.9.0 - Jun/2019, Windows & macOS only)
Fixes:
- Authentication database option isn't used properly (#1696)
- Add/Edit index ops fixed (re-written) (#1692)
- Crash when expanding admin users (#1728)
- Unable to run query after shell timeout reached (#1529)
Robo 3T 1.3.1 (Apr, 2019)
http://blog.robomongo.org/robo-3t-1-3
New Features:
- Biggest change in this version is Mongo Shell version upgrade from 3.4 to 4.0.5.
- Support for importing from DNS SRV based MongoDB connection strings
- Query results windows now supports tabbed output #1591 #1403
- Adding support for SCRAM-SHA-256 auth mechanism #1569
- Support for Ubuntu 18.04 and Mac 10.14.
- Support for creating version 4 UUID #1554
Improvements:
- Encrypted passwords are used in config. file instead of clear text passwords
- Showing much better error reason string from Mongo drivers for connection failures
Fixes:
- Broken create/edit/view user features fixed and updated #638 #1041
- Attempt to fix #1547: Crash when right click on existing results plus a new long running query
- Fix for application crash when adding index with invalid JSON
- 'Repair Database' in Robo3T needs a confirm dialog box #1568
- Robo 3T the input space causes connection failure #1551
- Crash when loading results + right click #1547
- Attempt to fix major connection problems seen with the second edit/add/remove document operation after MongoDB 4.0 upgrade #1603
- Attempt to fix #1581: For CRUD ops showing progress bar and disabling context menu while waiting for edit op to finish
- Fixing UI issue where Functions folder freezing with "Functions..." when fails to refresh
- Fix for #1529: Pagination does not work when the aggregation queries have dotted fields
Robo 3T 1.3.0 Beta (16 Feb, 2019)
Details: https://github.com/Studio3T/robomongo/releases/tag/v1.3.0-beta
Robo 3T 1.2.1 (19 Feb, 2018)
http://blog.robomongo.org/robo-3t-1-2
Fixes:
- Aggregate query results are not pagaeble
- Big double numbers are showing incorrectly #1447
- Editing a document from a projection causes data loss (override) (#881)
- Error: Resources temporarily unavailable. Error when starting up SSH session: -8 #1426
- robo3t 1.1 failed to start on Ubuntu 17.04 #1385
- Robo 3T is not opening on MacOS High Sierra (#1412)
- Cannot load list of indexes #1454
- Robo 3T is not buildable on latest MacOS High Sierra
Improvements
- Qt version upgraded from Qt 5.7.0 to Qt 5.9.3
- Auto switch to HTTP from HTTPS if the program crashes due to HTTPS related operations
- Improvements for Robo 3T is crashing constantly on High Sierra #1412
- PR: Improved query time formatting (#1358) #1455
Robo 3T 1.2.0 Beta (18 Dec, 2017)
https://github.com/Studio3T/robomongo/releases/tag/v1.2.0-beta
Improvements & Fixes:
- Qt version upgraded from Qt 5.7.0 to Qt 5.9.3
- Fix for "Cannot load list of indexes #1454"
- Improvements for Robo 3T is crashing constantly on High Sierra #1412
- PR: Improved query time formatting (#1358) #1455
- Fix for "Robo 3T is not buildable on latest MacOS vesion High Sierra"
- Fix attempt for "Error: Resources temporarily unavailable. Error when starting up SSH session: -8 #1426"
- Fix for "robo3t 1.1 failed to start on Ubuntu 17.04 #1385"
Robo 3T 1.1 (13 June, 2017)
http://blog.robomongo.org/robomongo-1-1/
New Features:
- MongoDB 3.4 support
- New NumberDecimal (Decimal128) data type support
- ECMAScript 2015 aka ES6 Support (Modernized JavaScript Implementation)
- Re-naming from Robomongo to Robo 3T
Improvements & Fixes:
- Stability Improvements: Fix included to prevent a crash on MACOS Sierra
- Shell timeout is configurable on UI now 'Options->Change Shell Timeout'
- Fix for Robomongo Shell Timeout Issue (silently, prematurely finishing long lasting scripts)
- Security Improvements: OpenSSL version upgrade to openssl-1.0.1u (22-Sep-2016)
- Tool chain upgrades: Modern C++14 features are enabled and usable for developers
Robomongo 1.1 Beta (12 May, 2017)
https://github.com/Studio3T/robomongo/releases/tag/v1.1.0-beta
New Features:
- MongoDB 3.4 Support
- New NumberDecimal (Decimal128) data type support
- ECMAScript 2015 (Modernized JavaScript Implementation aka ES6) Support
Improvements:
- Security Improvements: OpenSSL version upgrade to openssl-1.0.1u (22-Sep-2016)
- Tool Chain Improvements: Modern C++14 features are enabled
Latest Version:
Robomongo 1.0 (21 Apr, 2017)
http://blog.robomongo.org/robomongo-1-0
New Features:
Robomongo 1.x:
Major Features:
- Replica set support.
- Update Notifications Bar
- Welcome Tab
- Welcome Wizard
Improvements:
- Replica set name configurable on UI
- Configuration file system location change
- "About Robomongo" dialog changes
Fixes:
- Fix to avoid the same set name problem (https://github.com/Studio3T/robomongo/issues/1302)
- Timestamp value is represented incorrectly (https://github.com/Studio3T/robomongo/issues/1159)
- Local Timezone shows wrong date (https://github.com/Studio3T/robomongo/issues/501)
- Time zone shown as "000:00" when UTC +00:00 is used as local timezone(https://github.com/Studio3T/robomongo/issues/1309)
Robomongo 1.0-RC1 (1 Feb, 2017)
http://blog.robomongo.org/robomongo-1-rc1/
New Features:
- Replica set support.
- New 'Attributes' column in connections list window showing connection properties such as 'Replica Set', 'SSL' and 'SSH'.
- New operation logging for almost all operations.
Improvements:
- Improved error handling (no double error windows) for all fail and success conditions for the following operations:
. Create, Drop Database
. Create, Edit User
. Create, Drop, Duplicate, Rename Collection
. Insert Document
. Remove document, Delete document, Remove all documents (triggered both from explorer and from result widget)
. Refresh Users
. Refresh Functions
. Refresh Collections
. Connection establish & refresh server fail and success cases.
- Windows size is saved and restored for Edit, View and Insert Document dialogs.
- Connections are automatically imported from the latest Robomongo version.
- Better error reporting/handling and logging have been added for the operations below:
. Create, Drop Function
. Drop User
- More informative and adjusted log level prefix strings haven added for log window. (Error, Warn, Info etc..).
- After a new connection is created, now the focus goes to the newly created connection (end of list) instead of the
beginning of connections list. And when Robomongo is opened, the focus goes to the end of the connection list instead
of beginning.
- Error messages added and error handling for 'remove document', 'remove all documents' operations triggered explorer
and single or multi 'delete document' from results window have been re-implemented and improved.
- Relevant errors are shown for the following cases now:
. Drop attempt of non-existing collection.
. Duplicating a collection with a collection name which already exists finishes silently.
Fixes:
- Fix for the problem where the connections list comes empty if the Robomongo config file or it's directory do not exist.
- Fix for the problem where 'in-progress bar' widget was not centered on main window for "Update Documents/Remove Documents"
operations. https://github.com/paralect/robomongo/issues/1256
- Fix for two problems where the operations 'insert or update documents' in one tab was causing auto reloading of other
unrelated tabs and also multiple error windows to popup. https://github.com/paralect/robomongo/issues/1236
- Fix for the problem where the operations 'remove document', 'remove all documents' triggered explorer and single or
multi 'delete document' from results window were causing auto reloading of other unrelated tabs.
Major Fixes/Improvements:
- Improved error handling (no double error windows) for almost all operations.
- Timestamp value is represented incorrectly (https://github.com/Studio3T/robomongo/issues/1159)
- Local Timezone shows wrong date (https://github.com/Studio3T/robomongo/issues/501)
* What's new in patch 1.0.3 (7 June, 2017)
- Attempt to prevent MAC OS Sierra crash related to updates notification bar
* What's new in 1.0 (21 Apr, 2017)
New Features:
- Update Notifications Bar
- Welcome Tab
- Welcome Wizard
Improvements:
- Replica set name configurable on UI
- Configuration file system location change
- "About Robomongo" dialog changes
Fixes:
- Fix to avoid the same set name problem (https://github.com/Studio3T/robomongo/issues/1302)
- Timestamp value is represented incorrectly (https://github.com/Studio3T/robomongo/issues/1159)
- Local Timezone shows wrong date (https://github.com/Studio3T/robomongo/issues/501)
- Time zone shown as "000:00" when UTC +00:00 is used as local timezone(https://github.com/Studio3T/robomongo/issues/1309)
* What's new in 1.0-RC1 (1 Feb, 2017)
New Features:
- Replica set support.
- New 'Attributes' column in connections list window showing connection properties such as 'Replica Set', 'SSL' and 'SSH'.
- New operation logging for almost all operations.
Improvements:
- Improved error handling (no double error windows) for all fail and success conditions for the following operations:
. Create, Drop Database
. Create, Edit User
. Create, Drop, Duplicate, Rename Collection
. Insert Document
. Remove document, Delete document, Remove all documents (triggered both from explorer and from result widget)
. Refresh Users
. Refresh Functions
. Refresh Collections
. Connection establish & refresh server fail and success cases.
- Windows size is saved and restored for Edit, View and Insert Document dialogs.
- Connections are automatically imported from the latest Robomongo version.
- Better error reporting/handling and logging have been added for the operations below:
. Create, Drop Function
. Drop User
- More informative and adjusted log level prefix strings haven added for log window. (Error, Warn, Info etc..).
- After a new connection is created, now the focus goes to the newly created connection (end of list) instead of the
beginning of connections list. And when Robomongo is opened, the focus goes to the end of the connection list instead
of beginning.
- Error messages added and error handling for 'remove document', 'remove all documents' operations triggered explorer
and single or multi 'delete document' from results window have been re-implemented and improved.
- Relevant errors are shown for the following cases now:
. Drop attempt of non-existing collection.
. Duplicating a collection with a collection name which already exists finishes silently.
Fixes:
- Fix for the problem where the connections list comes empty if the Robomongo config file or it's directory do not exist.
- Fix for the problem where 'in-progress bar' widget was not centered on main window for "Update Documents/Remove Documents"
operations. https://github.com/paralect/robomongo/issues/1256
- Fix for two problems where the operations 'insert or update documents' in one tab was causing auto reloading of other
unrelated tabs and also multiple error windows to popup. https://github.com/paralect/robomongo/issues/1236
- Fix for the problem where the operations 'remove document', 'remove all documents' triggered explorer and single or
multi 'delete document' from results window were causing auto reloading of other unrelated tabs.
Robomongo 0.9:
@@ -227,7 +98,9 @@ Robomongo 0.9:
#910, #748, #697, #699, #760, #815, #870, #892,
#894, #905, #945, #974, #978, #990, #831, #842
- SSH connection failure to servers on Ubuntu and OS X with the following error:
"Resource temporarily unavailable. Error when starting up SSH session: -8" (#1090)
"Resource temporarily unavailable. Error when starting up SSH session: -8" (#1090)
What's new in 0.9.0 Final (30 Sep, 2016)
http://blog.robomongo.org/robomongo-0-9-0-final/
+7 -30
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8.0)
cmake_minimum_required(VERSION 3.0.0)
project(Robomongo)
# Where to look first for CMake modules, before "${CMAKE_ROOT}/Modules" is checked
@@ -6,15 +6,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Project version
set(PROJECT_VERSION_MAJOR "1")
set(PROJECT_VERSION_MINOR "4")
set(PROJECT_VERSION_PATCH "4")
set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "3")
set(PROJECT_VERSION_BUILD "")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_BUILD}")
# Enable C++17 features
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Modules
include(RobomongoPrintUtils)
include(RobomongoCMakeDefaults)
@@ -33,39 +29,20 @@ find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Xml REQUIRED)
if(NOT SYSTEM_LINUX)
find_package(Qt5WebEngineWidgets REQUIRED)
endif()
find_package(MongoDB REQUIRED)
find_package(OpenSSL REQUIRED)
if (SYSTEM_MACOSX)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14)
find_package(Qt5MacExtras REQUIRED)
endif()
# Projects
set(LIBSSH2_VERSION 1.9.0)
if(SYSTEM_LINUX)
set(LIBSSH2_VERSION 1.7.0)
endif()
set(LIBSSH2_DIR src/third-party/libssh2-${LIBSSH2_VERSION})
set(QJSON_VERSION 0.8.1)
set(QJSON_DIR src/third-party/qjson-${QJSON_VERSION})
set(QSCINTILLA_VERSION 2.8.4)
set(QSCINTILLA_DIR src/third-party/qscintilla-${QSCINTILLA_VERSION})
set(ESPRIMA_VERSION 2.7.3)
set(ESPRIMA_DIR src/third-party/esprima-${ESPRIMA_VERSION})
# todo: Use equivalent vars from googletest cmake files. Currently they are somehow not working.
set(GOOGLE_TEST_VERSION 1.8.1)
set(GOOGLE_TEST_DIR src/third-party/googletest-${GOOGLE_TEST_VERSION})
add_subdirectory(${LIBSSH2_DIR})
add_subdirectory(src/third-party/libssh2)
add_subdirectory(src/robomongo/ssh)
add_subdirectory(${QJSON_DIR})
add_subdirectory(${QSCINTILLA_DIR})
add_subdirectory(${GOOGLE_TEST_DIR})
add_subdirectory(src/third-party/qjson)
add_subdirectory(src/third-party/qscintilla)
add_subdirectory(src/robomongo)
add_subdirectory(src/robomongo-unit-tests)
# Show configuration summary
include(RobomongoConfigurationSummary)
+3 -3
View File
@@ -1,11 +1,11 @@
Robo 3T, shell-centric cross-platform MongoDB management tool.
Robomongo, shell-centric cross-platform MongoDB management tool.
Copyright 2014-2017 3T Software Labs Ltd.
The Robo 3T is released under the terms of the GNU General Public
The Robomongo is released under the terms of the GNU General Public
License, version 3.
The Robo 3T Project includes files written by third parties
The Robomongo Project includes files written by third parties
and used with permission or subject to their respective license
agreements.
+1 -1
View File
@@ -1,3 +1,3 @@
Robo 3T is a shell-centric cross-platform open source MongoDB management
Robomongo is a shell-centric cross-platform open source MongoDB management
tool (i.e. Admin GUI). Robomongo embeds the same JavaScript engine that
powers MongoDB's mongo shell.
-21
View File
@@ -1,21 +0,0 @@
FROM debian
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends --fix-missing\
libgl-dev \
qt5dxcb-plugin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
ADD https://download-test.robomongo.org/linux/robo3t-1.3.1-linux-x86_64-7419c406.tar.gz /opt/robo3t.tar.gz
RUN cd /opt/ \
&& mkdir robo3t \
&& tar -C /opt/robo3t --strip-components 1 -xzf robo3t.tar.gz && rm robo3t.tar.gz \
&& ls /opt/robo3t
VOLUME /root/.3T
VOLUME /root/.config/3T
CMD /opt/robo3t/bin/robo3t
+90 -94
View File
@@ -1,93 +1,111 @@
About Robo 3T
About Robomongo [![Join the chat at https://gitter.im/paralect/robomongo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/paralect/robomongo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
===============
[Robo 3T](http://www.robomongo.org) (formerly Robomongo *) is a shell-centric cross-platform MongoDB management tool. Unlike most other MongoDB admin UI tools, Robo 3T embeds the actual `mongo` shell in a tabbed interface with access to a shell command line as well as GUI interaction.
[Robomongo](http://www.robomongo.org) is a shell-centric cross-platform MongoDB management tool. Unlike most other MongoDB admin UI tools, Robomongo embeds the actual `mongo` shell in a tabbed interface with access to a shell command line as well as GUI interaction.
The latest stable release **Robo 3T 1.4** embeds **MongoDB 4.2** shell.
Starting from version 0.9, Robomongo is compatibile with MongoDB 3.x (including SCRAM-SHA-1 auth and support for WiredTiger storage engine). Robomongo 0.9 embeds the **MongoDB 3.2** shell.
Blog: http://blog.robomongo.org/robo-3t-1-4/
Robomongo 0.8.x embeds the **MongoDB 2.4.0** shell.
What's new in latest Robomongo 1.0?
====================================
Latest release of Robomongo 1.0 includes:
- Update Notifications Bar
- Welcome Tab
- Welcome Wizard
- Replica set name configurable on UI
- Fixes to avoid same replica set name problem
- Fixes to solve various problems regarding Data and Timestamp data types
Blog: http://blog.robomongo.org/robomongo-1-0/
Download: https://robomongo.org/download
All Releases: https://github.com/Studio3T/robomongo/releases
Watch: [Robo 3T Youtube channel](https://www.youtube.com/channel/UCM_7WAseRWeeiBikExppstA)
Watch: [Robomongo Youtube channel](https://www.youtube.com/channel/UCM_7WAseRWeeiBikExppstA)
Follow: https://twitter.com/Robomongo
**Embedded MongoDB shell history:**
Robo 3T 1.4 -> MongoDB 4.2
Robo 3T 1.3 -> MongoDB 4.0
Robo 3T 1.1 -> MongoDB 3.4
Robo 3T 0.9 -> MongoDB 3.2
Robo 3T 0.8.x -> MongoDB 2.4.0
\* [Robomongo has been acquired by 3T](https://studio3t.com/press/3t-software-labs-acquires-robomongo-the-most-widely-used-mongodb-tool/)
What's new in latest Robo 3T 1.4?
What's Planned for the Next Releases?
====================================
New Features:
- Mongo shell 4.2 upgrade
- Support for Ubuntu 20.04, macOS Big Sur and macOS 10.15 (Catalina)
- SSH: ECDSA and Ed25519 keys support on Windows & macOS (issues #1719, #1530, #1590)
- Manually specify visible databases (issues #1696, #1368, #389)
- New Welcome Tab - embeds Chromium using QtWebEngine (Windows, macOS only)
- Import keys from old version: autoExpand, lineNumbers, debugMode and shellTimeoutSec
Improvements:
- Qt Upgrade (v5.12.8 - Apr/2020, Windows & macOS only)
- OpenSSL upgrade (v1.1.1f - Mar/2020, Windows & macOS only)
- libssh2 upgrade (v1.9.0 - Jun/2019, Windows & macOS only)
- Database explorer section has smaller default width (#1556)
- Remember database explorer section size
We are currently working towards [Robomongo 2.0 milestone](https://github.com/paralect/robomongo/milestone/21).
Currently in progress:
- MongoDB 3.4 Support
Fixes:
- Fix previously broken IPv6 support from command line: robo3t --ipv6
- Fix crash when paging used in tabbed result window (#1661)
- Fix broken paging in DocumentDB (#1694)
- Authentication database option isn't used properly (#1696)
- Add/Edit index ops fixed (re-written) (#1692)
- Crash when expanding admin users (#1728)
- Unable to run query after shell timeout reached (#1529)
- Fix broken F2, F3, F4 shortcuts for tabbed result view
- One time re-order limit per new connections window to prevent data loss (macOS, #1790)
- Fix crash when new shell tab executed in server unreachable case
Plans for Future:
- User Roles
- Support execution of multiple simultaneous queries [#1161](https://github.com/paralect/robomongo/issues/1161)
- Selectable mongodb engines [#1249](https://github.com/paralect/robomongo/issues/1249)
- Enhancements for stability, running without crashes ([Stability Milestone](https://github.com/paralect/robomongo/milestone/15))
- More Documentation
- Unit Tests
- Refactoring Debug Log module
Supported Platforms
===============
Note: This sections is for Robo 3T and it directly depends on what MongoDB suppports
(See: https://docs.mongodb.com/manual/administration/production-notes/#prod-notes-supported-platforms)
| MongoDB Versions |
| :-------------------- |
| 3.2 |
| 3.0 |
| 2.6 |
| MongoDB Versions | MongoDB Cloud Platforms |
| :-------------------- | :-------------------- |
| 4.2 | Mongo Atlas |
| 4.0 |
| 3.6 |
| MongoDB Cloud Platforms|
| :------------ |
| MongoDB Atlas |
| Compose |
| mLab |
| ObjectRocket |
| Amazon EC2 |
| Windows | Mac | Linux |
|:---------------------- | :--------------------------------| :---------------------------|
| Windows 64-bit 10 | Mac OS X 11 (Big Sur) | Linux Ubuntu 20.04 64-bit |
Windows 64-bit 8.1 | Mac OS X 10.15 (Catalina) | Linux Ubuntu 18.04 64-bit |
| Windows 64-bit 7 | Mac OS X 10.14 (Mojave) | |
| Windows | Mac | Linux |
|:---------------------- | :---------------| :---------------------------|
| Windows 64-bit 10 | Mac OS X 10.11 | Linux Ubuntu 16.04 64-bit* |
Windows 64-bit 8.1 | Mac OS X 10.10 | Linux Ubuntu 14.04 64-bit* |
| Windows 64-bit 7 | | Linux CentOS 7 64-bit* |
| | | Linux CentOS 6 64-bit* |
\* latest stable build
Download
========
You can download tested install packages for OS X, Windows, and Linux from our site: [www.robomongo.org](http://www.robomongo.org).
The latest stable release is currently [**Robomongo 1.0**](http://blog.robomongo.org/robomongo-1-0/).
Support
=======
Robomongo is an open source project driven by volunteers. We'll try to get to your questions as soon as we can, but please be patient :).
You can:
- [Create a new issue in the Github issue queue](https://github.com/paralect/robomongo/issues)
- [Join developer discussion on Gitter](https://gitter.im/paralect/robomongo)
Build
=====
The wiki contains prerequisites and instructions to [Build Robomongo](https://github.com/paralect/robomongo/wiki).
If you want to compile from source yourself, you should be able to do so cleanly from a [release branch](https://github.com/paralect/robomongo/releases).
Contribute!
===========
### Suggest Features
New feature suggestions or UI improvements are always welcome.
[Create a new feature request on github](https://github.com/paralect/robomongo/issues/new)
This project is powered by open source volunteers, so we have a limited amount of development resource to address all requests. We will certainly make best efforts to progress (particularly for those with strong community upvotes).
### Code Contributions
See all docs here: https://github.com/Studio3T/robomongo/wiki
**Some important docs:**
- [Build Diagram](https://github.com/Studio3T/robomongo/wiki/Robo-3T-Schematics:-Build,-Class-and-UI-Diagrams#1-build-diagram)
- [Static Code Analysis](https://github.com/Studio3T/robomongo/wiki/Static-Code-Analysis)
- [Robo 3T Feature Specisification](https://github.com/Studio3T/robomongo/wiki/Feature-Spec)
- [Debugging](https://github.com/Studio3T/robomongo/blob/master/docs/Debug.md)
- [Schematics](https://github.com/Studio3T/robomongo/tree/master/schematics)
Code contributions are always welcome! Just try to follow our pre-commit checks and coding style:
- [Robo 3T Code Quality](https://github.com/paralect/robomongo/wiki/Robomongo-Code-Quality)
- [Robo 3T C++11/14 Transition Guide](https://github.com/Studio3T/robomongo/wiki/Robomongo-Cplusplus-11,-14-Transition-Guide)
- [Robo 3T Coding Style](https://github.com/paralect/robomongo/wiki/Robomongo-Coding-Style)
- [Robomongo Code Quality](https://github.com/paralect/robomongo/wiki/Robomongo-Code-Quality)
- [Robomongo Coding Style](https://github.com/paralect/robomongo/wiki/Robomongo-Coding-Style)
If you plan to contribute, please create a Github issue (or comment on the relevant existing issue) so we can help coordinate with upcoming release plans.
@@ -98,41 +116,19 @@ A usual naming approach for feature branches is `issue-###`. Include the issue n
For example:
```#248: updated QScintilla to 2.4.8 for retina display support".```
### Design
There are some cosmetic issues we could use help with (designing images or UI). They are marked in the issue queue with a [`Cosmetic`](https://github.com/paralect/robomongo/labels/cosmetic) label. If you see an open issue that you'd like to contribute to, please feel free to volunteer by commenting on it.
### Testing
- [Unit-Tests](https://github.com/Studio3T/robomongo/wiki/Unit-Tests)
- [Manual Tests](wiki/Tests)
- See all docs here: https://github.com/Studio3T/robomongo/wiki
### Suggest Features
New feature suggestions or UI improvements are always welcome.
[Create a new feature request on github](https://github.com/paralect/robomongo/issues/new)
This project is powered by open source volunteers, so we have a limited amount of development resource to address all requests. We will certainly make best efforts to progress (particularly for those with strong community upvotes).
Download
========
You can download tested installer packages for macOS, Windows, and Linux from our site: [www.robomongo.org](http://www.robomongo.org).
Support
=======
Robo 3T is an open source project driven by volunteers. We'll try to get to your questions as soon as we can, but please be patient :).
You can:
- [Create a new issue in the Github issue queue](https://github.com/paralect/robomongo/issues)
- [Join developer discussion on Gitter](https://gitter.im/paralect/robomongo)
There are a number of issues we could use help with reproducing. They are marked in the issue queue with a [`Needs Repro`](https://github.com/paralect/robomongo/labels/needs%20repro) label. If you see an open issue that doesn't appear to be reproducible yet, please feel free to test and comment with your findings.
License
=======
Copyright 2014-2021 [3T Software Labs Ltd](https://studio3t.com/). All rights reserved.
Copyright 2014-2017 [3T Software Labs Ltd](https://studio3t.com/). All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
-11
View File
@@ -3,8 +3,6 @@ Bash fronted for CMake
If you want to use this scripts, you need to set single environment variable:
E.g.:
export ROBOMONGO_CMAKE_PREFIX_PATH="/path/to/qt-5/5.5/gcc_64;/path/to/robomongo-shell"
Build Robomongo:
@@ -16,16 +14,7 @@ Install Robomongo:
$ bin/install
Run Robomongo:
$ bin/run
Pack Robomongo:
$ bin/pack
More:
- [Build Robo 3T - Mac OS X and Linux](https://github.com/paralect/robomongo/blob/master/docs/BuildRobo3TOnMacAndLinux.md)
- [Build Robo 3T - Windows](https://github.com/paralect/robomongo/blob/master/docs/BuildRobo3TOnWindows.md)
- [Unit Tests](wiki/Unit-Tests)
- [Static Code Analysis](wiki/Static-Code-Analysis)
+2 -2
View File
@@ -2,7 +2,7 @@
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1 # $1: release or debug
source $BIN_DIR/common/setup $1
cd $BUILD_DIR
cmake --build . "${@:2}" -- -j8
cmake --build . "${@:2}" -- -j8
-7
View File
@@ -1,7 +0,0 @@
#!/usr/bin/env bash
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/build || exit $?
source $BIN_DIR/run-tests $1
-15
View File
@@ -1,15 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
rem Path to bin and project folder
set BIN_DIR_WITH_BACKSLASH=%~dp0%
set BIN_DIR=%BIN_DIR_WITH_BACKSLASH:~0,-1%
set PROJECT_DIR=%BIN_DIR%\..
rem Run build
call "%BIN_DIR%\build.bat" %*
if %ERRORLEVEL% neq 0 (exit /b 1)
rem Run tests
call "%BIN_DIR%\run-tests.bat" %*
if %ERRORLEVEL% neq 0 (exit /b 1)
-5
View File
@@ -13,8 +13,3 @@ if %ERRORLEVEL% neq 0 (exit /b 1)
rem Run build
cd "%BUILD_DIR%"
cmake --build . --config %BUILD_TYPE%
rem Install debug *.dll files
if "%BUILD_TYPE%" == "Debug" (
call "%BIN_DIR%\install-debug-dlls.bat" %*
)
-10
View File
@@ -1,10 +0,0 @@
bugprone-*
cert-*
clang-analyzer-*
cppcoreguidelines-*
concurrency-*
hicpp-*
llvm-*
misc-*
performance-*
readability-*
-4
View File
@@ -1,4 +0,0 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
<ClangTidyChecks></ClangTidyChecks>
</PropertyGroup>
+20 -1
View File
@@ -27,4 +27,23 @@ PACK_PREFIX=$BUILD_DIR/package
PREFIX_PATH=$ROBOMONGO_CMAKE_PREFIX_PATH
mkdir -p $BUILD_DIR
mkdir -p $BUILD_DIR
if [ "$(uname -s)" == "Darwin" ]; then
# On Mac OS we specify minimal OS version that we support.
#
# The following environment variable will set "-mmacosx-version-min=10.6" option
# for compiler. From documentation to GCC or Clang:
#
# -mmacosx-version-min=version
#
# The earliest version of MacOS X that this executable will run on is
# version. Typical values of version include 10.1, 10.2, and 10.3.9.
#
# This value can also be set with the MACOSX_DEPLOYMENT_TARGET environment
# variable. If both the command-line option is specified and the
# environment variable is set, the command-line option will take precedence.
#
export MACOSX_DEPLOYMENT_TARGET=10.9
fi
+2 -3
View File
@@ -2,8 +2,7 @@
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1 # $1: release or debug
source $BIN_DIR/common/setup $1
cd $BUILD_DIR
# $BUILD_TYPE: Release or Debug
cmake -D "CMAKE_PREFIX_PATH=$PREFIX_PATH" -D "CMAKE_BUILD_TYPE=$BUILD_TYPE" -D "CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" "${@:2}" $PROJECT_DIR
cmake -D "CMAKE_PREFIX_PATH=$PREFIX_PATH" -D "CMAKE_BUILD_TYPE=$BUILD_TYPE" -D "CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" "${@:2}" $PROJECT_DIR
+1 -7
View File
@@ -11,11 +11,5 @@ call "%BIN_DIR%\common\setup.bat" %*
if %ERRORLEVEL% neq 0 (exit /b 1)
rem Run CMake configuration step
rem BUILD_TYPE: Release or Debug
cd "%BUILD_DIR%"
cmake -G "Visual Studio 15 2017 Win64" -D "CMAKE_PREFIX_PATH=%PREFIX_PATH%" -D "CMAKE_BUILD_TYPE=%BUILD_TYPE%" -D "CMAKE_INSTALL_PREFIX=%INSTALL_PREFIX%" %PROJECT_DIR%
@REM echo ___________________________________________________________________
@REM rem Enable Clang Tidy for Visual Studio 2019 IDE ...
@REM set ROBO_PROJ_FILE=%BUILD_DIR%/src/robomongo/robomongo.vcxproj
@REM python %BIN_DIR%\enable-visual-studio-clang-tidy.py %ROBO_PROJ_FILE% %BIN_DIR%
cmake -G "Visual Studio 12 2013 Win64" -D "CMAKE_PREFIX_PATH=%PREFIX_PATH%" -D "CMAKE_BUILD_TYPE=%BUILD_TYPE%" -D "CMAKE_INSTALL_PREFIX=%INSTALL_PREFIX%" %PROJECT_DIR%
-44
View File
@@ -1,44 +0,0 @@
import sys
from lxml import etree
print('\nEnabling Clang Tidy for Visual Studio 2019')
robo_proj_xml = sys.argv[1]
clang_tidy_xml = sys.argv[2] + '/clang-tidy.xml'
clang_checks_txt = sys.argv[2] + '/clang-checks.txt'
print(sys.argv[0] + ":\nProcessing: " + sys.argv[1])
## Read clang checks
clang_checks = None
with open(clang_checks_txt, "r") as file:
clang_checks = file.read().replace('\n', ',')
##
tree = etree.parse(robo_proj_xml)
ns = {'ns':'http://schemas.microsoft.com/developer/msbuild/2003'}
if(tree.find('//ns:EnableClangTidyCodeAnalysis', namespaces=ns) is not None):
tree.find('//ns:ClangTidyChecks', namespaces=ns).text = clang_checks
tree.write(robo_proj_xml)
print('Finished')
sys.exit()
## Append clang_tidy_xml - Todo: refactor using etree
with open(robo_proj_xml, "r") as in_file:
buf = in_file.readlines()
with open(clang_tidy_xml, "r") as in_file:
clang_tidy_xml_buf = in_file.read()
appended = False
with open(robo_proj_xml, "w") as out_file:
for line in buf:
if "</ItemGroup>" in line and appended == False:
line = line + clang_tidy_xml_buf
appended = True
out_file.write(line)
## Add clang checks
tree = etree.parse(robo_proj_xml)
tree.find('//ns:ClangTidyChecks', namespaces=ns).text = clang_checks
tree.write(robo_proj_xml)
print('Finished')
-54
View File
@@ -1,54 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
rem // This script installs debug *.dll files
rem -------------------------------------------
set INSTALL_DIR=%BUILD_DIR%\src\robomongo\Debug\
if not exist %INSTALL_DIR%*.dll (
echo ----------------------------------------
echo Installing debug *.dll files ...
echo INSTALL_DIR: %INSTALL_DIR%
echo ----------------------------------------
)
rem // Find OpenSSL and Qt paths
for %%i in (%ROBOMONGO_CMAKE_PREFIX_PATH%) do (
set xx=%%i
if not "!xx!"=="!xx:ssl=!" ( set OPENSSL_DIR=!xx! )
if not "!xx!"=="!xx:qt=!" ( set Qt_DIR=!xx! )
)
set OPENSSL_DIR=%OPENSSL_DIR: =%
set Qt_DIR=%Qt_DIR: =%
rem // Copy dll files
for /d %%a in (
"%VS140COMNTOOLS%\..\..\VC\redist\debug_nonredist\x64\Microsoft.VC140.DebugCRT\msvcp140d.dll"
"%VS140COMNTOOLS%\..\..\VC\redist\debug_nonredist\x64\Microsoft.VC140.DebugCRT\vcruntime140d.dll"
"%OPENSSL_DIR%\libssl-1_1-x64.dll"
"%OPENSSL_DIR%\libcrypto-1_1-x64.dll"
"%Qt_DIR%\bin\Qt5Cored.dll"
"%Qt_DIR%\bin\Qt5Guid.dll"
"%Qt_DIR%\bin\Qt5Networkd.dll"
"%Qt_DIR%\bin\Qt5Widgetsd.dll"
"%Qt_DIR%\bin\Qt5Positioningd.dll"
"%Qt_DIR%\bin\Qt5Qmld.dll"
"%Qt_DIR%\bin\Qt5Quickd.dll"
"%Qt_DIR%\bin\Qt5QuickWidgetsd.dll"
"%Qt_DIR%\bin\Qt5WebChanneld.dll"
"%Qt_DIR%\bin\Qt5WebEngineCored.dll"
"%Qt_DIR%\bin\Qt5WebEngineWidgetsd.dll"
"%Qt_DIR%\bin\Qt5PrintSupportd.dll"
) do (
if not exist !INSTALL_DIR!%%~NXa (
xcopy %%a !INSTALL_DIR! /d /y
)
)
if not exist %INSTALL_DIR%\imageformats\qgifd.dll (
xcopy /s "%Qt_DIR%\plugins\imageformats" %INSTALL_DIR%\imageformats\ /d /y
)
if not exist %INSTALL_DIR%\platforms\qminimald.dll (
xcopy /s "%Qt_DIR%\plugins\platforms" %INSTALL_DIR%\platforms\ /d /y
)
-6
View File
@@ -1,6 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
call "clean.bat" %*
call "configure.bat" %*
call "build.bat" %*
+4 -6
View File
@@ -4,11 +4,9 @@ BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get director
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1
echo "Note: ./install must be executed before this script."
if [ "$(uname -s)" == "Darwin" ]; then
echo "Starting $BUILD_DIR/install/Robo 3T.app/Contents/MacOS/Robo 3T"
"$BUILD_DIR/install/Robo 3T.app/Contents/MacOS/Robo 3T"
# On Mac OS we should run executable from bundle
"$BUILD_DIR/src/robomongo/Robomongo.app/Contents/MacOS/Robomongo"
else
echo "Starting $BUILD_DIR/install/bin/robo3t"
"$BUILD_DIR/install/bin/robo3t"
fi
"$BUILD_DIR/src/robomongo/robomongo"
fi
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env bash
### Common Setup
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1 # $1: release or debug
### Setup
CLANG_TIDY_BUILD_DIR=$PROJECT_DIR/build/clang-tidy-$BUILD_TYPE
rm -rf $CLANG_TIDY_BUILD_DIR
mkdir -p $CLANG_TIDY_BUILD_DIR && cd $CLANG_TIDY_BUILD_DIR
### Configure cmake
# Info: $BUILD_TYPE == Release or Debug
cmake -D "CMAKE_EXPORT_COMPILE_COMMANDS=ON" -D "CMAKE_PREFIX_PATH=$PREFIX_PATH" -D "CMAKE_BUILD_TYPE=$BUILD_TYPE" -D "CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" "${@:2}" $PROJECT_DIR
echo -e "\n------------------------------------------------"
echo "clang-tidy configured. Mode: $BUILD_TYPE"
echo -e "------------------------------------------------\n"
### Run clang-tidy
FILE_OR_PATH=/opt/robo/src/robomongo/ # or MainWindow.cpp
CHECKS=clang-analyzer-*,readability-implicit-bool-conversion
# All Checks: https://clang.llvm.org/extra/clang-tidy/checks/list.html
# e.g. $BIN_DIR/run-clang-tidy.py -checks=clang-analyzer-*,readability-implicit-bool-conversion /opt/robo/src/robomongo/
$BIN_DIR/run-clang-tidy.py -checks=$CHECKS $FILE_OR_PATH
echo -e "\n------------------------------------------------"
echo "clang-tidy finished"
echo "Mode : $BUILD_TYPE"
echo "CLANG_TIDY_BUILD_DIR: $CLANG_TIDY_BUILD_DIR"
echo "Command executed : $BIN_DIR/run-clang-tidy.py -checks=$CHECKS $FILE_OR_PATH"
echo -e "------------------------------------------------\n"
-326
View File
@@ -1,326 +0,0 @@
#!/usr/bin/env python
#
#===- run-clang-tidy.py - Parallel clang-tidy runner ---------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
# FIXME: Integrate with clang-tidy-diff.py
"""
Parallel clang-tidy runner
==========================
Runs clang-tidy over all files in a compilation database. Requires clang-tidy
and clang-apply-replacements in $PATH.
Example invocations.
- Run clang-tidy on all files in the current working directory with a default
set of checks and show warnings in the cpp files and all project headers.
run-clang-tidy.py $PWD
- Fix all header guards.
run-clang-tidy.py -fix -checks=-*,llvm-header-guard
- Fix all header guards included from clang-tidy and header guards
for clang-tidy headers.
run-clang-tidy.py -fix -checks=-*,llvm-header-guard extra/clang-tidy \
-header-filter=extra/clang-tidy
Compilation database setup:
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
"""
from __future__ import print_function
import argparse
import glob
import json
import multiprocessing
import os
import re
import shutil
import subprocess
import sys
import tempfile
import threading
import traceback
try:
import yaml
except ImportError:
yaml = None
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as queue
else:
import queue as queue
def find_compilation_database(path):
"""Adjusts the directory until a compilation database is found."""
result = './'
while not os.path.isfile(os.path.join(result, path)):
if os.path.realpath(result) == '/':
print('Error: could not find compilation database.')
sys.exit(1)
result += '../'
return os.path.realpath(result)
def make_absolute(f, directory):
if os.path.isabs(f):
return f
return os.path.normpath(os.path.join(directory, f))
def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
header_filter, extra_arg, extra_arg_before, quiet,
config):
"""Gets a command line for clang-tidy."""
start = [clang_tidy_binary]
if header_filter is not None:
start.append('-header-filter=' + header_filter)
if checks:
start.append('-checks=' + checks)
if tmpdir is not None:
start.append('-export-fixes')
# Get a temporary file. We immediately close the handle so clang-tidy can
# overwrite it.
(handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
os.close(handle)
start.append(name)
for arg in extra_arg:
start.append('-extra-arg=%s' % arg)
for arg in extra_arg_before:
start.append('-extra-arg-before=%s' % arg)
start.append('-p=' + build_path)
if quiet:
start.append('-quiet')
if config:
start.append('-config=' + config)
start.append(f)
return start
def merge_replacement_files(tmpdir, mergefile):
"""Merge all replacement files in a directory into a single file"""
# The fixes suggested by clang-tidy >= 4.0.0 are given under
# the top level key 'Diagnostics' in the output yaml files
mergekey="Diagnostics"
merged=[]
for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
content = yaml.safe_load(open(replacefile, 'r'))
if not content:
continue # Skip empty files.
merged.extend(content.get(mergekey, []))
if merged:
# MainSourceFile: The key is required by the definition inside
# include/clang/Tooling/ReplacementsYaml.h, but the value
# is actually never used inside clang-apply-replacements,
# so we set it to '' here.
output = { 'MainSourceFile': '', mergekey: merged }
with open(mergefile, 'w') as out:
yaml.safe_dump(output, out)
else:
# Empty the file:
open(mergefile, 'w').close()
def check_clang_apply_replacements_binary(args):
"""Checks if invoking supplied clang-apply-replacements binary works."""
try:
subprocess.check_call([args.clang_apply_replacements_binary, '--version'])
except:
print('Unable to run clang-apply-replacements. Is clang-apply-replacements '
'binary correctly specified?', file=sys.stderr)
traceback.print_exc()
sys.exit(1)
def apply_fixes(args, tmpdir):
"""Calls clang-apply-fixes on a given directory."""
invocation = [args.clang_apply_replacements_binary]
if args.format:
invocation.append('-format')
if args.style:
invocation.append('-style=' + args.style)
invocation.append(tmpdir)
subprocess.call(invocation)
def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
"""Takes filenames out of queue and runs clang-tidy on them."""
while True:
name = queue.get()
invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
tmpdir, build_path, args.header_filter,
args.extra_arg, args.extra_arg_before,
args.quiet, args.config)
proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = proc.communicate()
if proc.returncode != 0:
failed_files.append(name)
with lock:
sys.stdout.write(' '.join(invocation) + '\n' + output.decode('utf-8'))
if len(err) > 0:
sys.stdout.flush()
sys.stderr.write(err.decode('utf-8'))
queue.task_done()
def main():
parser = argparse.ArgumentParser(description='Runs clang-tidy over all files '
'in a compilation database. Requires '
'clang-tidy and clang-apply-replacements in '
'$PATH.')
parser.add_argument('-clang-tidy-binary', metavar='PATH',
default='clang-tidy',
help='path to clang-tidy binary')
parser.add_argument('-clang-apply-replacements-binary', metavar='PATH',
default='clang-apply-replacements',
help='path to clang-apply-replacements binary')
parser.add_argument('-checks', default=None,
help='checks filter, when not specified, use clang-tidy '
'default')
parser.add_argument('-config', default=None,
help='Specifies a configuration in YAML/JSON format: '
' -config="{Checks: \'*\', '
' CheckOptions: [{key: x, '
' value: y}]}" '
'When the value is empty, clang-tidy will '
'attempt to find a file named .clang-tidy for '
'each source file in its parent directories.')
parser.add_argument('-header-filter', default=None,
help='regular expression matching the names of the '
'headers to output diagnostics from. Diagnostics from '
'the main file of each translation unit are always '
'displayed.')
if yaml:
parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes',
help='Create a yaml file to store suggested fixes in, '
'which can be applied with clang-apply-replacements.')
parser.add_argument('-j', type=int, default=0,
help='number of tidy instances to be run in parallel.')
parser.add_argument('files', nargs='*', default=['.*'],
help='files to be processed (regex on path)')
parser.add_argument('-fix', action='store_true', help='apply fix-its')
parser.add_argument('-format', action='store_true', help='Reformat code '
'after applying fixes')
parser.add_argument('-style', default='file', help='The style of reformat '
'code after applying fixes')
parser.add_argument('-p', dest='build_path',
help='Path used to read a compile command database.')
parser.add_argument('-extra-arg', dest='extra_arg',
action='append', default=[],
help='Additional argument to append to the compiler '
'command line.')
parser.add_argument('-extra-arg-before', dest='extra_arg_before',
action='append', default=[],
help='Additional argument to prepend to the compiler '
'command line.')
parser.add_argument('-quiet', action='store_true',
help='Run clang-tidy in quiet mode')
args = parser.parse_args()
db_path = 'compile_commands.json'
if args.build_path is not None:
build_path = args.build_path
else:
# Find our database
build_path = find_compilation_database(db_path)
try:
invocation = [args.clang_tidy_binary, '-list-checks']
invocation.append('-p=' + build_path)
if args.checks:
invocation.append('-checks=' + args.checks)
invocation.append('-')
if args.quiet:
# Even with -quiet we still want to check if we can call clang-tidy.
with open(os.devnull, 'w') as dev_null:
subprocess.check_call(invocation, stdout=dev_null)
else:
subprocess.check_call(invocation)
except:
print("Unable to run clang-tidy.", file=sys.stderr)
sys.exit(1)
# Load the database and extract all files.
database = json.load(open(os.path.join(build_path, db_path)))
files = [make_absolute(entry['file'], entry['directory'])
for entry in database]
max_task = args.j
if max_task == 0:
max_task = multiprocessing.cpu_count()
tmpdir = None
if args.fix or (yaml and args.export_fixes):
check_clang_apply_replacements_binary(args)
tmpdir = tempfile.mkdtemp()
# Build up a big regexy filter from all command line arguments.
file_name_re = re.compile('|'.join(args.files))
return_code = 0
try:
# Spin up a bunch of tidy-launching threads.
task_queue = queue.Queue(max_task)
# List of files with a non-zero return code.
failed_files = []
lock = threading.Lock()
for _ in range(max_task):
t = threading.Thread(target=run_tidy,
args=(args, tmpdir, build_path, task_queue, lock, failed_files))
t.daemon = True
t.start()
# Fill the queue with files.
for name in files:
if file_name_re.search(name):
task_queue.put(name)
# Wait for all threads to be done.
task_queue.join()
if len(failed_files):
return_code = 1
except KeyboardInterrupt:
# This is a sad hack. Unfortunately subprocess goes
# bonkers with ctrl-c and we start forking merrily.
print('\nCtrl-C detected, goodbye.')
if tmpdir:
shutil.rmtree(tmpdir)
os.kill(0, 9)
if yaml and args.export_fixes:
print('Writing fixes to ' + args.export_fixes + ' ...')
try:
merge_replacement_files(tmpdir, args.export_fixes)
except:
print('Error exporting fixes.\n', file=sys.stderr)
traceback.print_exc()
return_code=1
if args.fix:
print('Applying fixes ...')
try:
apply_fixes(args, tmpdir)
except:
print('Error applying fixes.\n', file=sys.stderr)
traceback.print_exc()
return_code=1
if tmpdir:
shutil.rmtree(tmpdir)
sys.exit(return_code)
if __name__ == '__main__':
main()
-22
View File
@@ -1,22 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set CPP_VER=c++17
set FILE_OR_DIR=..\src\robomongo\
set PARAM_1=%1
if not "%PARAM_1%" == "" (
set FILE_OR_DIR=%PARAM_1%
)
rem Run analysis
echo.
echo ---------------------- Running cppcheck ----------------------
echo.
call cppcheck %FILE_OR_DIR% --enable=all --std=%CPP_VER%
echo.
echo ---------------------- End of cppcheck ----------------------
echo.
echo ---------------------- Info ----------------------
call cppcheck --version
echo Command called: cppcheck %FILE_OR_DIR% --enable=all --std=%CPP_VER%
-17
View File
@@ -1,17 +0,0 @@
#!/usr/bin/env bash
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1 # $1: release or debug
mkdir -p ../scan-build && cd ../scan-build
# $BUILD_TYPE: Release or Debug
# Hint: Use "--use-analyzer /usr/local/opt/llvm/bin/clang++" after "-v"
scan-build -v cmake -D "CMAKE_PREFIX_PATH=$PREFIX_PATH" -D "CMAKE_BUILD_TYPE=$BUILD_TYPE" -D "CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" "${@:2}" $PROJECT_DIR
echo -e "\n------------------------------------------------"
echo "Configured with scan-build in $BUILD_TYPE mode"
echo -e "------------------------------------------------\n"
scan-build cmake --build . "${@:2}" -- -j8
echo -e "\n------------------------------------------------"
echo "Built with scan-build in $BUILD_TYPE mode"
echo -e "------------------------------------------------\n"
-21
View File
@@ -1,21 +0,0 @@
#!/usr/bin/env bash
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Get directory of this file
PROJECT_DIR=$(dirname $BIN_DIR) # Get root directory of project
source $BIN_DIR/common/setup $1
echo
echo "******************* Running unit tests in $BUILD_TYPE mode *******************"
echo
if [ "$(uname -s)" == "Darwin" ]; then
EXE="$BUILD_DIR/src/robomongo-unit-tests/robo_unit_tests"
echo "Running file: $EXE"
"$EXE"
else # Linux
echo "Error: Currently unit testing is disabled for Linux due to MongoDB linking problem"
exit 0
EXE="$BUILD_DIR/src/robomongo-unit-tests/robo_unit_tests"
echo "Running file: $EXE"
"$EXE"
fi
-20
View File
@@ -1,20 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
rem Path to bin and project folder
set BIN_DIR_WITH_BACKSLASH=%~dp0%
set BIN_DIR=%BIN_DIR_WITH_BACKSLASH:~0,-1%
set PROJECT_DIR=%BIN_DIR%\..
rem Run common setup code
call "%BIN_DIR%\common\setup.bat" %*
if %ERRORLEVEL% neq 0 (exit /b 1)
rem Run tests
echo.
echo ******************* Running unit tests *******************
echo Mode: %BUILD_TYPE%
set TEST_EXE_DIR=%PROJECT_DIR%\\build\%BUILD_TYPE%\src\robomongo-unit-tests\%BUILD_TYPE%
echo Run : %TEST_EXE_DIR%\robo_unit_tests.exe
echo.
call "%TEST_EXE_DIR%\robo_unit_tests.exe" %*
-29
View File
@@ -1,29 +0,0 @@
@echo off
setlocal enableextensions enabledelayedexpansion
rem Path to bin and project folder
set BIN_DIR_WITH_BACKSLASH=%~dp0%
set BIN_DIR=%BIN_DIR_WITH_BACKSLASH:~0,-1%
set PROJECT_DIR=%BIN_DIR%\..
rem Run common setup code
call "%BIN_DIR%\common\setup.bat" %*
if %ERRORLEVEL% neq 0 (exit /b 1)
rem Run Visual Studio with RunCodeAnalysis
cd "%BUILD_DIR%"
set RULE_SET="/p:CodeAnalysisRuleSet=NativeRecommendedRules.ruleset"
set OUT_FILE=vs-code-analysis-%BUILD_TYPE%.txt
echo ------------- Running Visual Studio with RunCodeAnalysis -------------
echo Result will be written into file "%OUT_FILE%" in the end.
echo ...
cmake --build . --config %BUILD_TYPE% -- "/p:RunCodeAnalysis=true" %RULE_SET% > %BIN_DIR%\%OUT_FILE%
rem Rules: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets
rem https://docs.microsoft.com/en-us/visualstudio/code-quality/rule-set-reference?view=vs-2019
echo ------------- End of RunCodeAnalysis -------------
echo.
echo ------------- Info -------------
echo Mode : %BUILD_TYPE%
echo RULE_SET: %RULE_SET% (see the script comments for more info)
-42
View File
@@ -1,42 +0,0 @@
import os
from os.path import join
###
def force_warning_level_3(file):
with open(file, "r") as in_file:
buf = in_file.readlines()
push = '#pragma warning(push, 3)\n'
pop = '#pragma warning(pop)\n'
last_line_has_mongo = False
with open(file, "w") as out_file:
for line in buf:
if line.startswith(('#include <mongo', '#include "mongo')):
if last_line_has_mongo:
pass # line = line + pop
else:
line = push + line
last_line_has_mongo = True
else:
if last_line_has_mongo:
line = pop + line
last_line_has_mongo = False
out_file.write(line)
### main
root_dir = 'E:\\robo\\src\\robomongo\\'
# root_dir = 'E:\\robo\\src\\robomongo\\shell\\bson\\' # for testing
print('Processing all source files in root & sub directories...')
print('Root Dir:', root_dir)
print('---------------------------------------------------------')
for path, subdirs, files in os.walk(root_dir):
for name in files:
if name.endswith(('.h', '.cpp')):
file = os.path.join(path, name)
print(file)
force_warning_level_3(file)
+11 -38
View File
@@ -41,46 +41,38 @@ set(MongoDB_DEFINITIONS
BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
BOOST_THREAD_HAS_BUG
MONGO_CONFIG_HAVE_HEADER_UNISTD_H
# Suppress "warning C4996: std::allocator..." from third_party\abseil-cpp-master
_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
# Suppress "warning C4996: std::iterator..." from third_party\mozjs-60
_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
)
# Set common compiler include directories
set(MOZJS_VER mozjs-60)
set(MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src
${MongoDB_DIR}/src/third_party/abseil-cpp-master/abseil-cpp
${MongoDB_DIR}/src/third_party/boost-1.70.0
${MongoDB_DIR}/src/third_party/fmt/dist/include
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/include
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/mongo_sources
${MongoDB_DIR}/src/third_party/pcre-8.42
${MongoDB_DIR}/src/third_party/SafeInt
${MongoDB_DIR}/src
${MongoDB_DIR}/src/third_party/boost-1.56.0
${MongoDB_DIR}/src/third_party/mozjs-38/include
${MongoDB_DIR}/src/third_party/mozjs-38/mongo_sources
${MongoDB_DIR}/src/third_party/pcre-8.37
${MongoDB_BUILD_DIR}
)
if(SYSTEM_LINUX)
set(MongoDB_OBJECT_LIST_PLATFORM_PART linux)
list(APPEND MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/platform/x86_64/linux/include)
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/linux/include)
elseif(SYSTEM_WINDOWS)
set(MongoDB_OBJECT_LIST_PLATFORM_PART windows)
list(APPEND MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/platform/x86_64/windows/include)
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/windows/include)
elseif(SYSTEM_MACOSX)
set(MongoDB_OBJECT_LIST_PLATFORM_PART macosx)
list(APPEND MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/platform/x86_64/macOS/include)
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/osx/include)
elseif(SYSTEM_FREEBSD)
set(MongoDB_OBJECT_LIST_PLATFORM_PART freebsd)
list(APPEND MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/platform/x86_64/freebsd/include)
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/freebsd/include)
elseif(SYSTEM_OPENBSD)
set(MongoDB_OBJECT_LIST_PLATFORM_PART openbsd)
list(APPEND MongoDB_INCLUDE_DIRS
${MongoDB_DIR}/src/third_party/${MOZJS_VER}/platform/x86_64/openbsd/include)
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/openbsd/include)
endif()
# Read list of object files
@@ -94,30 +86,11 @@ string(STRIP "${MongoDB_RELATIVE_LIBS}" MongoDB_RELATIVE_LIBS)
# Convert string to list
string(REPLACE " " ";" MongoDB_RELATIVE_LIBS ${MongoDB_RELATIVE_LIBS})
# todo: Find a better solution
# Robo 1.4: Added as workaround fix for build error:
# fatal error LNK1170: line in command file contains 131071 or more characters
# Happens when the path of robo-shell is a long string (e.g. "E:/user/code/robomongo-shell")
set(MongoDB_OBJECTS_DIR_ENV $ENV{MongoDB_OBJECTS})
if(MongoDB_OBJECTS_DIR_ENV)
set(MongoDB_OBJECTS_DIR ${MongoDB_OBJECTS_DIR_ENV})
else()
set(MongoDB_OBJECTS_DIR ${MongoDB_DIR})
endif()
# Convert to absolute path
foreach(lib ${MongoDB_RELATIVE_LIBS})
list(APPEND MongoDB_LIBS ${MongoDB_OBJECTS_DIR}/${lib})
list(APPEND MongoDB_LIBS ${MongoDB_DIR}/${lib})
endforeach()
if(SYSTEM_WINDOWS)
list(APPEND MongoDB_LIBS Crypt32.lib Secur32.lib Dnsapi.lib winhttp.lib)
elseif(SYSTEM_MACOSX)
list(APPEND MongoDB_LIBS -lcurl)
elseif(SYSTEM_LINUX)
list(APPEND MongoDB_LIBS -lresolv -lcurl)
endif()
# Get MongoDB repository recent tag
execute_process(
COMMAND git describe --abbrev=0 --tags
+27 -18
View File
@@ -14,6 +14,7 @@
# Try to find OpenSSL directory (uses CMAKE_PREFIX_PATH locations)
#-------------------------------------------
find_path(
OpenSSL_DIR include/openssl/ssl.h
DOC "Path to OpenSSL (github.com/openssl/openssl) root directory"
@@ -21,7 +22,12 @@ find_path(
# Find OpenSSL version
#-------------------------------------------
set (OPENSSL_INCLUDE_DIR "${OpenSSL_DIR}/include")
if(SYSTEM_WINDOWS)
set (OPENSSL_INCLUDE_DIR "${OpenSSL_DIR}/inc32")
else()
set (OPENSSL_INCLUDE_DIR "${OpenSSL_DIR}/include")
endif()
function(from_hex HEX DEC)
string(TOUPPER "${HEX}" HEX)
@@ -100,30 +106,33 @@ add_library(ssl SHARED IMPORTED)
# Add imported target for crypto (libeay32)
add_library(crypto SHARED IMPORTED)
# todo: refactor
if(SYSTEM_WINDOWS)
set_target_properties(ssl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/inc32"
IMPORTED_IMPLIB "${OpenSSL_DIR}/out32dll/ssleay32.lib"
)
set_target_properties(crypto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/inc32"
IMPORTED_IMPLIB "${OpenSSL_DIR}/out32dll/libeay32.lib"
)
elseif(SYSTEM_MACOSX)
set_target_properties(ssl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_IMPLIB "${OpenSSL_DIR}/libssl.lib"
IMPORTED_LOCATION "${OpenSSL_DIR}/libssl.dylib"
)
set_target_properties(crypto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_IMPLIB "${OpenSSL_DIR}/libcrypto.lib"
IMPORTED_LOCATION "${OpenSSL_DIR}/libcrypto.dylib"
)
elseif(SYSTEM_LINUX)
set_target_properties(ssl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_LOCATION "${OpenSSL_DIR}/libssl.so"
)
set_target_properties(crypto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_LOCATION "${OpenSSL_DIR}/libcrypto.so"
)
else()
if(SYSTEM_MACOSX)
SET(EXT "dylib")
elseif(SYSTEM_LINUX)
SET(EXT "so")
endif()
set_target_properties(ssl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_LOCATION "${OpenSSL_DIR}/libssl.${EXT}"
)
set_target_properties(crypto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
IMPORTED_LOCATION "${OpenSSL_DIR}/libcrypto.${EXT}"
)
endif()
# End of file
View File
+2 -2
View File
@@ -1,3 +1,3 @@
set(ROBOMONGO_DISPLAY_NAME "Robo 3T")
set(ROBOMONGO_DISPLAY_FULL_NAME "Robo 3T ${PROJECT_VERSION}")
set(ROBOMONGO_DISPLAY_NAME "Robomongo")
set(ROBOMONGO_DISPLAY_FULL_NAME "Robomongo ${PROJECT_VERSION}")
+18 -48
View File
@@ -1,63 +1,33 @@
# Set MONGO_BUILD_FOLDER
set(MONGO_BUILD_FOLDER "build/opt") # Release
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(MONGO_BUILD_FOLDER "build/debug")
endif()
# Show configuration summary and build tip
message("")
message(" _______________[ Robo 3T configuration summary ]________________")
message(" _______________[ Robomongo configuration summary ]________________")
message("| ")
message("|-- Dependencies:")
message("| ")
message("| Qt5 Core: ${Qt5Core_VERSION} ${Qt5Core_DIR}")
message("| Qt5 Gui: ${Qt5Gui_VERSION} ${Qt5Gui_DIR}")
message("| Qt5 Widgets: ${Qt5Widgets_VERSION} ${Qt5Widgets_DIR}")
message("| Qt5 PrintSupport: ${Qt5Widgets_VERSION} ${Qt5PrintSupport_DIR}")
message("| Qt5 Network: ${Qt5Network_VERSION} ${Qt5Network_DIR}")
message("| Qt5 Xml: ${Qt5Xml_VERSION} ${Qt5Xml_DIR}")
if(NOT SYSTEM_LINUX)
message("| Qt5 WebEng*Widgets: ${Qt5WebEngineWidgets_VERSION} ${Qt5WebEngineWidgets_DIR}")
endif()
message("| MongoDB: ${MongoDB_VERSION} ${MongoDB_DIR}")
message("| MongoDB Objects: ${MongoDB_VERSION} ${MongoDB_OBJECTS_DIR}/${MONGO_BUILD_FOLDER}")
message("| Qt5 Core: ${Qt5Core_VERSION} ${Qt5Core_DIR}")
message("| Qt5 Gui: ${Qt5Gui_VERSION} ${Qt5Gui_DIR}")
message("| Qt5 Widgets: ${Qt5Widgets_VERSION} ${Qt5Widgets_DIR}")
message("| Qt5 PrintSupport: ${Qt5Widgets_VERSION} ${Qt5PrintSupport_DIR}")
message("| Qt5 Network: ${Qt5Network_VERSION} ${Qt5Network_DIR}")
message("| Qt5 Xml: ${Qt5Xml_VERSION} ${Qt5Xml_DIR}")
message("| MongoDB: ${MongoDB_VERSION} ${MongoDB_BUILD_DIR}")
message("| OpenSSL: ${OPENSSL_VERSION} ${OpenSSL_DIR}")
message("| libssh2: ${LIBSSH2_VERSION} ${LIBSSH2_DIR}")
message("| QJson: ${QJSON_VERSION} ${QJSON_DIR}")
message("| QScintilla: ${QSCINTILLA_VERSION} ${QSCINTILLA_DIR}")
message("| Google Test: ${GOOGLE_TEST_VERSION} ${GOOGLE_TEST_DIR}")
message("| ESPRIMA: ${ESPRIMA_VERSION} ${ESPRIMA_DIR}")
message("|")
message("|-- Summary:")
message("|")
message("| Version: ${PROJECT_VERSION}")
message("| System: ${CMAKE_SYSTEM_NAME}")
message("| System: ${CMAKE_SYSTEM_NAME}")
if (SYSTEM_MACOSX)
message("| Target SDK: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
message("| Target SDK: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
message("| Build type: ${CMAKE_BUILD_TYPE}")
message("| Commit: ${BUILD_NUMBER}")
message("| Install path: ${CMAKE_INSTALL_PREFIX}")
message("| Build type: ${CMAKE_BUILD_TYPE}")
message("| Install path: ${CMAKE_INSTALL_PREFIX}")
message("|")
message("|-- Build, Run and Install:")
message("|-- Building and installing:")
message("| ")
message("| $ bin/build")
message("| $ bin/run")
message("| $ bin/install")
message("| Now you can build Robomongo with the following command:")
message("| $ cmake --build .")
message("|")
message("|-- Run Unit Tests:")
message("| ")
message("| $ bin/build-and-run-tests")
message("| $ bin/run-tests")
message("|")
message("|-- Run Static Code Analysis:")
message("|")
if (SYSTEM_WINDOWS)
message("| $ bin/run-cppcheck <FILE_PATH OR DIR> (Default: /src/robomongo/)")
message("| $ bin/run-vs-code-analysis")
else()
message("| $ bin/run-clang-tidy")
message("| $ bin/run-scan-build")
endif()
message("| And install it to ${CMAKE_INSTALL_PREFIX}:")
message("| $ cmake --build . --target install")
message("|__________________________________________________________________")
message("")
message("")
+8 -38
View File
@@ -24,11 +24,10 @@ if(SYSTEM_LINUX)
set(qt_conf_dir ${bin_dir})
set(qt_conf_plugins "../lib")
elseif(SYSTEM_MACOSX)
set(bundle_name "Robo 3T.app")
set(bundle_name "Robomongo.app")
set(contents_path ${bundle_name}/Contents)
set(bin_dir ${contents_path}/MacOS)
set(styles_dir ${contents_path}/MacOS/styles)
set(lib_dir ${contents_path}/Frameworks)
set(resources_dir ${contents_path}/Resources)
set(license_dir ${resources_dir})
@@ -38,9 +37,8 @@ elseif(SYSTEM_MACOSX)
set(qt_conf_plugins "PlugIns/Qt")
elseif(SYSTEM_WINDOWS)
set(bin_dir .)
set(styles_dir ${bin_dir}/styles)
set(lib_dir .)
set(resources_dir ./resources)
set(resources_dir .)
set(license_dir .)
set(qt_plugins_dir ${lib_dir})
@@ -62,14 +60,14 @@ install(
if(SYSTEM_WINDOWS)
install(
FILES
"${OpenSSL_DIR}/libssl-1_1-x64.dll"
"${OpenSSL_DIR}/libcrypto-1_1-x64.dll"
"${OpenSSL_DIR}/out32dll/ssleay32.dll"
"${OpenSSL_DIR}/out32dll/libeay32.dll"
DESTINATION ${bin_dir})
elseif(SYSTEM_MACOSX)
install(
FILES
"${OpenSSL_DIR}/libssl.1.1.dylib"
"${OpenSSL_DIR}/libcrypto.1.1.dylib"
"${OpenSSL_DIR}/libssl.1.0.0.dylib"
"${OpenSSL_DIR}/libcrypto.1.0.0.dylib"
DESTINATION ${lib_dir}/lib)
elseif(SYSTEM_LINUX)
install(
@@ -97,28 +95,15 @@ install(
DESTINATION ${license_dir})
# Install common dependencies
SET(QT_LIBS Core Gui Widgets PrintSupport Network Xml)
if(NOT SYSTEM_LINUX)
SET(QT_LIBS ${QT_LIBS} WebEngineWidgets WebEngineCore Quick
QuickWidgets WebChannel Qml Positioning)
endif()
install_qt_lib(${QT_LIBS})
install_qt_lib(Core Gui Widgets PrintSupport Network Xml)
install_qt_plugins(QGifPlugin QICOPlugin)
install_icu_libs()
set(QT_STYLES_DIR ${Qt5Core_DIR}/../../../plugins/styles/)
set(QT_BIN_DIR ${Qt5Core_DIR}/../../../bin/)
set(QT_RESOURCES_DIR ${Qt5Core_DIR}/../../../resources/)
if(SYSTEM_LINUX)
install_qt_lib(XcbQpa DBus)
install_qt_plugins(
QXcbIntegrationPlugin)
install(
FILES
"/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
"/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28"
DESTINATION ${lib_dir})
elseif(SYSTEM_MACOSX)
install_qt_lib(MacExtras DBus)
install_qt_plugins(
@@ -130,27 +115,12 @@ elseif(SYSTEM_MACOSX)
install(
FILES "${CMAKE_SOURCE_DIR}/install/macosx/robomongo.icns"
DESTINATION "${resources_dir}")
# Install styles
install(FILES "${QT_STYLES_DIR}/libqmacstyle.dylib" DESTINATION ${styles_dir})
elseif(SYSTEM_WINDOWS)
install_qt_plugins(
QWindowsIntegrationPlugin
QMinimalIntegrationPlugin
QOffscreenIntegrationPlugin)
# Qt WebEngine dependencies
install(DIRECTORY ${QT_RESOURCES_DIR} DESTINATION ${resources_dir})
install(FILES
"${QT_BIN_DIR}/libEGL.dll"
"${QT_BIN_DIR}/libGLESv2.dll"
"${QT_BIN_DIR}/opengl32sw.dll"
"${QT_BIN_DIR}/QtWebEngineProcess.exe"
DESTINATION ${bin_dir})
# Install Styles
install(FILES "${QT_STYLES_DIR}/qwindowsvistastyle.dll" DESTINATION ${styles_dir})
# Install runtime libraries:
# msvcp120.dll
# msvcr120.dll
-1
View File
@@ -28,7 +28,6 @@ function(install_qt_lib)
install(
DIRECTORY ${qt_lib_dir}/${module_name}.framework
DESTINATION ${lib_dir}
USE_SOURCE_PERMISSIONS
PATTERN "*_debug" EXCLUDE # Exclude debug libraries
PATTERN "Headers" EXCLUDE) # Exclude Headers folders
endif()
+4 -4
View File
@@ -15,7 +15,7 @@ execute_process(
string(TIMESTAMP timestamp "%Y-%m-%d")
# Package name (as it should appear in UI)
set(CPACK_PACKAGE_NAME robo3t)
set(CPACK_PACKAGE_NAME robomongo)
# Version of the package
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
@@ -35,9 +35,9 @@ set(CPACK_STRIP_FILES ON)
# Additional information
set(CPACK_PACKAGE_VENDOR "3T Software Labs Ltd")
set(CPACK_PACKAGE_CONTACT robo3t@3t.io)
set(CPACK_PACKAGE_CONTACT robomongo@3t.io)
set(CPACK_PACKAGE_DESCRIPTION "Shell-centric cross-platform MongoDB management tool.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Robo 3T is a shell-centric cross-platform MongoDB management tool.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Robomongo is a shell-centric cross-platform MongoDB management tool.")
# Use lowercase for system name and package file name
string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
@@ -62,7 +62,7 @@ elseif(SYSTEM_MACOSX)
elseif(SYSTEM_WINDOWS)
set(files_dir "${CMAKE_SOURCE_DIR}/install/windows")
set(exe_name "robo3t.exe")
set(exe_name "robomongo.exe")
set(CPACK_GENERATOR NSIS ZIP)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/DESCRIPTION")
+3 -3
View File
@@ -15,13 +15,13 @@ elseif(SYSTEM_WINDOWS)
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} psapi.lib bcrypt.lib Iphlpapi.lib dbghelp.lib ws2_32.lib winmm.lib version.lib")
endif()
set(PROJECT_NAME "Robo 3T")
set(PROJECT_NAME "Robomongo")
set(PROJECT_NAME_TITLE ${PROJECT_NAME})
set(PROJECT_DOMAIN "www.robomongo.org")
set(PROJECT_COMPANYNAME "3T Software Labs Ltd")
set(PROJECT_COPYRIGHT "Copyright (C) 2014-2017 ${PROJECT_COMPANYNAME} All Rights Reserved.")
set(PROJECT_COMPANYNAME_DOMAIN "https://studio3t.com/")
set(PROJECT_GITHUB_FORK "www.github.com/Studio3T/robomongo")
set(PROJECT_GITHUB_ISSUES "www.github.com/Studio3T/robomongo/issues")
set(PROJECT_GITHUB_FORK "www.github.com/paralect/robomongo")
set(PROJECT_GITHUB_ISSUES "www.github.com/paralect/robomongo/issues")
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
-8
View File
@@ -1,11 +1,3 @@
See these docs for the latest info about this topic:
-------------
- [Build Robo 3T - Mac OS X and Linux](https://github.com/paralect/robomongo/blob/master/docs/BuildRobo3TOnMacAndLinux.md)
- [Build Robo 3T - Windows](https://github.com/paralect/robomongo/blob/master/docs/BuildRobo3TOnWindows.md)
------------------------------------
What is this?
-------------
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-11
View File
@@ -1,11 +0,0 @@
version: "3.9"
services:
robo3t:
image: robo3t
restart: unless-stopped
build: .
network_mode: host
environment:
- DISPLAY=${DISPLAY}
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
-243
View File
@@ -1,243 +0,0 @@
Building Robo 3T (macOS and Linux)
==================
A. Prerequisites
-------------
1. Modern Compiler
A modern and complete C++17 compiler:
```
GCC 8.0 or newer
Clang 7 (or Apple XCode 10 Clang) or newer
On Linux and macOS, the libcurl library and header is required. macOS includes libcurl.
Fedora/RHEL - dnf install libcurl-devel
Ubuntu/Debian - apt-get install libcurl-dev
Python 3.7
```
For details see: https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source
2. Install CMake (3.10.0 or later)
Example:
```
sudo apt-get install build-essential
// or
wget http://www.cmake.org/files/v3.10/cmake-3.10.0.tar.gz
tar xf cmake-3.10.0.tar.gz
cd cmake-3.10.0
./configure // macos: env CC=gcc ./bootstrap
make
sudo make install
(sudo make uninstall)
```
3. Install [Scons](http://scons.org/tag/releases.html) (3.1.2 or later)
```
cd scons-**
python setup.py install
```
4. Install Qt
macOS: Qt 5.12.8
Linux: Qt 5.9.3
```sh
Example installation for macOS and Ubuntu:
Go to http://download.qt.io/archive/qt/5.x/5.x.y/
Download, run and install
qt-opensource-mac-x64-clang-5.x.y.dmg (for macOS)
qt-opensource-linux-x64-5.x.y.run (for Linux)
After successful installation you should have
/path/to/qt-5.x.y/5.x/clang_64 (for macOS)
/path/to/qt-5.x.y/5.x/gcc_64 (for Linux)
More information for installing on Ubuntu:
https://wiki.qt.io/Install_Qt_5_on_Ubuntu
```
5. Download and Build OpenSSL - (explained below in section B)
B. Building Robo 3T and Dependencies
-------------
Ref: https://wiki.openssl.org/index.php/Compilation_and_Installation#OS_X
#### 1. Build OpenSSL
(Todo: Can we find pre-built OpenSSL? To check => https://wiki.openssl.org/index.php/Binaries)
Version 1.1.1f (Mar/2020) on macOS
Version 1.0.2o (Mar/2018) on Linux
**macOS:**
```sh
wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1f.tar.gz
tar -xf openssl-1.1.1f.tar.gz
cd /opt/openssl-1.1.1f
(make clean)
./Configure darwin64-x86_64-cc shared no-ssl2 no-ssl3 no-comp -mmacosx-version-min=xy.zt
// Notes:
// 1. Change -mmacosx-version same as CMAKE_OSX_DEPLOYMENT_TARGET in
// https://github.com/Studio3T/robomongo/blob/master/CMakeLists.txt
// 2. With openssl version 1.1.1, configure command with rpath stopped working
// Last working configure command with rpath was:
// ./Configure darwin64-x86_64-cc shared --openssldir="@rpath"
make (or sudo make)
// Verify libssl.dylib and libcrypto.dylib files are created
ll lib*.dylib
// Due to broken './Configure' command with rpath above, these extra steps are also required:
install_name_tool -id "@rpath/lib/libssl.1.1.dylib" libssl.1.1.dylib
install_name_tool -change /usr/local/lib/libcrypto.1.1.dylib @rpath/lib/libcrypto.1.1.dylib libssl.1.1.dylib
install_name_tool -id "@rpath/lib/libcrypto.1.1.dylib" libcrypto.1.1.dylib
// Finally, we should have this output using otool:
otool -L libssl.1.1.dylib
libssl.dylib:
@rpath/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
@rpath/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
otool -L libcrypto.1.1.dylib
libcrypto.dylib:
@rpath/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
// For robo-unit-test dependency:
mkdir lib/
cp lib*.dylib/lib/
```
**Linux:**
```sh
wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2o.tar.gz
tar -xf openssl-1.0.2o.tar.gz
cd /opt/openssl-1.0.2o
(make clean)
./config shared
make
// Verify libssl.so and libcrypto.so are created
```
#### 2. Build Robo 3T Shell (fork of MongoDB)
Clone Robo 3T Shell and make sure you are on latest branch:
```sh
$ git clone https://github.com/paralect/robomongo-shell.git
$ cd robomongo-shell
$ git branch // "roboshell-v4.2"
```
Set special environment variable `ROBOMONGO_CMAKE_PREFIX_PATH` to point to a set of
directories:
1. Location of Qt 5 SDK
2. Location of Robo 3T Shell
3. Location of OpenSSL
Separate directories by semicolon `;` (not colon):
// macOS example:
export ROBOMONGO_CMAKE_PREFIX_PATH="/path/to/qt-5.x.y/5.x/clang_64;/opt/robo-shell;/opt/openssl-x.y.z"
// Ubuntu example:
export ROBOMONGO_CMAKE_PREFIX_PATH="/home/<user>/Qt5.x.y/5.x.y/gcc_64/;/opt/<user>/robo-shell;/opt/openssl-x.y.z"
Install pip requirements
```
// macOS / Linux
pip3 install --user -r etc/pip/compile-requirements.txt
pip3 install --user -r etc/pip/dev-requirements.txt
```
```
// For ubuntu, the followings might be needed
sudo aptitude install libcurl-dev
sudo pip3 install Typing
sudo pip3 install Cheetah
```
Build Robo 3T Shell (in release mode by default):
```sh
$ bin/build
```
Build Robo 3T Shell in debug mode:
```sh
$ bin/build debug
```
Clean build files for release mode:
```sh
$ bin/clean
```
Clean build files for debug mode:
```sh
$ bin/clean debug
```
For more information refer to [Building Robo 3T Shell](BuildRobo3TShell.md)
#### 3. Build Robo 3T
Download Robo 3T:
$ git clone https://github.com/Studio3T/robomongo
$ cd robomongo
Run configuration step:
$ bin/configure
And finally, build Robo 3T:
$ bin/build
To run robomongo:
$ bin/run
**Debug mode**
For debug mode append `debug` for each command
e.g. `bin/configure debug` or `bin/build debug` etc..
**Helper commands**
Clean build files (in order to start build from scratch):
$ bin/clean
Install Robo 3T to `build/release/install` folder:
$ bin/install
Create package for your OS in `build/release/package` folder:
$ bin/pack
**Important Notes**
- For macOS builds, it might be needed to patch QScintilla with `QScintilla-2.9.3-xcode8.patch` found at robomongo repository's root.
- For Ubuntu 16.04 builds, it has been reported that Robo 3T /bin/configure step might fail and installing `mesa-common-dev` package solves it. Details: https://github.com/paralect/robomongo/issues/1268
- For Centos builds, Robo 3T /bin/configure step might fail due to error: `failed to find gl/gl.h`. In this case, the following packages must be installed:
```sh
$ sudo yum install mesa-libGL
$ sudo yum install mesa-libGL-devel
```
-229
View File
@@ -1,229 +0,0 @@
Building Robo 3T (Windows)
==============================
A. Prerequisites
-------------
#### 0. Git
Download Git installer from http://git-scm.com (we are using Git-2.7.0-64-bit).
When you'll see "Adjusting your PATH environment" wizard page, select
"Use Git from the Windows Command Prompt" option. This will allow to
execute Git from both Windows Command Prompt and Bash. This is required,
because both MongoDB and Robo 3T uses `git` command during build process
which must be perfomed from Windows Command Prompt (not Bash).
On "Configuring the line ending conversion" wizard page, select "Checkout
Windows-style, commit Unix-style line ending" option. This is a common mode
for cross-platform projects and required by both MongoDB and Robo 3T.
All other Git installer options are not important (use defaults).
If you are using SSH clone url, start SSH agent and add your private key
with this commands in Git Bash:
$ eval `ssh-agent` # starts ssh agent
$ ssh-add ~/.ssh/mykey # add your key (which can be in any folder)
#### 1. Visual Studio 2017 version 15.9 or newer (complete C++17 compiler)
We use Visual Studio 2017 version 15.9.22, and recommend to use this version to save
time for Qt compilation. Currently prebuilt binaries for Qt are available
from official Qt site. But you can use any newer version and compile Qt library
yourself.
#### 2. ActivePython 3.7.4
Download ActivePython from http://www.activestate.com/activepython/downloads
Download MSI x64 version. Use default settings in installation wizard.
This installer will add path to `python.exe` to your `PATH` variable.
#### 3. SCons 3.1.2 or newer
We use SCons 3.1.2
Download Scons from http://scons.org/tag/releases.html
Use ZIP archive, not MSI
Open Command Prompt, navigate to Scons directory and run:
$ setup.py install
This command will make `scons` command accessible from Command Prompt
#### 4. CMake
We use CMake 3.10.0
Download CMake from https://cmake.org/download
Use installer package, it will allow you to configure your PATH variable and `cmake`
command will be available from Command Prompt. For this set "Add CMake to the system
PATH for current user" in the installer wizard page.
#### 5. Qt 5.12.8
Download and install Qt from http://download.qt.io/archive/qt
Run the installer and select only 'msvc2017 64-bit'
#### 6. OpenSSL (1.1.1f)
Download openssl from https://www.openssl.org/source/old/1.1.1/openssl-1.1.1f.tar.gz
B. Building Robo 3T and Dependencies
-------------
#### 1. Build OpenSSL
(Todo: Can we find pre-built OpenSSL? To check => https://wiki.openssl.org/index.php/Binaries)
Steps to build OpenSSL on windows:
- Ensure you have perl installed on your machine (e.g. ActiveState or Strawberry), and available on your %PATH%
- Ensure you have NASM installed on your machine, and available on your %PATH%
```sh
Open Visual Studio tool x64 Cross Tools Command prompt
cd to the directory where you have openssl sources cd c:\myPath\openssl
perl Configure VC-WIN64A
(nmake clean)
nmake
// Verify these files are created:
libcrypto-1_1x64.dll, libssl-1_1-x64.dll (with all the build additionals such as .pdb .lik or static .lib)
```
Refer to OpenSSL documentation for more information:
https://wiki.openssl.org/index.php/Compilation_and_Installation#OpenSSL_1.1.0
#### 2. Build Robo 3T Shell (fork of MongoDB)
Clone Robo 3T Shell and make sure to be at `roboshell-v4.2` branch:
```sh
$ git clone https://github.com/paralect/robomongo-shell.git
$ cd robomongo-shell
$ git branch // roboshell-v4.2
```
Set environment variable `ROBOMONGO_CMAKE_PREFIX_PATH`, required by Robo 3T-Shell and Robo 3T build scripts, needs to be set according to the following directories:
1. Location of Qt SDK
2. Location of Robo 3T Shell
3. Location of OpenSSL
**Important:**
Make sure to move all your repos (robo, openssl, robo-shell etc..) into root directory of your drives (e.g. e:\robo-shell) and keep short repo names (e.g. robo-shell instead of robomongo-shell) otherwise you might end up with this error `If you see fatal error LNK1170: line in command file contains 131071 or more characters`
Separate directories by semicolon `;` (not colon). You can do this in Command Prompt:
> setx ROBOMONGO_CMAKE_PREFIX_PATH "e:\Qt\Qt5.9.3\5.9.3\msvc2015_64;e:\robo-shell;e:\openssl-x.y.z"
Open '**a new**' VS2017 x64 Native Tools Command Prompt and navigate to `robomongo-shell` folder.
**Note:**
Run
`pip3 install --user -r ../etc/pip/dev-requirements.txt`
If you have this type of errors:
```
// 1st error
ImportError: No module named typing
// Solution:
pip install Typing
pip install Cheetah
// 2nd error: shell: cheetah module not found
// Solution:
copy C:\Users\<user>\AppData\Roaming\Python\Python27\site-packages
to C:\Python27\Lib\site-packages
```
Build shell in release mode:
> bin\build
Build shell in debug mode:
> bin\build debug
Note that backslash is used (`\`), and not forward slash (`/`).
Clean build files for release mode:
> bin\clean
Clean build files for debug mode:
> bin\clean debug
Refer to MongoDB documentation for additional information:
https://docs.mongodb.org/manual/contributors/tutorial/build-mongodb-from-source/#windows-specific-instructions
#### 3. Build Robo 3T
Clone Robo 3T:
```sh
$ git clone https://github.com/paralect/robomongo.git
```
Open VS2017 x64 Native Tools Command Prompt and navigate to `robomongo` folder.
Run configuration step:
> bin\configure
And finally, build Robo 3T:
> bin\build
```
// If you see fatal error LNK1170: line in command file contains 131071 or more characters
Solution-1:
1. Move all your repos (robo, openssl, robo-shell etc..) into root directory of your drives.
2. Use short names e.g. robo-shell instead of robomongo-shell.
3. Update ROBOMONGO_CMAKE_PREFIX_PATH env. variable and try a fresh (clean) build.
Solution-2:
1. Create environment variable MongoDB_OBJECTS, set a short path e.g. "C:/"
2. Open a new VS2017 x64 Native Tools Command Prompt and build Robo 3T Shell
3. Robo 3T Shell build script will copy the object files into MongoDB_OBJECTS directory
4. Build Robo 3T again (clean build might be needed)
```
**Run Robo 3T**
Install Robo 3T to `build\Release\install` folder:
> bin\install
And run Robo 3T
> \robomongo\build\Release\install\robo3t.exe
**Package Robo 3T**
Install Robo 3T to `build\Release\install` folder:
> bin\pack
Note: nsis-2.46-setup.exe with Full setup must be present.
**Debug mode**
For debug mode append `debug` for each command
e.g. `bin\configure debug` or `bin\build debug` etc..
**Helper commands**
Clean build files (in order to start build from scratch):
> bin\clean
-57
View File
@@ -1,57 +0,0 @@
Building Robo 3T Shell
========================
Robo 3T uses [modified version](https://github.com/paralect/robomongo-shell/tree/roboshell-v3.4) of MongoDB that we call Robo 3T Shell.
Before you can build Robo 3T, you have to build Robo 3T Shell. The following instructions are applicable only for Mac OS X and Linux. For Windows instructions please check [Building Robo 3T on Windows](BuildRobo3TOnWindows.md).
Build for Mac OS X or Linux
---------------------------
#### Prerequisites
1. Install [Scons](http://scons.org/tag/releases.html) (2.3.5 or newer)
2. Clone Robo 3T Shell and checkout to `roboshell-v3.4` branch:
```sh
$ git clone https://github.com/paralect/robomongo-shell.git
$ cd robomongo-shell
$ git checkout roboshell-v3.4
```
3. Build Robo 3T Shell:
```sh
$ bin/build
```
Done! Now you can continue with building Robo 3T
with embedded MongoDB 3.4 shell (that you've just built).
<br/>
#### Advanced helper commands
The following commands are needed only if you are planning to develop or deeper understand
Robo 3T or Robo 3T Shell build processes.
Clean build files for release mode (folder `build/opt` will be removed):
$ bin/clean
Here is a command that is executed by `bin/build` script:
$ scons mongo -j8 --release --osx-version-min=10.9
Argument `--osx-version-min` is required only for Mac OS.
Build MongoDB shell in debug mode:
$ scons mongo -j8 --dbg
Clear builds:
$ scons -c mongo # clears release build
$ scons -c --dbg mongo # clears debug build
+1 -5
View File
@@ -1,10 +1,6 @@
Building Robomongo Shell (Old Document)
Building Robomongo Shell
========================
**Important Note:**
This document is for versions 1.0 and earlier and for MongoDB 3.2.
See latest documents here: https://github.com/Studio3T/robomongo/wiki
Robomongo uses [modified version](https://github.com/paralect/robomongo-shell/tree/roboshell-v3.2) of MongoDB that we call Robomongo Shell. Before you can build Robomongo, you have to build Robomongo Shell. The following instructions are applicable only for Mac OS X and Linux. For Windows instructions please check [Building Robomongo on Windows](BuildingRobomongoOnWindows.md).
Build for Mac OS X or Linux
-4
View File
@@ -1,10 +1,6 @@
Building Robomongo (Mac OS X and Linux)
==================
**Important Note:**
This document is for versions 1.0 and earlier and for MongoDB 3.2.
See latest documents here: https://github.com/Studio3T/robomongo/wiki
A. Prerequisites
-------------
-4
View File
@@ -1,10 +1,6 @@
Building Robomongo (Windows)
==============================
**Important Note:**
This document is for versions 1.0 and earlier and for MongoDB 3.2.
See latest documents here: https://github.com/Studio3T/robomongo/wiki
A. Prerequisites
-------------
-181
View File
@@ -1,181 +0,0 @@
Runtime Dependencies
====================
This information is for maintainers. If you want to just use Robomongo - download
prebuild packages for your platform.
Runtime dependencies that are not privided by platforms but required by Robomongo are:
1. Qt libraries
2. Qt plugins
Diagnostic of dependencies
--------------------------
### Windows
GUI: http://dependencywalker.com/
### Linux
#### a. View dependencies of executable or shared library:
$ ldd robomongo
$ readelf -d robomongo
#### b. View dependency tree of executable or shared library:
$ lddtree robomongo
$ ldd -v robomongo
#### c. View RPATH or RUNPATH records of executable or shared library:
$ objdump -x bin/robomongo | grep "RPATH\|RUNPATH"
$ readelf -d bin/robomongo | grep RPATH
For Robomongo binary it should be `$ORIGIN/../lib`
#### d. Enable extensive logging for run-time shared library search
$ export LD_DEBUG=files
$ bin/robomongo
Source:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
#### e. Modify RPATH using `chrpath` and the dynamic linker and RPATH using paths `patchelf`
$ patchelf --set-rpath '$ORIGIN/../lib' robo
More: https://nixos.org/patchelf.html
$ chrpath -r "/somepath/lib/" robomongo
More:
https://linux.die.net/man/1/chrpath
http://www.programering.com/a/MTOwcDNwATU.html // examples
#### f. Show symbols of shared lib file
Error:
```
/opt/robo-shell/src/mongo/util/net/ssl_manager_openssl.cpp:667:
undefined reference to `SSL_library_init'
```
How to debug:
```
openssl-1.1.1f: nm -gD libssl.so | grep SSL_library_init
// not found, since SSL_library_init() is deprecated in 1.1.1
openssl-1.0.2o: nm -gD libssl.so | grep SSL_library_init
0000000000055520 T SSL_library_init
```
#### g. Update path of a dependency of an executable
```
ldd exec_file | grep libcurlpp
libcurlpp.so.1 => not found
patchelf --replace-needed libcurlpp.so.1 /foo/bar/libcurlpp.so.1 exec_file
```
Another example (libcrypto.so.1.1 => not found):
```
cd /opt/openssl-1.1.1f
ldd libssl.so
linux-vdso.so.1 => (0x00007ffcaf911000)
libcrypto.so.1.1 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd4087b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd4083ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd408c65000)
sudo cp libcrypto.so.1.1 /lib/x86_64-linux-gnu/
ldd libssl.so
linux-vdso.so.1 => (0x00007fff0f5d8000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fd3dcc1e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd3dc854000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd3dc650000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd3dd2d6000)
```
### Mac OS X
#### a. Show dependencies of executable or shared library:
Show dependencies of executable or shared library:
$ otool -L robomongo
View LC_RPATH records of executable or shared library:
$ otool -l robomongo | grep -C2 RPATH
(option `-C2` asks grep to output 2 context lines before and after the match)
For Robomongo binary it should be `$executable_path/../Frameworks`
More about `otool -l`
```
$ otool -l /opt/robo/build/release/src/robomongo/Robo\ 3T.app/Contents/MacOS/Robo\ 3T
....
Load command 23
cmd LC_LOAD_DYLIB
cmdsize 56
name @rpath/lib/libssl.1.1.dylib (offset 24)
time stamp 2 Thu Jan 1 03:00:02 1970
current version 1.1.0
compatibility version 1.1.0
Load command 24
cmd LC_LOAD_DYLIB
cmdsize 56
name @rpath/lib/libcrypto.1.1.dylib (offset 24)
time stamp 2 Thu Jan 1 03:00:02 1970
current version 1.1.0
compatibility version 1.1.0
....
Load command 27
cmd LC_RPATH
cmdsize 48
path /opt/Qt5.9.3/5.9.3/clang_64/lib (offset 12)
Load command 28
cmd LC_RPATH
cmdsize 32
path /opt/openssl-1.1.1f (offset 12)
```
#### b. Edit dependencies of executable or shared library:
```
// Before
otool -L libssl.dylib
libssl.dylib:
/usr/local/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
// Edit
install_name_tool -id "@rpath/lib/libssl.1.1.dylib" libssl.dylib
install_name_tool -change /usr/local/lib/libcrypto.1.1.dylib @rpath/lib/libcrypto.1.1.dylib libssl.dylib
// After
otool -L libssl.dylib
libssl.dylib:
@rpath/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
@rpath/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
```
Diagnostic of Qt plugins
------------------------
Run Robomongo in the following way to see how plugins are resolved:
$ QT_DEBUG_PLUGINS=1 ./robomongo
+76
View File
@@ -0,0 +1,76 @@
Runtime Dependencies
====================
This information is for maintainers. If you want to just use Robomongo - download
prebuild packages for your platform.
Runtime dependencies that are not privided by platforms but required by Robomongo are:
1. Qt libraries
2. Qt plugins
Diagnostic of dependencies
--------------------------
#### Linux
a. View dependencies of executable or shared library:
$ ldd robomongo
$ readelf -d robomongo
b. View dependency tree of executable or shared library:
$ lddtree robomongo
$ ldd -v robomongo
c. View RPATH or RUNPATH records of executable or shared library:
$ objdump -x bin/robomongo | grep "RPATH\|RUNPATH"
$ readelf -d bin/robomongo | grep RPATH
For Robomongo binary it should be `$ORIGIN/../lib`
d. Enable extensive logging for run-time shared library search
$ export LD_DEBUG=files
$ bin/robomongo
Source:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
e. Modify RPATH using `chrpath` and the dynamic linker and RPATH using paths `patchelf`
$ patchelf --set-rpath '$ORIGIN/../lib' robo
More: https://nixos.org/patchelf.html
$ chrpath -r "/somepath/lib/" robomongo
More:
https://linux.die.net/man/1/chrpath
http://www.programering.com/a/MTOwcDNwATU.html // examples
#### Mac OS X
Show dependencies of executable or shared library:
$ otool -L robomongo
View LC_RPATH records of executable or shared library:
$ otool -l robomongo | grep -C2 RPATH
(option `-C2` asks grep to output 2 context lines before and after the match)
For Robomongo binary it should be `$executable_path/../Frameworks`
Diagnostic of Qt plugins
------------------------
Run Robomongo in the following way to see how plugins are resolved:
$ QT_DEBUG_PLUGINS=1 ./robomongo
Binary file not shown.
+1 -3
View File
@@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Robo 3T</string>
<string>Robomongo</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
@@ -36,7 +36,5 @@
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>NSRequiresAquaSystemAppearance</key>
<true/>
</dict>
</plist>
+1 -1
View File
@@ -14,7 +14,7 @@ File `robomongo.ico` will be generated.
Which icon sizes are used on Windows?
=====================================
The most important sizes are the one that is small. Robo 3T should include
The most important sizes are the one that is small. Robomongo should include
16, 20, 24, 40, 48. The bigger sizes are usually scaled well, without notable
degrading in quality.
+4 -4
View File
@@ -27,13 +27,13 @@ IDI_ICON1 ICON "@windows_icon@"
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "3T Software Labs Ltd\0"
VALUE "FileDescription", "Robo 3T, MongoDB management tool\0"
VALUE "FileDescription", "Robomongo, MongoDB management tool\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "LegalCopyright", "Copyright 3T Software Labs Ltd, 2014 - 2017\0"
VALUE "ProductName", "Robo 3T\0"
VALUE "ProductName", "Robomongo\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
VALUE "OriginalFilename", "robo3t.exe\0"
VALUE "InternalName", "Robo 3T\0"
VALUE "OriginalFilename", "Robomongo.exe\0"
VALUE "InternalName", "Robomongo\0"
END
END
BLOCK "VarFileInfo"
+11
View File
@@ -0,0 +1,11 @@
This is a logbook for notes about migration to MongoDB 3.2
DocumentTextEditor.cpp
----------------------
Commented error reporting.
Logger.cpp
----------
Commented Logger::print().
Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

-123
View File
@@ -1,123 +0,0 @@
#########################################
### Unit Testing with Google Test ###
#########################################
### --- Important Note
if (SYSTEM_LINUX)
message("\n *Note: Currently unit testing is disabled for Linux "
"due to MongoDB linking problems")
return()
endif()
### --- Enable and setup gtest
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
### --- Setup test source files
# New test & source file pairs MUST have the following format:
# Test file: /path/Foo_test.cpp
# Source file: /path/Foo.cpp or /path/Foo.h
set(ROBO_SRC_DIR ${CMAKE_HOME_DIRECTORY}/src/robomongo)
set(SOURCES_TEST
${ROBO_SRC_DIR}/utils/RoboCrypt_test.cpp
${ROBO_SRC_DIR}/utils/StringOperations_test.cpp
${ROBO_SRC_DIR}/core/HexUtils_test.cpp
)
### --- Setup robo_unit_tests exec. & link ROBO_OBJ_FILES
add_executable(robo_unit_tests ${SOURCES_TEST})
add_dependencies(robo_unit_tests robomongo)
target_include_directories(robo_unit_tests PRIVATE ${CMAKE_HOME_DIRECTORY}/src)
get_target_property(ROBO_SOURCES robomongo SOURCES)
list(FILTER ROBO_SOURCES INCLUDE REGEX "cpp")
list(FILTER ROBO_SOURCES EXCLUDE REGEX "main.cpp")
if(SYSTEM_WINDOWS)
set(OBJ_DIR ${CMAKE_BINARY_DIR}/src/robomongo/robomongo.dir/${CMAKE_BUILD_TYPE}/)
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}mocs_compilation.obj;")
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}qrc_gui.obj;")
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}qrc_robo.obj;")
foreach(SRC_FILE ${ROBO_SOURCES})
get_filename_component(FILENAME ${SRC_FILE} NAME)
string(REPLACE ".cpp" ".obj" FILENAME ${FILENAME})
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}${FILENAME};")
endforeach()
elseif(SYSTEM_MACOSX)
set(OBJ_DIR ${CMAKE_BINARY_DIR}/src/robomongo/CMakeFiles/robomongo.dir/)
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_autogen/mocs_compilation.cpp.o;")
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_autogen/YHP5W5E6RA/qrc_gui.cpp.o;")
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_autogen/3YJK5W5UP7/qrc_robo.cpp.o;")
foreach(SRC_FILE ${ROBO_SOURCES})
string(REPLACE ".cpp" ".cpp.o" OBJ_FILE ${SRC_FILE})
set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}${OBJ_FILE};")
endforeach()
find_library(SECURITY NAMES Security)
find_library(CORE_FOUNDATION NAMES CoreFoundation)
set(SSL_LIBRARIES ${SECURITY} ${CORE_FOUNDATION})
target_link_libraries(robo_unit_tests ${SSL_LIBRARIES} -lresolv)
# elseif(SYSTEM_LINUX)
# set(OBJ_DIR ${CMAKE_BINARY_DIR}/src/robomongo/CMakeFiles/robomongo.dir/)
# message("--- OBJ_DIR: " ${OBJ_DIR})
# set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_automoc.cpp.o;")
# set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_automoc.dir/gui/resources/qrc_gui.cpp.o;")
# set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}/robomongo_automoc.dir/resources/qrc_robo.cpp.o;")
# foreach(SRC_FILE ${ROBO_SOURCES})
# string(REPLACE ".cpp" ".cpp.o" OBJ_FILE ${SRC_FILE})
# set(ROBO_OBJ_FILES "${ROBO_OBJ_FILES}${OBJ_DIR}${OBJ_FILE};")
# endforeach()
endif()
# Disable WebEngineWidgets for Linux
SET(WebEngineWidgets "Qt5::WebEngineWidgets")
if(SYSTEM_LINUX)
SET(WebEngineWidgets)
endif()
target_link_libraries(robo_unit_tests
gtest
gtest_main
Qt5::Widgets
Qt5::Network
Qt5::Xml
${WebEngineWidgets}
qjson
qscintilla
mongodb
ssh
Threads::Threads
${ROBO_OBJ_FILES}
)
### --- Install DLLs for Windows
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(D "d")
endif()
if(SYSTEM_WINDOWS)
get_target_property(target_path Qt5::Core LOCATION)
get_filename_component(qt_bin_dir ${target_path} DIRECTORY)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Core${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Gui${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Network${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5PrintSupport${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Widgets${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Xml${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Positioning${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Qml${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5Quick${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5QuickWidgets${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5WebChannel${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5WebEngineCore${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5WebEngineWidgets${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
set(QT_BIN_FILES "${QT_BIN_FILES}" ${qt_bin_dir}/Qt5PrintSupport${D}${CMAKE_SHARED_LIBRARY_SUFFIX};)
get_target_property(TESTS_BIN_DIR robo_unit_tests BINARY_DIR)
file(COPY ${QT_BIN_FILES} DESTINATION ${TESTS_BIN_DIR}/${CMAKE_BUILD_TYPE})
file(COPY
${OpenSSL_DIR}/libssl-1_1-x64.dll
${OpenSSL_DIR}/libcrypto-1_1-x64.dll
DESTINATION ${TESTS_BIN_DIR}/${CMAKE_BUILD_TYPE})
endif()
-14
View File
@@ -1,14 +0,0 @@
This is just a placeholder for `cmake`.
Test source files are located in the same directory alongside the tested file in `robomongo/src/robomongo/` dir and sub-dirs.
e.g.
```
...
RoboCrypt.cpp
RoboCrypt_test.cpp
...
StringOperations.cpp
StringOperations_test.cpp
...
```
+26 -73
View File
@@ -10,6 +10,7 @@ set(CMAKE_AUTOUIC ON)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize}")
set(SOURCES
# Isolated Scope #1
core/utils/QtUtils.cpp
core/utils/StdUtils.cpp
@@ -27,11 +28,14 @@ set(SOURCES
core/EventBus.cpp
core/KeyboardManager.cpp
core/domain/MongoNamespace.cpp
core/domain/MongoUser.cpp
core/domain/MongoUser.cpp
core/domain/MongoFunction.cpp
core/domain/MongoUtils.cpp
core/domain/MongoCollection.cpp
core/domain/MongoCollectionInfo.cpp
core/domain/MongoQueryInfo.cpp
core/domain/MongoShellResult.cpp
core/domain/CursorPosition.cpp
core/domain/ScriptInfo.cpp
core/events/MongoEventsInfo.cpp
@@ -52,10 +56,8 @@ set(SOURCES
core/mongodb/ReplicaSet.cpp
core/settings/SettingsManager.cpp
core/AppRegistry.cpp
utils/StringOperations.cpp
utils/string_operations.cpp
utils/common.cpp
utils/SimpleCrypt.cpp
utils/RoboCrypt.cpp
# Isolated Scope #3
gui/GuiRegistry.cpp
@@ -77,20 +79,18 @@ set(SOURCES
# Isolated scope #4
gui/dialogs/PreferencesDialog.cpp
gui/dialogs/ConnectionsDialog.cpp
gui/dialogs/CreateConnectionDialog.cpp
gui/dialogs/ExportDialog.cpp
gui/dialogs/ChangeShellTimeoutDialog.cpp
# Isolated scope #5
gui/editors/PlainJavaScriptEditor.cpp
gui/editors/JSLexer.cpp
gui/editors/FindFrame.cpp
gui/widgets/explorer/AddEditIndexDialog.cpp
gui/widgets/explorer/EditIndexDialog.cpp
gui/widgets/workarea/ScriptWidget.cpp
# Isolated scope #6
gui/widgets/explorer/ExplorerCollectionTreeItem.cpp
gui/widgets/explorer/ExplorerCollectionIndexesDir.cpp
gui/widgets/explorer/ExplorerCollectionIndexItem.cpp
gui/widgets/explorer/ExplorerTreeItem.cpp
gui/widgets/explorer/ExplorerReplicaSetFolderItem.cpp
gui/widgets/explorer/ExplorerReplicaSetTreeItem.cpp
@@ -141,65 +141,27 @@ set(SOURCES
gui/resources/gui.qrc
)
# Robomongo target
add_executable(robomongo MACOSX_BUNDLE WIN32 app/main.cpp ${SOURCES})
# Disable WebEngineWidgets for Linux
SET(WebEngineWidgets "Qt5::WebEngineWidgets")
if(SYSTEM_LINUX)
SET(WebEngineWidgets)
endif()
target_link_libraries(robomongo
PRIVATE
Qt5::Widgets
Qt5::Network
Qt5::Xml
${WebEngineWidgets}
qjson
qscintilla
mongodb
ssh
Threads::Threads) # Target from FindThreads CMake module
if(APPLE)
find_library(SECURITY NAMES Security)
find_library(CORE_FOUNDATION NAMES CoreFoundation)
set(SSL_LIBRARIES ${SECURITY} ${CORE_FOUNDATION})
target_link_libraries(robomongo
PRIVATE
${SSL_LIBRARIES}
-lresolv)
endif(APPLE)
target_include_directories(robomongo
PRIVATE
${CMAKE_HOME_DIRECTORY}/src)
# Get build number
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE BUILD_NUMBER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else(GIT_FOUND)
MESSAGE( FATAL_ERROR "Unable to find Git" )
set(BUILD_NUMBER 0)
endif(GIT_FOUND)
if(BUILD_NUMBER STREQUAL "")
MESSAGE( FATAL_ERROR "Failed to get BUILD_NUMBER" )
endif()
set(BUILD_NUMBER ${BUILD_NUMBER} CACHE INTERNAL "")
target_compile_definitions(robomongo
PRIVATE
BUILDING_ROBO
PROJECT_NAME="${PROJECT_NAME}"
PROJECT_NAME_TITLE="${PROJECT_NAME_TITLE}"
PROJECT_COPYRIGHT="${PROJECT_COPYRIGHT}"
@@ -210,16 +172,8 @@ target_compile_definitions(robomongo
PROJECT_GITHUB_ISSUES="${PROJECT_GITHUB_ISSUES}"
PROJECT_VERSION="${PROJECT_VERSION}"
PROJECT_VERSION_SHORT="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
BUILD_NUMBER="${BUILD_NUMBER}"
PROJECT_NAME_LOWERCASE="${PROJECT_NAME_LOWERCASE}"
PROJECT_QT_VERSION="${Qt5Core_VERSION}"
MongoDB_VERSION="${MongoDB_VERSION}"
OPENSSL_VERSION="${OPENSSL_VERSION}"
LIBSSH2_VERSION="${LIBSSH2_VERSION}"
QJSON_VERSION="${QJSON_VERSION}"
GOOGLE_TEST_VERSION="${GOOGLE_TEST_VERSION}"
ESPRIMA_VERSION="${ESPRIMA_VERSION}"
)
PROJECT_QT_VERSION="${Qt5Core_VERSION}"
PROJECT_NAME_LOWERCASE="${PROJECT_NAME_LOWERCASE}")
if(SYSTEM_WINDOWS)
# Create Windows Resource file
@@ -230,47 +184,46 @@ if(SYSTEM_WINDOWS)
unset(windows_icon)
# Add additional source file to "robomongo" target
target_sources(robomongo PRIVATE "${CMAKE_BINARY_DIR}/winres.rc")
target_sources(robomongo
PRIVATE
"${CMAKE_BINARY_DIR}/winres.rc")
# Rename output name for Windows
set_target_properties(robomongo PROPERTIES OUTPUT_NAME "robo3t")
# Suppress "warning C4477: 'sprintf'..." from robomongo\shell\db\ptimeutil.cpp
# Suppress "warning C4291: ...no matching operator delete found" from third_party\mozjs-60
set_target_properties(robomongo PROPERTIES COMPILE_FLAGS "/wd4477 /wd4291")
# Start debug program with console
set_target_properties(robomongo PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(robomongo PROPERTIES
OUTPUT_NAME "Robomongo")
# Seems that we do not need to do this with recent versions of Qt
target_link_libraries(robomongo PRIVATE Qt5::WinMain)
target_link_libraries(robomongo
PRIVATE
Qt5::WinMain)
elseif(SYSTEM_MACOSX)
string(TIMESTAMP CURRENT_YEAR "%Y")
set_target_properties(robomongo PROPERTIES
INSTALL_RPATH "@executable_path/../Frameworks"
OUTPUT_NAME "Robo 3T"
OUTPUT_NAME "Robomongo"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/install/macosx/Info.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "Robo 3T"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.3tsoftwarelabs.robo3t"
MACOSX_BUNDLE_INFO_STRING "Robo 3T ${PROJECT_VERSION}. Copyright 3T Software Labs Ltd, 2014 - ${CURRENT_YEAR}"
MACOSX_BUNDLE_BUNDLE_NAME "Robomongo"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.3tsoftwarelabs.robomongo"
MACOSX_BUNDLE_INFO_STRING "Robomongo ${PROJECT_VERSION}. Copyright 3T Software Labs Ltd, 2014 - 2017"
MACOSX_BUNDLE_SHORT_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_LONG_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_COPYRIGHT "Copyright 3T Software Labs Ltd, 2014 - ${CURRENT_YEAR}"
MACOSX_BUNDLE_COPYRIGHT "Copyright 3T Software Labs Ltd, 2014 - 2017"
MACOSX_BUNDLE_ICON_FILE "robomongo")
elseif(SYSTEM_LINUX)
set_target_properties(robomongo PROPERTIES
INSTALL_RPATH "$ORIGIN/../lib"
OUTPUT_NAME "robo3t")
OUTPUT_NAME "robomongo")
endif()
# Install
include(RobomongoInstall)
#
# Tests targets (code below should be moved to separate file)
#
add_executable(tests WIN32 EXCLUDE_FROM_ALL app/main_test.cpp gui/editors/JSLexer.cpp)
target_link_libraries(tests Qt5::Widgets qjson qscintilla mongodb Threads::Threads)
target_include_directories(tests
+10 -41
View File
@@ -6,22 +6,17 @@
// Header "mongo/util/net/sock" is needed for mongo::enableIPv6()
// Header "mongo/platform/basic" is required by "sock.h" under Windows
#include <mongo/platform/basic.h>
#include <mongo/util/net/socket_utils.h>
#include <mongo/util/net/sock.h>
#include <mongo/base/initializer.h>
#include <mongo/util/net/ssl_options.h>
#include <mongo/db/service_context.h>
#include <mongo/transport/transport_layer_asio.h>
#include <mongo/shell/shell_options.h>
#include <mongo/db/storage/storage_engine_init.h>
#include "robomongo/core/AppRegistry.h"
#include "robomongo/core/settings/SettingsManager.h"
#include "robomongo/core/utils/Logger.h"
#include "robomongo/gui/MainWindow.h"
#include "robomongo/gui/AppStyle.h"
#include "robomongo/gui/dialogs/EulaDialog.h"
#include "robomongo/ssh/ssh.h"
#include "robomongo/utils/RoboCrypt.h"
int main(int argc, char *argv[], char** envp)
{
@@ -44,19 +39,6 @@ int main(int argc, char *argv[], char** envp)
// Initialization routine for MongoDB shell
mongo::runGlobalInitializersOrDie(argc, argv, envp);
mongo::setGlobalServiceContext(mongo::ServiceContext::make());
// Todo from mongo repo: This should use a TransportLayerManager or TransportLayerFactory
auto serviceContext = mongo::getGlobalServiceContext();
mongo::transport::TransportLayerASIO::Options opts;
// When true, it breaks connection to localhost, github #1757
opts.enableIPv6 = mongo::shellGlobalParams.enableIPv6;
opts.mode = mongo::transport::TransportLayerASIO::Options::kEgress;
serviceContext->setTransportLayer(
std::make_unique<mongo::transport::TransportLayerASIO>(opts, nullptr)
);
auto tlPtr = serviceContext->getTransportLayer();
uassertStatusOK(tlPtr->setup());
uassertStatusOK(tlPtr->start());
// Initialize Qt application
QApplication app(argc, argv);
@@ -73,40 +55,27 @@ int main(int argc, char *argv[], char** envp)
#ifdef Q_OS_MAC
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
// EULA License Agreement
auto const& settings { Robomongo::AppRegistry::instance().settingsManager() };
if (!settings->acceptedEulaVersions().contains(PROJECT_VERSION)) {
bool const showFormPage { settings->programExitedNormally() && !settings->disableHttpsFeatures() };
Robomongo::EulaDialog eulaDialog(showFormPage);
settings->setProgramExitedNormally(false);
settings->save();
int const result = eulaDialog.exec();
settings->setProgramExitedNormally(true);
settings->save();
if (QDialog::Rejected == result) {
auto const settingsManager = Robomongo::AppRegistry::instance().settingsManager();
if (!settingsManager->acceptedEulaVersions().contains(PROJECT_VERSION)) {
Robomongo::EulaDialog eulaDialog;
if (eulaDialog.exec() == QDialog::Rejected) {
rbm_ssh_cleanup();
return 1;
}
// EULA accepted
settings->addAcceptedEulaVersion(PROJECT_VERSION);
settings->save();
}
settingsManager->addAcceptedEulaVersion(PROJECT_VERSION);
settingsManager->save();
}
// Init GUI style
Robomongo::AppStyleUtils::initStyle();
// To be set true at normal program exit
settings->setProgramExitedNormally(false);
settings->save();
// Application main window
Robomongo::MainWindow mainWindow;
mainWindow.show();
for(auto const& msgAndSeverity : Robomongo::RoboCrypt::roboCryptLogs())
Robomongo::LOG_MSG(msgAndSeverity.first, msgAndSeverity.second);
int rc = app.exec();
rbm_ssh_cleanup();
return rc;
-1
View File
@@ -31,7 +31,6 @@ namespace Robomongo
class MongoDocument;
typedef boost::shared_ptr<MongoDocument> MongoDocumentPtr;
// todo: Use enum class
enum ConnectionType {
// This type of connection is shown in Explorer and also opens SSH tunnel for secondary
// connections (if needed)
+17 -15
View File
@@ -13,11 +13,11 @@
namespace
{
struct RemoveIfReciver
struct RemoveIfReciver : public std::unary_function<const Robomongo::EventBus::SubscribersType&, bool>
{
RemoveIfReciver(QObject *receiver) : _receiver(receiver) {}
bool operator()(const Robomongo::EventBus::EventTypeAndSubscriber& item) const {
bool operator()(const Robomongo::EventBus::SubscribersType& item) const {
if (item.second->receiver == _receiver) {
delete item.second;
return true;
@@ -28,13 +28,13 @@ namespace
QObject *_receiver;
};
struct FindIfReciver
struct FindIfReciver : public std::unary_function<const Robomongo::EventBus::SubscribersType&, bool>
{
FindIfReciver(QThread *thread) : _thread(thread) {}
bool operator()(const Robomongo::EventBus::ThreadAndDispatcher &item) const {
if (item.first == _thread)
bool operator()(const Robomongo::EventBus::DispatchersType &item) const {
if (item.first == _thread) {
return true;
}
return false;
}
QThread *_thread;
@@ -50,16 +50,19 @@ namespace Robomongo
EventBus::~EventBus()
{
for (auto const& dispatchersByThread : _dispatchersByThread)
delete dispatchersByThread.second;
for (DispatchersContainerType::iterator it = _dispatchersByThread.begin(); it != _dispatchersByThread.end(); ++it) {
DispatchersType item = *it;
delete item.second;
}
}
void EventBus::publish(Event *event)
{
QMutexLocker lock(&_lock);
QList<QObject*> theReceivers;
EventBusDispatcher *dis = nullptr;
for (auto const& item : _subscribersByEventType) {
EventBusDispatcher *dis = NULL;
for (SubscribersContainerType::iterator it = _subscribersByEventType.begin(); it != _subscribersByEventType.end(); ++it ) {
SubscribersType item = *it;
if (event->type() == item.first) {
EventBusSubscriber *subscriber = item.second;
if (!subscriber->sender || subscriber->sender == event->sender()) {
@@ -115,7 +118,7 @@ namespace Robomongo
VERIFY(connect(receiver, SIGNAL(destroyed(QObject*)), this, SLOT(unsubscibe(QObject*))));
// add subscriber
_subscribersByEventType.push_back(EventTypeAndSubscriber(type, new EventBusSubscriber(dis, receiver, sender)));
_subscribersByEventType.push_back(SubscribersType(type, new EventBusSubscriber(dis, receiver, sender)));
}
void EventBus::unsubscibe(QObject *receiver)
@@ -131,9 +134,8 @@ namespace Robomongo
*/
EventBusDispatcher *EventBus::dispatcher(QThread *thread)
{
auto const& disIt = std::find_if(
_dispatchersByThread.begin(), _dispatchersByThread.end(), FindIfReciver(thread)
);
DispatchersContainerType::iterator disIt = std::find_if(
_dispatchersByThread.begin(), _dispatchersByThread.end(), FindIfReciver(thread));
if (disIt != _dispatchersByThread.end()) {
return (*disIt).second;
@@ -141,7 +143,7 @@ namespace Robomongo
else {
EventBusDispatcher *dis = new EventBusDispatcher();
dis->moveToThread(thread);
_dispatchersByThread.push_back(ThreadAndDispatcher(thread, dis));
_dispatchersByThread.push_back(DispatchersType(thread, dis));
return dis;
}
}
+6 -5
View File
@@ -21,9 +21,10 @@ namespace Robomongo
Q_OBJECT
public:
typedef std::pair<QEvent::Type, EventBusSubscriber *> EventTypeAndSubscriber;
typedef std::pair<QThread *, EventBusDispatcher *> ThreadAndDispatcher;
typedef std::pair<QEvent::Type, EventBusSubscriber *> SubscribersType;
typedef std::vector<SubscribersType > SubscribersContainerType;
typedef std::pair<QThread *, EventBusDispatcher *> DispatchersType;
typedef std::vector<DispatchersType> DispatchersContainerType;
EventBus();
~EventBus();
@@ -64,7 +65,7 @@ namespace Robomongo
private:
QMutex _lock;
std::vector<EventTypeAndSubscriber> _subscribersByEventType;
std::vector<ThreadAndDispatcher> _dispatchersByThread;
SubscribersContainerType _subscribersByEventType;
DispatchersContainerType _dispatchersByThread;
};
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "robomongo/core/EventError.h"
#include "robomongo/utils/StringOperations.h"
#include "robomongo/utils/string_operations.h"
namespace Robomongo
{
+1 -1
View File
@@ -37,7 +37,7 @@ namespace Robomongo
const char *p = s.c_str();
for (size_t i = 0; i < bytes; i++) {
data[i] = mongo::fromHex(p).getValue();
data[i] = mongo::fromHex(p);
p += 2;
}
-19
View File
@@ -1,19 +0,0 @@
#include "gtest/gtest.h"
#include "HexUtils.h"
#include <string>
/* Example Test:
*
* TEST( [Test_Case_Name], [Test_Name] )
* TEST( [Test_Case_Name], [UnitOfWorkName_ScenarioUnderTest_ExpectedBehavior] )
* TEST( StringParserTests, NumberLeftOf_StringWithoutNumber_ReturnsFalse) {
// ...
}
*/
TEST(hex_utils_tests, test_1)
{
EXPECT_TRUE(Robomongo::HexUtils::isHexString("a"));
}
+98 -114
View File
@@ -1,8 +1,6 @@
#include "robomongo/core/domain/App.h"
#include <QHash>
#include <QInputDialog>
#include <QMessageBox>
#include "robomongo/core/domain/MongoServer.h"
#include "robomongo/core/domain/MongoShell.h"
@@ -37,9 +35,6 @@ namespace Robomongo
}
}
App::~App()
{}
App::App(EventBus *const bus) : QObject(),
_bus(bus), _lastServerHandle(0) {
_bus->subscribe(this, EstablishSshConnectionResponse::Type);
@@ -47,75 +42,17 @@ namespace Robomongo
_bus->subscribe(this, LogEvent::Type);
}
std::unique_ptr<MongoServer>
App::continueOpenServer(int serverHandle, ConnectionSettings* connSettings,
ConnectionType type, int localport)
App::~App()
{
ConnectionSettings* connSettingsClone = connSettings->clone();
// Modify connection settings when SSH tunnel is used
if ((type == ConnectionPrimary || type == ConnectionTest)
&& !connSettingsClone->isReplicaSet()
&& connSettingsClone->sshSettings()->enabled()
) {
connSettingsClone->setServerHost("127.0.0.1");
connSettingsClone->setServerPort(localport);
}
auto server { std::make_unique<MongoServer>(serverHandle, connSettingsClone, type) };
server->runWorkerThread();
auto replicaSetStr = QString::fromStdString(connSettings->connectionName()) + " [Replica Set]";
replicaSetStr = (connSettings->replicaSetSettings()->members().size() > 0)
? replicaSetStr + QString::fromStdString(connSettings->replicaSetSettings()->members()[0])
: replicaSetStr + "";
QString serverAddress = connSettings->isReplicaSet()
? replicaSetStr
: QString::fromStdString(connSettings->getFullAddress());
LOG_MSG(QString("Connecting to %1...").arg(serverAddress), mongo::logger::LogSeverity::Info());
server->tryConnect();
return server;
std::for_each(_shells.begin(), _shells.end(), stdutils::default_delete<MongoShell*>());
std::for_each(_servers.begin(), _servers.end(), stdutils::default_delete<MongoServer*>());
}
/**
* Creates and opens new server connection.
* @param connection: ConnectionSettings, that will be owned by MongoServer.
* @param visible: should this server be visible in UI (explorer) or not.
*/
std::unique_ptr<MongoServer>
App::openServerInternal(ConnectionSettings* connSettings, ConnectionType type)
{
++_lastServerHandle;
bool App::openServer(ConnectionSettings *connection, ConnectionType type) {
if (type == ConnectionPrimary)
_bus->publish(new ConnectingEvent(this));
// When connection is SECONDARY or SSH not enabled or replica set,
// then continue without SSH Tunnel
if (type == ConnectionSecondary || !connSettings->sshSettings()->enabled()
|| connSettings->isReplicaSet()
) {
return continueOpenServer(_lastServerHandle, connSettings, type);
}
// Open SSH channel and only after that open connection
LOG_MSG(QString("Creating SSH tunnel to %1:%2...")
.arg(QtUtils::toQString(connSettings->sshSettings()->host()))
.arg(connSettings->sshSettings()->port()), mongo::logger::LogSeverity::Info());
ConnectionSettings* settingsCopy = connSettings->clone();
SshTunnelWorker* sshWorker = new SshTunnelWorker(settingsCopy);
_bus->send(sshWorker, new EstablishSshConnectionRequest(this, _lastServerHandle, sshWorker, settingsCopy, type));
return nullptr;
}
bool App::openServer(ConnectionSettings *connection, ConnectionType type)
{
SshSettings *ssh = connection->sshSettings();
if (!connection->isReplicaSet() && ssh->enabled() && ssh->askPassword() &&
if (ssh->enabled() && ssh->askPassword() &&
(type == ConnectionPrimary || type == ConnectionTest)) {
bool ok = false;
@@ -160,43 +97,67 @@ namespace Robomongo
}
}
_servers.push_back(move(openServerInternal(connection, type)));
openServerInternal(connection, type);
return true;
}
/**
* Creates and opens new server connection.
* @param connection: ConnectionSettings, that will be owned by MongoServer.
* @param visible: should this server be visible in UI (explorer) or not.
*/
MongoServer *App::openServerInternal(ConnectionSettings* connSettings, ConnectionType type) {
++_lastServerHandle;
if (type == ConnectionPrimary)
_bus->publish(new ConnectingEvent(this));
// When connection is SECONDARY or do not have
// ssh settings enabled, continue without SSH Tunnel
if (type == ConnectionSecondary || !connSettings->sshSettings()->enabled()) {
return continueOpenServer(_lastServerHandle, connSettings, type);
}
// Open SSH channel and only after that open connection
LOG_MSG(QString("Creating SSH tunnel to %1:%2...")
.arg(QtUtils::toQString(connSettings->sshSettings()->host()))
.arg(connSettings->sshSettings()->port()), mongo::logger::LogSeverity::Info());
ConnectionSettings* settingsCopy = connSettings->clone();
SshTunnelWorker* sshWorker = new SshTunnelWorker(settingsCopy);
_bus->send(sshWorker, new EstablishSshConnectionRequest(this, _lastServerHandle, sshWorker, settingsCopy, type));
return NULL;
}
/**
* @brief Closes MongoServer connection and frees all resources, owned
* by MongoServer. Finally, specified MongoServer will also be deleted.
*/
void App::closeServer(MongoServer *server)
{
_servers.erase(std::remove_if(_servers.begin(), _servers.end(),
[&](auto const& el) { return el.get() == server; }), _servers.end());
_servers.erase(std::remove_if(_servers.begin(), _servers.end(), stdutils::RemoveIfFound<MongoServer*>(server)),
_servers.end());
}
void App::openShell(MongoCollection *collection, const QString &filePathToSave)
{
ConnectionSettings *connection = collection->database()->server()->connectionRecord();
auto const& dbname = collection->database()->name();
connection->setDefaultDatabase(dbname);
QString const& script = detail::buildCollectionQuery(collection->name(), "find({})");
openShell(collection->database()->server(), connection,
ScriptInfo(script, true, dbname, CursorPosition(0, -2), QtUtils::toQString(dbname), filePathToSave)
);
connection->setDefaultDatabase(collection->database()->name());
QString script = detail::buildCollectionQuery(collection->name(), "find({})");
openShell(collection->database()->server(), connection, ScriptInfo(script, true, CursorPosition(0, -2),
QtUtils::toQString(collection->database()->name()), filePathToSave));
}
void App::openShell(MongoServer *server, const QString &script, const std::string &dbName,
bool execute, const QString &shellName,
const CursorPosition &cursorPosition, const QString &filePathToSave)
bool execute, const QString &shellName,
const CursorPosition &cursorPosition, const QString &filePathToSave)
{
ConnectionSettings *connection = server->connectionRecord();
if (!dbName.empty())
connection->setDefaultDatabase(dbName);
openShell(server, connection,
ScriptInfo(script, execute, dbName, cursorPosition, shellName, filePathToSave)
);
openShell(server, connection, ScriptInfo(script, execute, cursorPosition, shellName, filePathToSave));
}
void App::openShell(MongoDatabase *database, const QString &script,
@@ -205,23 +166,22 @@ namespace Robomongo
{
ConnectionSettings *connection = database->server()->connectionRecord();
connection->setDefaultDatabase(database->name());
openShell(database->server(), connection, ScriptInfo(script, execute, database->name(),
cursorPosition, shellName, filePathToSave));
openShell(database->server(), connection, ScriptInfo(script, execute, cursorPosition,
shellName, filePathToSave));
}
void App::openShell(MongoServer* server, ConnectionSettings* connection, const ScriptInfo &scriptInfo)
{
auto serverClone{ openServerInternal(connection, ConnectionSecondary) };
MongoServer *serverClone = openServerInternal(connection, ConnectionSecondary);
if (!serverClone || !server)
return;
auto shell{ std::make_unique<MongoShell>(serverClone.get(), scriptInfo) };
_servers.push_back(move(serverClone));
MongoShell *shell = new MongoShell(serverClone, scriptInfo);
// Connection between explorer's server and tab's MongoShells
_bus->subscribe(server, ReplicaSetRefreshed::Type, shell.get());
_bus->publish(new OpeningShellEvent(this, shell.get()));
_bus->subscribe(server, ReplicaSetRefreshed::Type, shell);
_shells.push_back(shell);
_bus->publish(new OpeningShellEvent(this, shell));
shell->execute();
_shells.push_back(move(shell));
return;
}
@@ -231,16 +191,45 @@ namespace Robomongo
*/
void App::closeShell(MongoShell *shell)
{
auto const itr = std::find_if(_shells.begin(), _shells.end(),
[&](auto const& el) { return el.get() == shell; }
);
// Do nothing, if this shell not owned by this App.
if (itr == _shells.end())
MongoShellsContainerType::iterator it = std::find_if(_shells.begin(), _shells.end(), std::bind1st(std::equal_to<MongoShell *>(), shell));
if (it == _shells.end())
return;
_shells.erase(it);
closeServer(shell->server());
_shells.erase(itr);
delete shell;
}
MongoServer *App::continueOpenServer(int serverHandle, ConnectionSettings* connSettings, ConnectionType type,
int localport)
{
ConnectionSettings* connSettingsClone = connSettings->clone();
// Modify connection settings when SSH tunnel is used
if ((type == ConnectionPrimary || type == ConnectionTest)
&& connSettingsClone->sshSettings()->enabled()) {
connSettingsClone->setServerHost("127.0.0.1");
connSettingsClone->setServerPort(localport);
}
MongoServer *server = new MongoServer(serverHandle, connSettingsClone, type);
_servers.push_back(server);
server->runWorkerThread();
auto replicaSetStr = QString::fromStdString(connSettings->connectionName()) + " [Replica Set]";
replicaSetStr = (connSettings->replicaSetSettings()->members().size() > 0)
? replicaSetStr + QString::fromStdString(connSettings->replicaSetSettings()->members()[0])
: replicaSetStr + "";
QString serverAddress = connSettings->isReplicaSet()
? replicaSetStr
: QString::fromStdString(connSettings->getFullAddress());
LOG_MSG(QString("Connecting to %1...").arg(serverAddress), mongo::logger::LogSeverity::Info());
server->tryConnect();
return server;
}
void App::handle(EstablishSshConnectionResponse *event) {
@@ -253,31 +242,26 @@ namespace Robomongo
LOG_MSG(QString("SSH tunnel created successfully"), mongo::logger::LogSeverity::Info());
_servers.push_back(move(
continueOpenServer(event->serverHandle, event->settings, event->connectionType, event->localport)
));
continueOpenServer(event->serverHandle, event->settings, event->connectionType, event->localport);
_bus->send(event->worker, new ListenSshConnectionRequest(this, event->serverHandle, event->connectionType));
}
void App::handle(LogEvent *event) {
LOG_MSG(event->message, event->mongoLogSeverity());
if (!event->informUser)
return;
QMessageBox(
event->qMessageBoxIcon(),
QString::fromStdString(event->severity()),
QtUtils::toQString(event->severity() + ": " + event->message)
).exec();
if (event->level == LogEvent::RBM_ERROR) {
LOG_MSG(event->message, mongo::logger::LogSeverity::Error());
} else if (event->level == LogEvent::RBM_WARN) {
LOG_MSG(event->message, mongo::logger::LogSeverity::Warning());
} else if (event->level == LogEvent::RBM_INFO) {
LOG_MSG(event->message, mongo::logger::LogSeverity::Info());
} else if (event->level == LogEvent::RBM_DEBUG) {
LOG_MSG(event->message, mongo::logger::LogSeverity::Log());
}
}
void App::handle(ListenSshConnectionResponse *event) {
if (event->isError()) {
_bus->publish(
new ConnectionFailedEvent(this, event->serverHandle, event->connectionType,
event->error().errorMessage(), ConnectionFailedEvent::SshChannel)
);
_bus->publish(new ConnectionFailedEvent(this, event->serverHandle, event->connectionType, event->error().errorMessage(),
ConnectionFailedEvent::SshChannel));
return;
}
@@ -303,7 +287,7 @@ namespace Robomongo
s << std::endl << "Enter your PEM key passphrase (will never be stored):";
QString userInput = QInputDialog::getText(NULL, tr("TLS Authentication"),
QString userInput = QInputDialog::getText(NULL, tr("SSL Authentication"),
QtUtils::toQString(s.str()),
QLineEdit::Password, "", &ok);
+12 -14
View File
@@ -38,6 +38,8 @@ namespace Robomongo
Q_OBJECT
public:
typedef std::vector<MongoServer*> MongoServersContainerType;
typedef std::vector<MongoShell*> MongoShellsContainerType;
App(EventBus *const bus);
~App();
@@ -61,20 +63,19 @@ namespace Robomongo
void openShell(MongoCollection *collection, const QString &filePathToSave = QString());
void openShell(MongoServer *server, const QString &script, const std::string &dbName = std::string(),
bool execute = true, const QString &shellName = QString(),
const CursorPosition &cursorPosition = CursorPosition(), const QString &file = QString());
bool execute = true, const QString &shellName = QString(),
const CursorPosition &cursorPosition = CursorPosition(), const QString &file = QString());
void openShell(MongoDatabase *database, const QString &script,
bool execute = true, const QString &shellName = QString(),
const CursorPosition &cursorPosition = CursorPosition(),
const QString &filePathToSave = QString());
bool execute = true, const QString &shellName = QString(),
const CursorPosition &cursorPosition = CursorPosition(), const QString &filePathToSave = QString());
/**
* @brief Open new shell using explorer's MongoServer (ExplorerServerTreeItem's _server)
*/
void openShell(MongoServer* server, ConnectionSettings* connSettings, const ScriptInfo &scriptInfo);
auto const& getServers() const { return _servers; };
MongoServersContainerType getServers() const { return _servers; };
/**
* @brief Closes MongoShell and frees all resources, owned by specified MongoShell.
@@ -82,8 +83,7 @@ namespace Robomongo
*/
void closeShell(MongoShell *shell);
void fireConnectionFailedEvent(int serverHandle, ConnectionType type, std::string errormsg,
ConnectionFailedEvent::Reason reason);
void fireConnectionFailedEvent(int serverHandle, ConnectionType type, std::string errormsg, ConnectionFailedEvent::Reason reason);
int getLastServerHandle() const { return _lastServerHandle; };
@@ -93,10 +93,8 @@ namespace Robomongo
void handle(LogEvent *event);
private:
std::unique_ptr<MongoServer> openServerInternal(ConnectionSettings* connSettings, ConnectionType type);
std::unique_ptr<MongoServer>
continueOpenServer(int serverHandle, ConnectionSettings* connSettings, ConnectionType type, int localport = 0);
MongoServer *openServerInternal(ConnectionSettings* connSettings, ConnectionType type);
MongoServer *continueOpenServer(int serverHandle, ConnectionSettings* connSettings, ConnectionType type, int localport = 0);
/**
* @brief Create prompt dialog to enter SSL PEM key passphrase and save passphrase into SSL settings
@@ -108,12 +106,12 @@ namespace Robomongo
/**
* MongoServers, owned by this App.
*/
std::vector<std::unique_ptr<MongoServer>> _servers;
MongoServersContainerType _servers;
/**
* MongoShells, owned by this App.
*/
std::vector<std::unique_ptr<MongoShell>> _shells;
MongoShellsContainerType _shells;
EventBus *const _bus;
@@ -1,23 +0,0 @@
#pragma once
namespace Robomongo
{
struct AggrInfo
{
AggrInfo() {}
AggrInfo(const std::string& collectionName, int skip, int batchSize,
mongo::BSONObj const& pipeline, mongo::BSONObj const& options, int resultIndex) :
collectionName(collectionName), skip(skip), batchSize(batchSize), pipeline(pipeline),
options(options), isValid(true), resultIndex(resultIndex)
{}
std::string collectionName = "";
int skip = 0;
int batchSize = 0;
mongo::BSONObj pipeline;
mongo::BSONObj options;
bool isValid = false;
int resultIndex = -1;
};
}
@@ -1,6 +1,6 @@
#include "MongoCollectionInfo.h"
#include "robomongo/core/utils/BsonUtils.h"
#include <mongo/client/dbclient_base.h>
#include <mongo/client/dbclientinterface.h>
namespace Robomongo
{
+16 -12
View File
@@ -81,35 +81,39 @@ namespace Robomongo
_bus->send(_server->worker(), new CopyCollectionToDiffServerRequest(this, server->worker(), sourceDatabase, collection, _name));
}
void MongoDatabase::createUser(const MongoUser &user)
void MongoDatabase::createUser(const MongoUser &user, bool overwrite)
{
_bus->send(_server->worker(), new CreateUserRequest(this, _name, user));
_bus->send(_server->worker(), new CreateUserRequest(this, _name, user, overwrite));
}
void MongoDatabase::dropUser(std::string const& userName)
void MongoDatabase::dropUser(const mongo::OID &id, std::string const& userName)
{
_bus->send(_server->worker(), new DropUserRequest(this, _name, userName));
_bus->send(_server->worker(), new DropUserRequest(this, _name, id, userName));
}
void MongoDatabase::createFunction(const MongoFunction &fun)
{
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, _server->version(), fun));
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, fun));
}
void MongoDatabase::updateFunction(const std::string &name, const MongoFunction &fun)
{
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, _server->version(), fun, name));
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, fun, name));
}
void MongoDatabase::dropFunction(const std::string &name)
{
_bus->send(_server->worker(), new DropFunctionRequest(this, _name, _server->version(), name));
_bus->send(_server->worker(), new DropFunctionRequest(this, _name, name));
}
void MongoDatabase::handle(LoadCollectionNamesResponse *event)
{
if (event->isError()) {
_bus->publish(new MongoDatabaseCollectionListLoadedEvent(this, event->error()));
if (_server->connectionRecord()->isReplicaSet()) // replica set
handleIfReplicaSetUnreachable(event);
else // single server
_bus->publish(new MongoDatabaseCollectionListLoadedEvent(this, event->error()));
genericEventErrorHandler(event, "Failed to refresh 'Collections'.", _bus, this);
return;
}
@@ -150,10 +154,10 @@ namespace Robomongo
void MongoDatabase::handle(LoadUsersResponse *event)
{
if (event->isError()) {
_bus->publish(new MongoDatabaseUsersLoadedEvent(this, event->error()));
if (_server->connectionRecord()->isReplicaSet()) // replica set
handleIfReplicaSetUnreachable(event);
else // single server
_bus->publish(new MongoDatabaseUsersLoadedEvent(this, event->error()));
genericEventErrorHandler(event, "Failed to refresh 'Users'.", _bus, this);
return;
@@ -166,10 +170,10 @@ namespace Robomongo
void MongoDatabase::handle(LoadFunctionsResponse *event)
{
if (event->isError()) {
_bus->publish(new MongoDatabaseFunctionsLoadedEvent(this, event->error()));
if (_server->connectionRecord()->isReplicaSet()) // replica set
handleIfReplicaSetUnreachable(event);
else // single server
_bus->publish(new MongoDatabaseFunctionsLoadedEvent(this, event->error()));
genericEventErrorHandler(event, "Failed to refresh 'Functions'.", _bus, this);
return;
+2 -2
View File
@@ -62,8 +62,8 @@ namespace Robomongo
void duplicateCollection(const std::string &collection, const std::string &newCollection);
void copyCollection(MongoServer *server, const std::string &sourceDatabase, const std::string &collection);
void createUser(const MongoUser &user);
void dropUser(std::string const& userName);
void createUser(const MongoUser &user, bool overwrite);
void dropUser(const mongo::OID &id, std::string const& userName);
void createFunction(const MongoFunction &fun);
void updateFunction(const std::string &name, const MongoFunction &fun);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "robomongo/core/domain/MongoDocument.h"
#include <mongo/client/dbclient_base.h>
#include <mongo/client/dbclientinterface.h>
#include "robomongo/core/settings/SettingsManager.h"
#include "robomongo/core/AppRegistry.h"
#include "robomongo/core/utils/BsonUtils.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "robomongo/core/domain/MongoFunction.h"
#include "robomongo/core/utils/BsonUtils.h"
#include <mongo/client/dbclient_base.h>
#include <mongo/client/dbclientinterface.h>
namespace Robomongo
{
+1 -1
View File
@@ -1,6 +1,6 @@
#include "robomongo/core/domain/MongoQueryInfo.h"
#include <mongo/client/dbclient_base.h>
#include <mongo/client/dbclientinterface.h>
namespace Robomongo
{
+9 -39
View File
@@ -13,17 +13,13 @@
#include "robomongo/core/events/MongoEventsInfo.h"
#include "robomongo/core/utils/Logger.h"
#include "robomongo/core/utils/QtUtils.h"
#include "robomongo/gui/MainWindow.h"
#include "robomongo/utils/common.h"
#include "robomongo/utils/StringOperations.h"
#include <QApplication>
#include "robomongo/utils/string_operations.h"
namespace Robomongo {
R_REGISTER_EVENT(MongoServerLoadingDatabasesEvent)
MongoServer::MongoServer(int handle, ConnectionSettings *settings, ConnectionType connectionType)
: QObject(),
MongoServer::MongoServer(int handle, ConnectionSettings *settings, ConnectionType connectionType) : QObject(),
_version(0.0f),
_connectionType(connectionType),
_worker(nullptr),
@@ -221,16 +217,6 @@ namespace Robomongo {
if (ConnectionPrimary == event->connectionType)
_bus->send(_worker, new RefreshReplicaSetFolderRequest(this, false));
}
// Save connected db version if not saved before and if this is primary connection.
QString const versionStr = QString::fromStdString(info._dbVersionStr);
auto const& settingsManager = AppRegistry::instance().settingsManager();
if (ConnectionPrimary == _connectionType &&
!settingsManager->dbVersionsConnected().contains(versionStr)) {
settingsManager->addDbVersionConnected(versionStr);
settingsManager->save();
}
}
void MongoServer::handle(RefreshReplicaSetFolderResponse *event)
@@ -247,8 +233,10 @@ namespace Robomongo {
clearDatabases();
for (auto const& dbname : event->databaseNames)
addDatabase(new MongoDatabase(this, dbname));
for (auto const& dbname : event->databaseNames) {
MongoDatabase *db = new MongoDatabase(this, dbname);
addDatabase(db);
}
_bus->publish(new DatabaseListLoadedEvent(this, _databases));
LOG_MSG("Database list refreshed. Connection: " + _connSettings->connectionName(),
@@ -258,7 +246,6 @@ namespace Robomongo {
void MongoServer::handle(InsertDocumentResponse *event)
{
if (event->isError()) {
hideProgressBar();
if (_connSettings->isReplicaSet()) {
if (ConnectionPrimary == _connectionType) { // Insert document from explorer context menu
if (EventError::SetPrimaryUnreachable == event->error().errorCode()) {
@@ -276,10 +263,11 @@ namespace Robomongo {
_bus->publish(new InsertDocumentResponse(this, event->error()));
LOG_MSG("Document inserted.", mongo::logger::LogSeverity::Info());
}
}
void MongoServer::handle(RemoveDocumentResponse *event)
{
{
if (event->removeCount == RemoveDocumentCount::MULTI && event->index > 0)
return;
@@ -292,7 +280,6 @@ namespace Robomongo {
}
if (event->isError()) {
hideProgressBar();
if (_connSettings->isReplicaSet() &&
EventError::SetPrimaryUnreachable == event->error().errorCode()) {
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
@@ -352,11 +339,6 @@ namespace Robomongo {
handleReplicaSetRefreshEvents(event->isError(), event->error(), event->replicaSet, false);
}
void MongoServer::changeWorkerShellTimeout(int newTimeout)
{
_worker->changeTimeout(newTimeout);
}
void MongoServer::handleReplicaSetRefreshEvents(bool isError, EventError eventError,
ReplicaSet const& replicaSet, bool expanded)
{
@@ -462,7 +444,7 @@ namespace Robomongo {
auto reason = ConnectionFailedEvent::SslConnection;
ss.clear();
ss << "Cannot connect to the MongoDB at " << connectionRecord()->getFullAddress()
<< ".\n\nError:\n" << "TLS connection failure: " << event->error().errorMessage();
<< ".\n\nError:\n" << "SSL connection failure: " << event->error().errorMessage();
_app->fireConnectionFailedEvent(_handle, _connectionType, ss.str(), reason);
}
else
@@ -487,16 +469,4 @@ namespace Robomongo {
}
}
void MongoServer::hideProgressBar() const
{
MainWindow* mainWindow = nullptr;
for (auto wid : QApplication::topLevelWidgets()) {
if ((mainWindow = qobject_cast<MainWindow*>(wid)))
break;
}
if(mainWindow)
mainWindow->hideQueryWidgetProgressBar();
}
} // namespace Robomongo
-3
View File
@@ -105,8 +105,6 @@ namespace Robomongo
void handle(ReplicaSetRefreshed *event);
void changeWorkerShellTimeout(int newTimeout);
protected Q_SLOTS:
void handle(EstablishConnectionResponse *event);
void handle(RefreshReplicaSetFolderResponse *event);
@@ -122,7 +120,6 @@ namespace Robomongo
bool expanded);
void updateReplicaSetSettings(EstablishConnectionResponse* event);
void handleConnectionFailure(EstablishConnectionResponse* event);
void hideProgressBar() const;
MongoWorker *_worker;
std::unique_ptr<ConnectionSettings> _connSettings;
+35 -52
View File
@@ -12,20 +12,19 @@
namespace Robomongo
{
auto const& eventBus = []() { return AppRegistry::instance().bus(); };
MongoShell::MongoShell(MongoServer *server, ScriptInfo scriptInfo) :
MongoShell::MongoShell(MongoServer *server, const ScriptInfo &scriptInfo) :
QObject(),
_scriptInfo(scriptInfo),
_server(server)
_server(server)
{
}
void MongoShell::open(const std::string &script, const std::string &dbName)
{
eventBus()->publish(new ScriptExecutingEvent(this));
AppRegistry::instance().bus()->publish(new ScriptExecutingEvent(this));
_scriptInfo.setScript(QtUtils::toQString(script));
eventBus()->send(_server->worker(), new ExecuteScriptRequest(this, query(), dbName));
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteScriptRequest(this, query(), dbName));
LOG_MSG(_scriptInfo.script(), mongo::logger::LogSeverity::Info());
}
@@ -34,36 +33,31 @@ namespace Robomongo
return QtUtils::toStdString(_scriptInfo.script());
}
void MongoShell::execute(const std::string &script /* = "" */,
const std::string &dbName /* = "" */)
void MongoShell::execute(const std::string &dbName)
{
if (!_scriptInfo.execute())
return;
std::string const finalScript = script.empty() ? query() : script;
eventBus()->publish(new ScriptExecutingEvent(this));
eventBus()->send(_server->worker(),
new ExecuteScriptRequest(this, finalScript, dbName, _aggrInfo));
if (!_scriptInfo.script().isEmpty())
LOG_MSG(_scriptInfo.script(), mongo::logger::LogSeverity::Info());
if (_scriptInfo.execute()) {
AppRegistry::instance().bus()->publish(new ScriptExecutingEvent(this));
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteScriptRequest(this, query(), dbName));
if (!_scriptInfo.script().isEmpty())
LOG_MSG(_scriptInfo.script(), mongo::logger::LogSeverity::Info());
} else {
AppRegistry::instance().bus()->publish(new ScriptExecutingEvent(this));
_scriptInfo.setScript("");
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteScriptRequest(this, query() , dbName));
}
}
void MongoShell::query(int resultIndex, const MongoQueryInfo &info)
{
eventBus()->send(_server->worker(), new ExecuteQueryRequest(this, resultIndex, info));
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteQueryRequest(this, resultIndex, info));
}
void MongoShell::autocomplete(const std::string &prefix)
{
AutocompletionMode autocompletionMode {
AppRegistry::instance().settingsManager()->autocompletionMode()
};
AutocompletionMode autocompletionMode = AppRegistry::instance().settingsManager()->autocompletionMode();
if (autocompletionMode == AutocompleteNone)
return;
eventBus()->send(_server->worker(),
new AutocompleteRequest(this, prefix, autocompletionMode)
);
AppRegistry::instance().bus()->send(_server->worker(), new AutocompleteRequest(this, prefix, autocompletionMode));
}
void MongoShell::stop()
@@ -90,50 +84,39 @@ namespace Robomongo
void MongoShell::handle(ExecuteQueryResponse *event)
{
if (event->isError()) {
eventBus()->publish(new DocumentListLoadedEvent(this, event->error()));
AppRegistry::instance().bus()->publish(new DocumentListLoadedEvent(this, event->error()));
return;
}
eventBus()->publish(
new DocumentListLoadedEvent(this,
event->resultIndex, event->queryInfo, query(), event->documents)
);
AppRegistry::instance().bus()->publish(new DocumentListLoadedEvent(this, event->resultIndex, event->queryInfo, query(), event->documents));
}
void MongoShell::handle(ExecuteScriptResponse *event)
{
if (!event->isError()) {
eventBus()->publish(
new ScriptExecutedEvent(this, event->result, event->empty, event->timeoutReached())
);
return;
if (event->isError()) {
if (_server->connectionRecord()->isReplicaSet()) {
AppRegistry::instance().bus()->publish(
new ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo()));
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->error()));
return;
}
else { // single server
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->error()));
return;
}
}
if (_server->connectionRecord()->isReplicaSet()) {
eventBus()->publish(
new ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo())
);
eventBus()->publish(
new ScriptExecutedEvent(this, event->error(), event->timeoutReached())
);
return;
}
else { // single server
eventBus()->publish(
new ScriptExecutedEvent(this, event->error(), event->timeoutReached())
);
return;
}
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->result, event->empty));
}
void MongoShell::handle(AutocompleteResponse *event)
{
if (event->isError()) {
eventBus()->publish(new AutocompleteResponse(this, event->error()));
AppRegistry::instance().bus()->publish(new AutocompleteResponse(this, event->error()));
return;
}
eventBus()->publish(new AutocompleteResponse(this, event->list, event->prefix));
AppRegistry::instance().bus()->publish(new AutocompleteResponse(this, event->list, event->prefix));
}
}
+2 -9
View File
@@ -2,18 +2,15 @@
#include <QObject>
#include "robomongo/core/events/MongoEvents.h"
#include "robomongo/core/domain/ScriptInfo.h"
#include "robomongo/core/domain/MongoAggregateInfo.h"
namespace Robomongo
{
struct AggrInfo;
class MongoShell : public QObject
{
Q_OBJECT
public:
MongoShell(MongoServer *server, ScriptInfo scriptInfo);
MongoShell(MongoServer *server, const ScriptInfo &scriptInfo);
void open(const std::string &script, const std::string &dbName = std::string());
void query(int resultIndex, const MongoQueryInfo &info);
@@ -21,14 +18,11 @@ namespace Robomongo
void stop();
MongoServer *server() const { return _server; }
std::string query() const;
void execute(const std::string &script = "", const std::string &dbName = "");
void execute(const std::string &dbName = std::string());
bool isExecutable() const { return _scriptInfo.execute(); }
const QString &title() const { return _scriptInfo.title(); }
std::string dbname() const { return _scriptInfo.dbname(); }
const CursorPosition &cursor() const { return _scriptInfo.cursor(); }
void setScript(const QString &script) { return _scriptInfo.setScript(script); }
void setScriptExecutable(bool execute) { _scriptInfo.setExecutable(execute); }
void setAggrInfo(AggrInfo const& aggrInfo) { _aggrInfo = aggrInfo; }
QString filePath() const { return _scriptInfo.filePath(); }
bool saveToFile();
@@ -42,7 +36,6 @@ namespace Robomongo
private:
ScriptInfo _scriptInfo;
AggrInfo _aggrInfo;
MongoServer *_server;
};
@@ -0,0 +1,21 @@
#include "robomongo/core/domain/MongoShellResult.h"
namespace Robomongo
{
MongoShellResult::MongoShellResult(const std::string &type, const std::string &response, const MongoDocumentPtrContainerType &documents,
const MongoQueryInfo &queryInfo, qint64 elapsedms) :
_type(type),
_response(response),
_documents(documents),
_queryInfo(queryInfo),
_elapsedms(elapsedms) { }
MongoShellExecResult::MongoShellExecResult(const std::vector<MongoShellResult> &results,
const std::string &currentServer, bool isCurrentServerValid,
const std::string &currentDatabase, bool isCurrentDatabaseValid) :
_results(results),
_currentServer(currentServer),
_currentDatabase(currentDatabase),
_isCurrentServerValid(isCurrentServerValid),
_isCurrentDatabaseValid(isCurrentDatabaseValid) { }
}
+11 -46
View File
@@ -1,76 +1,43 @@
#pragma once
#include "robomongo/core/domain/MongoQueryInfo.h"
#include "robomongo/core/domain/MongoAggregateInfo.h"
#include "robomongo/core/domain/MongoDocument.h"
namespace Robomongo
{
/* -------------- MongoShellResult Class --------- */
class MongoShellResult
{
public:
MongoShellResult(
const std::string &type, const std::string &response,
const std::vector<MongoDocumentPtr> &documents,
const MongoQueryInfo &queryInfo, const std::string &statement,
qint64 elapsedms, AggrInfo aggrInfo = AggrInfo()) :
_type(type),
_response(response),
_documents(documents),
_queryInfo(queryInfo),
_statement(statement),
_elapsedms(elapsedms),
_aggrInfo(aggrInfo)
{ }
typedef std::vector<MongoDocumentPtr> MongoDocumentPtrContainerType;
MongoShellResult(const std::string &type, const std::string &response, const MongoDocumentPtrContainerType &documents,
const MongoQueryInfo &queryInfo, qint64 elapsedms);
std::string response() const { return _response; }
std::string type() const { return _type; }
std::vector<MongoDocumentPtr> documents() const { return _documents; }
MongoDocumentPtrContainerType documents() const { return _documents; }
MongoQueryInfo queryInfo() const { return _queryInfo; }
std::string statement() const { return _statement; }
std::string statementShort() const {
std::size_t const LEN = _statement.size() < 10 ? _statement.size() : 10;
std::string statementShort { _statement, 0, LEN };
statementShort.append((_statement.size() > 10) ? ".." : "");
return statementShort;
}
qint64 elapsedMs() const { return _elapsedms; }
AggrInfo const& aggrInfo() const { return _aggrInfo; }
private:
std::string _type;
std::string _response;
std::vector<MongoDocumentPtr> _documents;
MongoDocumentPtrContainerType _documents;
MongoQueryInfo _queryInfo;
std::string const _statement;
qint64 _elapsedms;
AggrInfo _aggrInfo = AggrInfo();
};
/* -------------- MongoShellExecResult Class --------- */
class MongoShellExecResult
{
public:
MongoShellExecResult() { }
MongoShellExecResult(
const std::vector<MongoShellResult> &results,
const std::string &currentServer, bool isCurrentServerValid,
const std::string &currentDatabase, bool isCurrentDatabaseValid,
bool timeoutReached = false) :
_results(results),
_currentServer(currentServer),
_currentDatabase(currentDatabase),
_isCurrentServerValid(isCurrentServerValid),
_isCurrentDatabaseValid(isCurrentDatabaseValid),
_timeoutReached(timeoutReached)
{ }
MongoShellExecResult(const std::vector<MongoShellResult> &results,
const std::string &currentServer, bool isCurrentServerValid,
const std::string &currentDatabase, bool isCurrentDatabaseValid);
MongoShellExecResult(bool error, std::string const& errorMsg = "", bool timeoutReached = false) :
_error(error), _errorMessage(errorMsg), _timeoutReached(timeoutReached) { }
MongoShellExecResult(bool error, std::string const& errorMsg = "") :
_error(error), _errorMessage(errorMsg) { }
std::vector<MongoShellResult> const& results() const { return _results; }
std::vector<MongoShellResult> results() const { return _results; }
std::string currentServer() const { return _currentServer; }
void setCurrentServer(std::string const& server) { _currentServer = server; }
std::string currentDatabase() const { return _currentDatabase; }
@@ -78,7 +45,6 @@ namespace Robomongo
bool isCurrentDatabaseValid() const { return _isCurrentDatabaseValid; }
std::string errorMessage() const { return _errorMessage; }
bool error() const { return _error; }
bool timeoutReached() const { return _timeoutReached; }
private:
std::vector<MongoShellResult> _results;
@@ -88,6 +54,5 @@ namespace Robomongo
bool _isCurrentDatabaseValid;
std::string _errorMessage;
bool _error = false;
bool _timeoutReached = false;
};
}
+63
View File
@@ -0,0 +1,63 @@
#include "robomongo/core/domain/MongoUser.h"
#include <mongo/client/dbclientinterface.h>
#include "robomongo/core/utils/BsonUtils.h"
namespace Robomongo
{
const float MongoUser::minimumSupportedVersion = 2.4f;
MongoUser::MongoUser(const float version, const mongo::BSONObj &obj) :
_version(version), _readOnly(false)
{
_id = obj.getField("_id").OID();
_name = BsonUtils::getField<mongo::String>(obj, "user");
_passwordHash = BsonUtils::getField<mongo::String>(obj, "pwd");
if (_version<minimumSupportedVersion) {
_readOnly = BsonUtils::getField<mongo::Bool>(obj, "readOnly");
}
else {
_userSource = BsonUtils::getField<mongo::String>(obj, "userSource");
std::vector<mongo::BSONElement> roles = BsonUtils::getField<mongo::Array>(obj, "roles");
for (std::vector<mongo::BSONElement>::const_iterator it = roles.begin(); it != roles.end(); ++it)
{
_role.push_back(BsonUtils::bsonelement_cast<std::string>(*it));
}
}
}
MongoUser::MongoUser(const float version) :
_version(version), _readOnly(false), _role() {}
mongo::BSONObj MongoUser::toBson() const
{
mongo::BSONObjBuilder builder;
if (!(_id == mongo::OID())) // if not empty (i.e. not Object("0000000000000000"))
builder.append("_id", _id);
builder.append("user", _name);
if (!_passwordHash.empty())
builder.append("pwd", _passwordHash);
if (_version<minimumSupportedVersion) {
builder.append("readOnly", _readOnly);
}
else {
if (!_userSource.empty())
builder.append("userSource", _userSource);
mongo::BSONArrayBuilder builderA;
for (RoleType::const_iterator it = _role.begin(); it != _role.end(); ++it)
{
builderA << *it;
}
mongo::BSONObj arObj = builderA.arr();
builder.appendArray("roles", arObj);
}
mongo::BSONObj obj = builder.obj();
return obj;
}
}
+20 -19
View File
@@ -2,45 +2,46 @@
#include <mongo/bson/bsonobj.h>
#include <mongo/bson/bsonelement.h>
#include "robomongo/core/utils/BsonUtils.h"
namespace Robomongo
{
class MongoUser
{
public:
typedef std::vector<std::string> RolesVector;
typedef std::vector<std::string> RoleType;
/**
* @brief Creates user from "system.users" document
*/
explicit MongoUser(const float version, const mongo::BSONObj &obj);
explicit MongoUser(const float version, const mongo::BSONObj &obj) :
_version(version), _readOnly(false),
_name(BsonUtils::getField<mongo::String>(obj, "user"))
{};
// Creates new user with empty attributes
MongoUser(const float version) :
_version(version), _readOnly(false), _roles() {}
/**
* @brief Creates new user with empty attributes
*/
MongoUser(const float version);
mongo::OID id() const { return _id; }
std::string name() const { return _name; }
std::string password() const { return _password; }
std::vector<std::string> roles() const { return _roles; }
RoleType role() const { return _role; }
std::string passwordHash() const { return _passwordHash; }
void setName(const std::string &name) { _name = name; }
void setPassword(const std::string &pwd) { _password = pwd; }
void setRoles(const std::vector<std::string> &roles) { _roles = roles; }
void setRole(const RoleType &role) { _role = role; }
void setPasswordHash(const std::string &hash) { _passwordHash = hash; }
std::string userSource() const { return _userSource; }
void setUserSource(const std::string &source) { _userSource = source; }
mongo::BSONObj toBson() const;
bool readOnly() const { return _readOnly; }
void setReadOnly(bool readonly) { _readOnly = readonly; }
float version() const { return _version; }
static constexpr float minimumSupportedVersion = 2.4f;
static const float minimumSupportedVersion;
private:
float _version;
mongo::OID _id;
std::string _name;
bool _readOnly;
RolesVector _roles;
std::string _password;
RoleType _role;
std::string _passwordHash;
std::string _userSource;
};
}
}
+13 -32
View File
@@ -1,8 +1,5 @@
#include "robomongo/core/domain/Notifier.h"
#include <thread>
#include <chrono>
#include <QAction>
#include <QClipboard>
#include <QApplication>
@@ -18,7 +15,6 @@
#include "robomongo/shell/db/ptimeutil.h"
#include "robomongo/gui/MainWindow.h"
#include "robomongo/gui/widgets/workarea/BsonTreeItem.h"
#include "robomongo/gui/dialogs/DocumentTextEditor.h"
#include "robomongo/gui/utils/DialogUtils.h"
@@ -142,9 +138,8 @@ namespace Robomongo
void Notifier::initMenu(QMenu *const menu, BsonTreeItem *const item)
{
bool const isProjection = !_queryInfo._fields.isEmpty();
bool const isEditable = _queryInfo._info.isValid() && !isProjection;
bool const onItem = item ? true : false;
bool isEditable = _queryInfo._info.isValid();
bool onItem = item ? true : false;
bool isSimple = false;
bool isDocument = false;
@@ -225,14 +220,12 @@ namespace Robomongo
RemoveDocumentCount::MULTI;
_shell->server()->removeDocuments(query, _queryInfo._info._ns, removeCount, index);
++index;
mainWindow()->showQueryWidgetProgressBar();
}
}
void Notifier::handle(InsertDocumentResponse *event)
{
if (event->isError()) { // Error
mainWindow()->hideQueryWidgetProgressBar();
if (_shell->server()->connectionRecord()->isReplicaSet()) {
// Insert document from tab results window (Notifier, OutputWindow widget)
if (EventError::SetPrimaryUnreachable == event->error().errorCode()) {
@@ -242,12 +235,11 @@ namespace Robomongo
}
else // single server
QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
return;
}
// Success
std::this_thread::sleep_for(std::chrono::milliseconds(100));
_shell->query(0, _queryInfo);
}
@@ -257,10 +249,8 @@ namespace Robomongo
if (!(event->removeCount == RemoveDocumentCount::MULTI && event->index > 0))
QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
}
else { // Success
std::this_thread::sleep_for(std::chrono::milliseconds(100));
_shell->query(0, _queryInfo);
}
else // Success
_shell->query(0, _queryInfo);
}
void Notifier::onCopyNameDocument()
@@ -310,16 +300,6 @@ namespace Robomongo
clipboard->setText(namesList.join("."));
}
MainWindow* Notifier::mainWindow() const
{
MainWindow* mainWindow;
for (auto wid : QApplication::topLevelWidgets()) {
if ((mainWindow = qobject_cast<MainWindow*>(wid)))
break;
}
return mainWindow;
}
void Notifier::handleDeleteCommand()
{
if (_observer->selectedIndexes().count() > 1)
@@ -378,20 +358,22 @@ namespace Robomongo
if (!documentItem)
return;
std::string str = BsonUtils::jsonString(documentItem->superRoot(), mongo::TenGen, 1,
AppRegistry::instance().settingsManager()->uuidEncoding(),
AppRegistry::instance().settingsManager()->timeZone());
mongo::BSONObj obj = documentItem->superRoot();
std::string str = BsonUtils::jsonString(obj, mongo::TenGen, 1,
AppRegistry::instance().settingsManager()->uuidEncoding(),
AppRegistry::instance().settingsManager()->timeZone());
const QString &json = QtUtils::toQString(str);
DocumentTextEditor editor(_queryInfo._info, json, false, dynamic_cast<QWidget*>(_observer));
DocumentTextEditor editor(_queryInfo._info,
json, false, dynamic_cast<QWidget*>(_observer));
editor.setWindowTitle("Edit Document");
int result = editor.exec();
if (result == QDialog::Accepted) {
_shell->server()->saveDocuments(editor.bsonObj(), _queryInfo._info._ns);
mainWindow()->showQueryWidgetProgressBar();
}
}
@@ -417,7 +399,7 @@ namespace Robomongo
json, true, dynamic_cast<QWidget*>(_observer));
editor->setWindowTitle("View Document");
editor->show();
editor->exec();
}
void Notifier::onInsertDocument()
@@ -438,7 +420,6 @@ namespace Robomongo
DocumentTextEditor::ReturnType obj = editor.bsonObj();
for (DocumentTextEditor::ReturnType::const_iterator it = obj.begin(); it != obj.end(); ++it) {
_shell->server()->insertDocument(*it, _queryInfo._info._ns);
mainWindow()->showQueryWidgetProgressBar();
}
}
-3
View File
@@ -11,7 +11,6 @@ QT_END_NAMESPACE
namespace Robomongo
{
class MainWindow;
class MongoShell;
class BsonTreeItem;
class InsertDocumentResponse;
@@ -66,8 +65,6 @@ namespace Robomongo
void onCopyPathDocument();
private:
MainWindow* mainWindow() const;
QAction *_deleteDocumentAction;
QAction *_deleteDocumentsAction;
QAction *_editDocumentAction;
+2 -3
View File
@@ -62,11 +62,10 @@ namespace
namespace Robomongo
{
ScriptInfo::ScriptInfo(const QString &script, bool execute, const std::string &dbname,
const CursorPosition &position, const QString &title, const QString &filePath) :
ScriptInfo::ScriptInfo(const QString &script, bool execute, const CursorPosition &position,
const QString &title, const QString &filePath) :
_script(script),
_execute(execute),
_dbname(dbname),
_title(title),
_cursor(position),
_filePath(filePath) {}
+2 -5
View File
@@ -9,14 +9,12 @@ namespace Robomongo
class ScriptInfo
{
public:
ScriptInfo(const QString &script, bool execute = false, const std::string &dbname = "",
ScriptInfo(const QString &script, bool execute = false,
const CursorPosition &position = CursorPosition(),
const QString &title = QString(), const QString &filePath = QString());
bool execute() const { return _execute; }
void setExecutable(bool execute) { _execute = execute; }
QString script() const { return _script; }
std::string dbname() const { return _dbname; }
const QString &title() const { return _title; }
const CursorPosition &cursor() const { return _cursor; }
void setScript(const QString &script) { _script = script; }
@@ -28,8 +26,7 @@ namespace Robomongo
private:
QString _script;
std::string _dbname;
bool _execute;
const bool _execute;
const QString _title;
const CursorPosition _cursor;
QString _filePath;
+58 -106
View File
@@ -15,7 +15,6 @@
//#include <third_party/js-1.7/jsstr.h>
#include <mongo/util/assert_util.h>
#include <mongo/util/exit_code.h>
#include <mongo/scripting/engine.h>
// v0.9
@@ -24,14 +23,12 @@
#include <mongo/shell/shell_utils.h>
#include <mongo/base/string_data.h>
#include <mongo/client/dbclient_base.h>
#include <mongo/client/dbclientinterface.h>
#include <pcrecpp.h>
#include "robomongo/core/events/MongoEvents.h"
#include "robomongo/core/settings/ConnectionSettings.h"
#include "robomongo/core/settings/CredentialSettings.h"
#include "robomongo/core/domain/MongoDocument.h"
#include "robomongo/core/utils/Logger.h"
#include "robomongo/core/utils/QtUtils.h"
namespace
@@ -53,6 +50,7 @@ namespace
namespace mongo {
extern bool isShell;
void logProcessDetailsForLogRotate() {}
void exitCleanly(ExitCode code) {}
}
namespace Robomongo
@@ -93,18 +91,19 @@ namespace Robomongo
<< _connection->primaryCredential()->userPassword() << "')";
{
mongo::shell_utils::dbConnect = ss.str();
mongo::shell_utils::_dbConnect = ss.str();
mongo::shell_utils::_dbAuth = "(function() { \nDB.prototype._defaultGssapiServiceName = \"mongodb\";\n}())";
// v0.9
// mongo::isShell = true;
mongo::ScriptEngine::setConnectCallback( mongo::shell_utils::onConnect );
mongo::ScriptEngine::setup();
mongo::getGlobalScriptEngine()->setScopeInitCallback(mongo::shell_utils::initScope);
mongo::getGlobalScriptEngine()->enableJIT(true);
mongo::ScriptEngine::setup();
mongo::globalScriptEngine->setScopeInitCallback(mongo::shell_utils::initScope);
mongo::globalScriptEngine->enableJIT(true);
_scope.reset(mongo::getGlobalScriptEngine()->newScope());
_engine = mongo::getGlobalScriptEngine();
_scope.reset(mongo::globalScriptEngine->newScope());
_engine = mongo::globalScriptEngine;
// Load '.mongorc.js' from user's home directory
if (isLoadMongoRcJs) {
@@ -138,7 +137,7 @@ namespace Robomongo
// Cache result of original "DB.autocomplete"
// Cache invalidated by the invalidateDbCollectionsCache() method.
std::string const cacheAutocompletion =
std::string cacheAutocompletion =
"__robomongoAutocompletionCache = null;"
"DB.autocompleteCached = function(obj) { "
" if (__robomongoAutocompletionCache == null) {"
@@ -149,26 +148,10 @@ namespace Robomongo
_scope->exec(cacheAutocompletion, "", false, false, false);
// Capture aggregate parameters: pipeline, options
std::string const aggregateInterceptor =
"__robomongoAggregateUsed = false;"
"__robomongoAggregate = DBCollection.prototype.aggregate;"
"__robomongoAggregatePipeline = null;"
"__robomongoAggregateOptions = null;"
"DBCollection.prototype.aggregate = function(pipeline, options) { "
" __robomongoAggregateUsed = true;"
" __robomongoAggregatePipeline = pipeline;"
" __robomongoAggregateOptions = options;"
" return __robomongoAggregate.call(this, pipeline, options);"
"}";
_scope->exec(aggregateInterceptor, "", false, false, false);
_initialized = true;
}
MongoShellExecResult ScriptEngine::exec(const std::string &originalScript, const std::string &dbName,
AggrInfo aggrInfo /* = AggrInfo() */)
MongoShellExecResult ScriptEngine::exec(const std::string &originalScript, const std::string &dbName)
{
QMutexLocker lock(&_mutex);
@@ -177,9 +160,6 @@ namespace Robomongo
return MongoShellExecResult(true, "Connection error. Uninitialized mongo scope.");
}
// robomongo shell timeout
bool timeoutReached = false;
/*
* Replace all commands ('show dbs', 'use db' etc.) with call
* to shellHelper('show', 'dbs') and so on.
@@ -199,14 +179,17 @@ namespace Robomongo
std::string error;
bool result = statementize(stdstr, statements, error);
if (!result && statements.size() == 0)
if (!result && statements.size() == 0) {
statements.push_back("print(__robomongoResult.error)");
}
std::vector<MongoShellResult> results;
use(dbName);
for (auto const& statement : statements) {
for (std::vector<std::string>::const_iterator it = statements.begin(); it != statements.end(); ++it)
{
std::string statement = *it;
// clear global objects
__objects.clear();
__type = "";
@@ -222,27 +205,23 @@ namespace Robomongo
_scope->exec( "__robomongoLastRes = __lastres__; shellPrintHelper( __lastres__ );",
"(shell2)" , true , true , false, _timeoutSec * 1000);
}
else // failed to run script
failed = true;
else { // failed to run script
failed = true;
}
qint64 elapsed = timer.elapsed(); // milliseconds
if (elapsed > _timeoutSec * 1000)
timeoutReached = true;
qint64 elapsed = timer.elapsed();
std::string logs = __logs.str();
std::string answer = logs.c_str();
std::string type = __type.c_str();
if (failed && !timeoutReached)
if (failed)
return MongoShellExecResult(true, answer);
std::vector<MongoDocumentPtr> docs = MongoDocument::fromBsonObj(__objects);
if (!answer.empty() || docs.size() > 0)
results.push_back(
prepareResult(type, answer, docs, elapsed, statement, aggrInfo)
);
results.push_back(prepareResult(type, answer, docs, elapsed));
}
catch (const std::exception &e) {
std::cout << "error:" << e.what() << std::endl;
@@ -250,7 +229,7 @@ namespace Robomongo
}
}
return prepareExecResult(results, timeoutReached);
return prepareExecResult(results);
}
void ScriptEngine::interrupt()
@@ -332,17 +311,14 @@ namespace Robomongo
}
MongoShellResult ScriptEngine::prepareResult(const std::string &type, const std::string &output,
const std::vector<MongoDocumentPtr> &objects, qint64 elapsedms,
const std::string &statement, AggrInfo aggrInfo /*= AggrInfo()*/)
const std::vector<MongoDocumentPtr> &objects, qint64 elapsedms)
{
const char *script =
"__robomongoQuery = false; \n"
"__robomongoIsAggregate = false; \n"
"__robomongoDbName = '[invalid database]'; \n"
"__robomongoServerAddress = '[invalid connection]'; \n"
"__robomongoCollectionName = '[invalid collection]'; \n"
"if (typeof __robomongoLastRes == 'object' && __robomongoLastRes != null \n"
" && __robomongoLastRes instanceof DBQuery) { \n"
"if (typeof __robomongoLastRes == 'object' && __robomongoLastRes != null && __robomongoLastRes instanceof DBQuery) { \n"
" __robomongoQuery = true; \n"
" __robomongoDbName = __robomongoLastRes._db.getName();\n "
" __robomongoServerAddress = __robomongoLastRes._mongo.host; \n"
@@ -354,27 +330,16 @@ namespace Robomongo
" __robomongoBatchSize = __robomongoLastRes._batchSize; \n"
" __robomongoOptions = __robomongoLastRes._options; \n"
" __robomongoSpecial = __robomongoLastRes._special; \n"
"} \n"
"else if (typeof __robomongoLastRes == 'object' && __robomongoLastRes != null \n"
" && __robomongoLastRes instanceof DBCommandCursor \n"
" && __robomongoAggregateUsed) { \n"
" __robomongoAggregateUsed = false; \n"
" __robomongoIsAggregate = true; \n"
" __robomongoDbName = __robomongoLastRes._db.getName();\n "
" __robomongoServerAddress = __robomongoLastRes._db._mongo.host; \n"
" __robomongoCollectionName = __robomongoLastRes._collName; \n"
"} \n"
;
"} \n";
_scope->exec(script, "(getresultinfo)", false, false, false);
bool const isQuery = _scope->getBoolean("__robomongoQuery");
bool const isAggregate = _scope->getBoolean("__robomongoIsAggregate");
bool isQuery = _scope->getBoolean("__robomongoQuery");
if (isQuery) {
std::string serverAddress = getString("__robomongoServerAddress");
std::string dbName = getString("__robomongoDbName");
std::string collectionName = getString("__robomongoCollectionName");
mongo::BSONObj query = _scope->getObject("__robomongoQuery");
mongo::BSONObj fields = _scope->getObject("__robomongoFields");
@@ -385,32 +350,15 @@ namespace Robomongo
bool special = _scope->getBoolean("__robomongoSpecial");
MongoQueryInfo const info{ CollectionInfo(serverAddress, dbName, collectionName),
query, fields, limit, skip, batchSize, options, special };
return MongoShellResult(type, output, objects, info, statement, elapsedms);
MongoQueryInfo info = MongoQueryInfo(CollectionInfo(serverAddress, dbName, collectionName),
query, fields, limit, skip, batchSize, options, special);
return MongoShellResult(type, output, objects, info, elapsedms);
}
else if (isAggregate) {
std::string const serverAddress = getString("__robomongoServerAddress");
std::string const dbName = getString("__robomongoDbName");
std::string const collectionName = getString("__robomongoCollectionName");
mongo::BSONObj const pipeline = _scope->getObject("__robomongoAggregatePipeline");
mongo::BSONObj const options = _scope->getObject("__robomongoAggregateOptions");
// This query can be paging of an original aggr. query, we store the original/unpaged
// pipeline object here.
mongo::BSONObj const origPipeline = aggrInfo.isValid ? aggrInfo.pipeline : pipeline;
int const skip = aggrInfo.isValid ? aggrInfo.skip : 0;
int const batchSize = aggrInfo.isValid ? aggrInfo.batchSize : 50;
int const resultIndex = aggrInfo.isValid ? aggrInfo.resultIndex : -1;
AggrInfo const newAggrInfo { collectionName, skip, batchSize, origPipeline, options, resultIndex };
return MongoShellResult(type, output, objects, MongoQueryInfo(), statement, elapsedms, newAggrInfo);
}
return MongoShellResult(type, output, objects, MongoQueryInfo(), statement, elapsedms);
return MongoShellResult(type, output, objects, MongoQueryInfo(), elapsedms);
}
MongoShellExecResult ScriptEngine::prepareExecResult(const std::vector<MongoShellResult> &results,
bool timeoutReached /* = false */)
MongoShellExecResult ScriptEngine::prepareExecResult(const std::vector<MongoShellResult> &results)
{
const char *script =
"__robomongoServerAddress = '[invalid connection]'; \n"
@@ -432,7 +380,7 @@ namespace Robomongo
std::string dbName = getString("__robomongoDbName");
bool dbIsValid = _scope->getBoolean("__robomongoDbIsValid");
return MongoShellExecResult(results, serverName, serverIsValid, dbName, dbIsValid, timeoutReached);
return MongoShellExecResult(results, serverName, serverIsValid, dbName, dbIsValid);
}
std::string ScriptEngine::getString(const char *fieldName)
@@ -440,12 +388,12 @@ namespace Robomongo
return _scope->getString(fieldName);
}
bool ScriptEngine::statementize(
const std::string &script, std::vector<std::string> &outVec, std::string &outError)
bool ScriptEngine::statementize(const std::string &script, std::vector<std::string> &outList, std::string &outError)
{
QString qScript = QtUtils::toQString(script);
_scope->setString("__robomongoEsprima", script.c_str());
mongo::StringData const data {
mongo::StringData data(
"var __robomongoResult = {};"
"try {"
"__robomongoResult.result = esprima.parse(__robomongoEsprima, { range: true, loc : true });"
@@ -453,31 +401,36 @@ namespace Robomongo
"__robomongoResult.error = e.name + ': ' + e.message;"
"}"
"__robomongoResult;"
};
);
if(!_scope->exec(data, "(esprima2)", false, true, false)) {
sendLog(this, LogEvent::RBM_ERROR, "ScriptEngine: Scope failed. Resetting scope.");
_scope->reset();
sendLog(this, LogEvent::RBM_INFO, "ScriptEngine: Scope reset complete.");
_scope->exec(data, "(esprima2)", false, true, false);
}
bool res2 = _scope->exec(data, "(esprima2)", false, true, false);
mongo::BSONObj obj = _scope->getObject("__lastres__");
mongo::BSONObj const obj = _scope->getObject("__lastres__");
if (obj.hasField("error")) {
outError = obj.getField("error");
return false;
}
for (auto const& bsonElem : obj.getField("result").Obj().getField("body").Array())
mongo::BSONObj result = obj.getField("result").Obj();
std::vector<mongo::BSONElement> v = result.getField("body").Array();
for (std::vector<mongo::BSONElement>::iterator it = v.begin(); it != v.end(); ++it)
{
mongo::BSONObj const item = bsonElem.Obj();
std::vector<mongo::BSONElement> const range = item.getField("range").Array();
auto const from = static_cast<int>(range.at(0).number());
auto const till = static_cast<int>(range.at(1).number());
mongo::BSONObj item = (*it).Obj();
mongo::BSONObj loc = item.getField("loc").Obj();
mongo::BSONObj start = loc.getField("start").Obj();
mongo::BSONObj end = loc.getField("end").Obj();
QString const qScript = QtUtils::toQString(script);
std::string statement = qScript.mid(from, till - from).toStdString();
outVec.push_back(statement);
int startLine = start.getIntField("line");
int startColumn = start.getIntField("column");
int endLine = end.getIntField("line");
int endColumn = end.getIntField("column");
std::vector<mongo::BSONElement> range = item.getField("range").Array();
int from = (int) range.at(0).number();
int till = (int) range.at(1).number();
std::string statement = QtUtils::toStdString(qScript.mid(from, till - from));
outList.push_back(statement);
}
return true;
@@ -504,4 +457,3 @@ namespace Robomongo
return QtUtils::toStdString(content);
}
}
+8 -17
View File
@@ -1,6 +1,5 @@
#pragma once
#include <QObject>
#include <QMutex>
#include <mongo/scripting/engine.h>
//#include <third_party/js-1.7/jsparse.h>
@@ -12,17 +11,15 @@ namespace Robomongo
{
class ConnectionSettings;
class ScriptEngine : public QObject
class ScriptEngine
{
Q_OBJECT
public:
ScriptEngine(ConnectionSettings *connection, int timeoutSec);
~ScriptEngine();
void init(bool isLoadMongoJs, const std::string& serverAddr = "", const std::string& dbName = "");
MongoShellExecResult exec(const std::string &script, const std::string &dbName = std::string(),
AggrInfo aggrInfo = AggrInfo());
MongoShellExecResult exec(const std::string &script, const std::string &dbName = std::string());
void interrupt();
void use(const std::string &dbName);
@@ -34,26 +31,20 @@ namespace Robomongo
bool failedScope() const { return _failedScope; }
void changeTimeout(int newTimeout) { _timeoutSec = newTimeout; }
private:
ConnectionSettings *_connection;
MongoShellResult prepareResult(const std::string &type, const std::string &output,
const std::vector<MongoDocumentPtr> &objects, qint64 elapsedms,
const std::string &statement, AggrInfo aggrInfo = AggrInfo());
MongoShellExecResult prepareExecResult(
const std::vector<MongoShellResult> &results, bool timeoutReached = false);
MongoShellResult prepareResult(const std::string &type, const std::string &output, const std::vector<MongoDocumentPtr> &objects, qint64 elapsedms);
MongoShellExecResult prepareExecResult(const std::vector<MongoShellResult> &results);
std::string loadFile(const QString &path, bool throwOnError);
std::string getString(const char *fieldName);
bool statementize(
const std::string &script, std::vector<std::string> &outVec, std::string &outError);
bool statementize(const std::string &script, std::vector<std::string> &outList, std::string &outError);
int _timeoutSec;
mongo::ScriptEngine *_engine;
std::unique_ptr<mongo::Scope> _scope; // MozJSProxyScope
std::unique_ptr<mongo::Scope> _scope;
bool _failedScope = false;
QMutex _mutex;
bool _initialized;

Some files were not shown because too many files have changed in this diff Show More