Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93c6b0276 | ||
|
|
36dbc07baf | ||
|
|
ff5d70590b | ||
|
|
388075378f | ||
|
|
82612e5cd4 | ||
|
|
b03527a7ad | ||
|
|
01633ee08e | ||
|
|
b9b454be9c | ||
|
|
2d021c80d3 | ||
|
|
0a1819eec2 | ||
|
|
90f6794e7d | ||
|
|
92d2e9e031 | ||
|
|
c5d88c244d | ||
|
|
0fcc30e22b | ||
|
|
e31414b610 | ||
|
|
744d693d90 | ||
|
|
d62d1f46e4 | ||
|
|
615c370e51 | ||
|
|
bc8bb0b03a | ||
|
|
700967baca | ||
|
|
70ad4a7035 | ||
|
|
4f29fd3790 | ||
|
|
5785ee2bc2 | ||
|
|
0584da0611 | ||
|
|
164fdeeb92 | ||
|
|
5d97f9db15 | ||
|
|
968a4fe04b | ||
|
|
e2c5b44408 | ||
|
|
5bcb75019a | ||
|
|
1733a525e0 | ||
|
|
fba5585f77 | ||
|
|
e1227bf0f8 | ||
|
|
5349d34513 | ||
|
|
465599701c | ||
|
|
e91c13cbf8 | ||
|
|
604d89c2c6 | ||
|
|
19f42ecfd1 | ||
|
|
0d55c20c26 | ||
|
|
26d4b91251 | ||
|
|
6836254234 | ||
|
|
5162291f9d | ||
|
|
44e3e0f3d6 | ||
|
|
5ae9f76629 | ||
|
|
a9ec2c1b6d | ||
|
|
4ccbbced54 | ||
|
|
da62ca474b | ||
|
|
e02696d47d | ||
|
|
6dc29b910c | ||
|
|
7e76d29ddf | ||
|
|
0bad62dfd4 | ||
|
|
98807b0487 | ||
|
|
78deee7ca2 | ||
|
|
a5ccfebff5 | ||
|
|
b39b945a6e | ||
|
|
18951047eb | ||
|
|
1124ec22c6 | ||
|
|
ab367fc890 | ||
|
|
22c632794f | ||
|
|
0fefd6d443 | ||
|
|
89f24ea07c | ||
|
|
d2a11bc0f2 | ||
|
|
575455b10e | ||
|
|
e858c68fa6 | ||
|
|
2df26740c6 | ||
|
|
39209ee2b8 | ||
|
|
3e9cd11aa3 | ||
|
|
f91b2c4a2f | ||
|
|
a2b1a07a4f | ||
|
|
82b5f434f9 | ||
|
|
a55b7398da | ||
|
|
d9b37b2094 | ||
|
|
230c5f37bc | ||
|
|
561bdbf2b4 | ||
|
|
0bafec7ce5 | ||
|
|
34dca72a09 | ||
|
|
428b576acf | ||
|
|
f26a08d9bc | ||
|
|
92ae9affd6 | ||
|
|
d52cd2e0c0 | ||
|
|
e11cbd1a26 | ||
|
|
4e58a6a6b4 | ||
|
|
e01de676fa | ||
|
|
9e43802e2a | ||
|
|
f02f4f6116 | ||
|
|
306689f30d | ||
|
|
43bf28968b | ||
|
|
df6e9a57d8 | ||
|
|
cbcafd28c9 | ||
|
|
4f181ec460 | ||
|
|
a72583df76 | ||
|
|
8f508e5e0f | ||
|
|
536f75fdb4 | ||
|
|
f37a070eda | ||
|
|
51c1267bf4 | ||
|
|
6a0b972aac | ||
|
|
94168f02ca | ||
|
|
88c8dfa26e | ||
|
|
c8050f0edd | ||
|
|
e3d90e63e8 | ||
|
|
ec20a3e4c9 | ||
|
|
83bac6b8aa | ||
|
|
34025743a1 | ||
|
|
ff02a303c7 | ||
|
|
4552576fa3 | ||
|
|
cc2c834359 | ||
|
|
b746aeb729 | ||
|
|
686fc08cef | ||
|
|
9d74aae3f5 | ||
|
|
b3fd99eb1b | ||
|
|
bf111c97f1 | ||
|
|
ac8d4cf899 | ||
|
|
04bd7fbffa | ||
|
|
8167e8d944 | ||
|
|
6c3174599a | ||
|
|
76aca637e8 | ||
|
|
832d843ea1 | ||
|
|
9aa702efcd | ||
|
|
cde6d9eaae | ||
|
|
91db033e3a | ||
|
|
7d6c0af7e7 | ||
|
|
d0c2345044 | ||
|
|
51c4b93bc7 | ||
|
|
242acbcd9d | ||
|
|
3079801e0f | ||
|
|
fdc02400b9 | ||
|
|
499b0da006 | ||
|
|
a7caf02ec6 | ||
|
|
70b819700d | ||
|
|
b1aca90888 | ||
|
|
73ccc5d3ad | ||
|
|
47d3fd7db9 | ||
|
|
56d2d7cb12 | ||
|
|
ac3c078141 | ||
|
|
0110a0df8d | ||
|
|
c1d6b51075 | ||
|
|
bc6c6a36da | ||
|
|
806d76d9a2 | ||
|
|
a0a476b57d | ||
|
|
d5dd24fa51 | ||
|
|
42561be37e | ||
|
|
c2fdee9cf8 | ||
|
|
9972ee4113 | ||
|
|
846b0ce9fd | ||
|
|
fe78fe4416 | ||
|
|
54d03ae788 | ||
|
|
55f895a7f5 | ||
|
|
22b557605b | ||
|
|
16ed6e844a | ||
|
|
d96b3de97a | ||
|
|
bd0436ffa0 | ||
|
|
496f5c256f | ||
|
|
6617d07e1e | ||
|
|
99837f0b8f | ||
|
|
6ed27b7b83 | ||
|
|
3247fd77d6 | ||
|
|
f9b9679b5e | ||
|
|
685d264ab7 | ||
|
|
2355f0cb54 | ||
|
|
68674fb1c2 | ||
|
|
0e1a942ecd | ||
|
|
d01ce11e47 | ||
|
|
eee9e1cbd4 | ||
|
|
54e2da3dc4 | ||
|
|
6887850eae | ||
|
|
ab16885112 | ||
|
|
5f3ff06403 | ||
|
|
81f872fdaf | ||
|
|
0ec739a2b7 | ||
|
|
752bc51452 | ||
|
|
3a23c62070 | ||
|
|
4512b4c998 | ||
|
|
684d2abcdc | ||
|
|
db3eb8872c | ||
|
|
885f388201 | ||
|
|
9431f7f2a8 | ||
|
|
f7752fd2b7 | ||
|
|
e4b2c2262e | ||
|
|
9a31b6259d | ||
|
|
995abe9401 | ||
|
|
a13b39907b | ||
|
|
c64fec22ee | ||
|
|
dd1d835dfe | ||
|
|
5a78becc6f | ||
|
|
f598e62d1c | ||
|
|
b8ae4d0fc5 | ||
|
|
5403c16f48 | ||
|
|
3d162032f4 | ||
|
|
c591a7a91e | ||
|
|
fd2c476ae5 | ||
|
|
42bf58a0b5 | ||
|
|
4d09e1b5a5 | ||
|
|
d825b065f2 | ||
|
|
13428b5ed6 | ||
|
|
521d1789bc | ||
|
|
f64257ae86 | ||
|
|
d228ca1c4b | ||
|
|
690f21e9ae | ||
|
|
743710a9f0 | ||
|
|
ba29971e20 | ||
|
|
f49e492a92 | ||
|
|
1c62abaec0 | ||
|
|
1940a03a61 | ||
|
|
9bee2f443f | ||
|
|
1cf331f83c | ||
|
|
685b835886 | ||
|
|
ab2494a6ba | ||
|
|
3ae0d61bd5 | ||
|
|
f4e11b623f | ||
|
|
938479e43f | ||
|
|
31ec650659 | ||
|
|
87c13ff74a | ||
|
|
2c820daae4 | ||
|
|
3b0cdc0caa | ||
|
|
85570dd61d | ||
|
|
400d3670be | ||
|
|
45c93a7f3e | ||
|
|
6ca3f492fe | ||
|
|
dee3768d34 | ||
|
|
d2570f9c44 | ||
|
|
a630fa9f98 | ||
|
|
875d4248f5 | ||
|
|
9523ff2472 | ||
|
|
cf92bda8db | ||
|
|
c73b5ed7dc | ||
|
|
ceb32f63ad | ||
|
|
4065193dd8 | ||
|
|
b4d7ae2d3e | ||
|
|
140dce8dd2 | ||
|
|
e80fd77299 | ||
|
|
7e552a4db0 | ||
|
|
7d28eec8d0 | ||
|
|
c29f8bf2f4 | ||
|
|
f76433729c | ||
|
|
db630fc549 | ||
|
|
4eb13e84cc | ||
|
|
16b8c8efea | ||
|
|
9b2c72e4a2 | ||
|
|
b3b9c52144 | ||
|
|
4bc319e0bb | ||
|
|
50071a2980 | ||
|
|
2036ce4ba1 | ||
|
|
f2624fea03 | ||
|
|
950bc3daaa | ||
|
|
39b6779a8c | ||
|
|
743486d88b | ||
|
|
50b0e90495 | ||
|
|
a8b049686a | ||
|
|
23f133dbbe | ||
|
|
b033375491 | ||
|
|
ca4060473d | ||
|
|
472b6a8c46 | ||
|
|
0947bac63c | ||
|
|
1a414a2723 | ||
|
|
d7bbf37cbb | ||
|
|
6063ff90eb | ||
|
|
20dd2eb564 | ||
|
|
4a80853be6 | ||
|
|
b6cd30e22d | ||
|
|
ea59ca59d3 | ||
|
|
c67d8a942b | ||
|
|
244d94b17d | ||
|
|
b05b348198 | ||
|
|
38a8595d15 | ||
|
|
f2226c92b3 | ||
|
|
466709df23 | ||
|
|
702459918b | ||
|
|
4efbd8b90a | ||
|
|
655bfcba0a | ||
|
|
041356ebac | ||
|
|
32e9ceb741 | ||
|
|
1aeb0e42dc | ||
|
|
9c419b1f2e | ||
|
|
0786489924 | ||
|
|
2835aa1685 | ||
|
|
9cc34df185 | ||
|
|
d5adcdf988 | ||
|
|
837c0e1a17 | ||
|
|
d458f43b63 | ||
|
|
1cfb1b6287 | ||
|
|
6f5124616a | ||
|
|
3ba2f8ae93 | ||
|
|
b6d87141f2 | ||
|
|
993e9355bb | ||
|
|
be655902b4 | ||
|
|
f9332befb3 | ||
|
|
66728df978 | ||
|
|
60dc85c2fc | ||
|
|
4b4eb623b9 | ||
|
|
d2c98bf559 | ||
|
|
9a31503996 | ||
|
|
cb4622f61f | ||
|
|
1ce1091eca | ||
|
|
4546eef1e3 | ||
|
|
1d8f24ced2 | ||
|
|
19a61ba517 | ||
|
|
2b377e35f1 | ||
|
|
f5011630a3 | ||
|
|
8967a84f12 | ||
|
|
38bed5e4eb | ||
|
|
5370ecedd8 | ||
|
|
0e8cd5cefc | ||
|
|
e3c3649b0f | ||
|
|
19f953fa54 | ||
|
|
ad1b5e35c7 | ||
|
|
ff2eb0fef6 | ||
|
|
d356c14f87 | ||
|
|
829cbf890b | ||
|
|
5ae52d4b4f | ||
|
|
4608c6b7ee | ||
|
|
7c7a818ca0 | ||
|
|
08c6d44185 | ||
|
|
dc8495b147 | ||
|
|
e2f5765a87 | ||
|
|
7ebc059430 | ||
|
|
0d3fda185f | ||
|
|
38df06261b | ||
|
|
0086df54f0 | ||
|
|
ddc0c910c8 | ||
|
|
31f74baef7 | ||
|
|
8cd4f50304 | ||
|
|
48f6abb361 | ||
|
|
27626665a1 | ||
|
|
47039d8685 | ||
|
|
bc9aded3b7 | ||
|
|
f919544d1e | ||
|
|
ea49d0508a | ||
|
|
894f508f6c | ||
|
|
2f2d3d584e | ||
|
|
67ae8a614d | ||
|
|
cbba0e639d | ||
|
|
8f3fdf3d1d | ||
|
|
650fdd60cc | ||
|
|
8b114b5122 | ||
|
|
bc96addce5 | ||
|
|
bac2c9d5ec | ||
|
|
94e0c37cf8 | ||
|
|
42d6181724 | ||
|
|
4c5f2e99cb | ||
|
|
95e2fef4a6 | ||
|
|
4d8e3e61a1 | ||
|
|
c227798a4b | ||
|
|
fc5a6b9ac6 | ||
|
|
b820f17b3c | ||
|
|
079ec51dac | ||
|
|
88dee956f2 | ||
|
|
53945eb095 | ||
|
|
578447ecc3 | ||
|
|
0cecad49b3 | ||
|
|
652df93690 | ||
|
|
efa81c11c5 | ||
|
|
4af070b5b8 | ||
|
|
95faf9332e | ||
|
|
7e87befd3d | ||
|
|
d6155f4c35 | ||
|
|
33c89eac63 | ||
|
|
335adc6bdb | ||
|
|
a107084745 | ||
|
|
67f60b19ea | ||
|
|
734b17d0e7 | ||
|
|
7739c92064 | ||
|
|
0ae5f12024 | ||
|
|
e05dd9d1e9 | ||
|
|
ecbbeaeeca | ||
|
|
ea164e82a7 | ||
|
|
bfa1e68ce0 | ||
|
|
dc010092ab | ||
|
|
82c6bd6452 | ||
|
|
49a1251091 | ||
|
|
97ffad1178 | ||
|
|
592883af29 | ||
|
|
51a38c5607 | ||
|
|
5a645015a2 | ||
|
|
064094489f | ||
|
|
218310c23c | ||
|
|
7c48a9e28d | ||
|
|
8ecffcbddb | ||
|
|
c31f8d8275 | ||
|
|
6db3fe11b9 | ||
|
|
ae7735f6bd | ||
|
|
22dc364f7e | ||
|
|
f11f22f6bb | ||
|
|
2e07f1a9cb | ||
|
|
62bc7e5ff7 | ||
|
|
6b9dd95b26 | ||
|
|
0f3fd3ace1 | ||
|
|
10b9e91c8e | ||
|
|
f813bc42ed | ||
|
|
1c713c0e7e | ||
|
|
6b36671ad7 | ||
|
|
720ee7981b | ||
|
|
dbed9b88a4 | ||
|
|
d5afee08af | ||
|
|
5ae70fcf29 | ||
|
|
16621d9ce1 | ||
|
|
32bfb590a8 | ||
|
|
0e2f9b427f | ||
|
|
1f8abd1be7 | ||
|
|
f7e24ba46c | ||
|
|
d3b993d67e | ||
|
|
eddd6269e7 | ||
|
|
ad14cf6a94 | ||
|
|
53f92d91e7 | ||
|
|
58e8c708c4 | ||
|
|
3b7f1f9cce | ||
|
|
d921975e9f | ||
|
|
9db35b6597 | ||
|
|
c6c5bd179b | ||
|
|
dd1d3ebdc4 | ||
|
|
d5110c4ac8 | ||
|
|
e08775f18a | ||
|
|
a1e273a147 | ||
|
|
79a7d163c4 | ||
|
|
4fd1a633e7 | ||
|
|
ce126b0f1d | ||
|
|
1ccde63c31 | ||
|
|
713972aed0 | ||
|
|
a1abb11ec4 | ||
|
|
2f86b628f9 | ||
|
|
23994758dd | ||
|
|
1c5b6a722a | ||
|
|
a62d826005 | ||
|
|
c98d72f0cd | ||
|
|
55d59c1944 | ||
|
|
064b0b5ee1 | ||
|
|
ebf03afa75 | ||
|
|
116b2efd5f | ||
|
|
dfa66b8113 | ||
|
|
620b0ff59a | ||
|
|
bc01acfef0 | ||
|
|
f8199eaa79 | ||
|
|
bb7408979a | ||
|
|
93a42e752b | ||
|
|
8959bcb912 | ||
|
|
d533e3bf8e | ||
|
|
fbdd73ec58 | ||
|
|
3c5e570e04 | ||
|
|
263c02eaab | ||
|
|
44ad01b3ad | ||
|
|
a37736eed6 | ||
|
|
a3c09047e6 | ||
|
|
dc30c28c02 | ||
|
|
d17f2e6eb9 | ||
|
|
fdabd03924 | ||
|
|
a8a04186ed | ||
|
|
164dd1d7a5 | ||
|
|
4fc487348a | ||
|
|
0bb566869e | ||
|
|
9fb495d785 | ||
|
|
df86e7c8ec | ||
|
|
1e6f4d8052 | ||
|
|
bd470b1330 | ||
|
|
60b3494207 | ||
|
|
475a7fc44c | ||
|
|
f19c5a0dc0 | ||
|
|
3e35f1dea3 | ||
|
|
d8197dd00e | ||
|
|
3205248519 | ||
|
|
224801dcd9 | ||
|
|
e8c0de07de | ||
|
|
cf7e061c7a | ||
|
|
a75becd6c5 | ||
|
|
e411bbe3c4 | ||
|
|
c8ca4bc945 | ||
|
|
ffd9d13d79 | ||
|
|
4addeb5835 | ||
|
|
c086c9ab83 | ||
|
|
44e30e4520 | ||
|
|
8f93cd7dd6 | ||
|
|
a4390d348b | ||
|
|
bd72766414 | ||
|
|
866828c1ba | ||
|
|
8cedcc5d55 | ||
|
|
860cee5f12 | ||
|
|
a75972cf3b | ||
|
|
03e3592443 | ||
|
|
c113244319 | ||
|
|
3a64e1310b | ||
|
|
306b759b74 | ||
|
|
5976884b0f | ||
|
|
ee907c3321 | ||
|
|
86307a724f | ||
|
|
997aa44654 | ||
|
|
feb1d277e9 | ||
|
|
7e1dac26f1 | ||
|
|
a7b95d4caf | ||
|
|
bb042fe70b | ||
|
|
e50ee8fbee | ||
|
|
55d8a6ff76 | ||
|
|
576fc07b5b | ||
|
|
b4978269a5 | ||
|
|
24e9a74a6c | ||
|
|
61e79155b4 | ||
|
|
d23d9a2e7a | ||
|
|
ae13e30494 | ||
|
|
292c664941 | ||
|
|
c78845571e | ||
|
|
a0d5c67e48 | ||
|
|
059a3dcc37 | ||
|
|
d543bb4539 | ||
|
|
3e8f800682 | ||
|
|
368f2abe0d | ||
|
|
1e8af399e7 | ||
|
|
72f669e189 | ||
|
|
c787b54e7c | ||
|
|
3512be30cf | ||
|
|
0bb279eec8 | ||
|
|
75331d9025 | ||
|
|
99a46eafc8 | ||
|
|
ac9300f5be | ||
|
|
4e4e5154f4 | ||
|
|
b54c096762 | ||
|
|
5d409ec1de |
@@ -1,30 +1,199 @@
|
||||
0.9.0-RC6 / February 13, 2016
|
||||
|
||||
Latest Version:
|
||||
Robo 3T 1.1 (13 June, 2017)
|
||||
http://blog.robomongo.org/robomongo-1-1/
|
||||
https://robomongo.org/download
|
||||
|
||||
Robo 3T 1.x:
|
||||
Major Features:
|
||||
- MongoDB 3.4 support
|
||||
- Replica set support.
|
||||
- ECMAScript 2015 aka ES6 Support (Modernized JavaScript Implementation)
|
||||
- Update Notifications Bar
|
||||
- Welcome Tab
|
||||
- New operation logging for almost all operations.
|
||||
|
||||
Major Fixes/Improvements:
|
||||
- Fix for Robomongo Shell Timeout Issue (silently, prematurely finishing long lasting scripts)
|
||||
- New NumberDecimal (Decimal128) data type support
|
||||
- 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 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
|
||||
|
||||
* What's new in 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
|
||||
|
||||
* What's new in Robomongo 1.0 (21 Apr, 2017)
|
||||
http://blog.robomongo.org/robomongo-1-0
|
||||
|
||||
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 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.
|
||||
|
||||
|
||||
Robomongo 0.9:
|
||||
Major Features:
|
||||
- Support for MongoDB 3.x and WiredTiger engine. Robomongo now embeds MongoDB 3.2 shell.
|
||||
(Ability to use the latest shell functionality)
|
||||
- SSH tunnel support for connections
|
||||
- SSL support
|
||||
- MongoDB Atlas (Cloud MongoDB) support
|
||||
- Both MONGODB-CR and SCRAM-SHA-1 authentication mechanisms are supported.
|
||||
- Allow direct connections to Replica Set members and support IPv6 protocol.
|
||||
- Loading of huge list of collections is now faster.
|
||||
- Create Collection dialog is now expandable to support all advanced options.
|
||||
(Supporting all major mongoDB versions 3.2, 3.0, 2.6 and all storage engine types (WiredTiger
|
||||
and MMAPV1) is added.)
|
||||
- Windows High DPI support.
|
||||
- Full size editor with dockable output window.
|
||||
|
||||
Fixed:
|
||||
- Incorrect representation of floating-point numbers (fixed since RC3). This bug was a reason of a big number of issues:
|
||||
#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)
|
||||
|
||||
What's new in 0.9.0 Final (30 Sep, 2016)
|
||||
http://blog.robomongo.org/robomongo-0-9-0-final/
|
||||
|
||||
New Features:
|
||||
- Full size editor with dockable output window.
|
||||
- New JSON object context menu items: "Copy Name" and "Copy Path" are added.
|
||||
- New database context menu items: "Current Operations" and "Kill Operation" are added.
|
||||
- Minimize to Tray Icon for Windows.
|
||||
|
||||
Other Changes
|
||||
- Cloud platforms Compose, mLab and Amazon EC2 were tested and added as supported platforms.
|
||||
- Maximize/Restore result button behavior and icon have been improved.
|
||||
- For better code quality and code reviews, Robomongo Code Quality and Robomongo Code Review pages have been created.
|
||||
https://github.com/paralect/robomongo/wiki/Robomongo-Code-Review
|
||||
https://github.com/paralect/robomongo/wiki/Robomongo-Code-Quality
|
||||
|
||||
Most important changes: support for MongoDB 3.x and WiredTiger engine. Robomongo
|
||||
now embeds MongoDB 3.2 shell. It means that you can now use the latest
|
||||
shell functionality. Both MONGODB-CR and SCRAM-SHA-1 authentication mechanisms are
|
||||
supprted. Also, we now allow direct connections to Replica Set members and
|
||||
support IPv6 protocol. Loading of huge list of collections is now faster.
|
||||
What's new in RC10 (Aug 8, 2016)
|
||||
http://blog.robomongo.org/robomongo-rc10/
|
||||
|
||||
New Features:
|
||||
- SSL connections with advanced options are now supported.
|
||||
- MongoDB Atlas (Cloud MongoDB) is supported.
|
||||
- Cross Platform High DPI enhancements.
|
||||
|
||||
Enhancements:
|
||||
- For better security, OpenSSL has been upgraded to OpenSSL 1.0.1p.
|
||||
- Qt has been updated from Qt 5.5 to latest Qt 5.7. With this update there are many
|
||||
enhancements including cross platform High DPI support.
|
||||
|
||||
Fixed incorrect representation of floating-point numbers (fixed since RC3).
|
||||
This bug was a reason of a big number of issues:
|
||||
|
||||
#910, #748, #697, #699, #760, #815, #870, #892,
|
||||
#894, #905, #945, #974, #978, #990, #831, #842
|
||||
|
||||
What's new in RC7 (March 4, 2016 )
|
||||
What's new in RC9 (May 30, 2016)
|
||||
http://blog.robomongo.org/robomongo-rc9/
|
||||
|
||||
New Features:
|
||||
- Create Collection dialog with advanced options.
|
||||
- New feature has been added to save/restore window sizes. (#1102)
|
||||
- Connection settings from previous versions of Robomongo are
|
||||
now automatically imported starting from Robomongo 0.9.0 RC9. (#1086)
|
||||
- Support for querying documents by UUIDs is added, both in legacy and new encoding. (#432)
|
||||
|
||||
Fixed:
|
||||
- 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)
|
||||
- Correct handling of create/drop of databases and collections. (#1083)
|
||||
|
||||
What's new in RC8 (April 14, 2016)
|
||||
http://blog.robomongo.org/robomongo-rc8/
|
||||
|
||||
What's new in RC7 (March 4, 2016)
|
||||
http://blog.robomongo.org/robomongo-rc7
|
||||
|
||||
What's new in RC6 (February 13, 2016 )
|
||||
What's new in RC6 (February 13, 2016)
|
||||
http://blog.robomongo.org/ipv6-protocol
|
||||
|
||||
What's new in RC5 (February 8, 2016 )
|
||||
What's new in RC5 (February 8, 2016)
|
||||
http://blog.robomongo.org/campaign-is-over-robomongo-is-not/
|
||||
|
||||
What's new in RC4 (February 1, 2016 )
|
||||
What's new in RC4 (February 1, 2016)
|
||||
http://blog.robomongo.org/robomongo-rc4
|
||||
|
||||
What's new in RC3 (January 29, 2016 )
|
||||
What's new in RC3 (January 29, 2016)
|
||||
http://blog.robomongo.org/robomongo-0-9-0-rc3-released
|
||||
|
||||
What's new in RC2 (January 26, 2016)
|
||||
@@ -86,7 +255,7 @@
|
||||
* [Andres Kievsky]
|
||||
- Added new app icon in a variety of png and iDraw formats (#693)
|
||||
* [Michael Steinacher]
|
||||
- Retina text display support (#724)
|
||||
- Retina text display support (#724)
|
||||
|
||||
0.8.4 / November 27, 2013
|
||||
|
||||
|
||||
@@ -5,12 +5,16 @@ project(Robomongo)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
# Project version
|
||||
set(PROJECT_VERSION_MAJOR "0")
|
||||
set(PROJECT_VERSION_MINOR "9")
|
||||
set(PROJECT_VERSION_PATCH "0")
|
||||
set(PROJECT_VERSION_BUILD "-RC7")
|
||||
set(PROJECT_VERSION_MAJOR "1")
|
||||
set(PROJECT_VERSION_MINOR "1")
|
||||
set(PROJECT_VERSION_PATCH "1")
|
||||
set(PROJECT_VERSION_BUILD "")
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_BUILD}")
|
||||
|
||||
# Enable C++14 features
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Modules
|
||||
include(RobomongoPrintUtils)
|
||||
include(RobomongoCMakeDefaults)
|
||||
@@ -27,14 +31,16 @@ find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5PrintSupport REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Xml REQUIRED)
|
||||
find_package(MongoDB REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
if (SYSTEM_MACOSX)
|
||||
find_package(Qt5MacExtras REQUIRED)
|
||||
endif()
|
||||
|
||||
# Projects
|
||||
add_subdirectory(src/third-party/openssl)
|
||||
add_subdirectory(src/third-party/libssh2)
|
||||
add_subdirectory(src/robomongo/ssh)
|
||||
add_subdirectory(src/third-party/qjson)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Robomongo, shell-centric cross-platform MongoDB management tool.
|
||||
Robo 3T, shell-centric cross-platform MongoDB management tool.
|
||||
|
||||
Copyright 2013, Paralect.
|
||||
Copyright 2014-2017 3T Software Labs Ltd.
|
||||
|
||||
The Robomongo is released under the terms of the GNU General Public
|
||||
The Robo 3T is released under the terms of the GNU General Public
|
||||
License, version 3.
|
||||
|
||||
The Robomongo Project includes files written by third parties
|
||||
The Robo 3T Project includes files written by third parties
|
||||
and used with permission or subject to their respective license
|
||||
agreements.
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Robomongo is a shell-centric cross-platform open source MongoDB management
|
||||
Robo 3T 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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
About Robomongo
|
||||
About Robomongo [](https://gitter.im/paralect/robomongo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
===============
|
||||
|
||||
[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.
|
||||
@@ -7,13 +7,79 @@ Starting from version 0.9, Robomongo is compatibile with MongoDB 3.x (including
|
||||
|
||||
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
|
||||
Watch: [Robomongo Youtube channel](https://www.youtube.com/channel/UCM_7WAseRWeeiBikExppstA)
|
||||
Follow: https://twitter.com/Robomongo
|
||||
|
||||
What's Planned for the Next Releases?
|
||||
====================================
|
||||
|
||||
We are currently working towards next release [Robomongo 1.1](https://github.com/Studio3T/robomongo/projects/1).
|
||||
|
||||
**Currently in progress:**
|
||||
- [MongoDB 3.4 Support](https://github.com/Studio3T/robomongo/issues/1250)
|
||||
- [New NumberDecimal (Decimal128) data type support](https://github.com/Studio3T/robomongo/issues/1248)
|
||||
|
||||
- [ECMAScript 2015 (Modernized JavaScript Implementation aka ES6) Support](https://github.com/Studio3T/robomongo/issues/1197)
|
||||
http://www.ecma-international.org/ecma-262/6.0/index.html
|
||||
|
||||
- Security Improvements: OpenSSL version upgrade to openssl-1.0.1u (22-Sep-2016)
|
||||
- Tool Chain Improvements: Modern C++14 features are enabled
|
||||
|
||||
**Plans for Future:**
|
||||
- Export/Import [High Vote]
|
||||
- User Roles [High Vote]
|
||||
- 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
|
||||
===============
|
||||
|
||||
| MongoDB Versions |
|
||||
| :-------------------- |
|
||||
| 3.2 |
|
||||
| 3.0 |
|
||||
| 2.6 |
|
||||
|
||||
| MongoDB Cloud Platforms|
|
||||
| :------------ |
|
||||
| MongoDB Atlas |
|
||||
| Compose |
|
||||
| mLab |
|
||||
| ObjectRocket |
|
||||
| Amazon EC2 |
|
||||
|
||||
| Windows | Mac | Linux |
|
||||
|:---------------------- | :--------------------------------| :---------------------------|
|
||||
| Windows 64-bit 10 | Mac OS X 10.12 (Sierra) | Linux Ubuntu 16.04 64-bit* |
|
||||
Windows 64-bit 8.1 | Mac OS X 10.11 (El Capitan) | Linux Ubuntu 14.04 64-bit* |
|
||||
| Windows 64-bit 7 | Mac OS X 10.10 (Yosemite) | 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 0.8.5**.
|
||||
The latest stable release is currently [**Robomongo 1.0**](http://blog.robomongo.org/robomongo-1-0/).
|
||||
|
||||
Support
|
||||
=======
|
||||
@@ -24,44 +90,33 @@ 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) [](https://gitter.im/paralect/robomongo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
- [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/Build-Robomongo).
|
||||
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).
|
||||
|
||||
What's Planned for the Next Release?
|
||||
====================================
|
||||
|
||||
We are currently working toward a [0.9.0 release milestone](https://github.com/paralect/robomongo/milestones/Robomongo%200.9.0)
|
||||
with some major features targeted including compatibility with MongoDB 3.0
|
||||
(updated shell, SCRAM-SHA-1 auth, support for WiredTiger storage engine)
|
||||
and full support for replica sets.
|
||||
|
||||
Contribute!
|
||||
===========
|
||||
|
||||
### Vote for Features
|
||||
|
||||
Please view our [Magic Backlog](http://app.robomongo.org/backlog) to see features prioritised by donation. The small amount of donations we currently receive are put toward hosting costs.
|
||||
|
||||
### 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
|
||||
|
||||
Code contributions are always welcome! Just try to follow our coding style: [Robomongo Coding Style](https://github.com/paralect/robomongo/wiki/Robomongo-Coding-Style).
|
||||
Code contributions are always welcome! Just try to follow our pre-commit checks and 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.
|
||||
|
||||
For a general workflow, see Github's guide to [Fork a Repo](https://help.github.com/articles/fork-a-repo/).
|
||||
|
||||
Pull requests (PRs) should generally be for discrete issues (i.e. one issue per PR please) and be clean to merge against the current master branch. It would also be helpful if you can confirm what testing has been done (specific O/S targets and MongoDB versions if applicable).
|
||||
|
||||
A usual naming approach for feature branches is `issue-###`. Include the issue number in your commit message / pull request description to link the PR to the original issue.
|
||||
@@ -81,7 +136,7 @@ There are a number of issues we could use help with reproducing. They are marked
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (C) 2013-2015 [Paralect, Inc](http://www.paralect.com)
|
||||
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
|
||||
|
||||
@@ -12,4 +12,4 @@ if %ERRORLEVEL% neq 0 (exit /b 1)
|
||||
|
||||
rem Run CMake configuration step
|
||||
cd "%BUILD_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%
|
||||
cmake -G "Visual Studio 14 2015 Win64" -D "CMAKE_PREFIX_PATH=%PREFIX_PATH%" -D "CMAKE_BUILD_TYPE=%BUILD_TYPE%" -D "CMAKE_INSTALL_PREFIX=%INSTALL_PREFIX%" %PROJECT_DIR%
|
||||
@@ -6,7 +6,7 @@ source $BIN_DIR/common/setup $1
|
||||
|
||||
if [ "$(uname -s)" == "Darwin" ]; then
|
||||
# On Mac OS we should run executable from bundle
|
||||
"$BUILD_DIR/src/robomongo/Robomongo.app/Contents/MacOS/Robomongo"
|
||||
"$BUILD_DIR/src/robomongo/Robo 3T.app/Contents/MacOS/Robo 3T"
|
||||
else
|
||||
"$BUILD_DIR/src/robomongo/robomongo"
|
||||
"$BUILD_DIR/src/robomongo/robo3t"
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/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
|
||||
|
||||
VERSION="$(echo $1 | tr '[A-Z]' '[a-z]')"
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Usage: tag <name>"
|
||||
echo "Example: tag 0.9.0-rc9"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
|
||||
echo "Error: You are not on master branch"
|
||||
exit
|
||||
fi
|
||||
|
||||
cd $PROJECT_DIR
|
||||
git tag -a "v${VERSION}" -m "${VERSION}"
|
||||
git push --tags
|
||||
@@ -46,33 +46,33 @@ set(MongoDB_DEFINITIONS
|
||||
# Set common compiler include directories
|
||||
set(MongoDB_INCLUDE_DIRS
|
||||
${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_DIR}/src/third_party/boost-1.60.0
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/include
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/mongo_sources
|
||||
${MongoDB_DIR}/src/third_party/pcre-8.39
|
||||
${MongoDB_BUILD_DIR}
|
||||
)
|
||||
|
||||
if(SYSTEM_LINUX)
|
||||
set(MongoDB_OBJECT_LIST_PLATFORM_PART linux)
|
||||
list(APPEND MongoDB_INCLUDE_DIRS
|
||||
${MongoDB_DIR}/src/third_party/mozjs-38/platform/x86_64/linux/include)
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/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-38/platform/x86_64/windows/include)
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/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-38/platform/x86_64/osx/include)
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/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-38/platform/x86_64/freebsd/include)
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/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-38/platform/x86_64/openbsd/include)
|
||||
${MongoDB_DIR}/src/third_party/mozjs-45/platform/x86_64/openbsd/include)
|
||||
endif()
|
||||
|
||||
# Read list of object files
|
||||
@@ -91,6 +91,10 @@ foreach(lib ${MongoDB_RELATIVE_LIBS})
|
||||
list(APPEND MongoDB_LIBS ${MongoDB_DIR}/${lib})
|
||||
endforeach()
|
||||
|
||||
if(SYSTEM_WINDOWS)
|
||||
list(APPEND MongoDB_LIBS $ENV{WindowsSdkDir}/Lib/winv6.3/um/x64/Crypt32.Lib)
|
||||
endif()
|
||||
|
||||
# Get MongoDB repository recent tag
|
||||
execute_process(
|
||||
COMMAND git describe --abbrev=0 --tags
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
##################################################
|
||||
# Find and Add OpenSSL shared (dynamic) library
|
||||
#
|
||||
# - This module defines the following variables:
|
||||
# OpenSSL_DIR
|
||||
# OPENSSL_VERSION
|
||||
#
|
||||
# - Imported shared(dynamic) libraries "ssl" and "crypto" are created.
|
||||
#
|
||||
# - It is assumed that OpenSSL has been built and path to OpenSSL build directory is
|
||||
# added into system(environment) variable ROBOMONGO_CMAKE_PREFIX_PATH.
|
||||
#
|
||||
##################################################
|
||||
|
||||
# Try to find OpenSSL directory (uses CMAKE_PREFIX_PATH locations)
|
||||
#-------------------------------------------
|
||||
|
||||
if(SYSTEM_WINDOWS)
|
||||
find_path(
|
||||
OpenSSL_DIR inc32/openssl/ssl.h
|
||||
DOC "Path to OpenSSL (github.com/openssl/openssl) root directory"
|
||||
)
|
||||
else()
|
||||
find_path(
|
||||
OpenSSL_DIR include/openssl/ssl.h
|
||||
DOC "Path to OpenSSL (github.com/openssl/openssl) root directory"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Find OpenSSL version
|
||||
#-------------------------------------------
|
||||
|
||||
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)
|
||||
set(_res 0)
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
|
||||
while (_strlen GREATER 0)
|
||||
math(EXPR _res "${_res} * 16")
|
||||
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
|
||||
string(SUBSTRING "${HEX}" 1 -1 HEX)
|
||||
if (NIBBLE STREQUAL "A")
|
||||
math(EXPR _res "${_res} + 10")
|
||||
elseif (NIBBLE STREQUAL "B")
|
||||
math(EXPR _res "${_res} + 11")
|
||||
elseif (NIBBLE STREQUAL "C")
|
||||
math(EXPR _res "${_res} + 12")
|
||||
elseif (NIBBLE STREQUAL "D")
|
||||
math(EXPR _res "${_res} + 13")
|
||||
elseif (NIBBLE STREQUAL "E")
|
||||
math(EXPR _res "${_res} + 14")
|
||||
elseif (NIBBLE STREQUAL "F")
|
||||
math(EXPR _res "${_res} + 15")
|
||||
else()
|
||||
math(EXPR _res "${_res} + ${NIBBLE}")
|
||||
endif()
|
||||
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
endwhile()
|
||||
|
||||
set(${DEC} ${_res} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if (OPENSSL_INCLUDE_DIR)
|
||||
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||
|
||||
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
|
||||
# The status gives if this is a developer or prerelease and is ignored here.
|
||||
# Major, minor, and fix directly translate into the version numbers shown in
|
||||
# the string. The patch field translates to the single character suffix that
|
||||
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
|
||||
# on.
|
||||
|
||||
string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
|
||||
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
|
||||
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
||||
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
||||
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
|
||||
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
|
||||
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
|
||||
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
|
||||
|
||||
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
|
||||
# 96 is the ASCII code of 'a' minus 1
|
||||
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
|
||||
unset(_tmp)
|
||||
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
|
||||
# this should be updated to handle that, too. This has not happened yet
|
||||
# so it is simply ignored here for now.
|
||||
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
|
||||
endif ()
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
# Add imported ssl and crypto libraries
|
||||
#-------------------------------------------
|
||||
|
||||
# Add imported target ssl (ssleay32)
|
||||
add_library(ssl SHARED IMPORTED)
|
||||
|
||||
# Add imported target for crypto (libeay32)
|
||||
add_library(crypto SHARED IMPORTED)
|
||||
|
||||
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_LOCATION "${OpenSSL_DIR}/libssl.dylib"
|
||||
)
|
||||
set_target_properties(crypto PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_DIR}/include"
|
||||
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"
|
||||
)
|
||||
endif()
|
||||
|
||||
# End of file
|
||||
@@ -1,3 +1,3 @@
|
||||
|
||||
set(ROBOMONGO_DISPLAY_NAME "Robomongo")
|
||||
set(ROBOMONGO_DISPLAY_FULL_NAME "Robomongo ${PROJECT_VERSION}")
|
||||
set(ROBOMONGO_DISPLAY_NAME "Robo 3T")
|
||||
set(ROBOMONGO_DISPLAY_FULL_NAME "Robo 3T ${PROJECT_VERSION}")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Show configuration summary and build tip
|
||||
message("")
|
||||
message(" _______________[ Robomongo configuration summary ]________________")
|
||||
message(" _______________[ Robo 3T configuration summary ]________________")
|
||||
message("| ")
|
||||
message("|-- Dependencies:")
|
||||
message("| ")
|
||||
@@ -8,7 +8,10 @@ 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("| MongoDB: ${MongoDB_VERSION} ${MongoDB_BUILD_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("|")
|
||||
message("|-- Summary:")
|
||||
message("|")
|
||||
@@ -21,7 +24,7 @@ message("| Install path: ${CMAKE_INSTALL_PREFIX}")
|
||||
message("|")
|
||||
message("|-- Building and installing:")
|
||||
message("| ")
|
||||
message("| Now you can build Robomongo with the following command:")
|
||||
message("| Now you can build Robo 3T with the following command:")
|
||||
message("| $ cmake --build .")
|
||||
message("|")
|
||||
message("| And install it to ${CMAKE_INSTALL_PREFIX}:")
|
||||
|
||||
@@ -52,6 +52,18 @@ elseif("${CMAKE_BUILD_TYPE}" MATCHES "MinSizeRel")
|
||||
set(BUILD_MINSIZEREL TRUE)
|
||||
endif()
|
||||
|
||||
# Compiler checks
|
||||
# We check Clang using MATCH instead of strict equality, because as of CMake 3.0.0 the
|
||||
# CMAKE_<LANG>_COMPILER_ID value for Apple-provided Clang is AppleClang. To test
|
||||
# for both the Apple-provided Clang and the regular Clang we use MATCH.
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(COMPILER_CLANG TRUE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU$")
|
||||
set(COMPILER_GCC TRUE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^MSVC$")
|
||||
set(COMPILER_MSVC TRUE)
|
||||
endif()
|
||||
|
||||
# Link "groups" and "whole-archive" options
|
||||
if(SYSTEM_LINUX OR SYSTEM_FREEBSD OR SYSTEM_OPENBSD)
|
||||
set(LINK_LIBGROUP_START -Wl,--start-group)
|
||||
|
||||
@@ -24,7 +24,7 @@ if(SYSTEM_LINUX)
|
||||
set(qt_conf_dir ${bin_dir})
|
||||
set(qt_conf_plugins "../lib")
|
||||
elseif(SYSTEM_MACOSX)
|
||||
set(bundle_name Robomongo.app)
|
||||
set(bundle_name "Robo 3T.app")
|
||||
set(contents_path ${bundle_name}/Contents)
|
||||
|
||||
set(bin_dir ${contents_path}/MacOS)
|
||||
@@ -56,6 +56,29 @@ install(
|
||||
FILES "${CMAKE_BINARY_DIR}/qt.conf"
|
||||
DESTINATION "${qt_conf_dir}")
|
||||
|
||||
# Install OpenSSL dynamic lib files
|
||||
if(SYSTEM_WINDOWS)
|
||||
install(
|
||||
FILES
|
||||
"${OpenSSL_DIR}/out32dll/ssleay32.dll"
|
||||
"${OpenSSL_DIR}/out32dll/libeay32.dll"
|
||||
DESTINATION ${bin_dir})
|
||||
elseif(SYSTEM_MACOSX)
|
||||
install(
|
||||
FILES
|
||||
"${OpenSSL_DIR}/libssl.1.0.0.dylib"
|
||||
"${OpenSSL_DIR}/libcrypto.1.0.0.dylib"
|
||||
DESTINATION ${lib_dir}/lib)
|
||||
elseif(SYSTEM_LINUX)
|
||||
install(
|
||||
FILES
|
||||
"${OpenSSL_DIR}/libssl.so"
|
||||
"${OpenSSL_DIR}/libssl.so.1.0.0"
|
||||
"${OpenSSL_DIR}/libcrypto.so"
|
||||
"${OpenSSL_DIR}/libcrypto.so.1.0.0"
|
||||
DESTINATION ${lib_dir})
|
||||
endif()
|
||||
|
||||
# Install binary
|
||||
install(
|
||||
TARGETS robomongo
|
||||
@@ -72,16 +95,21 @@ install(
|
||||
DESTINATION ${license_dir})
|
||||
|
||||
# Install common dependencies
|
||||
install_qt_lib(Core Gui Widgets PrintSupport)
|
||||
install_qt_lib(Core Gui Widgets PrintSupport Network Xml)
|
||||
install_qt_plugins(QGifPlugin QICOPlugin)
|
||||
install_icu_libs()
|
||||
|
||||
if(SYSTEM_LINUX)
|
||||
install_qt_lib(XcbQpa DBus)
|
||||
install_qt_plugins(
|
||||
QGtk2ThemePlugin
|
||||
QXcbIntegrationPlugin)
|
||||
|
||||
|
||||
# Install newer versions of libstdc++ to support C++11
|
||||
install(
|
||||
FILES
|
||||
"/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
|
||||
"/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22"
|
||||
DESTINATION ${lib_dir})
|
||||
elseif(SYSTEM_MACOSX)
|
||||
install_qt_lib(MacExtras DBus)
|
||||
install_qt_plugins(
|
||||
@@ -91,7 +119,7 @@ elseif(SYSTEM_MACOSX)
|
||||
|
||||
# Install icon
|
||||
install(
|
||||
FILES "${CMAKE_SOURCE_DIR}/install/macosx/Robomongo.icns"
|
||||
FILES "${CMAKE_SOURCE_DIR}/install/macosx/robomongo.icns"
|
||||
DESTINATION "${resources_dir}")
|
||||
elseif(SYSTEM_WINDOWS)
|
||||
install_qt_plugins(
|
||||
@@ -105,4 +133,3 @@ elseif(SYSTEM_WINDOWS)
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ execute_process(
|
||||
string(TIMESTAMP timestamp "%Y-%m-%d")
|
||||
|
||||
# Package name (as it should appear in UI)
|
||||
set(CPACK_PACKAGE_NAME Robomongo)
|
||||
set(CPACK_PACKAGE_NAME robo3t)
|
||||
|
||||
# Version of the package
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
@@ -34,10 +34,10 @@ set(CPACK_MONOLITHIC_INSTALL ON)
|
||||
set(CPACK_STRIP_FILES ON)
|
||||
|
||||
# Additional information
|
||||
set(CPACK_PACKAGE_VENDOR Paralect)
|
||||
set(CPACK_PACKAGE_CONTACT robomongo@paralect.com)
|
||||
set(CPACK_PACKAGE_VENDOR "3T Software Labs Ltd")
|
||||
set(CPACK_PACKAGE_CONTACT robo3t@3t.io)
|
||||
set(CPACK_PACKAGE_DESCRIPTION "Shell-centric cross-platform MongoDB management tool.")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Robomongo is a shell-centric cross-platform MongoDB management tool.")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Robo 3T 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 "Robomongo.exe")
|
||||
set(exe_name "robo3t.exe")
|
||||
|
||||
set(CPACK_GENERATOR NSIS ZIP)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/DESCRIPTION")
|
||||
|
||||
@@ -10,17 +10,18 @@ elseif(SYSTEM_WINDOWS)
|
||||
# The /MP option can reduce the total time to compile the source files. This option
|
||||
# causes the compiler to create one or more copies of itself, each in a separate process.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
|
||||
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 "Robomongo")
|
||||
set(PROJECT_NAME "Robo 3T")
|
||||
set(PROJECT_NAME_TITLE ${PROJECT_NAME})
|
||||
set(PROJECT_DOMAIN "www.robomongo.org")
|
||||
set(PROJECT_COMPANYNAME "Paralect")
|
||||
set(PROJECT_COPYRIGHT "Copyright (C) 2013-2015 ${PROJECT_COMPANYNAME} All Rights Reserved.")
|
||||
set(PROJECT_COMPANYNAME_DOMAIN "www.paralect.com")
|
||||
set(PROJECT_GITHUB_FORK "www.github.com/paralect/robomongo")
|
||||
set(PROJECT_GITHUB_ISSUES "www.github.com/paralect/robomongo/issues")
|
||||
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")
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
|
||||
|
||||
@@ -6,7 +6,12 @@ Robomongo uses [modified version](https://github.com/paralect/robomongo-shell/tr
|
||||
Build for Mac OS X or Linux
|
||||
---------------------------
|
||||
|
||||
1. Clone Robomongo Shell and checkout to `roboshell-v3.2` branch:
|
||||
#### Prerequisites
|
||||
|
||||
1. Install [Scons](http://scons.org/tag/releases.html) (2.4 or later)
|
||||
|
||||
|
||||
2. Clone Robomongo Shell and checkout to `roboshell-v3.2` branch:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/paralect/robomongo-shell.git
|
||||
@@ -14,7 +19,7 @@ Build for Mac OS X or Linux
|
||||
$ git checkout roboshell-v3.2
|
||||
```
|
||||
|
||||
2. Build Robomongo Shell:
|
||||
3. Build Robomongo Shell:
|
||||
|
||||
```sh
|
||||
$ bin/build
|
||||
|
||||
@@ -1,28 +1,104 @@
|
||||
Building Robomongo
|
||||
Building Robomongo (Mac OS X and Linux)
|
||||
==================
|
||||
|
||||
#### Step 1.
|
||||
A. Prerequisites
|
||||
-------------
|
||||
|
||||
Download and build Robomongo Shell (our fork of MongoDB).
|
||||
Refer to [Building Robomongo Shell](BuildingMongoDB.md) document.
|
||||
1. Install CMake (3.2 or later)
|
||||
2. Install [Scons](http://scons.org/tag/releases.html) (2.4 or later)
|
||||
3. Install Qt 5.7
|
||||
|
||||
#### Step 2.
|
||||
```sh
|
||||
Example installation for MAC OSX and Ubuntu:
|
||||
Go to http://download.qt.io/archive/qt/5.7/5.7.0/
|
||||
Download, run and install
|
||||
qt-opensource-mac-x64-clang-5.7.0.dmg (for MAC OSX)
|
||||
qt-opensource-linux-x64-5.7.0.run (for Linux)
|
||||
After successful installation you should have
|
||||
/path/to/qt-5.7.0/5.7/clang_64 (for MAC OSX)
|
||||
/path/to/qt-5.7.0/5.7/gcc_64 (for Linux)
|
||||
|
||||
More information for installing on Ubuntu:
|
||||
https://wiki.qt.io/Install_Qt_5_on_Ubuntu
|
||||
```
|
||||
|
||||
4. Download and Build OpenSSL (1.0.1p) - (explained below in section B)
|
||||
|
||||
B. Building Robomongo and Dependencies
|
||||
-------------
|
||||
|
||||
#### Step 1. Build OpenSSL (1.0.1p)
|
||||
|
||||
Steps to build OpenSSL on MAC:
|
||||
|
||||
```sh
|
||||
Download openssl-1.0.1p (ftp://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1p.tar.gz)
|
||||
tar -xvzf openssl-1.0.1p.tar.gz
|
||||
cd /Users/<user>/Downloads/openssl-1.0.1p
|
||||
./Configure darwin64-x86_64-cc shared --openssldir="@rpath"
|
||||
make (or sudo make)
|
||||
mkdir lib
|
||||
cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib lib/
|
||||
```
|
||||
Helper Commands
|
||||
```sh
|
||||
// to start fresh build
|
||||
make clean
|
||||
```
|
||||
|
||||
|
||||
Steps to build OpenSSL on Linux:
|
||||
|
||||
```sh
|
||||
Download openssl-1.0.1p (ftp://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1p.tar.gz)
|
||||
tar -xvzf openssl-1.0.1p.tar.gz
|
||||
cd /home/<user>/Downloads/openssl-1.0.1p
|
||||
./config shared
|
||||
make
|
||||
mkdir lib
|
||||
cp libssl* libcrypto* lib/
|
||||
```
|
||||
|
||||
#### Step 2. Build Robomongo Shell (fork of MongoDB)
|
||||
|
||||
Clone Robomongo Shell and checkout to `roboshell-v3.2` branch:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/paralect/robomongo-shell.git
|
||||
$ cd robomongo-shell
|
||||
$ git checkout roboshell-v3.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 Robomongo Shell
|
||||
3. Location of OpenSSL
|
||||
|
||||
Separate directories by semicolon `;` (not colon):
|
||||
|
||||
// MAC OSX example:
|
||||
$ export ROBOMONGO_CMAKE_PREFIX_PATH="/path/to/qt-5.7.0/5.7/clang_64;/path/to/robomongo-shell;/path/to/openssl-1.0.1p"
|
||||
// Ubuntu example:
|
||||
$ export ROBOMONGO_CMAKE_PREFIX_PATH="/path/to/qt-5.7.0/5.7/gcc_64;/path/to/robomongo-shell;/path/to/openssl-1.0.1p"
|
||||
|
||||
|
||||
Build Robomongo Shell:
|
||||
|
||||
```sh
|
||||
$ bin/build
|
||||
```
|
||||
|
||||
For more information refer to [Building Robomongo Shell](BuildingMongoDB.md)
|
||||
|
||||
#### Step 3. Build Robomongo
|
||||
|
||||
Download Robomongo:
|
||||
|
||||
$ git clone https://github.com/paralect/robomongo
|
||||
$ cd robomongo
|
||||
|
||||
Set special environment variable `ROBOMONGO_CMAKE_PREFIX_PATH` to point to a set of
|
||||
directories:
|
||||
|
||||
1. Location of Qt 5 SDK
|
||||
2. Location of Robomongo Shell (built in "Step 1")
|
||||
|
||||
Separate directories by semicolon `;` (not colon):
|
||||
|
||||
$ export ROBOMONGO_CMAKE_PREFIX_PATH="/path/to/qt-5.5/5.5/clang_64;/path/to/robomongo-shell"
|
||||
|
||||
Run configuration step:
|
||||
|
||||
$ bin/configure
|
||||
@@ -30,14 +106,14 @@ Run configuration step:
|
||||
And finally, build Robomongo:
|
||||
|
||||
$ bin/build
|
||||
|
||||
<br>
|
||||
## Helper commands
|
||||
|
||||
Execute just built Robomongo:
|
||||
To run robomongo:
|
||||
|
||||
$ bin/run
|
||||
|
||||
|
||||
**Helper commands**
|
||||
|
||||
Clean build files (in order to start build from scratch):
|
||||
|
||||
$ bin/clean
|
||||
@@ -49,4 +125,15 @@ Install Robomongo to `build/release/install` folder:
|
||||
Create package for your OS in `build/release/package` folder:
|
||||
|
||||
$ bin/pack
|
||||
|
||||
|
||||
**Important Notes**
|
||||
- For Ubuntu 16.04 builds, it has been reported that Robomongo /bin/configure step might fail and installing mesa-common-dev package solves it. Details: https://github.com/paralect/robomongo/issues/1268
|
||||
|
||||
- For Centos builds, Robomongo /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
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Building Robomongo for Windows
|
||||
Building Robomongo (Windows)
|
||||
==============================
|
||||
|
||||
Prerequisites
|
||||
A. Prerequisites
|
||||
-------------
|
||||
|
||||
#### 0. Git
|
||||
@@ -64,25 +64,70 @@ Prerequisites
|
||||
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.5
|
||||
#### 5. Qt 5.7
|
||||
|
||||
Download Qt from http://www.qt.io/download-open-source/ (we use Qt Online installer)
|
||||
|
||||
When installing Qt, only one component is required by Robomongo:
|
||||
|
||||
Qt 5.5
|
||||
Qt 5.7
|
||||
[x] msvc2013 64-bit.
|
||||
|
||||
This components contains prebuilt 64-bit binaries for Visual Studio 2013.
|
||||
|
||||
You may uncheck all other components to download as little as possible.
|
||||
|
||||
#### 6. OpenSSL (1.0.1p)
|
||||
Download openssl-1.0.1p (ftp://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1p.tar.gz)
|
||||
|
||||
|
||||
|
||||
B. Building Robomongo and Dependencies
|
||||
-------------
|
||||
|
||||
## Build Robomongo Shell (fork of MongoDB)
|
||||
#### 1. Build OpenSSL (1.0.1p)
|
||||
|
||||
Steps to build OpenSSL on windows:
|
||||
```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
|
||||
ms\do_win64a
|
||||
nmake -f ms\ntdll.mak
|
||||
```
|
||||
|
||||
**Check Point:**
|
||||
After successful build, newly created sub directory out32dll should contain dynamic lib files libeay32.lib (and libeay32.dll) and ssleay32.lib (and ssleay32.dll); and associated include files will be in newly created folder "inc32".
|
||||
|
||||
Helper Commands:
|
||||
```sh
|
||||
// clean to start fresh build
|
||||
nmake -f ms\ntdll.mak clean
|
||||
```
|
||||
|
||||
Refer to OpenSSL documentation for more information:
|
||||
https://wiki.openssl.org/index.php/Compilation_and_Installation#W64
|
||||
|
||||
#### 2. Build Robomongo Shell (fork of MongoDB)
|
||||
|
||||
Clone Robomongo Shell and checkout to roboshell-v3.2 branch:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/paralect/robomongo-shell.git
|
||||
$ cd robomongo-shell
|
||||
$ git checkout roboshell-v3.2
|
||||
```
|
||||
|
||||
Set environment variable `ROBOMONGO_CMAKE_PREFIX_PATH`, required by Robomongo-Shell and Robomongo build scripts, needs to be set according to the following directories:
|
||||
|
||||
1. Location of Qt SDK
|
||||
2. Location of Robomongo Shell
|
||||
3. Location of OpenSSL
|
||||
|
||||
Separate directories by semicolon `;` (not colon). You can do this in Command Prompt:
|
||||
|
||||
> setx ROBOMONGO_CMAKE_PREFIX_PATH "d:\Qt-5\5.7\msvc2013_64;d:\Projects\robomongo-shell;c:\myPath\openssl-1.0.1p"
|
||||
|
||||
Refer to MongoDB documentation for additional information:
|
||||
https://docs.mongodb.org/manual/contributors/tutorial/build-mongodb-from-source/#windows-specific-instructions
|
||||
|
||||
Open VS2013 x64 Native Tools Command Prompt and navigate to `robomongo-shell` folder.
|
||||
|
||||
@@ -96,20 +141,19 @@ Clean build files:
|
||||
|
||||
> bin\clean
|
||||
|
||||
Refer to MongoDB documentation for additional information:
|
||||
https://docs.mongodb.org/manual/contributors/tutorial/build-mongodb-from-source/#windows-specific-instructions
|
||||
|
||||
## Build Robomongo
|
||||
|
||||
Set special environment variable `ROBOMONGO_CMAKE_PREFIX_PATH` to point to set of
|
||||
directories:
|
||||
#### 3. Build Robomongo
|
||||
|
||||
1. Location of Qt SDK
|
||||
2. Location of Robomongo Shell
|
||||
Clone Robomongo:
|
||||
|
||||
Separate directories by semicolon `;` (not colon). You can do this in Command Prompt:
|
||||
|
||||
> setx ROBOMONGO_CMAKE_PREFIX_PATH "d:\Qt-5\5.5\msvc2013_64;d:\Projects\robomongo-shell"
|
||||
|
||||
Reopen your Command Prompt to make this variable available.
|
||||
```sh
|
||||
$ git clone https://github.com/paralect/robomongo.git
|
||||
```
|
||||
|
||||
Open VS2013 x64 Native Tools Command Prompt and navigate to `robomongo` folder.
|
||||
|
||||
Run configuration step:
|
||||
|
||||
@@ -118,15 +162,23 @@ Run configuration step:
|
||||
And finally, build Robomongo:
|
||||
|
||||
> bin\build
|
||||
|
||||
|
||||
#### Helper commands
|
||||
|
||||
|
||||
**Run Robomongo**
|
||||
|
||||
Install Robomongo to `build\Release\install` folder:
|
||||
|
||||
> bin\install
|
||||
|
||||
And run Robomongo
|
||||
|
||||
> \robomongo\build\Release\install\Robomongo.exe
|
||||
|
||||
**Helper commands**
|
||||
|
||||
Clean build files (in order to start build from scratch):
|
||||
|
||||
> bin\clean
|
||||
|
||||
Install Robomongo to `build\Release\install` folder:
|
||||
|
||||
> bin\install
|
||||
|
||||
|
||||
@@ -12,19 +12,46 @@ Runtime dependencies that are not privided by platforms but required by Robomong
|
||||
Diagnostic of dependencies
|
||||
--------------------------
|
||||
|
||||
##### Linux
|
||||
#### Linux
|
||||
|
||||
View dependencies of executable or shared library:
|
||||
a. View dependencies of executable or shared library:
|
||||
|
||||
$ ldd robomongo
|
||||
|
||||
View RPATH or RUNPATH records of executable or shared library:
|
||||
$ 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`
|
||||
|
||||
##### Mac OS X
|
||||
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:
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Robomongo</string>
|
||||
<string>Robo 3T</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
|
||||
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@@ -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. Robomongo should include
|
||||
The most important sizes are the one that is small. Robo 3T should include
|
||||
16, 20, 24, 40, 48. The bigger sizes are usually scaled well, without notable
|
||||
degrading in quality.
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ IDI_ICON1 ICON "@windows_icon@"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Paralect, Inc\0"
|
||||
VALUE "FileDescription", "Robomongo, MongoDB management tool\0"
|
||||
VALUE "CompanyName", "3T Software Labs Ltd\0"
|
||||
VALUE "FileDescription", "Robo 3T, MongoDB management tool\0"
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "LegalCopyright", "Copyright Paralect, 2013 - 2016\0"
|
||||
VALUE "ProductName", "Robomongo\0"
|
||||
VALUE "LegalCopyright", "Copyright 3T Software Labs Ltd, 2014 - 2017\0"
|
||||
VALUE "ProductName", "Robo 3T\0"
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
VALUE "OriginalFilename", "Robomongo.exe\0"
|
||||
VALUE "InternalName", "Robomongo\0"
|
||||
VALUE "OriginalFilename", "robo3t.exe\0"
|
||||
VALUE "InternalName", "Robo 3T\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Robomongo shortcut key reference
|
||||
================================
|
||||
|
||||
"3T", "Robomongo"
|
||||
### Windows/Linux users
|
||||
|
||||
Ctrl+Enter or F5 or Ctrl+R
|
||||
|
||||
@@ -5,6 +5,10 @@ set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
#set(sanitize "-fsanitize=address")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${sanitize}")
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize}")
|
||||
|
||||
set(SOURCES
|
||||
|
||||
# Isolated Scope #1
|
||||
@@ -49,12 +53,16 @@ set(SOURCES
|
||||
core/domain/App.cpp
|
||||
core/mongodb/MongoClient.cpp
|
||||
core/mongodb/MongoWorker.cpp
|
||||
core/mongodb/ReplicaSet.cpp
|
||||
core/settings/SettingsManager.cpp
|
||||
core/AppRegistry.cpp
|
||||
utils/string_operations.cpp
|
||||
utils/common.cpp
|
||||
|
||||
# Isolated Scope #3
|
||||
gui/GuiRegistry.cpp
|
||||
gui/dialogs/AboutDialog.cpp
|
||||
gui/dialogs/EulaDialog.cpp
|
||||
gui/dialogs/ConnectionAdvancedTab.cpp
|
||||
gui/dialogs/ConnectionAuthTab.cpp
|
||||
gui/dialogs/ConnectionBasicTab.cpp
|
||||
@@ -62,6 +70,7 @@ set(SOURCES
|
||||
gui/dialogs/ConnectionDialog.cpp
|
||||
gui/dialogs/CopyCollectionDialog.cpp
|
||||
gui/widgets/workarea/IndicatorLabel.cpp
|
||||
gui/dialogs/CreateCollectionDialog.cpp
|
||||
gui/dialogs/CreateDatabaseDialog.cpp
|
||||
gui/dialogs/CreateUserDialog.cpp
|
||||
gui/utils/ComboBoxUtils.cpp
|
||||
@@ -70,6 +79,9 @@ 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
|
||||
@@ -81,6 +93,8 @@ set(SOURCES
|
||||
# Isolated scope #6
|
||||
gui/widgets/explorer/ExplorerCollectionTreeItem.cpp
|
||||
gui/widgets/explorer/ExplorerTreeItem.cpp
|
||||
gui/widgets/explorer/ExplorerReplicaSetFolderItem.cpp
|
||||
gui/widgets/explorer/ExplorerReplicaSetTreeItem.cpp
|
||||
gui/widgets/explorer/ExplorerDatabaseTreeItem.cpp
|
||||
gui/widgets/explorer/ExplorerDatabaseCategoryTreeItem.cpp
|
||||
gui/widgets/explorer/ExplorerUserTreeItem.cpp
|
||||
@@ -111,31 +125,47 @@ set(SOURCES
|
||||
gui/widgets/workarea/QueryWidget.cpp
|
||||
gui/widgets/workarea/WorkAreaTabBar.cpp
|
||||
gui/widgets/workarea/WorkAreaTabWidget.cpp
|
||||
gui/widgets/workarea/WelcomeTab.cpp
|
||||
|
||||
# Final scope
|
||||
gui/widgets/LogWidget.cpp
|
||||
gui/MainWindow.cpp
|
||||
|
||||
gui/dialogs/SSHTunnelTab.cpp
|
||||
gui/dialogs/SSLTab.cpp
|
||||
core/settings/SshSettings.cpp
|
||||
core/settings/SslSettings.cpp
|
||||
core/settings/ReplicaSetSettings.cpp
|
||||
core/mongodb/SshTunnelWorker.cpp
|
||||
|
||||
resources/robo.qrc
|
||||
gui/resources/gui.qrc
|
||||
)
|
||||
|
||||
|
||||
# Robomongo target
|
||||
add_executable(robomongo MACOSX_BUNDLE WIN32 app/main.cpp ${SOURCES})
|
||||
|
||||
target_link_libraries(robomongo
|
||||
PRIVATE
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
Qt5::Xml
|
||||
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})
|
||||
endif(APPLE)
|
||||
|
||||
target_include_directories(robomongo
|
||||
PRIVATE
|
||||
${CMAKE_HOME_DIRECTORY}/src)
|
||||
@@ -151,6 +181,8 @@ target_compile_definitions(robomongo
|
||||
PROJECT_GITHUB_FORK="${PROJECT_GITHUB_FORK}"
|
||||
PROJECT_GITHUB_ISSUES="${PROJECT_GITHUB_ISSUES}"
|
||||
PROJECT_VERSION="${PROJECT_VERSION}"
|
||||
PROJECT_VERSION_SHORT="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
||||
PROJECT_QT_VERSION="${Qt5Core_VERSION}"
|
||||
PROJECT_NAME_LOWERCASE="${PROJECT_NAME_LOWERCASE}")
|
||||
|
||||
if(SYSTEM_WINDOWS)
|
||||
@@ -168,7 +200,7 @@ if(SYSTEM_WINDOWS)
|
||||
|
||||
# Rename output name for Windows
|
||||
set_target_properties(robomongo PROPERTIES
|
||||
OUTPUT_NAME "Robomongo")
|
||||
OUTPUT_NAME "robo3t")
|
||||
|
||||
# Seems that we do not need to do this with recent versions of Qt
|
||||
target_link_libraries(robomongo
|
||||
@@ -178,20 +210,21 @@ if(SYSTEM_WINDOWS)
|
||||
elseif(SYSTEM_MACOSX)
|
||||
set_target_properties(robomongo PROPERTIES
|
||||
INSTALL_RPATH "@executable_path/../Frameworks"
|
||||
OUTPUT_NAME "Robomongo"
|
||||
OUTPUT_NAME "Robo 3T"
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/install/macosx/Info.plist.in"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Robomongo"
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "com.paralect.Robomongo"
|
||||
MACOSX_BUNDLE_INFO_STRING "Robomongo ${PROJECT_VERSION}. Copyright Paralect, 2013 - 2016"
|
||||
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 - 2017"
|
||||
MACOSX_BUNDLE_SHORT_VERSION "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_LONG_VERSION "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_COPYRIGHT "Copyright Paralect, 2013 - 2016"
|
||||
MACOSX_BUNDLE_ICON_FILE "Robomongo")
|
||||
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")
|
||||
INSTALL_RPATH "$ORIGIN/../lib"
|
||||
OUTPUT_NAME "robo3t")
|
||||
endif()
|
||||
|
||||
# Install
|
||||
|
||||
@@ -7,19 +7,21 @@
|
||||
// Header "mongo/platform/basic" is required by "sock.h" under Windows
|
||||
#include <mongo/platform/basic.h>
|
||||
#include <mongo/util/net/sock.h>
|
||||
|
||||
#include <mongo/base/initializer.h>
|
||||
#include <mongo/util/net/ssl_options.h>
|
||||
|
||||
#include "robomongo/core/AppRegistry.h"
|
||||
#include "robomongo/core/settings/SettingsManager.h"
|
||||
#include "robomongo/gui/MainWindow.h"
|
||||
#include "robomongo/gui/AppStyle.h"
|
||||
|
||||
#include "robomongo/gui/dialogs/EulaDialog.h"
|
||||
#include "robomongo/ssh/ssh.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[], char** envp)
|
||||
{
|
||||
if (rbm_ssh_init()) {
|
||||
if (rbm_ssh_init())
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Please check, do we really need envp for other OSes?
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -29,6 +31,12 @@ int main(int argc, char *argv[], char** envp)
|
||||
// Support for IPv6 is disabled by default. Enable it.
|
||||
mongo::enableIPv6(true);
|
||||
|
||||
// Perform SSL-enabled mongo initialization
|
||||
mongo::sslGlobalParams.sslMode.store(mongo::SSLParams::SSLMode_allowSSL);
|
||||
|
||||
// Cross Platform High DPI support - Qt 5.7
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
// Initialization routine for MongoDB shell
|
||||
mongo::runGlobalInitializersOrDie(argc, argv, envp);
|
||||
|
||||
@@ -39,30 +47,34 @@ int main(int argc, char *argv[], char** envp)
|
||||
// This can cause a conflict when using POSIX functions, for instance, when
|
||||
// converting between data types such as floats and strings, since the notation
|
||||
// may differ between locales. To get around this problem, call the POSIX
|
||||
// function setlocale(LC_NUMERIC,"C") right after initializing QApplication or
|
||||
// function setlocale(LC_NUMERIC, "C") right after initializing QApplication or
|
||||
// QCoreApplication to reset the locale that is used for number formatting to "C"-locale.
|
||||
// (http://doc.qt.io/qt-5/qcoreapplication.html#locale-settings)
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
// EULA License Agreement
|
||||
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
|
||||
settingsManager->addAcceptedEulaVersion(PROJECT_VERSION);
|
||||
settingsManager->save();
|
||||
}
|
||||
|
||||
// Init GUI style
|
||||
Robomongo::AppStyleUtils::initStyle();
|
||||
|
||||
// Application main window
|
||||
Robomongo::MainWindow win;
|
||||
|
||||
// Resize main window. We are trying to keep it "almost" maximized.
|
||||
QRect screenGeometry = QApplication::desktop()->availableGeometry();
|
||||
int horizontalMargin = (int)(screenGeometry.width() * 0.1);
|
||||
int verticalMargin = (int)(screenGeometry.height() * 0.1);
|
||||
int width = screenGeometry.width() - horizontalMargin;
|
||||
int height = screenGeometry.height() - verticalMargin;
|
||||
win.resize(QSize(width, height));
|
||||
|
||||
// Center main window
|
||||
int x = (screenGeometry.width() - win.width()) / 2;
|
||||
int y = (screenGeometry.height() - win.height()) / 2;
|
||||
win.move(x, y);
|
||||
win.show();
|
||||
Robomongo::MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
int rc = app.exec();
|
||||
rbm_ssh_cleanup();
|
||||
|
||||
@@ -33,12 +33,19 @@ void precisionAssert(const std::string &text, double d) {
|
||||
std::stringstream s;
|
||||
s.precision(std::numeric_limits<double>::digits10);
|
||||
s << d;
|
||||
if (d == (long long)d)
|
||||
s << ".0";
|
||||
std::cout << "Checking " << text << " - ";
|
||||
assert(text == s.str());
|
||||
std::cout << "Correct. " << std::endl;
|
||||
}
|
||||
|
||||
void testPrecision() {
|
||||
precisionAssert("-9.987654321", -9.987654321);
|
||||
precisionAssert("-1.0", -1.0);
|
||||
precisionAssert("-0.0", -0.0);
|
||||
precisionAssert("0.0", 0.0);
|
||||
precisionAssert("9.0", 9.0);
|
||||
precisionAssert("9.8", 9.8);
|
||||
precisionAssert("9.9", 9.9);
|
||||
precisionAssert("9.98", 9.98);
|
||||
|
||||
@@ -30,4 +30,20 @@ namespace Robomongo
|
||||
|
||||
class MongoDocument;
|
||||
typedef boost::shared_ptr<MongoDocument> MongoDocumentPtr;
|
||||
|
||||
enum ConnectionType {
|
||||
// This type of connection is shown in Explorer and also opens SSH tunnel for secondary
|
||||
// connections (if needed)
|
||||
ConnectionPrimary = 0,
|
||||
|
||||
// Never shown in Explorer and uses SSH tunnel from primary connection (if needed)
|
||||
ConnectionSecondary = 1,
|
||||
|
||||
// The same as Primary, but is specifically for testing connections.
|
||||
ConnectionTest = 2,
|
||||
|
||||
// Never shown in Explorer and can be used to refresh (via reconnecting) current connection view
|
||||
// (i.e. db version, storage engine, current replica set primary, status of replica set etc...)
|
||||
ConnectionRefresh = 3
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace
|
||||
template<typename type, int size>
|
||||
inline type findTypeInArray(const char *(&arr)[size], const char *text)
|
||||
{
|
||||
for (int i=0; i < size;++i )
|
||||
for (int i = 0; i < size; ++i )
|
||||
{
|
||||
if (strcmp(text,arr[i])==0)
|
||||
if (strcmp(text, arr[i]) == 0)
|
||||
{
|
||||
return static_cast<type>(i);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
#include "robomongo/core/EventError.h"
|
||||
|
||||
#include "robomongo/utils/string_operations.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
EventError::EventError() :
|
||||
_isNull(true) {}
|
||||
|
||||
EventError::EventError(const std::string &errorMessage) :
|
||||
_errorMessage(errorMessage),
|
||||
EventError::EventError(const std::string &errorMessage, ErrorCode errorCode /*= Unknown*/,
|
||||
bool showErrorWindow /* = true */) :
|
||||
_errorMessage(captilizeFirstChar(errorMessage)),
|
||||
_errorCode(errorCode),
|
||||
_showErrorWindow(showErrorWindow),
|
||||
_isNull(false) {}
|
||||
|
||||
bool EventError::isNull() const {
|
||||
EventError::EventError(const std::string &errorMessage, ReplicaSet const& replicaSetInfo,
|
||||
bool showErrorWindow /* = true */ ) :
|
||||
_errorMessage(errorMessage),
|
||||
_errorCode(SetPrimaryUnreachable),
|
||||
_replicaSetInfo(replicaSetInfo),
|
||||
_showErrorWindow(showErrorWindow),
|
||||
_isNull(false) {}
|
||||
|
||||
bool EventError::isNull() const
|
||||
{
|
||||
return _isNull;
|
||||
}
|
||||
|
||||
const std::string &EventError::errorMessage() const {
|
||||
const std::string &EventError::errorMessage() const
|
||||
{
|
||||
return _errorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "robomongo/core/mongodb/ReplicaSet.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
/**
|
||||
@@ -10,7 +12,11 @@ namespace Robomongo
|
||||
*/
|
||||
class EventError
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum ErrorCode { Unknown, SetPrimaryUnreachable, ServerHasDifferentMembers };
|
||||
|
||||
/**
|
||||
* @brief Creates "null" (or, in other words, empty) error.
|
||||
* Subsequent call of isNull() on this object will return true.
|
||||
@@ -21,7 +27,14 @@ namespace Robomongo
|
||||
* @brief Creates error object with specified error message.
|
||||
* Subsequent call of isNull() on this object will return false.
|
||||
*/
|
||||
explicit EventError(const std::string &errorMessage);
|
||||
explicit EventError(const std::string &errorMessage, ErrorCode errorCode = Unknown,
|
||||
bool showErrorWindow = true);
|
||||
|
||||
/**
|
||||
* @brief Creates error object only for replica set connection failures
|
||||
*/
|
||||
explicit EventError(const std::string &errorMessage, ReplicaSet const& replicaSetInfo,
|
||||
bool showErrorWindow = true);
|
||||
|
||||
/**
|
||||
* @brief Tests whether error is "null" (or, in other words, empty).
|
||||
@@ -35,13 +48,19 @@ namespace Robomongo
|
||||
* @brief Returns error message that describes this error.
|
||||
*/
|
||||
const std::string &errorMessage() const;
|
||||
|
||||
ErrorCode errorCode() const { return _errorCode; }
|
||||
ReplicaSet replicaSetInfo() const { return _replicaSetInfo; }
|
||||
bool showErrorWindow() const { return _showErrorWindow; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Error message
|
||||
*/
|
||||
const std::string _errorMessage;
|
||||
|
||||
bool _isNull;
|
||||
std::string const _errorMessage;
|
||||
ErrorCode const _errorCode = Unknown;
|
||||
ReplicaSet const _replicaSetInfo;
|
||||
bool const _showErrorWindow = true;
|
||||
bool const _isNull;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Robomongo
|
||||
char *data = new char[bytes];
|
||||
|
||||
const char *p = s.c_str();
|
||||
for( size_t i = 0; i < bytes; i++ ) {
|
||||
for (size_t i = 0; i < bytes; i++) {
|
||||
data[i] = mongo::fromHex(p);
|
||||
p += 2;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace Robomongo
|
||||
mongo::BinDataType binType = element.binDataType();
|
||||
|
||||
if (binType != mongo::newUUID && binType != mongo::bdtUUID)
|
||||
throw new std::invalid_argument("Binary subtype should be 3 (bdtUUID) or 4 (newUUID)");
|
||||
throw std::invalid_argument("Binary subtype should be 3 (bdtUUID) or 4 (newUUID)");
|
||||
|
||||
int len;
|
||||
const char *data = element.binData(len);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#include "robomongo/core/domain/App.h"
|
||||
#include <QHash>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "robomongo/core/domain/MongoServer.h"
|
||||
#include "robomongo/core/domain/MongoShell.h"
|
||||
#include "robomongo/core/domain/MongoCollection.h"
|
||||
#include "robomongo/core/settings/ConnectionSettings.h"
|
||||
#include "robomongo/core/settings/ReplicaSetSettings.h"
|
||||
#include "robomongo/core/settings/SshSettings.h"
|
||||
#include "robomongo/core/settings/SslSettings.h"
|
||||
#include "robomongo/core/mongodb/SshTunnelWorker.h"
|
||||
#include "robomongo/core/EventBus.h"
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
@@ -33,7 +36,7 @@ namespace Robomongo
|
||||
}
|
||||
|
||||
App::App(EventBus *const bus) : QObject(),
|
||||
_bus(bus) {
|
||||
_bus(bus), _lastServerHandle(0) {
|
||||
_bus->subscribe(this, EstablishSshConnectionResponse::Type);
|
||||
_bus->subscribe(this, ListenSshConnectionResponse::Type);
|
||||
_bus->subscribe(this, LogEvent::Type);
|
||||
@@ -45,29 +48,84 @@ namespace Robomongo
|
||||
std::for_each(_servers.begin(), _servers.end(), stdutils::default_delete<MongoServer*>());
|
||||
}
|
||||
|
||||
bool App::openServer(ConnectionSettings *connection, ConnectionType type) {
|
||||
|
||||
SshSettings *ssh = connection->sshSettings();
|
||||
|
||||
if (ssh->enabled() && ssh->askPassword() &&
|
||||
(type == ConnectionPrimary || type == ConnectionTest)) {
|
||||
bool ok = false;
|
||||
|
||||
bool isByKey = ssh->authMethod() == "publickey";
|
||||
std::string passText = isByKey ? "passphrase" : "password";
|
||||
|
||||
std::stringstream s;
|
||||
s << "In order to continue, please provide the " << passText;
|
||||
|
||||
if (isByKey)
|
||||
s << " for the key file";
|
||||
|
||||
s << "." << std::endl << std::endl;
|
||||
|
||||
if (ssh->authMethod() == "publickey")
|
||||
s << "Private Key: " << ssh->privateKeyFile() << std::endl;
|
||||
|
||||
s << "Server: " << ssh->host() << std::endl;
|
||||
s << "User: " << ssh->userName() << std::endl;
|
||||
|
||||
|
||||
s << std::endl << "Enter your " << passText << " that will never be stored:";
|
||||
|
||||
QString userInput = QInputDialog::getText(NULL, tr("SSH Authentication"),
|
||||
QtUtils::toQString(s.str()),
|
||||
QLineEdit::Password, "", &ok);
|
||||
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
ssh->setAskedPassword(QtUtils::toStdString(userInput));
|
||||
}
|
||||
|
||||
SslSettings *sslSettings = connection->sslSettings();
|
||||
|
||||
if (sslSettings->sslEnabled() && sslSettings->usePemFile() && sslSettings->askPassphrase()
|
||||
&& (type == ConnectionPrimary || type == ConnectionTest))
|
||||
{
|
||||
if (!askSslPassphrasePromptDialog(connection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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::openServer(ConnectionSettings *connection, bool visible) {
|
||||
if (visible)
|
||||
MongoServer *App::openServerInternal(ConnectionSettings* connSettings, ConnectionType type) {
|
||||
++_lastServerHandle;
|
||||
|
||||
if (type == ConnectionPrimary)
|
||||
_bus->publish(new ConnectingEvent(this));
|
||||
|
||||
// When connection is not "visible" or do not have
|
||||
// When connection is SECONDARY or do not have
|
||||
// ssh settings enabled, continue without SSH Tunnel
|
||||
if (!visible || !connection->sshSettings()->enabled()) {
|
||||
return continueOpenServer(connection, visible);
|
||||
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(connection->sshSettings()->host()))
|
||||
.arg(connection->sshSettings()->port()), mongo::logger::LogSeverity::Info());
|
||||
.arg(QtUtils::toQString(connSettings->sshSettings()->host()))
|
||||
.arg(connSettings->sshSettings()->port()), mongo::logger::LogSeverity::Info());
|
||||
|
||||
ConnectionSettings* settingsCopy = connection->clone();
|
||||
ConnectionSettings* settingsCopy = connSettings->clone();
|
||||
SshTunnelWorker* sshWorker = new SshTunnelWorker(settingsCopy);
|
||||
_bus->send(sshWorker, new EstablishSshConnectionRequest(this, sshWorker, settingsCopy, visible));
|
||||
_bus->send(sshWorker, new EstablishSshConnectionRequest(this, _lastServerHandle, sshWorker, settingsCopy, type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -77,46 +135,54 @@ namespace Robomongo
|
||||
*/
|
||||
void App::closeServer(MongoServer *server)
|
||||
{
|
||||
_servers.erase(std::remove_if(_servers.begin(), _servers.end(), stdutils::RemoveIfFound<MongoServer*>(server)), _servers.end());
|
||||
_servers.erase(std::remove_if(_servers.begin(), _servers.end(), stdutils::RemoveIfFound<MongoServer*>(server)),
|
||||
_servers.end());
|
||||
}
|
||||
|
||||
MongoShell *App::openShell(MongoCollection *collection,const QString &filePathToSave)
|
||||
void App::openShell(MongoCollection *collection, const QString &filePathToSave)
|
||||
{
|
||||
ConnectionSettings *connection = collection->database()->server()->connectionRecord();
|
||||
connection->setDefaultDatabase(collection->database()->name());
|
||||
QString script = detail::buildCollectionQuery(collection->name(), "find({})");
|
||||
return openShell(connection, ScriptInfo(script, true, CursorPosition(0, -2), QtUtils::toQString(collection->database()->name()),filePathToSave));
|
||||
openShell(collection->database()->server(), connection, ScriptInfo(script, true, CursorPosition(0, -2),
|
||||
QtUtils::toQString(collection->database()->name()), filePathToSave));
|
||||
}
|
||||
|
||||
MongoShell *App::openShell(MongoServer *server,const QString &script, const std::string &dbName,
|
||||
void App::openShell(MongoServer *server, const QString &script, const std::string &dbName,
|
||||
bool execute, const QString &shellName,
|
||||
const CursorPosition &cursorPosition,const QString &filePathToSave)
|
||||
const CursorPosition &cursorPosition, const QString &filePathToSave)
|
||||
{
|
||||
ConnectionSettings *connection = server->connectionRecord();
|
||||
|
||||
if (!dbName.empty())
|
||||
connection->setDefaultDatabase(dbName);
|
||||
|
||||
return openShell(connection, ScriptInfo(script, execute, cursorPosition, shellName,filePathToSave));
|
||||
openShell(server, connection, ScriptInfo(script, execute, cursorPosition, shellName, filePathToSave));
|
||||
}
|
||||
|
||||
MongoShell *App::openShell(MongoDatabase *database, const QString &script,
|
||||
void App::openShell(MongoDatabase *database, const QString &script,
|
||||
bool execute, const QString &shellName,
|
||||
const CursorPosition &cursorPosition,const QString &filePathToSave)
|
||||
const CursorPosition &cursorPosition, const QString &filePathToSave)
|
||||
{
|
||||
ConnectionSettings *connection = database->server()->connectionRecord();
|
||||
connection->setDefaultDatabase(database->name());
|
||||
return openShell(connection, ScriptInfo(script, execute, cursorPosition, shellName,filePathToSave));
|
||||
openShell(database->server(), connection, ScriptInfo(script, execute, cursorPosition,
|
||||
shellName, filePathToSave));
|
||||
}
|
||||
|
||||
MongoShell *App::openShell(ConnectionSettings *connection, const ScriptInfo &scriptInfo)
|
||||
void App::openShell(MongoServer* server, ConnectionSettings* connection, const ScriptInfo &scriptInfo)
|
||||
{
|
||||
MongoServer *server = openServer(connection, false);
|
||||
MongoShell *shell = new MongoShell(server,scriptInfo);
|
||||
MongoServer *serverClone = openServerInternal(connection, ConnectionSecondary);
|
||||
if (!serverClone || !server)
|
||||
return;
|
||||
|
||||
MongoShell *shell = new MongoShell(serverClone, scriptInfo);
|
||||
// Connection between explorer's server and tab's MongoShells
|
||||
_bus->subscribe(server, ReplicaSetRefreshed::Type, shell);
|
||||
_shells.push_back(shell);
|
||||
_bus->publish(new OpeningShellEvent(this, shell));
|
||||
shell->execute();
|
||||
return shell;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +192,7 @@ namespace Robomongo
|
||||
void App::closeShell(MongoShell *shell)
|
||||
{
|
||||
// Do nothing, if this shell not owned by this App.
|
||||
MongoShellsContainerType::iterator it = std::find_if(_shells.begin(),_shells.end(),std::bind1st(std::equal_to<MongoShell *>(),shell));
|
||||
MongoShellsContainerType::iterator it = std::find_if(_shells.begin(), _shells.end(), std::bind1st(std::equal_to<MongoShell *>(), shell));
|
||||
if (it == _shells.end())
|
||||
return;
|
||||
|
||||
@@ -135,57 +201,103 @@ namespace Robomongo
|
||||
delete shell;
|
||||
}
|
||||
|
||||
MongoServer* App::continueOpenServer(ConnectionSettings *connection, bool visible, int localport) {
|
||||
ConnectionSettings* settings = connection->clone();
|
||||
MongoServer *App::continueOpenServer(int serverHandle, ConnectionSettings* connSettings, ConnectionType type,
|
||||
int localport)
|
||||
{
|
||||
ConnectionSettings* connSettingsClone = connSettings->clone();
|
||||
|
||||
// Modify connection settings when SSH tunnel is used
|
||||
if (visible && settings->sshSettings()->enabled()) {
|
||||
settings->setServerHost("127.0.0.1");
|
||||
settings->setServerPort(localport);
|
||||
if ((type == ConnectionPrimary || type == ConnectionTest)
|
||||
&& connSettingsClone->sshSettings()->enabled()) {
|
||||
connSettingsClone->setServerHost("127.0.0.1");
|
||||
connSettingsClone->setServerPort(localport);
|
||||
}
|
||||
|
||||
MongoServer *server = new MongoServer(settings, visible);
|
||||
MongoServer *server = new MongoServer(serverHandle, connSettingsClone, type);
|
||||
_servers.push_back(server);
|
||||
|
||||
server->runWorkerThread();
|
||||
|
||||
LOG_MSG(QString("Connecting to %1...").arg(QtUtils::toQString(server->connectionRecord()->getFullAddress())), mongo::logger::LogSeverity::Info());
|
||||
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) {
|
||||
if (event->isError()) {
|
||||
_bus->publish(new ConnectionFailedEvent(this, event->error().errorMessage()));
|
||||
_bus->publish(new ConnectionFailedEvent(
|
||||
this, event->serverHandle, event->connectionType, event->error().errorMessage(),
|
||||
ConnectionFailedEvent::SshConnection));
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_MSG(QString("SSH tunnel created successfully"), mongo::logger::LogSeverity::Info());
|
||||
|
||||
_bus->send(event->worker, new ListenSshConnectionRequest(this));
|
||||
continueOpenServer(event->settings, event->visible, event->localport);
|
||||
|
||||
// record event->worker and delete when needed
|
||||
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) {
|
||||
if (event->level == LogEvent::ERROR) {
|
||||
if (event->level == LogEvent::RBM_ERROR) {
|
||||
LOG_MSG(event->message, mongo::logger::LogSeverity::Error());
|
||||
} else if (event->level == LogEvent::WARN) {
|
||||
} else if (event->level == LogEvent::RBM_WARN) {
|
||||
LOG_MSG(event->message, mongo::logger::LogSeverity::Warning());
|
||||
} else if (event->level == LogEvent::INFO) {
|
||||
} else if (event->level == LogEvent::RBM_INFO) {
|
||||
LOG_MSG(event->message, mongo::logger::LogSeverity::Info());
|
||||
} else if (event->level == LogEvent::DEBUG) {
|
||||
} 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->error().errorMessage()));
|
||||
_bus->publish(new ConnectionFailedEvent(this, event->serverHandle, event->connectionType, event->error().errorMessage(),
|
||||
ConnectionFailedEvent::SshChannel));
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_MSG(QString("SSH tunnel closed."), mongo::logger::LogSeverity::Error());
|
||||
}
|
||||
|
||||
void App::fireConnectionFailedEvent(int serverHandle, ConnectionType type, std::string errormsg,
|
||||
ConnectionFailedEvent::Reason reason) {
|
||||
_bus->publish(new ConnectionFailedEvent(this, serverHandle, type, errormsg, reason));
|
||||
}
|
||||
|
||||
bool App::askSslPassphrasePromptDialog(ConnectionSettings *connSettings) const
|
||||
{
|
||||
auto sslSettings = connSettings->sslSettings();
|
||||
bool ok = false;
|
||||
|
||||
std::stringstream s;
|
||||
s << "In order to continue, please provide the passphrase";
|
||||
s << "." << std::endl << std::endl;
|
||||
|
||||
s << "Server: " << connSettings->serverHost() << ":" << connSettings->serverPort() << std::endl;
|
||||
s << "PEM file: " << sslSettings->pemKeyFile() << std::endl;
|
||||
|
||||
s << std::endl << "Enter your PEM key passphrase (will never be stored):";
|
||||
|
||||
QString userInput = QInputDialog::getText(NULL, tr("SSL Authentication"),
|
||||
QtUtils::toQString(s.str()),
|
||||
QLineEdit::Password, "", &ok);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sslSettings->setPemPassPhrase(QtUtils::toStdString(userInput));
|
||||
return ok;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ namespace Robomongo
|
||||
* @brief 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.
|
||||
* @return Succeeded or not
|
||||
*/
|
||||
MongoServer *openServer(ConnectionSettings *connection, bool visible);
|
||||
bool openServer(ConnectionSettings *connection, ConnectionType type);
|
||||
|
||||
/**
|
||||
* @brief Closes MongoServer connection and frees all resources, owned
|
||||
@@ -59,18 +60,22 @@ namespace Robomongo
|
||||
/**
|
||||
* @brief Open new shell based on specified collection
|
||||
*/
|
||||
MongoShell *openShell(MongoCollection *collection,const QString &filePathToSave=QString());
|
||||
void openShell(MongoCollection *collection, const QString &filePathToSave = QString());
|
||||
|
||||
MongoShell *openShell(MongoServer *server, const QString &script, const std::string &dbName = std::string(),
|
||||
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());
|
||||
|
||||
MongoShell *openShell(MongoDatabase *database, const QString &script,
|
||||
void openShell(MongoDatabase *database, const QString &script,
|
||||
bool execute = true, const QString &shellName = QString(),
|
||||
const CursorPosition &cursorPosition = CursorPosition(), const QString &filePathToSave = QString());
|
||||
|
||||
MongoShell *openShell(ConnectionSettings *connection, const ScriptInfo &scriptInfo);
|
||||
MongoServersContainerType getServers() const {return _servers; };
|
||||
/**
|
||||
* @brief Open new shell using explorer's MongoServer (ExplorerServerTreeItem's _server)
|
||||
*/
|
||||
void openShell(MongoServer* server, ConnectionSettings* connSettings, const ScriptInfo &scriptInfo);
|
||||
|
||||
MongoServersContainerType getServers() const { return _servers; };
|
||||
|
||||
/**
|
||||
* @brief Closes MongoShell and frees all resources, owned by specified MongoShell.
|
||||
@@ -78,13 +83,25 @@ namespace Robomongo
|
||||
*/
|
||||
void closeShell(MongoShell *shell);
|
||||
|
||||
void fireConnectionFailedEvent(int serverHandle, ConnectionType type, std::string errormsg, ConnectionFailedEvent::Reason reason);
|
||||
|
||||
int getLastServerHandle() const { return _lastServerHandle; };
|
||||
|
||||
public Q_SLOTS:
|
||||
void handle(EstablishSshConnectionResponse *event);
|
||||
void handle(ListenSshConnectionResponse *event);
|
||||
void handle(LogEvent *event);
|
||||
|
||||
private:
|
||||
MongoServer* continueOpenServer(ConnectionSettings *connection, bool visible, 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
|
||||
* @param connection Pointer to active connection settings
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool askSslPassphrasePromptDialog(ConnectionSettings *connSettings) const;
|
||||
|
||||
/**
|
||||
* MongoServers, owned by this App.
|
||||
@@ -97,5 +114,9 @@ namespace Robomongo
|
||||
MongoShellsContainerType _shells;
|
||||
|
||||
EventBus *const _bus;
|
||||
|
||||
// Increase monotonically when new MongoServer is created
|
||||
// Never decreases.
|
||||
int _lastServerHandle;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "robomongo/core/mongodb/MongoWorker.h"
|
||||
#include "robomongo/core/AppRegistry.h"
|
||||
#include "robomongo/core/EventBus.h"
|
||||
#include "robomongo/core/utils/Logger.h"
|
||||
#include "robomongo/utils/common.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
@@ -15,6 +17,13 @@ namespace Robomongo
|
||||
R_REGISTER_EVENT(MongoDatabaseFunctionsLoadingEvent)
|
||||
R_REGISTER_EVENT(MongoDatabaseCollectionsLoadingEvent)
|
||||
|
||||
const std::string MongoDatabase::StorageEngineType::WIRED_TIGER = "wiredTiger";
|
||||
const std::string MongoDatabase::StorageEngineType::MMAPV1 = "mmapv1";
|
||||
|
||||
const float MongoDatabase::DBVersion::MONGODB_2_6 = 2.6f;
|
||||
const float MongoDatabase::DBVersion::MONGODB_3_0 = 3.0f;
|
||||
const float MongoDatabase::DBVersion::MONGODB_3_2 = 3.2f;
|
||||
|
||||
MongoDatabase::MongoDatabase(MongoServer *server, const std::string &name) :
|
||||
QObject(),
|
||||
_system(name == "admin" || name == "local"),
|
||||
@@ -30,113 +39,148 @@ namespace Robomongo
|
||||
void MongoDatabase::loadCollections()
|
||||
{
|
||||
_bus->publish(new MongoDatabaseCollectionsLoadingEvent(this));
|
||||
_bus->send(_server->client(), new LoadCollectionNamesRequest(this, _name));
|
||||
_bus->send(_server->worker(), new LoadCollectionNamesRequest(this, _name));
|
||||
}
|
||||
|
||||
void MongoDatabase::loadUsers()
|
||||
{
|
||||
_bus->publish(new MongoDatabaseUsersLoadingEvent(this));
|
||||
_bus->send(_server->client(), new LoadUsersRequest(this, _name));
|
||||
_bus->send(_server->worker(), new LoadUsersRequest(this, _name));
|
||||
}
|
||||
|
||||
void MongoDatabase::loadFunctions()
|
||||
{
|
||||
_bus->publish(new MongoDatabaseFunctionsLoadingEvent(this));
|
||||
_bus->send(_server->client(), new LoadFunctionsRequest(this, _name));
|
||||
_bus->send(_server->worker(), new LoadFunctionsRequest(this, _name));
|
||||
}
|
||||
void MongoDatabase::createCollection(const std::string &collection)
|
||||
|
||||
void MongoDatabase::createCollection(const std::string &collection, long long size, bool capped, int maxDocNum, const mongo::BSONObj& extraOptions)
|
||||
{
|
||||
_bus->send(_server->client(), new CreateCollectionRequest(this, MongoNamespace(_name, collection)));
|
||||
_bus->send(_server->worker(),
|
||||
new CreateCollectionRequest(this, MongoNamespace(_name, collection), extraOptions, size, capped, maxDocNum));
|
||||
}
|
||||
|
||||
void MongoDatabase::dropCollection(const std::string &collection)
|
||||
{
|
||||
_bus->send(_server->client(), new DropCollectionRequest(this, MongoNamespace(_name, collection)));
|
||||
_bus->send(_server->worker(), new DropCollectionRequest(this, MongoNamespace(_name, collection)));
|
||||
}
|
||||
|
||||
void MongoDatabase::renameCollection(const std::string &collection, const std::string &newCollection)
|
||||
{
|
||||
_bus->send(_server->client(), new RenameCollectionRequest(this, MongoNamespace(_name, collection), newCollection));
|
||||
_bus->send(_server->worker(), new RenameCollectionRequest(this, MongoNamespace(_name, collection),
|
||||
newCollection));
|
||||
}
|
||||
|
||||
void MongoDatabase::duplicateCollection(const std::string &collection, const std::string &newCollection)
|
||||
{
|
||||
_bus->send(_server->client(), new DuplicateCollectionRequest(this, MongoNamespace(_name, collection), newCollection));
|
||||
_bus->send(_server->worker(), new DuplicateCollectionRequest(this, MongoNamespace(_name, collection), newCollection));
|
||||
}
|
||||
|
||||
void MongoDatabase::copyCollection(MongoServer *server, const std::string &sourceDatabase, const std::string &collection)
|
||||
{
|
||||
_bus->send(_server->client(), new CopyCollectionToDiffServerRequest(this, server->client(), sourceDatabase, collection, _name));
|
||||
_bus->send(_server->worker(), new CopyCollectionToDiffServerRequest(this, server->worker(), sourceDatabase, collection, _name));
|
||||
}
|
||||
|
||||
void MongoDatabase::createUser(const MongoUser &user, bool overwrite)
|
||||
{
|
||||
_bus->send(_server->client(), new CreateUserRequest(this, _name, user, overwrite));
|
||||
_bus->send(_server->worker(), new CreateUserRequest(this, _name, user, overwrite));
|
||||
}
|
||||
|
||||
void MongoDatabase::dropUser(const mongo::OID &id)
|
||||
void MongoDatabase::dropUser(const mongo::OID &id, std::string const& userName)
|
||||
{
|
||||
_bus->send(_server->client(), new DropUserRequest(this, _name, id));
|
||||
_bus->send(_server->worker(), new DropUserRequest(this, _name, id, userName));
|
||||
}
|
||||
|
||||
void MongoDatabase::createFunction(const MongoFunction &fun)
|
||||
{
|
||||
_bus->send(_server->client(), new CreateFunctionRequest(this, _name, fun));
|
||||
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, _server->version(), fun));
|
||||
}
|
||||
|
||||
void MongoDatabase::updateFunction(const std::string &name, const MongoFunction &fun)
|
||||
{
|
||||
_bus->send(_server->client(), new CreateFunctionRequest(this, _name, fun, name));
|
||||
_bus->send(_server->worker(), new CreateFunctionRequest(this, _name, _server->version(), fun, name));
|
||||
}
|
||||
|
||||
void MongoDatabase::dropFunction(const std::string &name)
|
||||
{
|
||||
_bus->send(_server->client(), new DropFunctionRequest(this, _name, name));
|
||||
_bus->send(_server->worker(), new DropFunctionRequest(this, _name, _server->version(), name));
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(LoadCollectionNamesResponse *loaded)
|
||||
void MongoDatabase::handle(LoadCollectionNamesResponse *event)
|
||||
{
|
||||
if (loaded->isError()) {
|
||||
_bus->publish(new MongoDatabaseCollectionListLoadedEvent(this, loaded->error()));
|
||||
if (event->isError()) {
|
||||
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;
|
||||
}
|
||||
|
||||
clearCollections();
|
||||
const std::vector<MongoCollectionInfo> &colectionsInfos = loaded->collectionInfos();
|
||||
for (std::vector<MongoCollectionInfo>::const_iterator it = colectionsInfos.begin(); it != colectionsInfos.end(); ++it) {
|
||||
const MongoCollectionInfo &info = *it;
|
||||
MongoCollection *collection = new MongoCollection(this, info);
|
||||
addCollection(collection);
|
||||
}
|
||||
|
||||
for (auto const& collectionInfo : event->collectionInfos())
|
||||
addCollection(new MongoCollection(this, collectionInfo));
|
||||
|
||||
_bus->publish(new MongoDatabaseCollectionListLoadedEvent(this, _collections));
|
||||
LOG_MSG("'Collections' refreshed.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(CreateFunctionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to create function \'" + event->functionName + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadFunctions();
|
||||
LOG_MSG("Function \'" + event->functionName + "\' created.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(CreateUserResponse *event)
|
||||
{
|
||||
if (event->isError())
|
||||
return;
|
||||
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to create user \'" + event->userName + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadUsers();
|
||||
LOG_MSG("User \'" + event->userName + "\' created.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(LoadUsersResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
_bus->publish(new MongoDatabaseUsersLoadedEvent(this, event->error()));
|
||||
|
||||
if (_server->connectionRecord()->isReplicaSet()) // replica set
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
|
||||
genericEventErrorHandler(event, "Failed to refresh 'Users'.", _bus, this);
|
||||
return;
|
||||
}
|
||||
|
||||
_bus->publish(new MongoDatabaseUsersLoadedEvent(this, this, event->users()));
|
||||
LOG_MSG("'Users' refreshed.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_bus->publish(new MongoDatabaseFunctionsLoadedEvent(this, this, event->functions()));
|
||||
LOG_MSG("'Functions' refreshed.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
void MongoDatabase::clearCollections()
|
||||
@@ -149,4 +193,92 @@ namespace Robomongo
|
||||
{
|
||||
_collections.push_back(collection);
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(CreateCollectionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to create collection \'" + event->collection + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadCollections();
|
||||
LOG_MSG("Collection \'" + event->collection + "\' created.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(DropCollectionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to drop collection \'" + event->collection + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadCollections();
|
||||
LOG_MSG("Collection \'" + event->collection + "\' dropped", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MongoDatabase::handle(DropFunctionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to remove function \'" + event->functionName + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadFunctions();
|
||||
LOG_MSG("Function \'" + event->functionName + "\' removed", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(DropUserResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to drop user \'" + event->username + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadUsers();
|
||||
LOG_MSG("User \'" + event->username + "\' dropped", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(RenameCollectionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to rename collection.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadCollections();
|
||||
LOG_MSG("Collection \'" + event->oldCollection + "\' renamed to \'" +
|
||||
event->newCollection +"\'." , mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handle(DuplicateCollectionResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
handleIfReplicaSetUnreachable(event);
|
||||
genericEventErrorHandler(event, "Failed to duplicate collection \'" + event->sourceCollection + "\'.",
|
||||
_bus, this);
|
||||
}
|
||||
else {
|
||||
loadCollections();
|
||||
LOG_MSG("Collection \'" + event->sourceCollection + "\' duplicated as \'" +
|
||||
event->duplicateCollection + "\'.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoDatabase::handleIfReplicaSetUnreachable(Event *event)
|
||||
{
|
||||
if (!_server->connectionRecord()->isReplicaSet())
|
||||
return;
|
||||
|
||||
if (EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
|
||||
_server->handle(&refreshEvent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,25 @@ namespace Robomongo
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Database storage engine type
|
||||
*/
|
||||
struct StorageEngineType
|
||||
{
|
||||
static const std::string WIRED_TIGER;
|
||||
static const std::string MMAPV1;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief MongoDB version
|
||||
*/
|
||||
struct DBVersion
|
||||
{
|
||||
static const float MONGODB_2_6;
|
||||
static const float MONGODB_3_0;
|
||||
static const float MONGODB_3_2;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief MongoDatabase
|
||||
* @param server: pointer to parent MongoServer
|
||||
@@ -37,14 +56,14 @@ namespace Robomongo
|
||||
|
||||
void loadFunctions();
|
||||
|
||||
void createCollection(const std::string &collection);
|
||||
void createCollection(const std::string &collection, long long size, bool capped, int maxDocNum, const mongo::BSONObj& extraOptions);
|
||||
void dropCollection(const std::string &collection);
|
||||
void renameCollection(const std::string &collection, const std::string &newCollection);
|
||||
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, bool overwrite);
|
||||
void dropUser(const mongo::OID &id);
|
||||
void dropUser(const mongo::OID &id, std::string const& userName);
|
||||
|
||||
void createFunction(const MongoFunction &fun);
|
||||
void updateFunction(const std::string &name, const MongoFunction &fun);
|
||||
@@ -64,11 +83,19 @@ namespace Robomongo
|
||||
void handle(LoadCollectionNamesResponse *event);
|
||||
void handle(LoadUsersResponse *event);
|
||||
void handle(LoadFunctionsResponse *event);
|
||||
void handle(CreateFunctionResponse *event);
|
||||
void handle(CreateUserResponse *event);
|
||||
void handle(CreateCollectionResponse *event);
|
||||
void handle(DropCollectionResponse *event);
|
||||
void handle(DropFunctionResponse *event);
|
||||
void handle(DropUserResponse *event);
|
||||
void handle(RenameCollectionResponse *event);
|
||||
void handle(DuplicateCollectionResponse *event);
|
||||
|
||||
private:
|
||||
void clearCollections();
|
||||
void addCollection(MongoCollection *collection);
|
||||
void handleIfReplicaSetUnreachable(Event *event);
|
||||
|
||||
private:
|
||||
MongoServer *_server;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Robomongo
|
||||
std::vector<MongoDocumentPtr> MongoDocument::fromBsonObj(const std::vector<mongo::BSONObj> &bsonObjs)
|
||||
{
|
||||
std::vector<MongoDocumentPtr> list;
|
||||
for (std::vector<mongo::BSONObj>::const_iterator it=bsonObjs.begin(); it!=bsonObjs.end(); ++it) {
|
||||
for (std::vector<mongo::BSONObj>::const_iterator it = bsonObjs.begin(); it != bsonObjs.end(); ++it) {
|
||||
list.push_back(fromBsonObj(*it));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Robomongo
|
||||
{
|
||||
MongoFunction::MongoFunction(const mongo::BSONObj &obj)
|
||||
{
|
||||
_name = BsonUtils::getField<mongo::String>(obj,"_id");
|
||||
_name = BsonUtils::getField<mongo::String>(obj, "_id");
|
||||
_code = obj.getField("value")._asCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Robomongo
|
||||
std::string prepareServerAddress(const std::string &address)
|
||||
{
|
||||
size_t pos = address.find_first_of("{");
|
||||
if (pos!=std::string::npos){
|
||||
return address.substr(0,pos);
|
||||
if (pos != std::string::npos) {
|
||||
return address.substr(0, pos);
|
||||
}
|
||||
return address;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Robomongo
|
||||
|
||||
CollectionInfo::CollectionInfo(const std::string &server, const std::string &database, const std::string &collection)
|
||||
:_serverAddress(server),
|
||||
_ns(database,collection)
|
||||
_ns(database, collection)
|
||||
{}
|
||||
|
||||
bool CollectionInfo::isValid() const
|
||||
|
||||
@@ -4,55 +4,82 @@
|
||||
#include "robomongo/core/settings/ConnectionSettings.h"
|
||||
#include "robomongo/core/settings/SshSettings.h"
|
||||
#include "robomongo/core/settings/SettingsManager.h"
|
||||
#include "robomongo/core/settings/ReplicaSetSettings.h"
|
||||
#include "robomongo/core/mongodb/MongoWorker.h"
|
||||
#include "robomongo/core/mongodb/SshTunnelWorker.h"
|
||||
#include "robomongo/core/AppRegistry.h"
|
||||
#include "robomongo/core/domain/App.h"
|
||||
#include "robomongo/core/EventBus.h"
|
||||
#include "robomongo/core/events/MongoEventsInfo.h"
|
||||
#include "robomongo/core/utils/Logger.h"
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
#include "robomongo/utils/common.h"
|
||||
#include "robomongo/utils/string_operations.h"
|
||||
|
||||
namespace Robomongo {
|
||||
R_REGISTER_EVENT(MongoServerLoadingDatabasesEvent)
|
||||
|
||||
MongoServer::MongoServer(ConnectionSettings *settings, bool visible) : QObject(),
|
||||
MongoServer::MongoServer(int handle, ConnectionSettings *settings, ConnectionType connectionType) : QObject(),
|
||||
_version(0.0f),
|
||||
_visible(visible),
|
||||
_client(NULL),
|
||||
_connectionType(connectionType),
|
||||
_worker(nullptr),
|
||||
_isConnected(false),
|
||||
_settings(settings),
|
||||
_bus(AppRegistry::instance().bus()) { }
|
||||
_connSettings(settings),
|
||||
_handle(handle),
|
||||
_bus(AppRegistry::instance().bus()),
|
||||
_app(AppRegistry::instance().app()),
|
||||
_replicaSetInfo(nullptr)
|
||||
{}
|
||||
|
||||
bool MongoServer::isConnected() const {
|
||||
return _isConnected;
|
||||
}
|
||||
|
||||
ConnectionSettings *MongoServer::connectionRecord() const {
|
||||
return _settings;
|
||||
return _connSettings.get();
|
||||
}
|
||||
|
||||
MongoServer::~MongoServer() {
|
||||
clearDatabases();
|
||||
|
||||
if (_client != NULL) {
|
||||
_client->stopAndDelete();
|
||||
if (_worker) {
|
||||
_worker->stopAndDelete();
|
||||
}
|
||||
|
||||
// MongoWorker "_client" does not deleted here, because it is now owned by
|
||||
// MongoWorker "_worker" is not deleted here, because it is now owned by
|
||||
// another thread (call to moveToThread() made in MongoWorker constructor).
|
||||
// It will be deleted by this thread by means of "deleteLater()", which
|
||||
// is also specified in MongoWorker constructor.
|
||||
|
||||
delete _settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Try to connect to MongoDB server.
|
||||
* @throws MongoException, if fails
|
||||
*/
|
||||
void MongoServer::tryConnect() {
|
||||
_bus->send(_client, new EstablishConnectionRequest(this));
|
||||
void MongoServer::tryConnect()
|
||||
{
|
||||
_bus->send(_worker, new EstablishConnectionRequest(this, _connectionType, _connSettings->uuid().toStdString()));
|
||||
}
|
||||
|
||||
QStringList MongoServer::getDatabasesNames() const {
|
||||
void MongoServer::tryRefresh()
|
||||
{
|
||||
_bus->send(_worker, new EstablishConnectionRequest(this, ConnectionRefresh, _connSettings->uuid().toStdString()));
|
||||
}
|
||||
|
||||
void MongoServer::tryRefreshReplicaSetConnection()
|
||||
{
|
||||
_bus->send(_worker, new EstablishConnectionRequest(this, ConnectionRefresh, _connSettings->uuid().toStdString()));
|
||||
}
|
||||
|
||||
void MongoServer::tryRefreshReplicaSetFolder(bool expanded, bool showLoading /*= true*/)
|
||||
{
|
||||
if (!_connSettings->isReplicaSet())
|
||||
return;
|
||||
|
||||
if (showLoading)
|
||||
_bus->publish(new ReplicaSetFolderLoading(this));
|
||||
|
||||
_bus->send(_worker, new RefreshReplicaSetFolderRequest(this, expanded));
|
||||
}
|
||||
|
||||
QStringList MongoServer::getDatabasesNames() const
|
||||
{
|
||||
QStringList result;
|
||||
for (QList<MongoDatabase *>::const_iterator it = _databases.begin(); it != _databases.end(); ++it) {
|
||||
MongoDatabase *datab = *it;
|
||||
@@ -61,11 +88,17 @@ namespace Robomongo {
|
||||
return result;
|
||||
}
|
||||
|
||||
void MongoServer::createDatabase(const std::string &dbName) {
|
||||
_bus->send(_client,new CreateDatabaseRequest(this, dbName));
|
||||
void MongoServer::addDatabase(MongoDatabase *database) {
|
||||
_databases.append(database);
|
||||
}
|
||||
|
||||
MongoDatabase *MongoServer::findDatabaseByName(const std::string &dbName) const {
|
||||
void MongoServer::createDatabase(const std::string &dbName)
|
||||
{
|
||||
_bus->send(_worker, new CreateDatabaseRequest(this, dbName));
|
||||
}
|
||||
|
||||
MongoDatabase *MongoServer::findDatabaseByName(const std::string &dbName) const
|
||||
{
|
||||
for (QList<MongoDatabase *>::const_iterator it = _databases.begin(); it != _databases.end(); ++it) {
|
||||
MongoDatabase *datab = *it;
|
||||
if (datab->name() == dbName) {
|
||||
@@ -76,7 +109,7 @@ namespace Robomongo {
|
||||
}
|
||||
|
||||
void MongoServer::dropDatabase(const std::string &dbName) {
|
||||
_bus->send(_client,new DropDatabaseRequest(this, dbName));
|
||||
_bus->send(_worker, new DropDatabaseRequest(this, dbName));
|
||||
}
|
||||
|
||||
void MongoServer::insertDocuments(const std::vector<mongo::BSONObj> &objCont,
|
||||
@@ -87,94 +120,358 @@ namespace Robomongo {
|
||||
}
|
||||
|
||||
void MongoServer::insertDocument(const mongo::BSONObj &obj, const MongoNamespace &ns) {
|
||||
_bus->send(_client,new InsertDocumentRequest(this, obj, ns));
|
||||
_bus->send(_worker, new InsertDocumentRequest(this, obj, ns));
|
||||
}
|
||||
|
||||
void MongoServer::saveDocuments(const std::vector<mongo::BSONObj> &objCont, const MongoNamespace &ns) {
|
||||
for (std::vector<mongo::BSONObj>::const_iterator it = objCont.begin(); it != objCont.end(); it++) {
|
||||
saveDocument(*it,ns);
|
||||
saveDocument(*it, ns);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns) {
|
||||
_bus->send(_client, new InsertDocumentRequest(this, obj, ns, true));
|
||||
_bus->send(_worker, new InsertDocumentRequest(this, obj, ns, true));
|
||||
}
|
||||
|
||||
void MongoServer::removeDocuments(mongo::Query query, const MongoNamespace &ns, bool justOne) {
|
||||
_bus->send(_client, new RemoveDocumentRequest(this, query, ns, justOne));
|
||||
void MongoServer::removeDocuments(mongo::Query query, const MongoNamespace &ns,
|
||||
RemoveDocumentCount removeCount, int index)
|
||||
{
|
||||
_bus->send(_worker, new RemoveDocumentRequest(this, query, ns, removeCount, index));
|
||||
}
|
||||
|
||||
void MongoServer::loadDatabases() {
|
||||
void MongoServer::loadDatabases()
|
||||
{
|
||||
_bus->publish(new MongoServerLoadingDatabasesEvent(this));
|
||||
_bus->send(_client, new LoadDatabaseNamesRequest(this));
|
||||
if (_connSettings->isReplicaSet()) {
|
||||
tryRefreshReplicaSetConnection();
|
||||
}
|
||||
else { // single server
|
||||
_bus->send(_worker, new LoadDatabaseNamesRequest(this));
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::clearDatabases() {
|
||||
void MongoServer::clearDatabases()
|
||||
{
|
||||
qDeleteAll(_databases);
|
||||
_databases.clear();
|
||||
}
|
||||
|
||||
void MongoServer::addDatabase(MongoDatabase *database) {
|
||||
_databases.append(database);
|
||||
}
|
||||
void MongoServer::handle(EstablishConnectionResponse *event)
|
||||
{
|
||||
_connectionType = event->connectionType;
|
||||
|
||||
void MongoServer::handle(EstablishConnectionResponse *event) {
|
||||
// In any case, replica set info must be updated, there might be reachable secondary(ies).
|
||||
// Also cached set name must be updated or cleared for failed connections.
|
||||
updateReplicaSetSettings(event);
|
||||
|
||||
// --- Connection Failed
|
||||
if (event->isError()) {
|
||||
_isConnected = false;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Cannot connect to the MongoDB at " << connectionRecord()->getFullAddress()
|
||||
<< ".\n\nError:\n" << event->error().errorMessage();
|
||||
|
||||
_bus->publish(new ConnectionFailedEvent(this, ss.str()));
|
||||
handleConnectionFailure(event);
|
||||
return;
|
||||
}
|
||||
|
||||
const ConnectionInfo &info = event->info();
|
||||
// --- Connections Successful
|
||||
// Save various information after successful connection
|
||||
const ConnectionInfo &info = event->info;
|
||||
_version = info._version;
|
||||
_storageEngineType = info._storageEngineType;
|
||||
_isConnected = true;
|
||||
|
||||
// Do nothing if this is not "visible" connection
|
||||
if (!_visible) {
|
||||
return;
|
||||
// ConnectionRefresh is used just to update connection view (_version, _storageEngineType, _repPrimary etc..)
|
||||
// So we return here after updating(refreshing) information related to connection view.
|
||||
if (ConnectionRefresh == event->connectionType) {
|
||||
if (_connSettings->isReplicaSet()) {
|
||||
// If it is replica set connection, do not return yet.
|
||||
LOG_MSG("Replica set refreshed. [" + _connSettings->connectionName() + ']',
|
||||
mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
else { // single server
|
||||
LOG_MSG("Server refreshed.", mongo::logger::LogSeverity::Info());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_bus->publish(new ConnectionEstablishedEvent(this));
|
||||
// Only for single servers
|
||||
if (!_connSettings->isReplicaSet()) {
|
||||
_bus->publish(new ConnectionEstablishedEvent(this, _connectionType, info));
|
||||
// Do nothing if this is not a "primary" connection
|
||||
if (ConnectionPrimary != _connectionType)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConnectionPrimary == _connectionType)
|
||||
LOG_MSG("Establish connection successful. Connection: " + _connSettings->connectionName(),
|
||||
mongo::logger::LogSeverity::Info());
|
||||
|
||||
clearDatabases();
|
||||
for(std::vector<std::string>::const_iterator it = info._databases.begin(); it != info._databases.end(); ++it) {
|
||||
const std::string &name = *it;
|
||||
MongoDatabase *db = new MongoDatabase(this, name);
|
||||
addDatabase(db);
|
||||
for (auto const& dbname : info._databases) {
|
||||
MongoDatabase *db = new MongoDatabase(this, dbname);
|
||||
addDatabase(db); // todo: serverClones for replica sets should not do this
|
||||
}
|
||||
|
||||
if (_connSettings->isReplicaSet()) {
|
||||
_bus->publish(new ConnectionEstablishedEvent(this, event->connectionType, info));
|
||||
// In order to do first connection much faster, time consuming refresh
|
||||
// "repSetMonitor->startOrContinueRefresh(). refreshAll()" is being requested after
|
||||
// successful connection.
|
||||
if (ConnectionPrimary == event->connectionType)
|
||||
_bus->send(_worker, new RefreshReplicaSetFolderRequest(this, false));
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::handle(LoadDatabaseNamesResponse *event) {
|
||||
void MongoServer::handle(RefreshReplicaSetFolderResponse *event)
|
||||
{
|
||||
handleReplicaSetRefreshEvents(event->isError(), event->error(), event->replicaSet, event->expanded);
|
||||
}
|
||||
|
||||
void MongoServer::handle(LoadDatabaseNamesResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
_bus->publish(new DatabaseListLoadedEvent(this, event->error()));
|
||||
return;
|
||||
}
|
||||
|
||||
clearDatabases();
|
||||
for(std::vector<std::string>::iterator it = event->databaseNames.begin(); it != event->databaseNames.end(); ++it) {
|
||||
const std::string &name = *it;
|
||||
MongoDatabase *db = new MongoDatabase(this, name);
|
||||
|
||||
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(),
|
||||
mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
void MongoServer::handle(InsertDocumentResponse *event) {
|
||||
_bus->publish(new InsertDocumentResponse(event->sender(), event->error()));
|
||||
void MongoServer::handle(InsertDocumentResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
if (_connSettings->isReplicaSet()) {
|
||||
if (ConnectionPrimary == _connectionType) { // Insert document from explorer context menu
|
||||
if (EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
|
||||
handle(&refreshEvent);
|
||||
}
|
||||
}
|
||||
else { // Insert document from tab results window (Notifier, OutputWindow widget)
|
||||
_bus->publish(new InsertDocumentResponse(this, event->error()));
|
||||
}
|
||||
}
|
||||
genericEventErrorHandler(event, "Failed to insert document.", _bus, this);
|
||||
}
|
||||
else {
|
||||
_bus->publish(new InsertDocumentResponse(this, event->error()));
|
||||
LOG_MSG("Document inserted.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MongoServer::handle(RemoveDocumentResponse *event) {
|
||||
_bus->publish(new RemoveDocumentResponse(event->sender(), event->error()));
|
||||
void MongoServer::handle(RemoveDocumentResponse *event)
|
||||
{
|
||||
if (event->removeCount == RemoveDocumentCount::MULTI && event->index > 0)
|
||||
return;
|
||||
|
||||
std::string subStr;
|
||||
switch (event->removeCount) {
|
||||
case RemoveDocumentCount::ONE: subStr = "document."; break;
|
||||
case RemoveDocumentCount::MULTI: subStr = "documents."; break;
|
||||
case RemoveDocumentCount::ALL: subStr = "all documents."; break;
|
||||
default: subStr = "(logic error)."; break;
|
||||
}
|
||||
|
||||
if (event->isError()) {
|
||||
if (_connSettings->isReplicaSet() &&
|
||||
EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
|
||||
handle(&refreshEvent);
|
||||
}
|
||||
genericEventErrorHandler(event, "Failed to remove " + subStr, _bus, this);
|
||||
}
|
||||
else { // success
|
||||
_bus->publish(new RemoveDocumentResponse(this, event->error(), event->removeCount, event->index));
|
||||
LOG_MSG("Removed " + subStr, mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::runWorkerThread() {
|
||||
_client = new MongoWorker(_settings->clone(),
|
||||
AppRegistry::instance().settingsManager()->loadMongoRcJs(),
|
||||
AppRegistry::instance().settingsManager()->batchSize());
|
||||
void MongoServer::runWorkerThread()
|
||||
{
|
||||
_worker = new MongoWorker(_connSettings->clone(),
|
||||
AppRegistry::instance().settingsManager()->loadMongoRcJs(),
|
||||
AppRegistry::instance().settingsManager()->batchSize(),
|
||||
AppRegistry::instance().settingsManager()->mongoTimeoutSec(),
|
||||
AppRegistry::instance().settingsManager()->shellTimeoutSec());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::handle(CreateDatabaseResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
if (_connSettings->isReplicaSet() &&
|
||||
EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
|
||||
handle(&refreshEvent);
|
||||
}
|
||||
genericEventErrorHandler(event, "Failed to create database \'" + event->database + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadDatabases();
|
||||
LOG_MSG("Database \'" + event->database + "\' created.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::handle(DropDatabaseResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
if (_connSettings->isReplicaSet() &&
|
||||
EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
auto refreshEvent = ReplicaSetRefreshed(this, event->error(), event->error().replicaSetInfo());
|
||||
handle(&refreshEvent);
|
||||
}
|
||||
genericEventErrorHandler(event, "Failed to drop database \'" + event->database + "\'.", _bus, this);
|
||||
}
|
||||
else {
|
||||
loadDatabases();
|
||||
LOG_MSG("Database \'" + event->database + "\' dropped.", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::handle(ReplicaSetRefreshed *event)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (isError) { // Primary is unreachable
|
||||
_replicaSetInfo.reset(new ReplicaSet(replicaSet));
|
||||
LOG_MSG("Replica set folder refreshed with error. " + eventError.errorMessage() +
|
||||
". Connection: " + _connSettings->connectionName(), mongo::logger::LogSeverity::Error());
|
||||
_bus->publish(new ReplicaSetFolderRefreshed(this, eventError, true));
|
||||
return;
|
||||
}
|
||||
|
||||
// Primary is reachable
|
||||
// Update replica set settings and mongo server _replicaSetInfo
|
||||
_replicaSetInfo.reset(new ReplicaSet(replicaSet));
|
||||
_connSettings->setServerHost(_replicaSetInfo->primary.host());
|
||||
_connSettings->setServerPort(_replicaSetInfo->primary.port());
|
||||
_connSettings->replicaSetSettings()->setCachedSetName(
|
||||
_connSettings->replicaSetSettings()->setNameUserEntered().empty() ? _replicaSetInfo->setName : "");
|
||||
|
||||
LOG_MSG("Replica set folder refreshed. Connection: " + _connSettings->connectionName(),
|
||||
mongo::logger::LogSeverity::Info());
|
||||
_bus->publish(new ReplicaSetFolderRefreshed(this, expanded));
|
||||
}
|
||||
|
||||
void MongoServer::updateReplicaSetSettings(EstablishConnectionResponse* event)
|
||||
{
|
||||
if (!_connSettings->isReplicaSet())
|
||||
return;
|
||||
|
||||
_replicaSetInfo.reset(new ReplicaSet(event->replicaSet));
|
||||
_connSettings->setServerHost(_replicaSetInfo->primary.host());
|
||||
_connSettings->setServerPort(_replicaSetInfo->primary.port());
|
||||
_connSettings->replicaSetSettings()->setCachedSetName(
|
||||
_connSettings->replicaSetSettings()->setNameUserEntered().empty() ? _replicaSetInfo->setName : "");
|
||||
|
||||
if (_connSettings->replicaSetSettings()->setNameUserEntered().empty()) {
|
||||
// Cache replica set name for 2 times faster first connection
|
||||
if (ConnectionPrimary == _connectionType) {
|
||||
ConnectionSettings* originalConnSettings = AppRegistry::instance().settingsManager()
|
||||
->getConnectionSettingsByUuid(event->info._uuid);
|
||||
if (originalConnSettings) {
|
||||
auto setName = event->isError() ? "" : _replicaSetInfo->setName;
|
||||
originalConnSettings->replicaSetSettings()->setCachedSetName(setName);
|
||||
AppRegistry::instance().settingsManager()->save();
|
||||
LOG_MSG("Replica set name cached as \"" + setName + "\".", mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
else
|
||||
LOG_MSG("Failed to cache the replica set name.", mongo::logger::LogSeverity::Warning());
|
||||
}
|
||||
}
|
||||
else { // User entered set name is not empty, clear cached set name just in case
|
||||
ConnectionSettings* originalConnSettings = AppRegistry::instance().settingsManager()
|
||||
->getConnectionSettingsByUuid(event->info._uuid);
|
||||
if (originalConnSettings) {
|
||||
originalConnSettings->replicaSetSettings()->setCachedSetName("");
|
||||
AppRegistry::instance().settingsManager()->save();
|
||||
LOG_MSG("Replica set's cached set name cleared. Using user entered set name.",
|
||||
mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MongoServer::handleConnectionFailure(EstablishConnectionResponse* event)
|
||||
{
|
||||
_isConnected = false;
|
||||
|
||||
std::stringstream ss("Unknown error");
|
||||
auto eventErrorReason = event->errorReason;
|
||||
|
||||
if (_connSettings->isReplicaSet())
|
||||
{
|
||||
ss.clear();
|
||||
std::string server = "";
|
||||
if (_connSettings->replicaSetSettings()->members().size() > 0)
|
||||
server = "[" + _connSettings->replicaSetSettings()->members().front() + "]";
|
||||
|
||||
if (event->error().errorCode() == EventError::ErrorCode::ServerHasDifferentMembers) {
|
||||
ss << "Cannot connect to replica set \"" << _connSettings->connectionName() << "\"" << server
|
||||
<< ". \n\nA primary with different host name [" << event->replicaSet.primary <<
|
||||
"] found in server side. "
|
||||
"Please double check if same host names and ports are used as in server's replica set"
|
||||
" configuration. \nIf same set name is used for different replica sets, this configuration"
|
||||
" is supported only on different instances of Robomongo. "
|
||||
" Please open a new Robomongo instance for each replica set which has the same set name."
|
||||
"\n\nReason:\n" << event->error().errorMessage();
|
||||
}
|
||||
else {
|
||||
ss << "Cannot connect to replica set \"" << _connSettings->connectionName() << "\"" << server
|
||||
<< ". \nSet's primary is unreachable.\n\nReason:\n" << event->error().errorMessage();
|
||||
}
|
||||
|
||||
_bus->publish(new ConnectionFailedEvent(this, _handle, event->connectionType, ss.str(),
|
||||
ConnectionFailedEvent::MongoConnection));
|
||||
_app->fireConnectionFailedEvent(_handle, event->connectionType, ss.str(),
|
||||
ConnectionFailedEvent::MongoConnection);
|
||||
LOG_MSG("Establish connection failed. " + event->error().errorMessage() + ". Connection: "
|
||||
+ _connSettings->connectionName(), mongo::logger::LogSeverity::Error());
|
||||
}
|
||||
else // single server
|
||||
{
|
||||
if (EstablishConnectionResponse::ErrorReason::MongoSslConnection == eventErrorReason)
|
||||
{
|
||||
auto reason = ConnectionFailedEvent::SslConnection;
|
||||
ss.clear();
|
||||
ss << "Cannot connect to the MongoDB at " << connectionRecord()->getFullAddress()
|
||||
<< ".\n\nError:\n" << "SSL connection failure: " << event->error().errorMessage();
|
||||
_app->fireConnectionFailedEvent(_handle, _connectionType, ss.str(), reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto reason = (EstablishConnectionResponse::ErrorReason::MongoAuth == eventErrorReason) ?
|
||||
ConnectionFailedEvent::MongoAuth : ConnectionFailedEvent::MongoConnection;
|
||||
ss.clear();
|
||||
ss << "Cannot connect to the MongoDB at " << connectionRecord()->getFullAddress()
|
||||
<< ".\n\nError:\n" << event->error().errorMessage();
|
||||
_app->fireConnectionFailedEvent(_handle, _connectionType, ss.str(), reason);
|
||||
}
|
||||
|
||||
// When connection cannot be established, we should cleanup this instance of MongoServer if it wasn't
|
||||
// shown in UI (i.e. it is not a Secondary connection that is used for shells tab)
|
||||
if (_connectionType == ConnectionPrimary || _connectionType == ConnectionTest)
|
||||
{
|
||||
LOG_MSG("Establish connection failed. " + event->error().errorMessage() +
|
||||
". Connection: " + _connSettings->connectionName(),
|
||||
mongo::logger::LogSeverity::Error());
|
||||
_app->closeServer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Robomongo
|
||||
|
||||
@@ -8,10 +8,16 @@ namespace Robomongo
|
||||
{
|
||||
class MongoWorker;
|
||||
class MongoDatabase;
|
||||
class EstablishConnectionResponse;
|
||||
class EventBus;
|
||||
class App;
|
||||
|
||||
// Messages
|
||||
struct EstablishConnectionResponse;
|
||||
struct RefreshReplicaSetFolderResponse;
|
||||
class LoadDatabaseNamesResponse;
|
||||
class InsertDocumentResponse;
|
||||
class EventBus;
|
||||
struct CreateDatabaseResponse;
|
||||
struct DropDatabaseResponse;
|
||||
|
||||
/**
|
||||
* @brief MongoServer represents active connection to MongoDB server.
|
||||
@@ -29,30 +35,60 @@ namespace Robomongo
|
||||
* @param visible
|
||||
* @param defaultDatabase
|
||||
*/
|
||||
MongoServer(ConnectionSettings *connectionRecord, bool visible);
|
||||
MongoServer(int handle, ConnectionSettings *connectionRecord, ConnectionType connectionType);
|
||||
~MongoServer();
|
||||
|
||||
void runWorkerThread();
|
||||
|
||||
/**
|
||||
* @brief Try to connect to MongoDB server.
|
||||
* @brief Try to connect to MongoDB single server or replica set.
|
||||
* @throws MongoException, if fails
|
||||
*/
|
||||
void tryConnect();
|
||||
bool isConnected()const;
|
||||
|
||||
/**
|
||||
* @brief Try to re-connect to MongoDB server in order to refresh connection view.
|
||||
* Never shown in Explorer and can be used to refresh (via reconnecting) current connection view.
|
||||
* (i.e. db version, storage engine etc...)
|
||||
* @throws MongoException, if fails
|
||||
*/
|
||||
void tryRefresh();
|
||||
|
||||
/**
|
||||
* @brief Try to re-connect to MongoDB replica set in order to refresh connection view.
|
||||
* It is used to refresh (via reconnecting) current connection view.
|
||||
* (i.e. db version, storage engine, current replica set primary, status of replica set etc...)
|
||||
* It will update Explorer widgets depending on replica set status (online if primary reachable and
|
||||
* offline otherwise)
|
||||
*/
|
||||
void tryRefreshReplicaSetConnection();
|
||||
|
||||
/**
|
||||
* @brief Try to re-connect to MongoDB replica set in order to refresh connection view.
|
||||
* It is used to refresh (via reconnecting) current connection view.
|
||||
* (i.e. db version, storage engine, current replica set primary, status of replica set etc...)
|
||||
* It will update only 'Replica Set' folder widgets depending on replica set status
|
||||
* (online if primary reachable and offline otherwise)
|
||||
*/
|
||||
void tryRefreshReplicaSetFolder(bool expanded, bool showLoading = true);
|
||||
|
||||
bool isConnected() const;
|
||||
|
||||
void addDatabase(MongoDatabase *database);
|
||||
void createDatabase(const std::string &dbName);
|
||||
void dropDatabase(const std::string &dbName);
|
||||
QStringList getDatabasesNames() const;
|
||||
QList<MongoDatabase*> const& databases() const { return _databases; };
|
||||
MongoDatabase *findDatabaseByName(const std::string &dbName) const;
|
||||
|
||||
void insertDocuments(const std::vector<mongo::BSONObj> &objCont, const MongoNamespace &ns);
|
||||
void insertDocument(const mongo::BSONObj &obj, const MongoNamespace &ns);
|
||||
void saveDocuments(const std::vector<mongo::BSONObj> &objCont, const MongoNamespace &ns);
|
||||
void saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns);
|
||||
void removeDocuments(mongo::Query query, const MongoNamespace &ns, bool justOne = true);
|
||||
void removeDocuments(mongo::Query query, const MongoNamespace &ns, RemoveDocumentCount removeCount,
|
||||
int index = 0);
|
||||
float version() const{ return _version; }
|
||||
|
||||
const std::string& getStorageEngineType() const { return _storageEngineType; }
|
||||
|
||||
/**
|
||||
* @brief Returns associated connection record
|
||||
@@ -63,28 +99,43 @@ namespace Robomongo
|
||||
* @brief Loads databases of this server asynchronously.
|
||||
*/
|
||||
void loadDatabases();
|
||||
bool visible() const { return _visible; }
|
||||
MongoWorker *const client() const { return _client; }
|
||||
MongoWorker *const worker() const { return _worker; }
|
||||
|
||||
ReplicaSet* replicaSetInfo() const { return _replicaSetInfo.get(); }
|
||||
|
||||
void handle(ReplicaSetRefreshed *event);
|
||||
|
||||
void changeWorkerShellTimeout(int newTimeout);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void handle(EstablishConnectionResponse *event);
|
||||
void handle(RefreshReplicaSetFolderResponse *event);
|
||||
void handle(LoadDatabaseNamesResponse *event);
|
||||
void handle(InsertDocumentResponse *event);
|
||||
void handle(RemoveDocumentResponse *event);
|
||||
void handle(CreateDatabaseResponse *event);
|
||||
void handle(DropDatabaseResponse *event);
|
||||
|
||||
private:
|
||||
private:
|
||||
void clearDatabases();
|
||||
void addDatabase(MongoDatabase *database);
|
||||
void handleReplicaSetRefreshEvents(bool isError, EventError eventError, ReplicaSet const& replicaSet,
|
||||
bool expanded);
|
||||
void updateReplicaSetSettings(EstablishConnectionResponse* event);
|
||||
void handleConnectionFailure(EstablishConnectionResponse* event);
|
||||
|
||||
MongoWorker* _client;
|
||||
ConnectionSettings* _settings;
|
||||
EventBus* _bus;
|
||||
MongoWorker *_worker;
|
||||
std::unique_ptr<ConnectionSettings> _connSettings;
|
||||
EventBus *_bus;
|
||||
App *_app;
|
||||
|
||||
float _version;
|
||||
bool _visible;
|
||||
std::string _storageEngineType;
|
||||
ConnectionType _connectionType;
|
||||
bool _isConnected;
|
||||
int _handle;
|
||||
|
||||
QList<MongoDatabase *> _databases;
|
||||
std::unique_ptr<ReplicaSet> _replicaSetInfo;
|
||||
};
|
||||
|
||||
class MongoServerLoadingDatabasesEvent : public Event
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "robomongo/core/settings/SettingsManager.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
{
|
||||
|
||||
MongoShell::MongoShell(MongoServer *server, const ScriptInfo &scriptInfo) :
|
||||
QObject(),
|
||||
@@ -24,7 +24,7 @@ namespace Robomongo
|
||||
{
|
||||
AppRegistry::instance().bus()->publish(new ScriptExecutingEvent(this));
|
||||
_scriptInfo.setScript(QtUtils::toQString(script));
|
||||
AppRegistry::instance().bus()->send(_server->client(), new ExecuteScriptRequest(this, query(), dbName));
|
||||
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteScriptRequest(this, query(), dbName));
|
||||
LOG_MSG(_scriptInfo.script(), mongo::logger::LogSeverity::Info());
|
||||
}
|
||||
|
||||
@@ -37,19 +37,19 @@ namespace Robomongo
|
||||
{
|
||||
if (_scriptInfo.execute()) {
|
||||
AppRegistry::instance().bus()->publish(new ScriptExecutingEvent(this));
|
||||
AppRegistry::instance().bus()->send(_server->client(), new ExecuteScriptRequest(this, query(), dbName));
|
||||
if(!_scriptInfo.script().isEmpty())
|
||||
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->client(), new ExecuteScriptRequest(this,query() , dbName));
|
||||
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteScriptRequest(this, query() , dbName));
|
||||
}
|
||||
}
|
||||
|
||||
void MongoShell::query(int resultIndex, const MongoQueryInfo &info)
|
||||
{
|
||||
AppRegistry::instance().bus()->send(_server->client(), new ExecuteQueryRequest(this, resultIndex, info));
|
||||
AppRegistry::instance().bus()->send(_server->worker(), new ExecuteQueryRequest(this, resultIndex, info));
|
||||
}
|
||||
|
||||
void MongoShell::autocomplete(const std::string &prefix)
|
||||
@@ -57,12 +57,12 @@ namespace Robomongo
|
||||
AutocompletionMode autocompletionMode = AppRegistry::instance().settingsManager()->autocompletionMode();
|
||||
if (autocompletionMode == AutocompleteNone)
|
||||
return;
|
||||
AppRegistry::instance().bus()->send(_server->client(), new AutocompleteRequest(this, prefix, autocompletionMode));
|
||||
AppRegistry::instance().bus()->send(_server->worker(), new AutocompleteRequest(this, prefix, autocompletionMode));
|
||||
}
|
||||
|
||||
void MongoShell::stop()
|
||||
{
|
||||
// _server->client()->interrupt();
|
||||
// _server->worker()->interrupt();
|
||||
// mongo::Scope::setInterruptFlag(true);
|
||||
}
|
||||
|
||||
@@ -94,11 +94,23 @@ namespace Robomongo
|
||||
void MongoShell::handle(ExecuteScriptResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->error()));
|
||||
return;
|
||||
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(), event->timeoutReached()));
|
||||
return;
|
||||
}
|
||||
else { // single server
|
||||
AppRegistry::instance().bus()->publish(
|
||||
new ScriptExecutedEvent(this, event->error(), event->timeoutReached()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->result, event->empty));
|
||||
AppRegistry::instance().bus()->publish(new ScriptExecutedEvent(this, event->result, event->empty,
|
||||
event->timeoutReached()));
|
||||
}
|
||||
|
||||
void MongoShell::handle(AutocompleteResponse *event)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Robomongo
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MongoShell(MongoServer *server,const 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);
|
||||
@@ -19,7 +19,7 @@ namespace Robomongo
|
||||
MongoServer *server() const { return _server; }
|
||||
std::string query() const;
|
||||
void execute(const std::string &dbName = std::string());
|
||||
bool isExecutable() const {return _scriptInfo.execute(); }
|
||||
bool isExecutable() const { return _scriptInfo.execute(); }
|
||||
const QString &title() const { return _scriptInfo.title(); }
|
||||
const CursorPosition &cursor() const { return _scriptInfo.cursor(); }
|
||||
void setScript(const QString &script) { return _scriptInfo.setScript(script); }
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
MongoShellResult::MongoShellResult(const std::string &type, const std::string &response, const MongoDocumentPtrContainerType &documents,
|
||||
const MongoQueryInfo &queryInfo, qint64 elapsedms) :
|
||||
MongoShellResult::MongoShellResult(const std::string &type, const std::string &response,
|
||||
const MongoDocumentPtrContainerType &documents,
|
||||
const MongoQueryInfo &queryInfo, qint64 elapsedms) :
|
||||
_type(type),
|
||||
_response(response),
|
||||
_documents(documents),
|
||||
@@ -12,10 +13,13 @@ namespace Robomongo
|
||||
|
||||
MongoShellExecResult::MongoShellExecResult(const std::vector<MongoShellResult> &results,
|
||||
const std::string ¤tServer, bool isCurrentServerValid,
|
||||
const std::string ¤tDatabase, bool isCurrentDatabaseValid) :
|
||||
const std::string ¤tDatabase, bool isCurrentDatabaseValid,
|
||||
bool timeoutReached /* = false */) :
|
||||
_results(results),
|
||||
_currentServer(currentServer),
|
||||
_currentDatabase(currentDatabase),
|
||||
_isCurrentServerValid(isCurrentServerValid),
|
||||
_isCurrentDatabaseValid(isCurrentDatabaseValid) { }
|
||||
_isCurrentDatabaseValid(isCurrentDatabaseValid),
|
||||
_timeoutReached(timeoutReached)
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Robomongo
|
||||
{
|
||||
public:
|
||||
typedef std::vector<MongoDocumentPtr> MongoDocumentPtrContainerType;
|
||||
MongoShellResult(const std::string &type, const std::string &response, const MongoDocumentPtrContainerType &documents,
|
||||
MongoShellResult(const std::string &type, const std::string &response,
|
||||
const MongoDocumentPtrContainerType &documents,
|
||||
const MongoQueryInfo &queryInfo, qint64 elapsedms);
|
||||
|
||||
std::string response() const { return _response; }
|
||||
@@ -29,15 +30,24 @@ namespace Robomongo
|
||||
{
|
||||
public:
|
||||
MongoShellExecResult() { }
|
||||
|
||||
MongoShellExecResult(const std::vector<MongoShellResult> &results,
|
||||
const std::string ¤tServer, bool isCurrentServerValid,
|
||||
const std::string ¤tDatabase, bool isCurrentDatabaseValid);
|
||||
const std::string ¤tDatabase, bool isCurrentDatabaseValid,
|
||||
bool timeoutReached = false);
|
||||
|
||||
std::vector<MongoShellResult> results() const { return _results; }
|
||||
MongoShellExecResult(bool error, std::string const& errorMsg = "", bool timeoutReached = false) :
|
||||
_error(error), _errorMessage(errorMsg), _timeoutReached(timeoutReached) { }
|
||||
|
||||
std::vector<MongoShellResult> const& results() const { return _results; }
|
||||
std::string currentServer() const { return _currentServer; }
|
||||
std::string currentDatabase() const { return _currentDatabase; }
|
||||
void setCurrentServer(std::string const& server) { _currentServer = server; }
|
||||
std::string currentDatabase() const { return _currentDatabase; }
|
||||
bool isCurrentServerValid() const { return _isCurrentServerValid; }
|
||||
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;
|
||||
@@ -45,5 +55,8 @@ namespace Robomongo
|
||||
std::string _currentDatabase;
|
||||
bool _isCurrentServerValid;
|
||||
bool _isCurrentDatabaseValid;
|
||||
std::string _errorMessage;
|
||||
bool _error = false;
|
||||
bool _timeoutReached = false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ namespace Robomongo
|
||||
_version(version), _readOnly(false)
|
||||
{
|
||||
_id = obj.getField("_id").OID();
|
||||
_name = BsonUtils::getField<mongo::String>(obj,"user");
|
||||
_passwordHash = BsonUtils::getField<mongo::String>(obj,"pwd");
|
||||
_name = BsonUtils::getField<mongo::String>(obj, "user");
|
||||
_passwordHash = BsonUtils::getField<mongo::String>(obj, "pwd");
|
||||
if (_version<minimumSupportedVersion) {
|
||||
_readOnly = BsonUtils::getField<mongo::Bool>(obj,"readOnly");
|
||||
_readOnly = BsonUtils::getField<mongo::Bool>(obj, "readOnly");
|
||||
}
|
||||
else {
|
||||
_userSource = BsonUtils::getField<mongo::String>(obj,"userSource");
|
||||
_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)
|
||||
for (std::vector<mongo::BSONElement>::const_iterator it = roles.begin(); it != roles.end(); ++it)
|
||||
{
|
||||
_role.push_back(BsonUtils::bsonelement_cast<std::string>(*it));
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace Robomongo
|
||||
}
|
||||
|
||||
MongoUser::MongoUser(const float version) :
|
||||
_version(version),_readOnly(false),_role() {}
|
||||
_version(version), _readOnly(false), _role() {}
|
||||
|
||||
mongo::BSONObj MongoUser::toBson() const
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace Robomongo
|
||||
builder.append("userSource", _userSource);
|
||||
|
||||
mongo::BSONArrayBuilder builderA;
|
||||
for (RoleType::const_iterator it = _role.begin(); it!=_role.end(); ++it)
|
||||
for (RoleType::const_iterator it = _role.begin(); it != _role.end(); ++it)
|
||||
{
|
||||
builderA << *it;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Robomongo
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
bool isSimpleType(Robomongo::BsonTreeItem *item)
|
||||
bool isSimpleType(Robomongo::BsonTreeItem const *item)
|
||||
{
|
||||
return Robomongo::BsonUtils::isSimpleType(item->type())
|
||||
|| Robomongo::BsonUtils::isUuidType(item->type(), item->binType());
|
||||
return BsonUtils::isSimpleType(item->type()) ||
|
||||
BsonUtils::isUuidType(item->type(), item->binType());
|
||||
}
|
||||
|
||||
bool isObjectIdType(Robomongo::BsonTreeItem *item)
|
||||
@@ -38,12 +38,22 @@ namespace Robomongo
|
||||
|
||||
bool isMultiSelection(const QModelIndexList &indexes)
|
||||
{
|
||||
return indexes.count()>1;
|
||||
return indexes.count() > 1;
|
||||
}
|
||||
|
||||
bool isDocumentType(BsonTreeItem *item)
|
||||
bool isDocumentType(BsonTreeItem const *item)
|
||||
{
|
||||
return Robomongo::BsonUtils::isDocument(item->type());
|
||||
return BsonUtils::isDocument(item->type());
|
||||
}
|
||||
|
||||
bool isArrayChild(BsonTreeItem const *item)
|
||||
{
|
||||
return BsonUtils::isArray(dynamic_cast<BsonTreeItem*>(item->parent())->type());
|
||||
}
|
||||
|
||||
bool isDocumentRoot(BsonTreeItem const *item)
|
||||
{
|
||||
return ( item == item->superParent() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,20 +65,20 @@ namespace Robomongo
|
||||
QModelIndexList uniqueRows(QModelIndexList indexes, bool returnSuperParents)
|
||||
{
|
||||
QModelIndexList result;
|
||||
for (QModelIndexList::const_iterator it = indexes.begin(); it!=indexes.end(); ++it)
|
||||
for (QModelIndexList::const_iterator it = indexes.begin(); it != indexes.end(); ++it)
|
||||
{
|
||||
QModelIndex isUnique = *it;
|
||||
Robomongo::BsonTreeItem *item = Robomongo::QtUtils::item<Robomongo::BsonTreeItem*>(isUnique);
|
||||
if(item){
|
||||
for (QModelIndexList::const_iterator jt = result.begin(); jt!=result.end(); ++jt)
|
||||
if (item) {
|
||||
for (QModelIndexList::const_iterator jt = result.begin(); jt != result.end(); ++jt)
|
||||
{
|
||||
Robomongo::BsonTreeItem *jItem = Robomongo::QtUtils::item<Robomongo::BsonTreeItem*>(*jt);
|
||||
if (jItem && jItem->superParent() == item->superParent()){
|
||||
if (jItem && jItem->superParent() == item->superParent()) {
|
||||
isUnique = QModelIndex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isUnique.isValid()){
|
||||
if (isUnique.isValid()) {
|
||||
if (returnSuperParents) {
|
||||
// Move index onto "super parent" element before pushing it into result set
|
||||
QModelIndex parent = isUnique.parent();
|
||||
@@ -92,8 +102,8 @@ namespace Robomongo
|
||||
_queryInfo(queryInfo)
|
||||
{
|
||||
QWidget *wid = dynamic_cast<QWidget*>(_observer);
|
||||
AppRegistry::instance().bus()->subscribe(this, InsertDocumentResponse::Type);
|
||||
AppRegistry::instance().bus()->subscribe(this, RemoveDocumentResponse::Type);
|
||||
AppRegistry::instance().bus()->subscribe(this, InsertDocumentResponse::Type, _shell->server());
|
||||
AppRegistry::instance().bus()->subscribe(this, RemoveDocumentResponse::Type, _shell->server());
|
||||
|
||||
_deleteDocumentAction = new QAction("Delete Document...", wid);
|
||||
VERIFY(connect(_deleteDocumentAction, SIGNAL(triggered()), SLOT(onDeleteDocument())));
|
||||
@@ -113,6 +123,12 @@ namespace Robomongo
|
||||
_copyValueAction = new QAction("Copy Value", wid);
|
||||
VERIFY(connect(_copyValueAction, SIGNAL(triggered()), SLOT(onCopyDocument())));
|
||||
|
||||
_copyValueNameAction = new QAction("Copy Name", wid);
|
||||
VERIFY(connect(_copyValueNameAction, SIGNAL(triggered()), SLOT(onCopyNameDocument())));
|
||||
|
||||
_copyValuePathAction = new QAction("Copy Path", wid);
|
||||
VERIFY(connect(_copyValuePathAction, SIGNAL(triggered()), SLOT(onCopyPathDocument())));
|
||||
|
||||
_copyTimestampAction = new QAction("Copy Timestamp from ObjectId", wid);
|
||||
VERIFY(connect(_copyTimestampAction, SIGNAL(triggered()), SLOT(onCopyTimestamp())));
|
||||
|
||||
@@ -128,20 +144,29 @@ namespace Robomongo
|
||||
bool isSimple = false;
|
||||
bool isDocument = false;
|
||||
bool isObjectId = false;
|
||||
bool isNotArrayChild = false;
|
||||
bool isRoot = false;
|
||||
|
||||
if (item) {
|
||||
isSimple = detail::isSimpleType(item);
|
||||
isDocument = detail::isDocumentType(item);
|
||||
isObjectId = detail::isObjectIdType(item);
|
||||
isNotArrayChild = !detail::isArrayChild(item);
|
||||
isRoot = detail::isDocumentRoot(item);
|
||||
}
|
||||
|
||||
if (onItem && isEditable) menu->addAction(_editDocumentAction);
|
||||
if (onItem) menu->addAction(_viewDocumentAction);
|
||||
if (isEditable) menu->addAction(_insertDocumentAction);
|
||||
|
||||
if (onItem && (isSimple || isDocument)) menu->addSeparator();
|
||||
|
||||
if (onItem && isSimple) menu->addAction(_copyValueAction);
|
||||
|
||||
if (onItem && (isSimple || isDocument) && isNotArrayChild && !isRoot)
|
||||
menu->addAction(_copyValueNameAction);
|
||||
|
||||
if (onItem && (isSimple || isDocument) && !isRoot)
|
||||
menu->addAction(_copyValuePathAction);
|
||||
|
||||
if (onItem && isObjectId) menu->addAction(_copyTimestampAction);
|
||||
if (onItem && isDocument) menu->addAction(_copyJsonAction);
|
||||
if (onItem && isEditable) menu->addSeparator();
|
||||
@@ -156,11 +181,12 @@ namespace Robomongo
|
||||
if (isEditable) menu->addAction(_deleteDocumentsAction);
|
||||
}
|
||||
|
||||
void Notifier::deleteDocuments(std::vector<BsonTreeItem*> items, bool force)
|
||||
void Notifier::deleteDocuments(std::vector<BsonTreeItem*> const& items, bool force)
|
||||
{
|
||||
bool isNeededRefresh = false;
|
||||
for (std::vector<BsonTreeItem*>::const_iterator it = items.begin(); it != items.end(); ++it) {
|
||||
BsonTreeItem * documentItem = *it;
|
||||
|
||||
int index = 0;
|
||||
for (auto const * const documentItem : items) {
|
||||
if (!documentItem)
|
||||
break;
|
||||
|
||||
@@ -168,7 +194,8 @@ namespace Robomongo
|
||||
mongo::BSONElement id = obj.getField("_id");
|
||||
|
||||
if (id.eoo()) {
|
||||
QMessageBox::warning(dynamic_cast<QWidget*>(_observer), "Cannot delete", "Selected document doesn't have _id field. \n"
|
||||
QMessageBox::warning(dynamic_cast<QWidget*>(_observer), "Cannot delete",
|
||||
"Selected document doesn't have _id field. \n"
|
||||
"Maybe this is a system document that should be managed in a special way?");
|
||||
break;
|
||||
}
|
||||
@@ -187,45 +214,98 @@ namespace Robomongo
|
||||
break;
|
||||
}
|
||||
|
||||
isNeededRefresh=true;
|
||||
_shell->server()->removeDocuments(query, _queryInfo._info._ns);
|
||||
}
|
||||
isNeededRefresh = true;
|
||||
|
||||
if (isNeededRefresh)
|
||||
_shell->query(0, _queryInfo);
|
||||
RemoveDocumentCount removeCount = items.size() == 1 ? RemoveDocumentCount::ONE :
|
||||
RemoveDocumentCount::MULTI;
|
||||
_shell->server()->removeDocuments(query, _queryInfo._info._ns, removeCount, index);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
void Notifier::handle(InsertDocumentResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
|
||||
if (event->isError()) { // Error
|
||||
if (_shell->server()->connectionRecord()->isReplicaSet()) {
|
||||
// Insert document from tab results window (Notifier, OutputWindow widget)
|
||||
if (EventError::SetPrimaryUnreachable == event->error().errorCode()) {
|
||||
AppRegistry::instance().bus()->publish(
|
||||
new ReplicaSetRefreshed(_shell, event->error(), event->error().replicaSetInfo()));
|
||||
}
|
||||
}
|
||||
else // single server
|
||||
QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Success
|
||||
_shell->query(0, _queryInfo);
|
||||
}
|
||||
|
||||
void Notifier::handle(RemoveDocumentResponse *event)
|
||||
{
|
||||
if (event->isError()) {
|
||||
// Commented because when you'll delete multiple documents,
|
||||
// we'll receive this event as many times as many selected
|
||||
// documents you have. This is incorrect and remove of
|
||||
// multiple documents should be a single command, instead
|
||||
// of many. Error message should be printed in the logs.
|
||||
if (event->isError()) {
|
||||
if (!(event->removeCount == RemoveDocumentCount::MULTI && event->index > 0))
|
||||
QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
|
||||
}
|
||||
else // Success
|
||||
_shell->query(0, _queryInfo);
|
||||
}
|
||||
|
||||
// QMessageBox::warning(NULL, "Database Error", QString::fromStdString(event->error().errorMessage()));
|
||||
void Notifier::onCopyNameDocument()
|
||||
{
|
||||
QModelIndex const& selectedInd = _observer->selectedIndex();
|
||||
if (!selectedInd.isValid())
|
||||
return;
|
||||
|
||||
BsonTreeItem const *documentItem = QtUtils::item<BsonTreeItem*>(selectedInd);
|
||||
if (!documentItem)
|
||||
return;
|
||||
|
||||
if (!(detail::isSimpleType(documentItem) || detail::isDocumentType(documentItem) ||
|
||||
!detail::isArrayChild(documentItem) || !detail::isDocumentRoot(documentItem)))
|
||||
return;
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(QString::fromStdString(documentItem->fieldName()));
|
||||
}
|
||||
|
||||
void Notifier::onCopyPathDocument()
|
||||
{
|
||||
QModelIndex const& selectedInd = _observer->selectedIndex();
|
||||
if (!selectedInd.isValid())
|
||||
return;
|
||||
|
||||
BsonTreeItem const *documentItem = QtUtils::item<BsonTreeItem*>(selectedInd);
|
||||
if (!documentItem)
|
||||
return;
|
||||
|
||||
if (!(detail::isSimpleType(documentItem) || detail::isDocumentType(documentItem) ||
|
||||
!detail::isDocumentRoot(documentItem)))
|
||||
return;
|
||||
|
||||
QStringList namesList;
|
||||
BsonTreeItem const *documentItemHelper = documentItem;
|
||||
|
||||
while (!detail::isDocumentRoot(documentItemHelper)) {
|
||||
if (!detail::isArrayChild(documentItemHelper)) {
|
||||
namesList.push_front(QString::fromStdString(documentItemHelper->fieldName()));
|
||||
}
|
||||
|
||||
documentItemHelper = dynamic_cast<BsonTreeItem*>(documentItemHelper->parent());
|
||||
}
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(namesList.join("."));
|
||||
}
|
||||
|
||||
void Notifier::handleDeleteCommand()
|
||||
{
|
||||
if (_observer->selectedIndexes().count() > 1) {
|
||||
if (_observer->selectedIndexes().count() > 1)
|
||||
onDeleteDocuments();
|
||||
} else {
|
||||
onDeleteDocument();
|
||||
}
|
||||
else
|
||||
onDeleteDocument();
|
||||
}
|
||||
|
||||
void Notifier::onDeleteDocuments()
|
||||
@@ -237,14 +317,16 @@ namespace Robomongo
|
||||
if (!detail::isMultiSelection(selectedIndexes))
|
||||
return;
|
||||
|
||||
int answer = QMessageBox::question(dynamic_cast<QWidget*>(_observer), "Delete", QString("Do you want to delete %1 selected documents?").arg(selectedIndexes.count()));
|
||||
if (answer == QMessageBox::Yes) {
|
||||
int const answer = QMessageBox::question(dynamic_cast<QWidget*>(_observer), "Delete",
|
||||
QString("Do you want to delete %1 selected documents?").
|
||||
arg(selectedIndexes.count()));
|
||||
|
||||
if (QMessageBox::Yes == answer) {
|
||||
std::vector<BsonTreeItem*> items;
|
||||
for (QModelIndexList::const_iterator it = selectedIndexes.begin(); it!= selectedIndexes.end(); ++it) {
|
||||
BsonTreeItem *item = QtUtils::item<BsonTreeItem*>(*it);
|
||||
items.push_back(item);
|
||||
}
|
||||
deleteDocuments(items,true);
|
||||
for (auto index : selectedIndexes)
|
||||
items.push_back(QtUtils::item<BsonTreeItem*>(index));
|
||||
|
||||
deleteDocuments(items, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +342,7 @@ namespace Robomongo
|
||||
BsonTreeItem *documentItem = QtUtils::item<BsonTreeItem*>(selectedIndex);
|
||||
std::vector<BsonTreeItem*> vec;
|
||||
vec.push_back(documentItem);
|
||||
return deleteDocuments(vec,false);
|
||||
return deleteDocuments(vec, false);
|
||||
}
|
||||
|
||||
void Notifier::onEditDocument()
|
||||
@@ -339,8 +421,6 @@ namespace Robomongo
|
||||
for (DocumentTextEditor::ReturnType::const_iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
_shell->server()->insertDocument(*it, _queryInfo._info._ns);
|
||||
}
|
||||
|
||||
_shell->query(0, _queryInfo);
|
||||
}
|
||||
|
||||
void Notifier::onCopyDocument()
|
||||
@@ -376,19 +456,19 @@ namespace Robomongo
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
|
||||
// new Date(parseInt(this.valueOf().slice(0,8), 16)*1000);
|
||||
QString hexTimestamp = documentItem->value().mid(10,8);
|
||||
QString hexTimestamp = documentItem->value().mid(10, 8);
|
||||
bool ok;
|
||||
long long milliTimestamp = (long long)hexTimestamp.toLongLong(&ok,16)*1000;
|
||||
long long milliTimestamp = (long long)hexTimestamp.toLongLong(&ok, 16)*1000;
|
||||
|
||||
bool isSupportedDate = (miutil::minDate < milliTimestamp) && (milliTimestamp < miutil::maxDate);
|
||||
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1));
|
||||
boost::posix_time::time_duration diff = boost::posix_time::millisec(milliTimestamp);
|
||||
boost::posix_time::ptime time = epoch + diff;
|
||||
|
||||
if(isSupportedDate)
|
||||
if (isSupportedDate)
|
||||
{
|
||||
std::string date = miutil::isotimeString(time,false,false);
|
||||
std::string date = miutil::isotimeString(time, false, false);
|
||||
clipboard->setText("ISODate(\""+QString::fromStdString(date)+"\")");
|
||||
}
|
||||
else {
|
||||
@@ -411,13 +491,13 @@ namespace Robomongo
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
mongo::BSONObj obj = documentItem->root();
|
||||
if (documentItem != documentItem->superParent()){
|
||||
obj = obj[QtUtils::toStdString(documentItem->key())].Obj();
|
||||
if (documentItem != documentItem->superParent()) {
|
||||
obj = obj[documentItem->fieldName()].Obj();
|
||||
}
|
||||
bool isArray = BsonUtils::isArray(documentItem->type());
|
||||
std::string str = BsonUtils::jsonString(obj, mongo::TenGen, 1,
|
||||
AppRegistry::instance().settingsManager()->uuidEncoding(),
|
||||
AppRegistry::instance().settingsManager()->timeZone(),isArray);
|
||||
AppRegistry::instance().settingsManager()->timeZone(), isArray);
|
||||
|
||||
const QString &json = QtUtils::toQString(str);
|
||||
clipboard->setText(json);
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace Robomongo
|
||||
class MongoShell;
|
||||
class BsonTreeItem;
|
||||
class InsertDocumentResponse;
|
||||
class RemoveDocumentResponse;
|
||||
struct RemoveDocumentResponse;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
bool isSimpleType(BsonTreeItem *item);
|
||||
bool isSimpleType(BsonTreeItem const *item);
|
||||
bool isObjectIdType(BsonTreeItem *item);
|
||||
bool isMultiSelection(const QModelIndexList &indexes);
|
||||
bool isDocumentType(BsonTreeItem *item);
|
||||
bool isDocumentType(BsonTreeItem const *item);
|
||||
QModelIndexList uniqueRows(QModelIndexList indexes, bool returnSuperParents = false);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Robomongo
|
||||
void initMenu(QMenu *const menu, BsonTreeItem *const item);
|
||||
void initMultiSelectionMenu(QMenu *const menu);
|
||||
|
||||
void deleteDocuments(std::vector<BsonTreeItem*> items, bool force);
|
||||
void deleteDocuments(std::vector<BsonTreeItem*> const& items, bool force);
|
||||
void handleDeleteCommand();
|
||||
|
||||
public Q_SLOTS:
|
||||
@@ -60,6 +60,10 @@ namespace Robomongo
|
||||
void handle(InsertDocumentResponse *event);
|
||||
void handle(RemoveDocumentResponse *event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCopyNameDocument();
|
||||
void onCopyPathDocument();
|
||||
|
||||
private:
|
||||
QAction *_deleteDocumentAction;
|
||||
QAction *_deleteDocumentsAction;
|
||||
@@ -67,6 +71,8 @@ namespace Robomongo
|
||||
QAction *_viewDocumentAction;
|
||||
QAction *_insertDocumentAction;
|
||||
QAction *_copyValueAction;
|
||||
QAction *_copyValueNameAction;
|
||||
QAction *_copyValuePathAction;
|
||||
QAction *_copyTimestampAction;
|
||||
QAction *_copyJsonAction;
|
||||
const MongoQueryInfo _queryInfo;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
ScriptInfo::ScriptInfo(const QString &script, bool execute,const CursorPosition &position,
|
||||
ScriptInfo::ScriptInfo(const QString &script, bool execute, const CursorPosition &position,
|
||||
const QString &title, const QString &filePath) :
|
||||
_script(script),
|
||||
_execute(execute),
|
||||
@@ -73,10 +73,10 @@ namespace Robomongo
|
||||
bool ScriptInfo::loadFromFile(const QString &filePath)
|
||||
{
|
||||
bool result = false;
|
||||
QString filepath = QFileDialog::getOpenFileName(QApplication::activeWindow(), filePath,QString(), filterForScripts);
|
||||
QString filepath = QFileDialog::getOpenFileName(QApplication::activeWindow(), filePath, QString(), filterForScripts);
|
||||
if (!filepath.isEmpty()) {
|
||||
QString out;
|
||||
if (loadFromFileText(filepath,out)) {
|
||||
if (loadFromFileText(filepath, out)) {
|
||||
_script = out;
|
||||
_filePath = filepath;
|
||||
result = true;
|
||||
@@ -95,7 +95,7 @@ namespace Robomongo
|
||||
QString filepath = QFileDialog::getSaveFileName(QApplication::activeWindow(),
|
||||
QObject::tr("Save As"), _filePath, filterForScripts);
|
||||
|
||||
if (saveToFileText(filepath,_script)) {
|
||||
if (saveToFileText(filepath, _script)) {
|
||||
_filePath = filepath;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
//#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
|
||||
@@ -50,39 +51,34 @@ namespace
|
||||
namespace mongo {
|
||||
extern bool isShell;
|
||||
void logProcessDetailsForLogRotate() {}
|
||||
void exitCleanly(ExitCode code) {}
|
||||
}
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
ScriptEngine::ScriptEngine(ConnectionSettings *connection) :
|
||||
ScriptEngine::ScriptEngine(ConnectionSettings *connection, int timeoutSec) :
|
||||
_connection(connection),
|
||||
_scope(NULL),
|
||||
_scope(nullptr),
|
||||
_engine(NULL),
|
||||
_timeoutSec(timeoutSec),
|
||||
_initialized(false),
|
||||
_mutex(QMutex::Recursive) { }
|
||||
|
||||
ScriptEngine::~ScriptEngine()
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
|
||||
delete _scope;
|
||||
_scope = NULL;
|
||||
|
||||
// delete _engine;
|
||||
// _engine = NULL;
|
||||
}
|
||||
|
||||
void ScriptEngine::init(bool isLoadMongoRcJs)
|
||||
void ScriptEngine::init(bool isLoadMongoRcJs, const std::string& serverAddr, const std::string& dbName)
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
|
||||
std::string connectDatabase = "test";
|
||||
std::string connectDatabase = dbName.empty() ? "test" : dbName;
|
||||
|
||||
if (_connection->hasEnabledPrimaryCredential())
|
||||
connectDatabase = _connection->primaryCredential()->databaseName();
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "db = connect('" << _connection->info().toString() << "/" << connectDatabase;
|
||||
auto hostAndPort = serverAddr.empty() ? _connection->hostAndPort().toString() : serverAddr;
|
||||
ss << "db = connect('" << hostAndPort << "/" << connectDatabase;
|
||||
|
||||
// v0.9
|
||||
// ss << "db = connect('" << _connection->serverHost() << ":" << _connection->serverPort() << _connection->sslInfo() << _connection->sshInfo() << "/" << connectDatabase;
|
||||
@@ -102,53 +98,70 @@ namespace Robomongo
|
||||
// mongo::isShell = true;
|
||||
|
||||
mongo::ScriptEngine::setConnectCallback( mongo::shell_utils::onConnect );
|
||||
mongo::ScriptEngine::setup();
|
||||
mongo::globalScriptEngine->setScopeInitCallback(mongo::shell_utils::initScope);
|
||||
mongo::globalScriptEngine->enableJIT(true);
|
||||
mongo::ScriptEngine::setup();
|
||||
mongo::getGlobalScriptEngine()->setScopeInitCallback(mongo::shell_utils::initScope);
|
||||
mongo::getGlobalScriptEngine()->enableJIT(true);
|
||||
|
||||
mongo::Scope *scope = mongo::globalScriptEngine->newScope();
|
||||
_scope = scope;
|
||||
_engine = mongo::globalScriptEngine;
|
||||
_scope.reset(mongo::getGlobalScriptEngine()->newScope());
|
||||
_engine = mongo::getGlobalScriptEngine();
|
||||
|
||||
// Load '.mongorc.js' from user's home directory
|
||||
if (isLoadMongoRcJs) {
|
||||
QString mongorcPath = QString("%1/.mongorc.js").arg(QDir::homePath());
|
||||
if (QFile::exists(mongorcPath)) {
|
||||
scope->execFile(QtUtils::toStdString(mongorcPath), false, false);
|
||||
_scope->execFile(QtUtils::toStdString(mongorcPath), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Load '.robomongorc.js'
|
||||
QString robomongorcPath = QString("%1/.robomongorc.js").arg(QDir::homePath());
|
||||
if (QFile::exists(robomongorcPath)) {
|
||||
scope->execFile(QtUtils::toStdString(robomongorcPath), false, false);
|
||||
_scope->execFile(QtUtils::toStdString(robomongorcPath), false, false);
|
||||
}
|
||||
_failedScope = false;
|
||||
}
|
||||
|
||||
// Esprima ECMAScript parser: http://esprima.org/
|
||||
QFile file(":/robomongo/scripts/esprima.js");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
throw std::runtime_error("Unable to read esprima.js ");
|
||||
std::string esprima = loadFile(":/robomongo/scripts/esprima.js", true);
|
||||
_scope->exec(esprima, "(esprima)", false, true, true);
|
||||
|
||||
QTextStream in(&file);
|
||||
QString esprima = in.readAll();
|
||||
|
||||
// Inject Esprima into Javascript scope
|
||||
_scope->exec(QtUtils::toStdString(esprima), "(esprima)", true, true, true);
|
||||
// UUID helpers
|
||||
std::string uuidhelpers = loadFile(":/robomongo/scripts/uuidhelpers.js", true);
|
||||
_scope->exec(uuidhelpers, "(uuidhelpers)", false, true, true);
|
||||
|
||||
// Enable verbose shell reporting
|
||||
_scope->exec("_verboseShell = true;", "(verboseShell)", false, false, false);
|
||||
|
||||
// Save original autocomplete function so it can be restored if overwritten by user preference
|
||||
_scope->exec("DB.autocompleteOriginal = DB.autocomplete;", "(saveOriginalAutocomplete)", false, false, false);
|
||||
|
||||
// Cache result of original "DB.autocomplete"
|
||||
// Cache invalidated by the invalidateDbCollectionsCache() method.
|
||||
std::string cacheAutocompletion =
|
||||
"__robomongoAutocompletionCache = null;"
|
||||
"DB.autocompleteCached = function(obj) { "
|
||||
" if (__robomongoAutocompletionCache == null) {"
|
||||
" __robomongoAutocompletionCache = DB.autocompleteOriginal(obj);"
|
||||
" }"
|
||||
" return __robomongoAutocompletionCache;"
|
||||
"}";
|
||||
|
||||
_scope->exec(cacheAutocompletion, "", false, false, false);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
MongoShellExecResult ScriptEngine::exec(const std::string &originalScript, const std::string &dbName)
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
|
||||
if(!_scope)
|
||||
return MongoShellExecResult();
|
||||
if (!_scope) {
|
||||
_failedScope = true;
|
||||
return MongoShellExecResult(true, "Connection error. Uninitialized mongo scope.");
|
||||
}
|
||||
|
||||
// robomongo shell timeout
|
||||
bool timeoutReached = false;
|
||||
|
||||
/*
|
||||
* Replace all commands ('show dbs', 'use db' etc.) with call
|
||||
@@ -177,7 +190,7 @@ namespace Robomongo
|
||||
|
||||
use(dbName);
|
||||
|
||||
for(std::vector<std::string>::const_iterator it = statements.begin(); it != statements.end(); ++it)
|
||||
for (std::vector<std::string>::const_iterator it = statements.begin(); it != statements.end(); ++it)
|
||||
{
|
||||
std::string statement = *it;
|
||||
// clear global objects
|
||||
@@ -188,17 +201,28 @@ namespace Robomongo
|
||||
|
||||
if (true /* ! wascmd */) {
|
||||
try {
|
||||
bool failed = false;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
if ( _scope->exec( statement , "(shell)" , false , true , false, 0 ) ) {
|
||||
_scope->exec( "__robomongoLastRes = __lastres__; shellPrintHelper( __lastres__ );" , "(shell2)" , true , true , false, 0);
|
||||
if ( _scope->exec( statement , "(shell)" , false , true , false, _timeoutSec * 1000) ) {
|
||||
_scope->exec( "__robomongoLastRes = __lastres__; shellPrintHelper( __lastres__ );",
|
||||
"(shell2)" , true , true , false, _timeoutSec * 1000);
|
||||
}
|
||||
else // failed to run script
|
||||
failed = true;
|
||||
|
||||
qint64 elapsed = timer.elapsed();
|
||||
qint64 elapsed = timer.elapsed(); // milliseconds
|
||||
|
||||
if (elapsed > _timeoutSec * 1000)
|
||||
timeoutReached = true;
|
||||
|
||||
std::string logs = __logs.str();
|
||||
std::string answer = logs.c_str();
|
||||
std::string type = __type.c_str();
|
||||
|
||||
if (failed && !timeoutReached)
|
||||
return MongoShellExecResult(true, answer);
|
||||
|
||||
std::vector<MongoDocumentPtr> docs = MongoDocument::fromBsonObj(__objects);
|
||||
|
||||
if (!answer.empty() || docs.size() > 0)
|
||||
@@ -210,7 +234,7 @@ namespace Robomongo
|
||||
}
|
||||
}
|
||||
|
||||
return prepareExecResult(results);
|
||||
return prepareExecResult(results, timeoutReached);
|
||||
}
|
||||
|
||||
void ScriptEngine::interrupt()
|
||||
@@ -251,8 +275,11 @@ namespace Robomongo
|
||||
|
||||
void ScriptEngine::ping()
|
||||
{
|
||||
if (!_scope)
|
||||
return;
|
||||
|
||||
QMutexLocker lock(&_mutex);
|
||||
_scope->exec("if (db) { db.runCommand({ping:1}); }", "(ping)", false, false, false);
|
||||
_scope->exec("if (db) { db.runCommand({ping:1}); }", "(ping)", false, false, false, 3000);
|
||||
}
|
||||
|
||||
QStringList ScriptEngine::complete(const std::string &prefix, const AutocompletionMode mode)
|
||||
@@ -262,7 +289,7 @@ namespace Robomongo
|
||||
|
||||
try {
|
||||
if (mode == AutocompleteAll)
|
||||
_scope->exec("DB.autocomplete = DB.autocompleteOriginal;", "", false, false, false);
|
||||
_scope->exec("DB.autocomplete = DB.autocompleteCached;", "", false, false, false);
|
||||
else if (mode == AutocompleteNoCollectionNames)
|
||||
_scope->exec("DB.autocomplete = function(obj){return [];}", "", false, false, false);
|
||||
|
||||
@@ -336,7 +363,8 @@ namespace Robomongo
|
||||
return MongoShellResult(type, output, objects, MongoQueryInfo(), elapsedms);
|
||||
}
|
||||
|
||||
MongoShellExecResult ScriptEngine::prepareExecResult(const std::vector<MongoShellResult> &results)
|
||||
MongoShellExecResult ScriptEngine::prepareExecResult(const std::vector<MongoShellResult> &results,
|
||||
bool timeoutReached /* = false */)
|
||||
{
|
||||
const char *script =
|
||||
"__robomongoServerAddress = '[invalid connection]'; \n"
|
||||
@@ -358,7 +386,7 @@ namespace Robomongo
|
||||
std::string dbName = getString("__robomongoDbName");
|
||||
bool dbIsValid = _scope->getBoolean("__robomongoDbIsValid");
|
||||
|
||||
return MongoShellExecResult(results, serverName, serverIsValid, dbName, dbIsValid);
|
||||
return MongoShellExecResult(results, serverName, serverIsValid, dbName, dbIsValid, timeoutReached);
|
||||
}
|
||||
|
||||
std::string ScriptEngine::getString(const char *fieldName)
|
||||
@@ -413,4 +441,25 @@ namespace Robomongo
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptEngine::invalidateDbCollectionsCache() {
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_scope->exec("__robomongoAutocompletionCache = null;", "", false, false, false);
|
||||
}
|
||||
|
||||
std::string ScriptEngine::loadFile(const QString &path, bool throwOnError) {
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
if (throwOnError)
|
||||
throw std::runtime_error("Unable to load file");
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
QString content = in.readAll();
|
||||
return QtUtils::toStdString(content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace Robomongo
|
||||
{
|
||||
|
||||
public:
|
||||
ScriptEngine(ConnectionSettings *connection);
|
||||
ScriptEngine(ConnectionSettings *connection, int timeoutSec);
|
||||
~ScriptEngine();
|
||||
|
||||
void init(bool isLoadMongoJs);
|
||||
void init(bool isLoadMongoJs, const std::string& serverAddr = "", const std::string& dbName = "");
|
||||
MongoShellExecResult exec(const std::string &script, const std::string &dbName = std::string());
|
||||
void interrupt();
|
||||
|
||||
@@ -27,20 +27,30 @@ namespace Robomongo
|
||||
void ping();
|
||||
QStringList complete(const std::string &prefix, const AutocompletionMode mode);
|
||||
|
||||
void invalidateDbCollectionsCache();
|
||||
|
||||
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);
|
||||
MongoShellExecResult prepareExecResult(const std::vector<MongoShellResult> &results);
|
||||
MongoShellResult prepareResult(const std::string &type, const std::string &output,
|
||||
const std::vector<MongoDocumentPtr> &objects, qint64 elapsedms);
|
||||
|
||||
MongoShellExecResult prepareExecResult(const std::vector<MongoShellResult> &results,
|
||||
bool timeoutReached = false);
|
||||
|
||||
std::string loadFile(const QString &path, bool throwOnError);
|
||||
std::string getString(const char *fieldName);
|
||||
|
||||
bool statementize(const std::string &script, std::vector<std::string> &outList, std::string &outError);
|
||||
std::vector<std::string> statementize2(const std::string &script);
|
||||
// void parseTree(JSParseNode * root, int indent, const std::string &script, std::vector<std::string> &list, bool topList);
|
||||
|
||||
int _timeoutSec;
|
||||
mongo::ScriptEngine *_engine;
|
||||
mongo::Scope *_scope;
|
||||
std::unique_ptr<mongo::Scope> _scope;
|
||||
bool _failedScope = false;
|
||||
QMutex _mutex;
|
||||
bool _initialized;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ namespace Robomongo
|
||||
{
|
||||
R_REGISTER_EVENT(EstablishConnectionRequest)
|
||||
R_REGISTER_EVENT(EstablishConnectionResponse)
|
||||
R_REGISTER_EVENT(ReplicaSetRefreshed)
|
||||
R_REGISTER_EVENT(RefreshReplicaSetFolderRequest)
|
||||
R_REGISTER_EVENT(RefreshReplicaSetFolderResponse)
|
||||
R_REGISTER_EVENT(ReplicaSetFolderLoading)
|
||||
R_REGISTER_EVENT(ReplicaSetFolderRefreshed)
|
||||
R_REGISTER_EVENT(LoadDatabaseNamesRequest)
|
||||
R_REGISTER_EVENT(LoadDatabaseNamesResponse)
|
||||
R_REGISTER_EVENT(LoadCollectionNamesRequest)
|
||||
@@ -66,4 +71,5 @@ namespace Robomongo
|
||||
R_REGISTER_EVENT(ListenSshConnectionResponse)
|
||||
R_REGISTER_EVENT(LogEvent)
|
||||
R_REGISTER_EVENT(StopScriptRequest)
|
||||
R_REGISTER_EVENT(OperationFailedEvent)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "robomongo/core/events/MongoEventsInfo.h"
|
||||
#include "robomongo/core/Event.h"
|
||||
#include "robomongo/core/Enums.h"
|
||||
#include "robomongo/core/mongodb/ReplicaSet.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
@@ -26,32 +27,119 @@ namespace Robomongo
|
||||
* @brief EstablishConnection
|
||||
*/
|
||||
|
||||
class EstablishConnectionRequest : public Event
|
||||
struct EstablishConnectionRequest : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
EstablishConnectionRequest(QObject *sender) :
|
||||
EstablishConnectionRequest(QObject *sender, ConnectionType connectionType, std::string const& uuid) :
|
||||
Event(sender),
|
||||
connectionType(connectionType),
|
||||
uuid(uuid) {}
|
||||
|
||||
ConnectionType const connectionType;
|
||||
std::string const uuid;
|
||||
};
|
||||
|
||||
struct EstablishConnectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
enum ErrorReason {
|
||||
NoError = 0,
|
||||
MongoConnection = 1,
|
||||
MongoAuth = 2,
|
||||
MongoSslConnection = 3
|
||||
};
|
||||
|
||||
EstablishConnectionResponse(QObject *sender, const ConnectionInfo &info, ConnectionType connectionType,
|
||||
const ReplicaSet& replicaSet) :
|
||||
Event(sender),
|
||||
info(info),
|
||||
connectionType(connectionType),
|
||||
replicaSet(replicaSet)
|
||||
{}
|
||||
|
||||
EstablishConnectionResponse(QObject *sender, const EventError &error, ConnectionType connectionType,
|
||||
ConnectionInfo const& info, const ReplicaSet& replicaSet, ErrorReason errorReason) :
|
||||
Event(sender, error),
|
||||
info(info),
|
||||
connectionType(connectionType),
|
||||
errorReason(errorReason),
|
||||
replicaSet(replicaSet)
|
||||
{}
|
||||
|
||||
ConnectionInfo const info;
|
||||
ConnectionType const connectionType;
|
||||
ErrorReason const errorReason = NoError;
|
||||
ReplicaSet const replicaSet;
|
||||
};
|
||||
|
||||
struct ReplicaSetRefreshed : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ReplicaSetRefreshed(QObject *sender) :
|
||||
Event(sender) {}
|
||||
|
||||
ReplicaSetRefreshed(QObject *sender, const EventError &error, ReplicaSet const& replicaSet) :
|
||||
Event(sender, error), replicaSet(replicaSet) {}
|
||||
|
||||
ReplicaSet const replicaSet;
|
||||
};
|
||||
|
||||
struct RefreshReplicaSetFolderRequest : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
RefreshReplicaSetFolderRequest(QObject *sender, bool expanded) :
|
||||
Event(sender), expanded(expanded) {}
|
||||
|
||||
bool const expanded = false;
|
||||
};
|
||||
|
||||
struct RefreshReplicaSetFolderResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
// Primary is reachable
|
||||
RefreshReplicaSetFolderResponse(QObject *sender, ReplicaSet const& replicaSet, bool expanded) :
|
||||
Event(sender), replicaSet(replicaSet), expanded(expanded) {}
|
||||
|
||||
// Primary is unreachable, secondary(ies) might be reachable
|
||||
RefreshReplicaSetFolderResponse(QObject *sender, ReplicaSet const& replicaSet, bool expanded,
|
||||
const EventError &error) :
|
||||
Event(sender, error), replicaSet(replicaSet), expanded(expanded) {}
|
||||
|
||||
ReplicaSet const replicaSet;
|
||||
bool const expanded = false;
|
||||
};
|
||||
|
||||
struct ReplicaSetFolderLoading : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ReplicaSetFolderLoading(QObject *sender) :
|
||||
Event(sender) {}
|
||||
};
|
||||
|
||||
class EstablishConnectionResponse : public Event
|
||||
struct ReplicaSetFolderRefreshed : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
EstablishConnectionResponse(QObject *sender, const ConnectionInfo &info) :
|
||||
Event(sender),
|
||||
_info(info) {}
|
||||
ReplicaSetFolderRefreshed(QObject *sender, bool expanded) :
|
||||
Event(sender), expanded(expanded) {}
|
||||
|
||||
EstablishConnectionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error),_info() {}
|
||||
ReplicaSetFolderRefreshed(QObject *sender, const EventError &error, bool expanded) :
|
||||
Event(sender, error), expanded(expanded) {}
|
||||
|
||||
const ConnectionInfo &info() const{
|
||||
return _info;
|
||||
}
|
||||
const ConnectionInfo _info;
|
||||
ReplicaSetFolderRefreshed(QObject *sender, const EventError &error, ReplicaSet const& replicaSet,
|
||||
bool expanded) :
|
||||
Event(sender, error), replicaSet(replicaSet), expanded(expanded) {}
|
||||
|
||||
ReplicaSet const replicaSet;
|
||||
bool const expanded = false;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief LoadDatabaseNames
|
||||
*/
|
||||
@@ -109,7 +197,7 @@ namespace Robomongo
|
||||
_databaseName(databaseName),
|
||||
_collectionInfos(collectionInfos) { }
|
||||
|
||||
LoadCollectionNamesResponse(QObject *sender,const EventError &error) :
|
||||
LoadCollectionNamesResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
|
||||
std::string databaseName() const { return _databaseName; }
|
||||
@@ -125,7 +213,7 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
public:
|
||||
LoadCollectionIndexesRequest(QObject *sender, const MongoCollectionInfo &collection) :
|
||||
Event(sender),_collection(collection) {}
|
||||
Event(sender), _collection(collection) {}
|
||||
MongoCollectionInfo collection() const { return _collection; }
|
||||
private:
|
||||
const MongoCollectionInfo _collection;
|
||||
@@ -148,7 +236,7 @@ namespace Robomongo
|
||||
class EnsureIndexRequest : public Event
|
||||
{
|
||||
R_EVENT
|
||||
EnsureIndexRequest(QObject *sender,const EnsureIndexInfo &oldInfo,const EnsureIndexInfo &newInfo) : Robomongo::Event(sender),oldInfo_(oldInfo),newInfo_(newInfo) {}
|
||||
EnsureIndexRequest(QObject *sender, const EnsureIndexInfo &oldInfo, const EnsureIndexInfo &newInfo) : Robomongo::Event(sender), oldInfo_(oldInfo), newInfo_(newInfo) {}
|
||||
const EnsureIndexInfo &oldInfo() const
|
||||
{
|
||||
return oldInfo_;
|
||||
@@ -172,7 +260,7 @@ namespace Robomongo
|
||||
_name(name) {}
|
||||
|
||||
MongoCollectionInfo collection() const { return _collection; }
|
||||
std::string name() const {return _name;}
|
||||
std::string name() const { return _name; }
|
||||
private:
|
||||
const MongoCollectionInfo _collection;
|
||||
std::string _name;
|
||||
@@ -182,14 +270,14 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
public:
|
||||
DeleteCollectionIndexResponse(QObject *sender, const MongoCollectionInfo &collection,const std::string &index) :
|
||||
Event(sender),_collection(collection),_index(index) {}
|
||||
DeleteCollectionIndexResponse(QObject *sender, const MongoCollectionInfo &collection, const std::string &index) :
|
||||
Event(sender), _collection(collection), _index(index) {}
|
||||
|
||||
DeleteCollectionIndexResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
|
||||
MongoCollectionInfo collection() const { return _collection; }
|
||||
std::string index() const {return _index;}
|
||||
std::string index() const { return _index; }
|
||||
private:
|
||||
MongoCollectionInfo _collection;
|
||||
std::string _index;
|
||||
@@ -199,11 +287,11 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
public:
|
||||
EditIndexRequest(QObject *sender, const MongoCollectionInfo &collection,const std::string &oldIndex,const std::string &newIndex) :
|
||||
Event(sender),_collection(collection),_oldIndex(oldIndex),_newIndex(newIndex) {}
|
||||
EditIndexRequest(QObject *sender, const MongoCollectionInfo &collection, const std::string &oldIndex, const std::string &newIndex) :
|
||||
Event(sender), _collection(collection), _oldIndex(oldIndex), _newIndex(newIndex) {}
|
||||
MongoCollectionInfo collection() const { return _collection; }
|
||||
std::string oldIndex() const {return _oldIndex;}
|
||||
std::string newIndex() const {return _newIndex;}
|
||||
std::string oldIndex() const { return _oldIndex; }
|
||||
std::string newIndex() const { return _newIndex; }
|
||||
private:
|
||||
const MongoCollectionInfo _collection;
|
||||
std::string _oldIndex;
|
||||
@@ -240,7 +328,7 @@ namespace Robomongo
|
||||
_databaseName(databaseName),
|
||||
_users(users) { }
|
||||
|
||||
LoadUsersResponse(QObject *sender,const EventError &error) :
|
||||
LoadUsersResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
|
||||
std::string databaseName() const { return _databaseName; }
|
||||
@@ -282,7 +370,7 @@ namespace Robomongo
|
||||
_databaseName(databaseName),
|
||||
_functions(functions) { }
|
||||
|
||||
LoadFunctionsResponse(QObject *sender,const EventError &error) :
|
||||
LoadFunctionsResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
|
||||
std::string databaseName() const { return _databaseName; }
|
||||
@@ -326,7 +414,7 @@ namespace Robomongo
|
||||
InsertDocumentResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
|
||||
InsertDocumentResponse(QObject *sender, const EventError &error) :
|
||||
InsertDocumentResponse(QObject *sender, EventError const& error) :
|
||||
Event(sender, error) {}
|
||||
};
|
||||
|
||||
@@ -334,37 +422,46 @@ namespace Robomongo
|
||||
* @brief Remove Document
|
||||
*/
|
||||
|
||||
enum class RemoveDocumentCount { ONE, MULTI, ALL };
|
||||
|
||||
class RemoveDocumentRequest : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
RemoveDocumentRequest(QObject *sender, mongo::Query query, const MongoNamespace &ns, bool justOne = true) :
|
||||
RemoveDocumentRequest(QObject *sender, mongo::Query query, const MongoNamespace &ns,
|
||||
RemoveDocumentCount removeCount, int index) :
|
||||
Event(sender),
|
||||
_query(query),
|
||||
_ns(ns),
|
||||
_justOne(justOne) {}
|
||||
_removeCount(removeCount),
|
||||
_index(index) {}
|
||||
|
||||
mongo::Query query() const { return _query; }
|
||||
MongoNamespace ns() const { return _ns; }
|
||||
bool justOne() const { return _justOne; }
|
||||
RemoveDocumentCount removeCount() const { return _removeCount; }
|
||||
int index() const { return _index; }
|
||||
|
||||
private:
|
||||
mongo::Query _query;
|
||||
const MongoNamespace _ns;
|
||||
bool _justOne;
|
||||
mongo::Query const _query;
|
||||
MongoNamespace const _ns;
|
||||
RemoveDocumentCount const _removeCount;
|
||||
// if this is a multi remove, this is the index of current document deleted. 0 for first document.
|
||||
int const _index;
|
||||
};
|
||||
|
||||
class RemoveDocumentResponse : public Event
|
||||
struct RemoveDocumentResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
RemoveDocumentResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
RemoveDocumentResponse(QObject *sender, RemoveDocumentCount removeCount, int index) :
|
||||
Event(sender), removeCount(removeCount), index(index) {}
|
||||
|
||||
RemoveDocumentResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
RemoveDocumentResponse(QObject *sender, const EventError &error, RemoveDocumentCount removeCount, int index) :
|
||||
Event(sender, error), removeCount(removeCount), index(index) {}
|
||||
|
||||
RemoveDocumentCount const removeCount;
|
||||
int const index;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -383,52 +480,49 @@ namespace Robomongo
|
||||
std::string database() const { return _database; }
|
||||
|
||||
private:
|
||||
std::string _database;
|
||||
std::string const _database;
|
||||
};
|
||||
|
||||
class CreateDatabaseResponse : public Event
|
||||
struct CreateDatabaseResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
CreateDatabaseResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
CreateDatabaseResponse(QObject *sender, const std::string &database) :
|
||||
Event(sender), database(database) {}
|
||||
|
||||
CreateDatabaseResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
CreateDatabaseResponse(QObject *sender, const std::string &database, const EventError &error) :
|
||||
Event(sender, error), database(database) {}
|
||||
|
||||
std::string const database;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Drop Database
|
||||
*/
|
||||
|
||||
class DropDatabaseRequest : public Event
|
||||
struct DropDatabaseRequest : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropDatabaseRequest(QObject *sender, const std::string &database) :
|
||||
Event(sender),
|
||||
_database(database) {}
|
||||
Event(sender), database(database) {}
|
||||
|
||||
std::string database() const { return _database; }
|
||||
|
||||
private:
|
||||
std::string _database;
|
||||
std::string const database;
|
||||
};
|
||||
|
||||
class DropDatabaseResponse : public Event
|
||||
struct DropDatabaseResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropDatabaseResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
DropDatabaseResponse(QObject *sender, const std::string &database) :
|
||||
Event(sender), database(database) {}
|
||||
|
||||
DropDatabaseResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
DropDatabaseResponse(QObject *sender, const std::string &database, const EventError &error) :
|
||||
Event(sender, error), database(database) {}
|
||||
|
||||
std::string const database;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -440,26 +534,40 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
CreateCollectionRequest(QObject *sender, const MongoNamespace &ns) :
|
||||
Event(sender),
|
||||
_ns(ns) {}
|
||||
CreateCollectionRequest(QObject *sender, const MongoNamespace &ns,
|
||||
const mongo::BSONObj& extraOptions,
|
||||
long long size = 0,
|
||||
bool capped = false,
|
||||
int maxDocNum = 0
|
||||
) :
|
||||
Event(sender), _ns(ns), _extraOptions(extraOptions),
|
||||
_size(size), _capped(capped), _maxDocNum(maxDocNum) {}
|
||||
|
||||
MongoNamespace ns() const { return _ns; }
|
||||
long long getSize() const { return _size; }
|
||||
bool getCapped() const { return _capped; }
|
||||
int getMaxDocNum() const { return _maxDocNum; }
|
||||
const mongo::BSONObj getExtraOptions() const { return _extraOptions; }
|
||||
|
||||
private:
|
||||
const MongoNamespace _ns;
|
||||
MongoNamespace const _ns;
|
||||
long long const _size;
|
||||
bool const _capped;
|
||||
int const _maxDocNum;
|
||||
mongo::BSONObj const _extraOptions;
|
||||
};
|
||||
|
||||
class CreateCollectionResponse : public Event
|
||||
struct CreateCollectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
CreateCollectionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
CreateCollectionResponse(QObject *sender, std::string const& collection) :
|
||||
Event(sender), collection(collection) {}
|
||||
|
||||
CreateCollectionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
CreateCollectionResponse(QObject *sender, std::string const& collection, const EventError &error) :
|
||||
Event(sender, error), collection(collection) {}
|
||||
|
||||
std::string const collection;
|
||||
};
|
||||
|
||||
|
||||
@@ -483,16 +591,18 @@ namespace Robomongo
|
||||
MongoNamespace _ns;
|
||||
};
|
||||
|
||||
class DropCollectionResponse : public Event
|
||||
struct DropCollectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropCollectionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
DropCollectionResponse(QObject *sender, std::string const& collection) :
|
||||
Event(sender), collection(collection) {}
|
||||
|
||||
DropCollectionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
DropCollectionResponse(QObject *sender, std::string const& collection, const EventError &error) :
|
||||
Event(sender, error), collection(collection) {}
|
||||
|
||||
std::string const collection;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -513,20 +623,23 @@ namespace Robomongo
|
||||
std::string newCollection() const { return _newCollection; }
|
||||
|
||||
private:
|
||||
MongoNamespace _ns;
|
||||
std::string _newCollection;
|
||||
MongoNamespace const _ns;
|
||||
std::string const _newCollection;
|
||||
};
|
||||
|
||||
class RenameCollectionResponse : public Event
|
||||
struct RenameCollectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
RenameCollectionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
RenameCollectionResponse(QObject *sender, std::string const& oldCollection,
|
||||
std::string const& newCollection) :
|
||||
Event(sender), oldCollection(oldCollection), newCollection(newCollection) {}
|
||||
|
||||
RenameCollectionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
|
||||
std::string const oldCollection;
|
||||
std::string const newCollection;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -547,20 +660,24 @@ namespace Robomongo
|
||||
std::string newCollection() const { return _newCollection; }
|
||||
|
||||
private:
|
||||
MongoNamespace _ns;
|
||||
std::string _newCollection;
|
||||
MongoNamespace const _ns;
|
||||
std::string const _newCollection;
|
||||
};
|
||||
|
||||
class DuplicateCollectionResponse : public Event
|
||||
struct DuplicateCollectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DuplicateCollectionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
DuplicateCollectionResponse(QObject *sender, std::string const& sourceCollection,
|
||||
std::string const& duplicateCollection) :
|
||||
Event(sender), sourceCollection(sourceCollection), duplicateCollection(duplicateCollection) {}
|
||||
|
||||
DuplicateCollectionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
DuplicateCollectionResponse(QObject *sender, std::string const& sourceCollection, const EventError &error) :
|
||||
Event(sender, error), sourceCollection(sourceCollection) {}
|
||||
|
||||
std::string const sourceCollection;
|
||||
std::string const duplicateCollection;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -580,7 +697,7 @@ namespace Robomongo
|
||||
_to(databaseTo, collection) {}
|
||||
|
||||
MongoWorker *worker() const { return _worker; }
|
||||
MongoNamespace from() const { return _from;}
|
||||
MongoNamespace from() const { return _from; }
|
||||
MongoNamespace to() const { return _to; }
|
||||
private:
|
||||
MongoWorker *_worker;
|
||||
@@ -625,16 +742,17 @@ namespace Robomongo
|
||||
bool _overwrite;
|
||||
};
|
||||
|
||||
class CreateUserResponse : public Event
|
||||
struct CreateUserResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
CreateUserResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
CreateUserResponse(QObject *sender, std::string const& userName) :
|
||||
Event(sender), userName(userName) {}
|
||||
|
||||
CreateUserResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
CreateUserResponse(QObject *sender, std::string const& userName, const EventError &error) :
|
||||
Event(sender, error), userName(userName) {}
|
||||
|
||||
std::string const userName;
|
||||
};
|
||||
|
||||
|
||||
@@ -647,29 +765,31 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropUserRequest(QObject *sender, const std::string &database, const mongo::OID &id) :
|
||||
Event(sender),
|
||||
_database(database),
|
||||
_id(id) {}
|
||||
DropUserRequest(QObject *sender, const std::string &database, const mongo::OID &id,
|
||||
std::string const& username) :
|
||||
Event(sender), _database(database), _id(id), _username(username) {}
|
||||
|
||||
std::string database() const { return _database; }
|
||||
mongo::OID id() const { return _id; }
|
||||
std::string username() const { return _username; }
|
||||
|
||||
private:
|
||||
std::string _database;
|
||||
mongo::OID _id;
|
||||
std::string const _username;
|
||||
};
|
||||
|
||||
class DropUserResponse : public Event
|
||||
struct DropUserResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropUserResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
DropUserResponse(QObject *sender, std::string const& username) :
|
||||
Event(sender), username(username) {}
|
||||
|
||||
DropUserResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
DropUserResponse(QObject *sender, std::string const& username, const EventError &error) :
|
||||
Event(sender, error), username(username) {}
|
||||
|
||||
std::string const username;
|
||||
};
|
||||
|
||||
|
||||
@@ -682,39 +802,45 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
CreateFunctionRequest(QObject *sender, const std::string &database, const MongoFunction &function,
|
||||
const std::string &existingFunctionName = std::string(), bool overwrite = false) :
|
||||
CreateFunctionRequest(QObject *sender, const std::string &database, float dbVersion,
|
||||
const MongoFunction &function, const std::string &existingFunctionName = std::string(),
|
||||
bool overwrite = false) :
|
||||
Event(sender),
|
||||
_database(database),
|
||||
_dbVersion(dbVersion),
|
||||
_existingFunctionName(existingFunctionName),
|
||||
_function(function),
|
||||
_overwrite(overwrite) {}
|
||||
|
||||
std::string database() const { return _database; }
|
||||
float dbVersion() const { return _dbVersion; }
|
||||
std::string existingFunctionName() const { return _existingFunctionName; }
|
||||
MongoFunction function() const { return _function; }
|
||||
bool overwrite() const { return _overwrite; }
|
||||
|
||||
private:
|
||||
std::string _database;
|
||||
float const _dbVersion = 0.0f;
|
||||
std::string _existingFunctionName;
|
||||
MongoFunction _function;
|
||||
bool _overwrite;
|
||||
};
|
||||
|
||||
class CreateFunctionResponse : public Event
|
||||
struct CreateFunctionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
enum Operation { NewFunction, NameUpdate, CodeUpdate }; // todo
|
||||
|
||||
public:
|
||||
CreateFunctionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
CreateFunctionResponse(QObject *sender, std::string const& functionName) :
|
||||
Event(sender), functionName(functionName) {}
|
||||
|
||||
CreateFunctionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
CreateFunctionResponse(QObject *sender, std::string const& functionName, const EventError &error) :
|
||||
Event(sender, error), functionName(functionName) {}
|
||||
|
||||
std::string const functionName;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Drop Function
|
||||
*/
|
||||
@@ -724,29 +850,34 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropFunctionRequest(QObject *sender, const std::string &database, const std::string &name) :
|
||||
DropFunctionRequest(QObject *sender, const std::string &database, float dbVersion,
|
||||
const std::string &funcName) :
|
||||
Event(sender),
|
||||
_database(database),
|
||||
_name(name) {}
|
||||
_dbVersion(dbVersion),
|
||||
_functionName(funcName) {}
|
||||
|
||||
std::string database() const { return _database; }
|
||||
std::string name() const { return _name; }
|
||||
float dbVersion() const { return _dbVersion; }
|
||||
std::string functionName() const { return _functionName; }
|
||||
|
||||
private:
|
||||
std::string _database;
|
||||
std::string _name;
|
||||
float const _dbVersion = 0.0f;
|
||||
std::string _functionName;
|
||||
};
|
||||
|
||||
class DropFunctionResponse : public Event
|
||||
struct DropFunctionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
DropFunctionResponse(QObject *sender) :
|
||||
Event(sender) {}
|
||||
DropFunctionResponse(QObject *sender, const std::string &functionName) :
|
||||
Event(sender), functionName(functionName) {}
|
||||
|
||||
DropFunctionResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
DropFunctionResponse(QObject *sender, const std::string &functionName, const EventError &error) :
|
||||
Event(sender, error), functionName(functionName) {}
|
||||
|
||||
std::string const functionName;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -806,7 +937,7 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
AutocompleteResponse(QObject *sender,const QStringList &list, const std::string &prefix) :
|
||||
AutocompleteResponse(QObject *sender, const QStringList &list, const std::string &prefix) :
|
||||
Event(sender),
|
||||
list(list),
|
||||
prefix(prefix) {}
|
||||
@@ -844,16 +975,18 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ExecuteScriptResponse(QObject *sender, const MongoShellExecResult &result, bool empty) :
|
||||
Event(sender),
|
||||
result(result),
|
||||
empty(empty) { }
|
||||
ExecuteScriptResponse(QObject *sender, const MongoShellExecResult &result, bool empty,
|
||||
bool timeoutReached = false) :
|
||||
Event(sender), result(result), empty(empty), _timeoutReached(timeoutReached) {}
|
||||
|
||||
ExecuteScriptResponse(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
ExecuteScriptResponse(QObject *sender, const EventError &error, bool timeoutReached = false) :
|
||||
Event(sender, error), _timeoutReached(timeoutReached) {}
|
||||
|
||||
bool timeoutReached() const { return _timeoutReached; }
|
||||
|
||||
MongoShellExecResult result;
|
||||
bool empty;
|
||||
bool const _timeoutReached = false;
|
||||
};
|
||||
|
||||
class ConnectingEvent : public Event
|
||||
@@ -879,27 +1012,43 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ConnectionFailedEvent(QObject *sender, const std::string& message) :
|
||||
Event(sender),
|
||||
message(message) {}
|
||||
enum Reason {
|
||||
MongoConnection = 1,
|
||||
MongoAuth = 2,
|
||||
SshConnection = 3,
|
||||
SshChannel = 4,
|
||||
SslConnection = 5
|
||||
};
|
||||
|
||||
ConnectionFailedEvent(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
ConnectionFailedEvent(QObject *sender, int serverHandle, ConnectionType connectionType,
|
||||
const std::string& message, Reason reason) :
|
||||
Event(sender),
|
||||
message(message),
|
||||
reason(reason),
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
std::string message;
|
||||
Reason reason;
|
||||
ConnectionType connectionType;
|
||||
int serverHandle;
|
||||
};
|
||||
|
||||
// class ScriptExecute
|
||||
|
||||
class ConnectionEstablishedEvent : public Event
|
||||
struct ConnectionEstablishedEvent : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ConnectionEstablishedEvent(MongoServer *server) :
|
||||
ConnectionEstablishedEvent(MongoServer *server, ConnectionType type, ConnectionInfo connInfo) :
|
||||
Event((QObject *)server),
|
||||
server(server) { }
|
||||
server(server),
|
||||
connectionType(type),
|
||||
connInfo(connInfo) { }
|
||||
|
||||
MongoServer *server;
|
||||
ConnectionType const connectionType;
|
||||
ConnectionInfo const connInfo;
|
||||
};
|
||||
|
||||
class DatabaseListLoadedEvent : public Event
|
||||
@@ -948,20 +1097,21 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
ScriptExecutedEvent(QObject *sender, const MongoShellExecResult &result, bool empty) :
|
||||
Event(sender),
|
||||
_result(result),
|
||||
_empty(empty) { }
|
||||
ScriptExecutedEvent(QObject *sender, const MongoShellExecResult &result, bool empty,
|
||||
bool timeoutReached = false) :
|
||||
Event(sender), _result(result), _empty(empty), _timeoutReached(timeoutReached) {}
|
||||
|
||||
ScriptExecutedEvent(QObject *sender, const EventError &error) :
|
||||
Event(sender, error) {}
|
||||
ScriptExecutedEvent(QObject *sender, const EventError &error, bool timeoutReached = false) :
|
||||
Event(sender, error), _timeoutReached(timeoutReached) {}
|
||||
|
||||
MongoShellExecResult result() const { return _result; }
|
||||
bool empty() const { return _empty; }
|
||||
bool timeoutReached() const { return _timeoutReached; }
|
||||
|
||||
private:
|
||||
MongoShellExecResult _result;
|
||||
bool _empty;
|
||||
bool const _timeoutReached = false;
|
||||
};
|
||||
|
||||
class ScriptExecutingEvent : public Event
|
||||
@@ -973,6 +1123,20 @@ namespace Robomongo
|
||||
Event(sender) { }
|
||||
};
|
||||
|
||||
class OperationFailedEvent : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
public:
|
||||
OperationFailedEvent(QObject *sender, const std::string &technicalErrorMessage, const std::string &userFriendlyErrorMessage) :
|
||||
technicalErrorMessage(technicalErrorMessage),
|
||||
userFriendlyErrorMessage(userFriendlyErrorMessage),
|
||||
Event(sender) { }
|
||||
|
||||
std::string technicalErrorMessage;
|
||||
std::string userFriendlyErrorMessage;
|
||||
};
|
||||
|
||||
class QueryWidgetUpdatedEvent : public Event
|
||||
{
|
||||
R_EVENT
|
||||
@@ -996,38 +1160,43 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
EstablishSshConnectionRequest(QObject *sender, SshTunnelWorker* worker, ConnectionSettings* settings, bool visible) :
|
||||
EstablishSshConnectionRequest(QObject *sender, int serverHandle, SshTunnelWorker* worker, ConnectionSettings* settings, ConnectionType connectionType) :
|
||||
Event(sender),
|
||||
worker(worker),
|
||||
settings(settings),
|
||||
visible(visible) {}
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
ConnectionSettings* settings;
|
||||
bool visible;
|
||||
ConnectionType connectionType;
|
||||
SshTunnelWorker* worker;
|
||||
int serverHandle;
|
||||
};
|
||||
|
||||
class EstablishSshConnectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
EstablishSshConnectionResponse(QObject *sender, SshTunnelWorker* worker, ConnectionSettings* settings, bool visible, int localport) :
|
||||
EstablishSshConnectionResponse(QObject *sender, int serverHandle, SshTunnelWorker* worker, ConnectionSettings* settings, ConnectionType connectionType, int localport) :
|
||||
Event(sender),
|
||||
worker(worker),
|
||||
settings(settings),
|
||||
visible(visible),
|
||||
connectionType(connectionType),
|
||||
serverHandle(serverHandle),
|
||||
localport(localport) {}
|
||||
|
||||
EstablishSshConnectionResponse(QObject *sender, const EventError &error, SshTunnelWorker* worker, ConnectionSettings* settings, bool visible) :
|
||||
EstablishSshConnectionResponse(QObject *sender, int serverHandle, const EventError &error, SshTunnelWorker* worker, ConnectionSettings* settings, ConnectionType connectionType) :
|
||||
Event(sender, error),
|
||||
worker(worker),
|
||||
settings(settings),
|
||||
visible(visible) {}
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
ConnectionSettings* settings;
|
||||
bool visible;
|
||||
ConnectionType connectionType;
|
||||
SshTunnelWorker* worker;
|
||||
int localport;
|
||||
int serverHandle;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1038,23 +1207,34 @@ namespace Robomongo
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ListenSshConnectionRequest(QObject *sender) :
|
||||
Event(sender) {}
|
||||
ListenSshConnectionRequest(QObject *sender, int serverHandle, ConnectionType connectionType) :
|
||||
Event(sender),
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
ConnectionType connectionType;
|
||||
int serverHandle;
|
||||
};
|
||||
|
||||
class ListenSshConnectionResponse : public Event
|
||||
{
|
||||
R_EVENT
|
||||
|
||||
ListenSshConnectionResponse(QObject *sender, ConnectionSettings* settings) :
|
||||
ListenSshConnectionResponse(QObject *sender, int serverHandle, ConnectionSettings* settings, ConnectionType connectionType) :
|
||||
Event(sender),
|
||||
settings(settings) {}
|
||||
settings(settings),
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
ListenSshConnectionResponse(QObject *sender, const EventError &error, ConnectionSettings* settings) :
|
||||
ListenSshConnectionResponse(QObject *sender, const EventError &error, int serverHandle, ConnectionSettings* settings, ConnectionType connectionType) :
|
||||
Event(sender, error),
|
||||
settings(settings) {}
|
||||
settings(settings),
|
||||
serverHandle(serverHandle),
|
||||
connectionType(connectionType) {}
|
||||
|
||||
ConnectionSettings* settings;
|
||||
ConnectionType connectionType;
|
||||
int serverHandle;
|
||||
};
|
||||
|
||||
class LogEvent : public Event
|
||||
@@ -1062,10 +1242,10 @@ namespace Robomongo
|
||||
R_EVENT
|
||||
|
||||
enum LogLevel {
|
||||
ERROR = 1,
|
||||
WARN = 2,
|
||||
INFO = 3,
|
||||
DEBUG = 100 // log as much as possible
|
||||
RBM_ERROR = 1,
|
||||
RBM_WARN = 2,
|
||||
RBM_INFO = 3,
|
||||
RBM_DEBUG = 100 // log as much as possible
|
||||
};
|
||||
|
||||
LogEvent(QObject *sender, const std::string& message, LogLevel level) :
|
||||
|
||||
@@ -17,13 +17,19 @@ namespace Robomongo
|
||||
_languageOverride(languageOverride),
|
||||
_textWeights(textWeights) {}
|
||||
|
||||
ConnectionInfo::ConnectionInfo() :
|
||||
ConnectionInfo::ConnectionInfo(std::string const& uuid) :
|
||||
_address(),
|
||||
_databases(),
|
||||
_version(0.0f) {}
|
||||
_version(0.0f),
|
||||
_uuid(uuid)
|
||||
{}
|
||||
|
||||
ConnectionInfo::ConnectionInfo(const std::string &address, const std::vector<std::string> &databases, float version) :
|
||||
ConnectionInfo::ConnectionInfo(const std::string &address, const std::vector<std::string> &databases,
|
||||
float version, const std::string& storageEngine, std::string const& uuid) :
|
||||
_address(address),
|
||||
_databases(databases),
|
||||
_version(version) {}
|
||||
_version(version),
|
||||
_storageEngineType(storageEngine),
|
||||
_uuid(uuid)
|
||||
{}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,13 @@ namespace Robomongo
|
||||
|
||||
struct ConnectionInfo
|
||||
{
|
||||
ConnectionInfo();
|
||||
ConnectionInfo(const std::string &address, const std::vector<std::string> &databases, float version);
|
||||
ConnectionInfo(std::string const& uuid);
|
||||
ConnectionInfo(const std::string &address, const std::vector<std::string> &databases, float version,
|
||||
const std::string& storageEngine, std::string const& uuid);
|
||||
const std::string _address;
|
||||
const std::vector<std::string> _databases;
|
||||
const float _version;
|
||||
const std::string _storageEngineType;
|
||||
std::string const _uuid;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "robomongo/core/mongodb/MongoClient.h"
|
||||
|
||||
#include "mongo/db/namespace_string.h"
|
||||
|
||||
#include "robomongo/core/domain/MongoDocument.h"
|
||||
#include "robomongo/core/utils/BsonUtils.h"
|
||||
#include "robomongo/shell/bson/json.h"
|
||||
@@ -13,7 +15,7 @@ namespace
|
||||
using namespace Robomongo::BsonUtils;
|
||||
Robomongo::EnsureIndexInfo info(collection);
|
||||
info._name = getField<mongo::String>(obj, "name");
|
||||
mongo::BSONObj keyObj = getField<mongo::Object>(obj,"key");
|
||||
mongo::BSONObj keyObj = getField<mongo::Object>(obj, "key");
|
||||
if (keyObj.isValid()) {
|
||||
info._request = jsonString(keyObj, mongo::TenGen, 1, Robomongo::DefaultEncoding, Robomongo::Utc);
|
||||
}
|
||||
@@ -37,30 +39,35 @@ namespace Robomongo
|
||||
MongoClient::MongoClient(mongo::DBClientBase *const dbclient) :
|
||||
_dbclient(dbclient) { }
|
||||
|
||||
std::vector<std::string> MongoClient::getCollectionNames(const std::string &dbname) const
|
||||
std::vector<std::string> MongoClient::getCollectionNamesWithDbname(const std::string &dbname) const
|
||||
{
|
||||
typedef std::list<std::string> cont_string_t;
|
||||
cont_string_t dbs = _dbclient->getCollectionNames(dbname);
|
||||
std::list<mongo::BSONObj> collList = _dbclient->getCollectionInfos(dbname);
|
||||
|
||||
std::vector<std::string> stringList;
|
||||
for (cont_string_t::const_iterator i = dbs.begin(); i != dbs.end(); i++) {
|
||||
stringList.push_back(*i);
|
||||
}
|
||||
std::sort(stringList.begin(), stringList.end());
|
||||
return stringList;
|
||||
std::vector<std::string> collNames;
|
||||
for (auto const& coll : collList)
|
||||
collNames.push_back(dbname + '.' + coll.getStringField("name")); // todo: verify
|
||||
|
||||
std::sort(collNames.begin(), collNames.end());
|
||||
return collNames;
|
||||
}
|
||||
|
||||
|
||||
float MongoClient::getVersion() const
|
||||
{
|
||||
float result = 0.0f;
|
||||
mongo::BSONObj resultObj;
|
||||
_dbclient->runCommand("db", BSON("buildInfo" << "1"), resultObj);
|
||||
std::string resultStr = BsonUtils::getField<mongo::String>(resultObj,"version");
|
||||
std::string resultStr = BsonUtils::getField<mongo::String>(resultObj, "version");
|
||||
result = atof(resultStr.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string MongoClient::getStorageEngineType() const
|
||||
{
|
||||
mongo::BSONObj resultObj;
|
||||
_dbclient->runCommand("db", BSON("serverStatus" << "1"), resultObj);
|
||||
return resultObj.getObjectField("storageEngine").getStringField("name");
|
||||
}
|
||||
|
||||
std::vector<std::string> MongoClient::getDatabaseNames() const
|
||||
{
|
||||
typedef std::list<std::string> cont_string_t;
|
||||
@@ -87,7 +94,7 @@ namespace Robomongo
|
||||
float ver = getVersion();
|
||||
while (cursor->more()) {
|
||||
mongo::BSONObj bsonObj = cursor->next();
|
||||
MongoUser user(ver,bsonObj);
|
||||
MongoUser user(ver, bsonObj);
|
||||
users.push_back(user);
|
||||
}
|
||||
|
||||
@@ -99,9 +106,10 @@ namespace Robomongo
|
||||
MongoNamespace ns(dbName, "system.users");
|
||||
mongo::BSONObj obj = user.toBson();
|
||||
|
||||
if (!overwrite) {
|
||||
if (!overwrite) { // create new user
|
||||
_dbclient->insert(ns.toString(), obj);
|
||||
} else {
|
||||
}
|
||||
else { // update existing user
|
||||
mongo::BSONElement id = obj.getField("_id");
|
||||
mongo::BSONObjBuilder builder;
|
||||
builder.append(id);
|
||||
@@ -110,6 +118,10 @@ namespace Robomongo
|
||||
|
||||
_dbclient->update(ns.toString(), query, obj, true, false);
|
||||
}
|
||||
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
}
|
||||
|
||||
void MongoClient::dropUser(const std::string &dbName, const mongo::OID &id)
|
||||
@@ -122,6 +134,10 @@ namespace Robomongo
|
||||
mongo::Query query(bsonQuery);
|
||||
|
||||
_dbclient->remove(ns.toString(), query, true);
|
||||
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
}
|
||||
|
||||
std::vector<MongoFunction> MongoClient::getFunctions(const std::string &dbName)
|
||||
@@ -137,10 +153,9 @@ namespace Robomongo
|
||||
|
||||
while (cursor->more()) {
|
||||
mongo::BSONObj bsonObj = cursor->next();
|
||||
|
||||
try {
|
||||
MongoFunction user(bsonObj);
|
||||
functions.push_back(user);
|
||||
MongoFunction func(bsonObj);
|
||||
functions.push_back(func);
|
||||
} catch (const std::exception &) {
|
||||
// skip invalid docs
|
||||
}
|
||||
@@ -153,17 +168,15 @@ namespace Robomongo
|
||||
std::vector<EnsureIndexInfo> result;
|
||||
std::list<mongo::BSONObj> indexes = _dbclient->getIndexSpecs(collection.ns().toString());
|
||||
|
||||
// std::unique_ptr<mongo::DBClientCursor> cursor(_dbclient->getIndexSpecs(collection.ns().toString()));
|
||||
|
||||
for (std::list<mongo::BSONObj>::iterator it = indexes.begin(); it != indexes.end(); ++it) {
|
||||
mongo::BSONObj bsonObj = *it;
|
||||
result.push_back(makeEnsureIndexInfoFromBsonObj(collection,bsonObj));
|
||||
result.push_back(makeEnsureIndexInfoFromBsonObj(collection, bsonObj));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void MongoClient::ensureIndex(const EnsureIndexInfo &oldInfo,const EnsureIndexInfo &newInfo) const
|
||||
void MongoClient::ensureIndex(const EnsureIndexInfo &oldInfo, const EnsureIndexInfo &newInfo) const
|
||||
{
|
||||
std::string ns = newInfo._collection.ns().toString();
|
||||
|
||||
@@ -172,8 +185,8 @@ namespace Robomongo
|
||||
|
||||
mongo::BSONObj keys = mongo::Robomongo::fromjson(newInfo._request);
|
||||
mongo::BSONObjBuilder toSave;
|
||||
bool cache=true;
|
||||
int version =-1;
|
||||
bool cache = true;
|
||||
int version = -1;
|
||||
|
||||
toSave.append( "ns" , ns );
|
||||
toSave.append( "key" , keys );
|
||||
@@ -284,36 +297,46 @@ namespace Robomongo
|
||||
_dbclient->dropIndex(collection.ns().toString(), indexName);
|
||||
}
|
||||
|
||||
void MongoClient::createFunction(const std::string &dbName, const MongoFunction &fun, const std::string &existingFunctionName /* = QString() */)
|
||||
void MongoClient::createFunction(const std::string &dbName, const MongoFunction &fun,
|
||||
const std::string &existingFunctionName /* = QString() */)
|
||||
{
|
||||
MongoNamespace ns(dbName, "system.js");
|
||||
mongo::BSONObj obj = fun.toBson();
|
||||
|
||||
if (existingFunctionName.empty()) { // this is insert
|
||||
if (existingFunctionName.empty()) { // create new function
|
||||
_dbclient->insert(ns.toString(), obj);
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
} else { // this is update
|
||||
|
||||
std::string name = fun.name();
|
||||
|
||||
if (existingFunctionName == name) {
|
||||
if (existingFunctionName == name) { // update existing function code
|
||||
mongo::BSONObjBuilder builder;
|
||||
builder.append("_id", name);
|
||||
mongo::BSONObj bsonQuery = builder.obj();
|
||||
mongo::Query query(bsonQuery);
|
||||
|
||||
_dbclient->update(ns.toString(), query, obj, true, false);
|
||||
} else {
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
} else { // update function name (remove & insert)
|
||||
_dbclient->insert(ns.toString(), obj);
|
||||
std::string res = _dbclient->getLastError();
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
|
||||
// if no errors
|
||||
if (res.empty()) {
|
||||
if (errorStr.empty()) {
|
||||
mongo::BSONObjBuilder builder;
|
||||
builder.append("_id", existingFunctionName);
|
||||
mongo::BSONObj bsonQuery = builder.obj();
|
||||
mongo::Query query(bsonQuery);
|
||||
_dbclient->remove(ns.toString(), query, true);
|
||||
}
|
||||
else {
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,6 +351,9 @@ namespace Robomongo
|
||||
mongo::Query query(bsonQuery);
|
||||
|
||||
_dbclient->remove(ns.toString(), query, true);
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
}
|
||||
|
||||
void MongoClient::createDatabase(const std::string &dbName)
|
||||
@@ -342,7 +368,7 @@ namespace Robomongo
|
||||
|
||||
// If <dbName>.temp already exists, stop.
|
||||
if (_dbclient->exists(ns.toString()))
|
||||
return;
|
||||
throw mongo::DBException(dbName + ".temp already exists.", 0);
|
||||
|
||||
// Building { _id : "temp" } document
|
||||
mongo::BSONObjBuilder builder;
|
||||
@@ -351,6 +377,9 @@ namespace Robomongo
|
||||
|
||||
// Insert this document
|
||||
_dbclient->insert(ns.toString(), obj);
|
||||
std::string errorStr = _dbclient->getLastError();
|
||||
if (!errorStr.empty())
|
||||
throw mongo::DBException(errorStr, 0);
|
||||
|
||||
// Drop temp collection
|
||||
_dbclient->dropCollection(ns.toString());
|
||||
@@ -358,12 +387,50 @@ namespace Robomongo
|
||||
|
||||
void MongoClient::dropDatabase(const std::string &dbName)
|
||||
{
|
||||
_dbclient->dropDatabase(dbName);
|
||||
mongo::BSONObj info;
|
||||
if (!_dbclient->dropDatabase(dbName, mongo::WriteConcernOptions(), &info)) { // todo: do we catch errorStr via info - test it??
|
||||
std::string errStr = info.toString();
|
||||
if (errStr.empty())
|
||||
errStr = "Failed to get error message.";
|
||||
|
||||
throw mongo::DBException(errStr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoClient::createCollection(const MongoNamespace &ns)
|
||||
void MongoClient::createCollection(const std::string& ns, long long size, bool capped, int max,
|
||||
const mongo::BSONObj& extraOptions, mongo::BSONObj* info)
|
||||
{
|
||||
_dbclient->createCollection(ns.toString());
|
||||
verify(!capped || size);
|
||||
mongo::BSONObj o;
|
||||
if (info == 0)
|
||||
info = &o;
|
||||
mongo::BSONObjBuilder b;
|
||||
std::string db = mongo::nsToDatabase(ns);
|
||||
b.append("create", ns.c_str() + db.length() + 1);
|
||||
if (size) {
|
||||
b.append("size", size);
|
||||
}
|
||||
if (capped) {
|
||||
b.append("capped", true);
|
||||
}
|
||||
if (max) {
|
||||
b.append("max", max);
|
||||
}
|
||||
b.appendElements(extraOptions);
|
||||
|
||||
if (!_dbclient->exists(ns)) {
|
||||
mongo::BSONObj result;
|
||||
if (!_dbclient->runCommand(db.c_str(), b.done(), result)) {
|
||||
std::string errStr = result.getStringField("errmsg");
|
||||
if (errStr.empty())
|
||||
errStr = "Failed to get error message.";
|
||||
|
||||
throw mongo::DBException(errStr, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw mongo::DBException("Collection with same name already exists.", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoClient::renameCollection(const MongoNamespace &ns, const std::string &newCollectionName)
|
||||
@@ -377,18 +444,38 @@ namespace Robomongo
|
||||
command.append("to", to.toString());
|
||||
|
||||
mongo::BSONObj result;
|
||||
_dbclient->runCommand("admin", command.obj(), result); // this command should be run against "admin" db
|
||||
if (!_dbclient->runCommand("admin", command.obj(), result)) { // this command should be run against "admin" db
|
||||
std::string errStr = result.getStringField("errmsg");
|
||||
if (errStr.empty())
|
||||
errStr = "Failed to get error message.";
|
||||
|
||||
throw mongo::DBException(errStr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoClient::duplicateCollection(const MongoNamespace &ns, const std::string &newCollectionName)
|
||||
{
|
||||
MongoNamespace from(ns);
|
||||
MongoNamespace to(ns.databaseName(), newCollectionName);
|
||||
MongoNamespace sourceCollection(ns);
|
||||
MongoNamespace newCollection(ns.databaseName(), newCollectionName);
|
||||
|
||||
if (!_dbclient->exists(to.toString()))
|
||||
_dbclient->createCollection(to.toString());
|
||||
if (!_dbclient->exists(newCollection.toString())) {
|
||||
mongo::BSONObj result;
|
||||
// todo: Issue #1258 : Duplicate Collection should support advanced collection options.
|
||||
// _dbclient->createCollection() should be called with properties of source collection
|
||||
// not with default parameters as below.
|
||||
if (!_dbclient->createCollection(newCollection.toString(), 0, false, 0, &result)) {
|
||||
std::string errStr = result.getStringField("errmsg");
|
||||
if (errStr.empty())
|
||||
errStr = "Failed to get error message.";
|
||||
|
||||
std::unique_ptr<mongo::DBClientCursor> cursor(_dbclient->query(from.toString(), mongo::Query()));
|
||||
throw mongo::DBException(errStr, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw mongo::DBException("Collection with same name already exists.", 0);
|
||||
}
|
||||
|
||||
std::unique_ptr<mongo::DBClientCursor> cursor(_dbclient->query(sourceCollection.toString(), mongo::Query()));
|
||||
|
||||
// Cursor may be NULL, it means we have connectivity problem
|
||||
if (!cursor)
|
||||
@@ -396,11 +483,12 @@ namespace Robomongo
|
||||
|
||||
while (cursor->more()) {
|
||||
mongo::BSONObj bsonObj = cursor->next();
|
||||
_dbclient->insert(to.toString(), bsonObj);
|
||||
_dbclient->insert(newCollection.toString(), bsonObj);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoClient::copyCollectionToDiffServer(mongo::DBClientBase *const fromServ,const MongoNamespace &from, const MongoNamespace &to)
|
||||
void MongoClient::copyCollectionToDiffServer(mongo::DBClientBase *const fromServ, const MongoNamespace &from,
|
||||
const MongoNamespace &to)
|
||||
{
|
||||
if (!_dbclient->exists(to.toString()))
|
||||
_dbclient->createCollection(to.toString());
|
||||
@@ -419,7 +507,19 @@ namespace Robomongo
|
||||
|
||||
void MongoClient::dropCollection(const MongoNamespace &ns)
|
||||
{
|
||||
_dbclient->dropCollection(ns.toString());
|
||||
if (_dbclient->exists(ns.toString())) {
|
||||
mongo::BSONObj info;
|
||||
if (!_dbclient->dropCollection(ns.toString(), mongo::WriteConcernOptions(), &info)) {
|
||||
std::string errStr = info.toString();
|
||||
if (errStr.empty())
|
||||
errStr = "Failed to get error message.";
|
||||
|
||||
throw mongo::DBException(errStr, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw mongo::DBException("Collection does not exist.", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void MongoClient::insertDocument(const mongo::BSONObj &obj, const MongoNamespace &ns)
|
||||
@@ -497,11 +597,10 @@ namespace Robomongo
|
||||
std::vector<MongoCollectionInfo> MongoClient::runCollStatsCommand(const std::vector<std::string> &namespaces)
|
||||
{
|
||||
std::vector<MongoCollectionInfo> infos;
|
||||
for (std::vector<std::string>::const_iterator it = namespaces.begin(); it!=namespaces.end(); ++it) {
|
||||
MongoCollectionInfo info = runCollStatsCommand(*it);
|
||||
if (info.ns().isValid()){
|
||||
for (auto const& ns : namespaces) {
|
||||
MongoCollectionInfo info = runCollStatsCommand(ns);
|
||||
if (info.ns().isValid())
|
||||
infos.push_back(info);
|
||||
}
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <mongo/client/dbclientinterface.h>
|
||||
#include <mongo/bson/bsonobj.h>
|
||||
|
||||
#include "robomongo/core/Core.h"
|
||||
#include "robomongo/core/domain/MongoQueryInfo.h"
|
||||
#include "robomongo/core/domain/MongoUser.h"
|
||||
@@ -14,9 +16,10 @@ namespace Robomongo
|
||||
public:
|
||||
MongoClient(mongo::DBClientBase *const scopedConnection);
|
||||
|
||||
std::vector<std::string> getCollectionNames(const std::string &dbname) const;
|
||||
std::vector<std::string> getCollectionNamesWithDbname(const std::string &dbname) const;
|
||||
std::vector<std::string> getDatabaseNames() const;
|
||||
float getVersion() const;
|
||||
std::string getStorageEngineType() const;
|
||||
|
||||
std::vector<MongoUser> getUsers(const std::string &dbName);
|
||||
void createUser(const std::string &dbName, const MongoUser &user, bool overwrite);
|
||||
@@ -37,11 +40,11 @@ namespace Robomongo
|
||||
void createDatabase(const std::string &dbName);
|
||||
void dropDatabase(const std::string &dbName);
|
||||
|
||||
void createCollection(const MongoNamespace &ns);
|
||||
void createCollection(const std::string &ns, long long size, bool capped, int max, const mongo::BSONObj& extraOptions, mongo::BSONObj* info = nullptr);
|
||||
void renameCollection(const MongoNamespace &ns, const std::string &newCollectionName);
|
||||
void duplicateCollection(const MongoNamespace &ns, const std::string &newCollectionName);
|
||||
void dropCollection(const MongoNamespace &ns);
|
||||
void copyCollectionToDiffServer(mongo::DBClientBase *const,const MongoNamespace &from, const MongoNamespace &to);
|
||||
void copyCollectionToDiffServer(mongo::DBClientBase *const, const MongoNamespace &from, const MongoNamespace &to);
|
||||
|
||||
void insertDocument(const mongo::BSONObj &obj, const MongoNamespace &ns);
|
||||
void saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <QMutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <mongo/client/dbclient_rs.h>
|
||||
|
||||
#include "robomongo/core/events/MongoEvents.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -22,15 +24,24 @@ namespace Robomongo
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef std::vector<std::string> DatabasesContainerType;
|
||||
explicit MongoWorker(ConnectionSettings *connection, bool isLoadMongoRcJs, int batchSize, QObject *parent = NULL);
|
||||
~MongoWorker();
|
||||
enum { pingTimeMs = 60 * 1000 };
|
||||
|
||||
typedef std::vector<std::string> DatabasesContainerType;
|
||||
using DBClientReplicaSet = std::unique_ptr<mongo::DBClientReplicaSet>;
|
||||
using DBClientConnection = std::unique_ptr<mongo::DBClientConnection>;
|
||||
|
||||
explicit MongoWorker(ConnectionSettings *connection, bool isLoadMongoRcJs, int batchSize,
|
||||
int mongoTimeoutSec, int shellTimeoutSec, QObject *parent = NULL);
|
||||
|
||||
~MongoWorker();
|
||||
void interrupt();
|
||||
void stopAndDelete();
|
||||
|
||||
protected Q_SLOTS: // handlers:
|
||||
void changeTimeout(int newTimeout);
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
void init();
|
||||
|
||||
/**
|
||||
* @brief Every minute we are issuing { ping : 1 } command to every used connection
|
||||
* in order to avoid dropped connections.
|
||||
@@ -40,7 +51,13 @@ namespace Robomongo
|
||||
/**
|
||||
* @brief Initiate connection to MongoDB
|
||||
*/
|
||||
void handle(EstablishConnectionRequest *event);
|
||||
bool handle(EstablishConnectionRequest *event);
|
||||
|
||||
/**
|
||||
* @brief Try to re-connect to MongoDB replica set in order to refresh connection view.
|
||||
* For more details, see MongoServer::tryRefreshReplicaSetFolder()
|
||||
*/
|
||||
void handle(RefreshReplicaSetFolderRequest *event);
|
||||
|
||||
/**
|
||||
* @brief Load list of all database names
|
||||
@@ -127,33 +144,75 @@ namespace Robomongo
|
||||
* @brief Send event to this MongoWorker
|
||||
*/
|
||||
void send(Event *event);
|
||||
|
||||
DatabasesContainerType getDatabaseNamesSafe();
|
||||
std::string getAuthBase() const;
|
||||
|
||||
mongo::DBClientBase *_dbclient;
|
||||
mongo::DBClientBase *getConnection();
|
||||
mongo::DBClientBase *getConnection(bool mayReturnNull = false);
|
||||
MongoClient *getClient();
|
||||
|
||||
/**
|
||||
*@brief Reset and update global mongo SSL settings (mongo::sslGlobalParams)
|
||||
*/
|
||||
void configureSSL();
|
||||
|
||||
/**
|
||||
*@brief Update global mongo SSL settings (mongo::sslGlobalParams) according to active connection
|
||||
* request's SSL settings.
|
||||
*/
|
||||
void updateGlobalSSLparams() const;
|
||||
|
||||
/**
|
||||
*@brief Reset global mongo SSL settings (mongo::sslGlobalParams) into default zero state
|
||||
*/
|
||||
void resetGlobalSSLparams() const;
|
||||
|
||||
/**
|
||||
*@brief Update Replica Set related parameters/settings.
|
||||
* Warning: Using parameter 'refresh' as false might return incorrect cached values for status
|
||||
* of secondary members.
|
||||
* @param refresh : If true it will be deep scan of replica set status which
|
||||
* might take quite some time. If false, it will be quick scan
|
||||
* which might return incorrect cached values for status of secondary members.
|
||||
* Use false only to achieve quick first connection, in all other cases true
|
||||
* should be used.
|
||||
*/
|
||||
ReplicaSet getReplicaSetInfo(bool refresh = true) const;
|
||||
|
||||
std::string connectAndGetReplicaSetName() const;
|
||||
|
||||
/**
|
||||
* @brief Send reply event to object 'obj'
|
||||
*/
|
||||
void reply(QObject *receiver, Event *event);
|
||||
|
||||
/**
|
||||
* @brief Send hear beat messages to database in order to keep connection alive
|
||||
*/
|
||||
void pingDatabase(mongo::DBClientBase *dbclient) const;
|
||||
|
||||
QThread *_thread;
|
||||
QMutex _firstConnectionMutex;
|
||||
|
||||
ScriptEngine *_scriptEngine;
|
||||
std::unique_ptr<ScriptEngine> _scriptEngine;
|
||||
|
||||
bool _isAdmin;
|
||||
const bool _isLoadMongoRcJs;
|
||||
const int _batchSize;
|
||||
int _timerId;
|
||||
int _dbAutocompleteCacheTimerId;
|
||||
int _mongoTimeoutSec;
|
||||
int _shellTimeoutSec;
|
||||
QAtomicInteger<int> _isQuiting;
|
||||
|
||||
ConnectionSettings *_connection;
|
||||
std::unique_ptr<mongo::DBClientConnection> _dbclient;
|
||||
std::unique_ptr<mongo::DBClientReplicaSet> _dbclientRepSet;
|
||||
|
||||
ConnectionSettings *_connSettings;
|
||||
|
||||
// Collection of created databases.
|
||||
// Starting from 3.0, MongoDB drops empty databases.
|
||||
// It means, we do not find a way to create "empty" database.
|
||||
// It means, we did not find a way to create "empty" database.
|
||||
// We save all created databases in this collection and merge with
|
||||
// list of real databases returned from MongoDB server.
|
||||
std::unordered_set<std::string> _createdDbs;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
#include "robomongo/core/mongodb/ReplicaSet.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
ReplicaSet::ReplicaSet(std::string const& setName, const mongo::HostAndPort primary,
|
||||
std::vector<std::pair<std::string, bool>> const& membersAndHealths,
|
||||
std::string const& errorStr)
|
||||
: setName(setName), primary(primary), membersAndHealths(membersAndHealths),
|
||||
errorStr(errorStr)
|
||||
{}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <mongo/util/net/hostandport.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
/**
|
||||
* @brief Struct to represent live information of a replica set.
|
||||
*/
|
||||
struct ReplicaSet
|
||||
{
|
||||
ReplicaSet(std::string const& setName, const mongo::HostAndPort primary,
|
||||
std::vector<std::pair<std::string, bool>> const& membersAndHealths, std::string const& errorStr = "");
|
||||
|
||||
ReplicaSet() {};
|
||||
|
||||
std::string const setName;
|
||||
mongo::HostAndPort const primary;
|
||||
std::vector<std::pair<std::string, bool>> const membersAndHealths; // pair: {HostNameAndPort, Health}
|
||||
std::string const errorStr;
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "robomongo/core/mongodb/SshTunnelWorker.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
#include "robomongo/core/utils/Logger.h"
|
||||
#include "robomongo/core/settings/ConnectionSettings.h"
|
||||
@@ -15,50 +17,23 @@ namespace Robomongo
|
||||
{
|
||||
SshTunnelWorker::SshTunnelWorker(ConnectionSettings *settings) : QObject(),
|
||||
_settings(settings),
|
||||
_sshConfig(NULL),
|
||||
_sshSession(NULL)
|
||||
_sshSession(NULL),
|
||||
_configCreator(settings)
|
||||
{
|
||||
_thread = new QThread();
|
||||
moveToThread(_thread);
|
||||
VERIFY(connect(_thread, SIGNAL(started()), this, SLOT(init())));
|
||||
VERIFY(connect(_thread, SIGNAL(finished()), _thread, SLOT(deleteLater())));
|
||||
VERIFY(connect(_thread, SIGNAL(finished()), this, SLOT(deleteLater())));
|
||||
_thread->start();
|
||||
}
|
||||
|
||||
void SshTunnelWorker::init()
|
||||
{
|
||||
try {
|
||||
SshSettings *ssh = _settings->sshSettings();
|
||||
|
||||
// We are going to access raw char* buffers, so prepare copies
|
||||
// of strings (and rest of the things for symmetry)
|
||||
_sshhost = ssh->host();
|
||||
_sshport = ssh->port();
|
||||
_remotehost = _settings->serverHost();
|
||||
_remoteport = _settings->serverPort();
|
||||
_localip = "127.0.0.1";
|
||||
_localport = 27040;
|
||||
|
||||
_userName = ssh->userName();
|
||||
_userPassword = ssh->userPassword();
|
||||
_privateKeyFile = ssh->privateKeyFile();
|
||||
_publicKeyFile = ssh->publicKeyFile();
|
||||
_passphrase = ssh->passphrase();
|
||||
_authMethod = ssh->authMethod(); // "password" or "publickey"
|
||||
}
|
||||
catch (const std::exception &ex) {
|
||||
LOG_MSG(ex.what(), mongo::logger::LogSeverity::Error());
|
||||
}
|
||||
}
|
||||
|
||||
SshTunnelWorker::~SshTunnelWorker()
|
||||
{
|
||||
// QThread "_thread" and MongoWorker itself will be deleted later
|
||||
// (see MongoWorker() constructor)
|
||||
|
||||
delete _settings;
|
||||
delete _sshConfig;
|
||||
printf("SSH tunnel closed.\n");
|
||||
}
|
||||
|
||||
void SshTunnelWorker::stopAndDelete() {
|
||||
@@ -71,30 +46,12 @@ namespace Robomongo
|
||||
if (_isQuiting)
|
||||
return;
|
||||
|
||||
_sshConfig = new rbm_ssh_tunnel_config;
|
||||
_sshConfig->sshserverip = const_cast<char*>(_sshhost.c_str());
|
||||
_sshConfig->sshserverport = static_cast<unsigned int>(_sshport);
|
||||
_sshConfig->remotehost = const_cast<char*>(_remotehost.c_str());
|
||||
_sshConfig->remoteport = static_cast<unsigned int>(_remoteport);
|
||||
_sshConfig->localip = const_cast<char*>(_localip.c_str());
|
||||
_sshConfig->localport = static_cast<unsigned int>(_localport);
|
||||
|
||||
_sshConfig->username = const_cast<char*>(_userName.c_str());
|
||||
_sshConfig->password = const_cast<char*>(_userPassword.c_str());
|
||||
_sshConfig->privatekeyfile = const_cast<char*>(_privateKeyFile.c_str());
|
||||
_sshConfig->publickeyfile = _publicKeyFile.empty() ? NULL : const_cast<char*>(_publicKeyFile.c_str());
|
||||
_sshConfig->passphrase = const_cast<char*>(_passphrase.c_str());
|
||||
_sshConfig->authtype = (_authMethod == "publickey") ? RBM_SSH_AUTH_TYPE_PUBLICKEY : RBM_SSH_AUTH_TYPE_PASSWORD;
|
||||
|
||||
_sshConfig->logcontext = this;
|
||||
_sshConfig->logcallback = &SshTunnelWorker::logCallbackHandler;
|
||||
_sshConfig->loglevel = (rbm_ssh_log_type) _settings->sshSettings()->logLevel(); // RBM_SSH_LOG_TYPE_DEBUG;
|
||||
|
||||
if ((_sshSession = rbm_ssh_session_create(_sshConfig)) == 0) {
|
||||
// Cleanup config structure
|
||||
delete _sshConfig;
|
||||
_sshConfig = NULL;
|
||||
// Additionally configure "rbm_ssh_tunnel_config"
|
||||
_configCreator.config()->logcontext = this;
|
||||
_configCreator.config()->logcallback = &SshTunnelWorker::logCallbackHandler;
|
||||
_configCreator.config()->loglevel = (rbm_ssh_log_type) _settings->sshSettings()->logLevel(); // RBM_SSH_LOG_TYPE_DEBUG;
|
||||
|
||||
if ((_sshSession = rbm_ssh_session_create(_configCreator.config())) == 0) {
|
||||
// Not much we can say about this error
|
||||
throw std::runtime_error("Failed to create SSH session");
|
||||
}
|
||||
@@ -113,20 +70,16 @@ namespace Robomongo
|
||||
rbm_ssh_session_close(_sshSession);
|
||||
_sshSession = NULL;
|
||||
|
||||
// Cleanup config
|
||||
delete _sshConfig;
|
||||
_sshConfig = NULL;
|
||||
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
||||
reply(event->sender(), new EstablishSshConnectionResponse(
|
||||
this, event->worker, event->settings, event->visible, _sshConfig->localport));
|
||||
this, event->serverHandle, event->worker, event->settings, event->connectionType, _configCreator.config()->localport));
|
||||
|
||||
} catch (const std::exception& ex) {
|
||||
reply(event->sender(),
|
||||
new EstablishSshConnectionResponse(this, EventError(ex.what()),
|
||||
event->worker, event->settings, event->visible));
|
||||
new EstablishSshConnectionResponse(this, event->serverHandle, EventError(ex.what()),
|
||||
event->worker, event->settings, event->connectionType));
|
||||
|
||||
// In case of error in connection, we should cleanup SshTunnelWorker
|
||||
stopAndDelete();
|
||||
@@ -134,28 +87,50 @@ namespace Robomongo
|
||||
}
|
||||
|
||||
void SshTunnelWorker::handle(ListenSshConnectionRequest *event) {
|
||||
|
||||
// do it here, i.e. cycle
|
||||
|
||||
try {
|
||||
if (_isQuiting)
|
||||
return;
|
||||
|
||||
if (_sshSession == NULL || _sshConfig == NULL)
|
||||
if (_sshSession == NULL)
|
||||
return;
|
||||
|
||||
// We are running this timer in order to distinguish between two
|
||||
// types of errors:
|
||||
// 1) SSH tunnel wasn't successfully created
|
||||
// 2) SSH tunnel was disconnected
|
||||
// This is used now only for UI error message, that we show to user.
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
// This function will block until all TCP connections disconnects.
|
||||
// Initially, it will wait for at least one such connection.
|
||||
if (rbm_ssh_open_tunnel(_sshSession) != 0) {
|
||||
|
||||
qint64 elapsed = timer.elapsed();
|
||||
bool wasDisconnected = elapsed > 20000; // More than 20 seconds passed
|
||||
|
||||
// Prepare copy of error message (if any)
|
||||
std::string error(_sshSession->lasterror);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "You are disconnected from SSH tunnel ("
|
||||
<< _settings->sshSettings()->host() << ":"
|
||||
<< _settings->sshSettings()->port() << "). "
|
||||
<< "Please initiate a new connection and reopen all tabs.\n\nError:\n"
|
||||
<< error;
|
||||
|
||||
if (wasDisconnected) {
|
||||
ss << "You are disconnected from SSH tunnel ("
|
||||
<< _settings->sshSettings()->host() << ":"
|
||||
<< _settings->sshSettings()->port() << "). "
|
||||
<< "Please initiate a new connection and reopen all tabs.\n\nError:\n"
|
||||
<< error;
|
||||
} else {
|
||||
ss << "Cannot establish SSH tunnel ("
|
||||
<< _settings->sshSettings()->host() << ":"
|
||||
<< _settings->sshSettings()->port() << "). "
|
||||
<< "\n\nError:\n"
|
||||
<< error;
|
||||
}
|
||||
|
||||
// Cleanup session
|
||||
rbm_ssh_session_close(_sshSession);
|
||||
_sshSession = NULL;
|
||||
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
@@ -164,7 +139,7 @@ namespace Robomongo
|
||||
|
||||
} catch (const std::exception& ex) {
|
||||
reply(event->sender(),
|
||||
new ListenSshConnectionResponse(this, EventError(ex.what()), _settings));
|
||||
new ListenSshConnectionResponse(this, EventError(ex.what()), event->serverHandle, _settings, event->connectionType));
|
||||
}
|
||||
|
||||
// When we done with SSH (i.e. rbm_ssh_open_tunnel exits) regardless
|
||||
@@ -195,4 +170,60 @@ namespace Robomongo
|
||||
void SshTunnelWorker::logCallbackHandler(void *context, char *message, int level) {
|
||||
static_cast<SshTunnelWorker*>(context)->log(message, level);
|
||||
}
|
||||
|
||||
/*
|
||||
* SshTunnelConfigCreator
|
||||
*/
|
||||
SshTunnelConfigCreator::SshTunnelConfigCreator(ConnectionSettings *settings) {
|
||||
SshSettings *ssh = settings->sshSettings();
|
||||
|
||||
// We are going to access raw char* buffers, so prepare copies
|
||||
// of strings (and rest of the things for symmetry)
|
||||
_sshhost = ssh->host();
|
||||
_sshport = ssh->port();
|
||||
_remotehost = settings->serverHost();
|
||||
_remoteport = settings->serverPort();
|
||||
_localip = "127.0.0.1";
|
||||
_localport = 27040;
|
||||
|
||||
_userName = ssh->userName();
|
||||
_userPassword = ssh->userPassword();
|
||||
_privateKeyFile = ssh->privateKeyFile();
|
||||
_publicKeyFile = ssh->publicKeyFile();
|
||||
_passphrase = ssh->passphrase();
|
||||
_authMethod = ssh->authMethod(); // "password" or "publickey"
|
||||
|
||||
// Use "askedPassword" for both passphrase and password if required
|
||||
if (ssh->askPassword()) {
|
||||
_passphrase = ssh->askedPassword();
|
||||
_userPassword = ssh->askedPassword();
|
||||
}
|
||||
|
||||
_sshConfig = new rbm_ssh_tunnel_config;
|
||||
_sshConfig->sshserverhost = const_cast<char*>(_sshhost.c_str());
|
||||
_sshConfig->sshserverport = static_cast<unsigned int>(_sshport);
|
||||
_sshConfig->remotehost = const_cast<char*>(_remotehost.c_str());
|
||||
_sshConfig->remoteport = static_cast<unsigned int>(_remoteport);
|
||||
_sshConfig->localip = const_cast<char*>(_localip.c_str());
|
||||
_sshConfig->localport = static_cast<unsigned int>(_localport);
|
||||
|
||||
_sshConfig->username = const_cast<char*>(_userName.c_str());
|
||||
_sshConfig->password = const_cast<char*>(_userPassword.c_str());
|
||||
_sshConfig->privatekeyfile = const_cast<char*>(_privateKeyFile.c_str());
|
||||
_sshConfig->publickeyfile = _publicKeyFile.empty() ? NULL : const_cast<char*>(_publicKeyFile.c_str());
|
||||
_sshConfig->passphrase = const_cast<char*>(_passphrase.c_str());
|
||||
_sshConfig->authtype = (_authMethod == "publickey") ? RBM_SSH_AUTH_TYPE_PUBLICKEY : RBM_SSH_AUTH_TYPE_PASSWORD;
|
||||
|
||||
// Default settings
|
||||
_sshConfig->logcontext = NULL;
|
||||
_sshConfig->logcallback = NULL;
|
||||
_sshConfig->loglevel = RBM_SSH_LOG_TYPE_ERROR;
|
||||
|
||||
}
|
||||
|
||||
SshTunnelConfigCreator::~SshTunnelConfigCreator() {
|
||||
delete _sshConfig;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <robomongo/ssh/ssh.h>
|
||||
#include "robomongo/core/events/MongoEvents.h"
|
||||
|
||||
@@ -17,6 +18,34 @@ namespace Robomongo
|
||||
class EstablishSshConnectionRequest;
|
||||
class ListenSshConnectionRequest;
|
||||
|
||||
/*
|
||||
* Helper class for creating rbm_ssh_tunnel_config from ConnectionSettings
|
||||
* Automatically deletes allocated structure
|
||||
*/
|
||||
class SshTunnelConfigCreator {
|
||||
public:
|
||||
explicit SshTunnelConfigCreator(ConnectionSettings *settings);
|
||||
~SshTunnelConfigCreator();
|
||||
rbm_ssh_tunnel_config *config() { return _sshConfig; }
|
||||
|
||||
private:
|
||||
std::string _sshhost;
|
||||
int _sshport;
|
||||
std::string _remotehost;
|
||||
int _remoteport;
|
||||
std::string _localip;
|
||||
int _localport;
|
||||
|
||||
std::string _userName;
|
||||
std::string _userPassword;
|
||||
std::string _privateKeyFile;
|
||||
std::string _publicKeyFile;
|
||||
std::string _passphrase;
|
||||
std::string _authMethod; // "password" or "publickey"
|
||||
|
||||
rbm_ssh_tunnel_config* _sshConfig;
|
||||
};
|
||||
|
||||
class SshTunnelWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -31,7 +60,6 @@ namespace Robomongo
|
||||
void stopAndDelete();
|
||||
|
||||
protected Q_SLOTS: // handlers:
|
||||
void init();
|
||||
void handle(EstablishSshConnectionRequest *event);
|
||||
void handle(ListenSshConnectionRequest *event);
|
||||
|
||||
@@ -42,21 +70,9 @@ namespace Robomongo
|
||||
QThread *_thread;
|
||||
QAtomicInteger<int> _isQuiting;
|
||||
ConnectionSettings* _settings;
|
||||
rbm_ssh_tunnel_config* _sshConfig;
|
||||
rbm_ssh_session* _sshSession;
|
||||
|
||||
std::string _sshhost;
|
||||
int _sshport;
|
||||
std::string _remotehost;
|
||||
int _remoteport;
|
||||
std::string _localip;
|
||||
int _localport;
|
||||
|
||||
std::string _userName;
|
||||
std::string _userPassword;
|
||||
std::string _privateKeyFile;
|
||||
std::string _publicKeyFile;
|
||||
std::string _passphrase;
|
||||
std::string _authMethod; // "password" or "publickey"
|
||||
SshTunnelConfigCreator _configCreator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,37 +2,87 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
#include "robomongo/core/settings/CredentialSettings.h"
|
||||
#include "robomongo/core/settings/ReplicaSetSettings.h"
|
||||
#include "robomongo/core/settings/SshSettings.h"
|
||||
#include "robomongo/core/settings/SslSettings.h"
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
const unsigned port = 27017;
|
||||
const char *defaultServerHost = "localhost";
|
||||
const char *defaultNameConnection = "New Connection";
|
||||
|
||||
const int maxLength = 300;
|
||||
}
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates ConnectionSettings with default values
|
||||
*/
|
||||
ConnectionSettings::ConnectionSettings() : QObject(),
|
||||
ConnectionSettings::ConnectionSettings(bool isClone) : QObject(),
|
||||
_connectionName(defaultNameConnection),
|
||||
_host(defaultServerHost),
|
||||
_port(port),
|
||||
_sshSettings(new SshSettings()) { }
|
||||
_imported(false),
|
||||
_sshSettings(new SshSettings()),
|
||||
_sslSettings(new SslSettings()),
|
||||
_isReplicaSet(false),
|
||||
_replicaSetSettings(new ReplicaSetSettings()),
|
||||
_clone(isClone)
|
||||
{ }
|
||||
|
||||
ConnectionSettings::ConnectionSettings(const mongo::MongoURI& uri, bool isClone)
|
||||
: _connectionName(defaultNameConnection),
|
||||
_host(defaultServerHost),
|
||||
_port(port),
|
||||
_imported(false),
|
||||
_sshSettings(new SshSettings()),
|
||||
_sslSettings(new SslSettings()),
|
||||
_isReplicaSet((uri.type() == mongo::ConnectionString::ConnectionType::SET)),
|
||||
_replicaSetSettings(new ReplicaSetSettings(uri)),
|
||||
_clone(isClone)
|
||||
{
|
||||
// Disabling unfinished feature : Export / Import to / from MongoURI
|
||||
/*
|
||||
if (!uri.getServers().empty()) {
|
||||
_host = uri.getServers().front().host();
|
||||
_port = uri.getServers().front().port();
|
||||
}
|
||||
|
||||
auto str = std::string(uri.getOptions().getStringField("ssl"));
|
||||
auto sslEnabled = ("true" == str);
|
||||
if (sslEnabled) {
|
||||
_sslSettings->enableSSL(true);
|
||||
_sslSettings->setAllowInvalidCertificates(true);
|
||||
}
|
||||
|
||||
auto credential = new CredentialSettings();
|
||||
credential->setUserName(uri.getUser());
|
||||
credential->setUserPassword(uri.getPassword());
|
||||
credential->setDatabaseName(uri.getDatabase());
|
||||
if (!credential->userName().empty() && !credential->userPassword().empty()) { // todo:
|
||||
credential->setEnabled(true);
|
||||
}
|
||||
addCredential(credential);
|
||||
*/
|
||||
}
|
||||
|
||||
void ConnectionSettings::fromVariant(const QVariantMap &map) {
|
||||
setConnectionName(QtUtils::toStdString(map.value("connectionName").toString()));
|
||||
setServerHost(QtUtils::toStdString(map.value("serverHost").toString()));
|
||||
setServerHost(QtUtils::toStdString(map.value("serverHost").toString().left(maxLength)));
|
||||
setServerPort(map.value("serverPort").toInt());
|
||||
setDefaultDatabase(QtUtils::toStdString(map.value("defaultDatabase").toString()));
|
||||
|
||||
setReplicaSet(map.value("isReplicaSet").toBool());
|
||||
|
||||
QVariantList list = map.value("credentials").toList();
|
||||
for(QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
QVariant var = *it;
|
||||
CredentialSettings *credential = new CredentialSettings(var.toMap());
|
||||
addCredential(credential);
|
||||
@@ -42,6 +92,21 @@ namespace Robomongo
|
||||
_sshSettings->fromVariant(map.value("ssh").toMap());
|
||||
}
|
||||
|
||||
if (map.contains("ssl")) {
|
||||
_sslSettings->fromVariant(map.value("ssl").toMap());
|
||||
}
|
||||
|
||||
if (isReplicaSet()) {
|
||||
_replicaSetSettings->fromVariant(map.value("replicaSet").toMap());
|
||||
}
|
||||
|
||||
// If UUID has never been created or is empty, create a new one. Otherwise load the existing.
|
||||
if (!map.contains("uuid") || map.value("uuid").toString().isEmpty())
|
||||
_uuid = QUuid::createUuid().toString();
|
||||
else
|
||||
_uuid = map.value("uuid").toString();
|
||||
|
||||
|
||||
//#ifdef MONGO_SSL
|
||||
// ,SSLInfo(map.value("sslEnabled").toBool(),QtUtils::toStdString(map.value("sslPemKeyFile").toString()))
|
||||
//#endif
|
||||
@@ -53,7 +118,6 @@ namespace Robomongo
|
||||
ConnectionSettings::~ConnectionSettings()
|
||||
{
|
||||
clearCredentials();
|
||||
delete _sshSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,9 +125,10 @@ namespace Robomongo
|
||||
*/
|
||||
ConnectionSettings *ConnectionSettings::clone() const
|
||||
{
|
||||
ConnectionSettings *record = new ConnectionSettings();
|
||||
record->apply(this);
|
||||
return record;
|
||||
auto settings = new ConnectionSettings(true);
|
||||
settings->setUuid(_uuid);
|
||||
settings->apply(this);
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +140,8 @@ namespace Robomongo
|
||||
setServerHost(source->serverHost());
|
||||
setServerPort(source->serverPort());
|
||||
setDefaultDatabase(source->defaultDatabase());
|
||||
setImported(source->imported());
|
||||
setReplicaSet(source->isReplicaSet());
|
||||
|
||||
clearCredentials();
|
||||
QList<CredentialSettings *> cred = source->credentials();
|
||||
@@ -82,8 +149,9 @@ namespace Robomongo
|
||||
addCredential((*it)->clone());
|
||||
}
|
||||
|
||||
// Clone SSH settings
|
||||
_sshSettings = source->sshSettings()->clone();
|
||||
_sshSettings.reset(source->sshSettings()->clone());
|
||||
_sslSettings.reset(source->sslSettings()->clone());
|
||||
_replicaSetSettings.reset(source->_replicaSetSettings->clone());
|
||||
|
||||
//#ifdef MONGO_SSL
|
||||
// setSslInfo(source->sslInfo());
|
||||
@@ -100,27 +168,34 @@ namespace Robomongo
|
||||
map.insert("serverHost", QtUtils::toQString(serverHost()));
|
||||
map.insert("serverPort", serverPort());
|
||||
map.insert("defaultDatabase", QtUtils::toQString(defaultDatabase()));
|
||||
map.insert("isReplicaSet", isReplicaSet());
|
||||
if (isReplicaSet()) {
|
||||
map.insert("replicaSet", _replicaSetSettings->toVariant());
|
||||
}
|
||||
|
||||
#ifdef MONGO_SSL
|
||||
SSLInfo infl = _info.sslInfo();
|
||||
map.insert("sslEnabled", infl._sslSupport);
|
||||
map.insert("sslPemKeyFile", QtUtils::toQString(infl._sslPEMKeyFile));
|
||||
#endif
|
||||
QVariantList list;
|
||||
for(QList<CredentialSettings *>::const_iterator it = _credentials.begin(); it != _credentials.end(); ++it) {
|
||||
for (QList<CredentialSettings *>::const_iterator it = _credentials.begin(); it != _credentials.end(); ++it) {
|
||||
CredentialSettings *credential = *it;
|
||||
list.append(credential->toVariant());
|
||||
}
|
||||
map.insert("credentials", list);
|
||||
|
||||
map.insert("ssh", _sshSettings->toVariant());
|
||||
map.insert("ssl", _sslSettings->toVariant());
|
||||
map.insert("uuid", _uuid);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
CredentialSettings *ConnectionSettings::findCredential(const std::string &databaseName) const
|
||||
{
|
||||
CredentialSettings *result = NULL;
|
||||
for(QList<CredentialSettings *>::const_iterator it = _credentials.begin(); it != _credentials.end(); ++it) {
|
||||
CredentialSettings *result = nullptr;
|
||||
for (QList<CredentialSettings *>::const_iterator it = _credentials.begin(); it != _credentials.end(); ++it) {
|
||||
CredentialSettings *cred = *it;
|
||||
if (cred->databaseName() == databaseName) {
|
||||
result = cred;
|
||||
@@ -143,7 +218,7 @@ namespace Robomongo
|
||||
* @brief Checks whether this connection has primary credential
|
||||
* which is also enabled.
|
||||
*/
|
||||
bool ConnectionSettings::hasEnabledPrimaryCredential()
|
||||
bool ConnectionSettings::hasEnabledPrimaryCredential() const
|
||||
{
|
||||
if (_credentials.count() == 0)
|
||||
return false;
|
||||
@@ -152,12 +227,13 @@ namespace Robomongo
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns primary credential, or NULL if no credentials exists.
|
||||
* @brief Returns primary credential
|
||||
*/
|
||||
CredentialSettings *ConnectionSettings::primaryCredential()
|
||||
CredentialSettings *ConnectionSettings::primaryCredential() const
|
||||
{
|
||||
if (_credentials.count() == 0)
|
||||
return NULL;
|
||||
if (_credentials.count() == 0) {
|
||||
_credentials.append(new CredentialSettings());
|
||||
}
|
||||
|
||||
return _credentials.at(0);
|
||||
}
|
||||
@@ -173,9 +249,26 @@ namespace Robomongo
|
||||
|
||||
std::string ConnectionSettings::getFullAddress() const
|
||||
{
|
||||
return info().toString();
|
||||
return hostAndPort().toString();
|
||||
}
|
||||
|
||||
mongo::HostAndPort ConnectionSettings::hostAndPort() const
|
||||
{
|
||||
// If it doesn't look like IPv6 address,
|
||||
// treat it like IPv4 or literal hostname
|
||||
if (_host.find(':') == std::string::npos) {
|
||||
return mongo::HostAndPort(_host, _port);
|
||||
}
|
||||
|
||||
// The following code assumes, that it is IPv6 address
|
||||
// If address contains square brackets ("["), remove them:
|
||||
std::string hostCopy = _host;
|
||||
if (_host.find('[') != std::string::npos) {
|
||||
boost::erase_all(hostCopy, "[");
|
||||
boost::erase_all(hostCopy, "]");
|
||||
}
|
||||
|
||||
return mongo::HostAndPort(hostCopy, _port);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <mongo/client/dbclientinterface.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <mongo/client/mongo_uri.h>
|
||||
#include <mongo/util/net/hostandport.h>
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
class CredentialSettings;
|
||||
class SshSettings;
|
||||
class SslSettings;
|
||||
class ReplicaSetSettings;
|
||||
|
||||
/**
|
||||
* @brief Represents connection record
|
||||
*/
|
||||
@@ -21,9 +26,14 @@ namespace Robomongo
|
||||
/**
|
||||
* @brief Creates ConnectionSettings with default values
|
||||
*/
|
||||
ConnectionSettings();
|
||||
ConnectionSettings(bool isClone);
|
||||
|
||||
/**
|
||||
* @brief Creates ConnectionSettings from mongo connection string URI
|
||||
*/
|
||||
ConnectionSettings(const mongo::MongoURI& uri, bool isClone);
|
||||
|
||||
explicit ConnectionSettings(QVariantMap map);
|
||||
explicit ConnectionSettings(QVariantMap map, bool isClone);
|
||||
|
||||
/**
|
||||
* @brief Cleanup used resources
|
||||
@@ -61,7 +71,7 @@ namespace Robomongo
|
||||
/**
|
||||
* @brief Port of server
|
||||
*/
|
||||
unsigned short serverPort() const { return _port; }
|
||||
int serverPort() const { return _port; }
|
||||
void setServerPort(const int port) { _port = port; }
|
||||
|
||||
/**
|
||||
@@ -70,6 +80,12 @@ namespace Robomongo
|
||||
std::string defaultDatabase() const { return _defaultDatabase; }
|
||||
void setDefaultDatabase(const std::string &defaultDatabase) { _defaultDatabase = defaultDatabase; }
|
||||
|
||||
/**
|
||||
* Was this connection imported from somewhere?
|
||||
*/
|
||||
bool imported() const { return _imported; }
|
||||
void setImported(bool imported) { _imported = imported; }
|
||||
|
||||
/**
|
||||
* @brief Adds credential to this connection
|
||||
*/
|
||||
@@ -84,12 +100,12 @@ namespace Robomongo
|
||||
* @brief Checks whether this connection has primary credential
|
||||
* which is also enabled.
|
||||
*/
|
||||
bool hasEnabledPrimaryCredential();
|
||||
bool hasEnabledPrimaryCredential() const;
|
||||
|
||||
/**
|
||||
* @brief Returns primary credential, or NULL if no credentials exists.
|
||||
* @brief Returns primary credential
|
||||
*/
|
||||
CredentialSettings *primaryCredential();
|
||||
CredentialSettings *primaryCredential() const;
|
||||
|
||||
/**
|
||||
* @brief Returns number of credentials
|
||||
@@ -124,34 +140,46 @@ namespace Robomongo
|
||||
return _connectionName;
|
||||
}
|
||||
|
||||
mongo::HostAndPort info() const {
|
||||
// If it doesn't look like IPv6 address,
|
||||
// treat it like IPv4 or literal hostname
|
||||
if (_host.find(':') == std::string::npos) {
|
||||
return mongo::HostAndPort(_host, _port);
|
||||
}
|
||||
mongo::HostAndPort hostAndPort() const;
|
||||
SshSettings *sshSettings() const { return _sshSettings.get(); }
|
||||
SslSettings *sslSettings() const { return _sslSettings.get(); }
|
||||
ReplicaSetSettings *replicaSetSettings() const { return _replicaSetSettings.get(); }
|
||||
|
||||
// The following code assumes, that it is IPv6 address
|
||||
// If address contains square brackets ("["), remove them:
|
||||
std::string hostCopy = _host;
|
||||
if (_host.find('[') != std::string::npos) {
|
||||
boost::erase_all(hostCopy, "[");
|
||||
boost::erase_all(hostCopy, "]");
|
||||
}
|
||||
|
||||
return mongo::HostAndPort(hostCopy, _port);
|
||||
}
|
||||
|
||||
SshSettings *sshSettings() const { return _sshSettings; }
|
||||
bool isReplicaSet() const { return _isReplicaSet; }
|
||||
void setReplicaSet(bool flag) { _isReplicaSet = flag; }
|
||||
|
||||
QString uuid() const { return _uuid; }
|
||||
void setUuid(QString const& uuid) { _uuid = uuid; }
|
||||
|
||||
private:
|
||||
CredentialSettings *findCredential(const std::string &databaseName) const;
|
||||
|
||||
std::string _connectionName;
|
||||
std::string _host;
|
||||
int _port;
|
||||
std::string _defaultDatabase;
|
||||
QList<CredentialSettings *> _credentials;
|
||||
SshSettings *_sshSettings;
|
||||
mutable QList<CredentialSettings *> _credentials;
|
||||
std::unique_ptr<SshSettings> _sshSettings;
|
||||
std::unique_ptr<SslSettings> _sslSettings;
|
||||
bool _isReplicaSet;
|
||||
std::unique_ptr<ReplicaSetSettings> _replicaSetSettings;
|
||||
|
||||
// Was this connection imported from somewhere?
|
||||
bool _imported;
|
||||
|
||||
// Flag to check if this is a clone(copy) or original ConnectionSettings
|
||||
// Note: If this is not a clone connection settings, this object is original connection
|
||||
// ConnectionSettings object which is loaded/saved into Robomongo config. file.
|
||||
bool _clone = false;
|
||||
|
||||
// If this is a clone connection settings, unique ID will be used to identify from which
|
||||
// original connection settings this object is cloned.
|
||||
// -1 for invalid(uninitialized) unique ID which should not be seen in theory
|
||||
int _uniqueId = -1;
|
||||
|
||||
// UUID string taken from QUuid.
|
||||
// It is used to identify the unique ID of a connection settings object
|
||||
QString _uuid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Robomongo
|
||||
std::string _userName;
|
||||
std::string _userPassword;
|
||||
std::string _databaseName;
|
||||
std::string _mechanism; // authentication mechanism
|
||||
std::string _mechanism; // authentication mechanism (MONGODB-CR or SCRAM-SHA-1)
|
||||
|
||||
/**
|
||||
* @brief Flag, indecating whether we should use this
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "robomongo/core/settings/ReplicaSetSettings.h"
|
||||
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
|
||||
ReplicaSetSettings::ReplicaSetSettings()
|
||||
: _cachedSetName(""), _members(), _readPreference(ReadPreference::PRIMARY)
|
||||
{}
|
||||
|
||||
ReplicaSetSettings::ReplicaSetSettings(const mongo::MongoURI& uri)
|
||||
: ReplicaSetSettings()
|
||||
{
|
||||
_cachedSetName = uri.getSetName();
|
||||
for (auto const& server : uri.getServers()) {
|
||||
_members.push_back(server.host() + ":" + std::to_string(server.port()));
|
||||
}
|
||||
}
|
||||
|
||||
ReplicaSetSettings *ReplicaSetSettings::clone() const
|
||||
{
|
||||
ReplicaSetSettings *cloned = new ReplicaSetSettings(*this);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
QVariant ReplicaSetSettings::toVariant() const
|
||||
{
|
||||
QVariantMap map;
|
||||
map.insert("setNameUserEntered", QString::fromStdString(_setNameUserEntered));
|
||||
map.insert("cachedSetName", QString::fromStdString(_cachedSetName));
|
||||
int idx = 0;
|
||||
for (std::string const& str : _members) {
|
||||
map.insert(QString::number(idx), QtUtils::toQString(str));
|
||||
++idx;
|
||||
}
|
||||
map.insert("readPreference", static_cast<int>(readPreference()));
|
||||
return map;
|
||||
}
|
||||
|
||||
void ReplicaSetSettings::fromVariant(const QVariantMap &map)
|
||||
{
|
||||
setSetNameUserEntered(map.value("setNameUserEntered").toString().toStdString());
|
||||
setCachedSetName(map.value("cachedSetName").toString().toStdString());
|
||||
// Extract and set replica members
|
||||
std::vector<std::string> vec;
|
||||
auto itr = map.begin();
|
||||
int idx = 0;
|
||||
do
|
||||
{
|
||||
itr = map.find(QString::number(idx));
|
||||
if (map.end() == itr) break;
|
||||
vec.push_back(itr->toString().toStdString());
|
||||
++idx;
|
||||
} while (map.end() != itr);
|
||||
setMembers(vec);
|
||||
// Extract and set read reference
|
||||
setReadPreference(static_cast<ReadPreference>(map.value("readPreference").toInt()));
|
||||
}
|
||||
|
||||
void ReplicaSetSettings::setMembers(const std::vector<std::string>& members)
|
||||
{
|
||||
_members.clear();
|
||||
for (auto const& member : members)
|
||||
_members.push_back(member);
|
||||
}
|
||||
|
||||
void ReplicaSetSettings::setMembers(const std::vector<std::pair<std::string, bool>>& membersAndHealts)
|
||||
{
|
||||
_members.clear();
|
||||
|
||||
for (auto const& memberAndHealth : membersAndHealts)
|
||||
_members.push_back(memberAndHealth.first);
|
||||
}
|
||||
|
||||
std::vector<mongo::HostAndPort> ReplicaSetSettings::membersToHostAndPort() const
|
||||
{
|
||||
std::vector<mongo::HostAndPort> membersHostAndPort;
|
||||
for (auto const& member : _members)
|
||||
membersHostAndPort.push_back(mongo::HostAndPort(member));
|
||||
|
||||
return membersHostAndPort;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <mongo/util/net/hostandport.h>
|
||||
#include <mongo/client/mongo_uri.h>
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
class ReplicaSetSettings
|
||||
{
|
||||
public:
|
||||
enum class ReadPreference
|
||||
{
|
||||
PRIMARY = 0,
|
||||
PRIMARY_PREFERRED = 1
|
||||
// todo: Add all supported read preferences
|
||||
};
|
||||
|
||||
ReplicaSetSettings();
|
||||
|
||||
ReplicaSetSettings(const mongo::MongoURI& uri);
|
||||
|
||||
/**
|
||||
* Clones Replica Set settings.
|
||||
*/
|
||||
ReplicaSetSettings* clone() const;
|
||||
|
||||
/**
|
||||
* Converts to QVariantMap
|
||||
*/
|
||||
QVariant toVariant() const;
|
||||
void fromVariant(const QVariantMap &map);
|
||||
|
||||
// Getters
|
||||
std::string const& setNameUserEntered() { return _setNameUserEntered; }
|
||||
std::string const& cachedSetName() { return _cachedSetName; }
|
||||
std::vector<std::string> const& members() const { return _members; }
|
||||
std::vector<mongo::HostAndPort> membersToHostAndPort() const;
|
||||
|
||||
std::set<mongo::HostAndPort> membersToHostAndPortAsSet() const
|
||||
{
|
||||
auto const& members = membersToHostAndPort();
|
||||
return std::set<mongo::HostAndPort>(members.begin(), members.end());
|
||||
}
|
||||
|
||||
ReadPreference readPreference() const { return _readPreference; }
|
||||
|
||||
// Setters
|
||||
void setSetNameUserEntered(const std::string& setName) { _setNameUserEntered = setName; }
|
||||
void setCachedSetName(const std::string& setName) { _cachedSetName = setName; }
|
||||
void setMembers(const std::vector<std::string>& members);
|
||||
void setMembers(const std::vector<std::pair<std::string,bool>>& membersAndHealts);
|
||||
void deleteAllMembers() { _members.clear(); }
|
||||
void setReadPreference(ReadPreference readPreference) { _readPreference = readPreference; }
|
||||
|
||||
|
||||
private:
|
||||
std::string _setNameUserEntered;
|
||||
std::string _cachedSetName;
|
||||
std::vector<std::string> _members;
|
||||
ReadPreference _readPreference = ReadPreference::PRIMARY;
|
||||
};
|
||||
}
|
||||
@@ -3,36 +3,90 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QVariantList>
|
||||
#include <QUuid>
|
||||
#include <QJsonArray>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
// Todo:
|
||||
// Note:
|
||||
// Currently, this include statement should be maintained manually.
|
||||
// The Qt version must be updated if Qt is upgraded. Otherwise it might cause build error.
|
||||
// The correct path will be: PROJECT_QT_VERSION/QtGui/private/qzipreader_p.h
|
||||
// Details:
|
||||
// Ideally, private class inside qzipreader_p.h should not be used since it is not
|
||||
// a publicly/officially supported API by Qt. It is used here since we are doing a
|
||||
// a very lightweight zip operation which is unzipping a zip archive with one, small file.
|
||||
// The alternative is including QuaZip and Zlib third party libraries into CMAKE project and
|
||||
// building, and using them which might be time consuming.
|
||||
#include <5.7.0/QtGui/private/qzipreader_p.h>
|
||||
|
||||
#include <parser.h>
|
||||
#include <serializer.h>
|
||||
|
||||
#include "robomongo/core/settings/ConnectionSettings.h"
|
||||
#include "robomongo/core/settings/CredentialSettings.h"
|
||||
#include "robomongo/core/settings/SshSettings.h"
|
||||
#include "robomongo/core/settings/SslSettings.h"
|
||||
#include "robomongo/core/utils/Logger.h"
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
#include "robomongo/core/utils/StdUtils.h"
|
||||
#include "robomongo/gui/AppStyle.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
/**
|
||||
* @brief Version of schema
|
||||
*/
|
||||
const QString SchemaVersion = "2.0";
|
||||
|
||||
/**
|
||||
* @brief Config file absolute path
|
||||
* (usually: /home/user/.config/robomongo/robomongo.json)
|
||||
*/
|
||||
const QString _configPath = QString("%1/.config/robomongo/0.9/robomongo.json").arg(QDir::homePath());
|
||||
|
||||
/**
|
||||
* @brief Config file containing directory path
|
||||
* (usually: /home/user/.config/robomongo)
|
||||
*/
|
||||
const QString _configDir = QString("%1/.config/robomongo/0.9").arg(QDir::homePath());
|
||||
}
|
||||
#include "robomongo/utils/common.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
// 3T config files
|
||||
auto const Studio3T_PropertiesDat = QString("%1/.3T/studio-3t/properties.dat").arg(QDir::homePath());
|
||||
auto const DataMongodb_PropertiesDat = QString("%1/.3T/data-man-mongodb/properties.dat").arg(QDir::homePath());
|
||||
auto const MongoChefPro_PropertiesDat = QString("%1/.3T/mongochef-pro/properties.dat").arg(QDir::homePath());
|
||||
auto const MongoChefEnt_PropertiesDat = QString("%1/.3T/mongochef-enterprise/properties.dat").arg(QDir::homePath());
|
||||
|
||||
const std::vector<std::pair<QString, QString>> S_3T_ZipFile_And_ConfigFile_List
|
||||
{
|
||||
{ Studio3T_PropertiesDat, "Studio3T.properties" },
|
||||
{ DataMongodb_PropertiesDat, "3T.data-man-mongodb.properties" },
|
||||
{ MongoChefPro_PropertiesDat, "3T.mongochef-pro.properties" },
|
||||
{ MongoChefEnt_PropertiesDat, "3T.mongochef-enterprise.properties" }
|
||||
};
|
||||
|
||||
// Extract zipFile and find the value of "anonymousID" field in propFile
|
||||
QString extractAnonymousIDFromZip(QString const& zipFile, QString const& propfile);
|
||||
|
||||
// Extract "anonymousID" from old config file
|
||||
QString extractAnonymousID(QString const& oldConfigFile);
|
||||
|
||||
/**
|
||||
* @brief Version of schema
|
||||
*/
|
||||
const QString SchemaVersion = "2.0";
|
||||
|
||||
/**
|
||||
* @brief Robomongo config. files of old versions
|
||||
*/
|
||||
const auto CONFIG_FILE_0_8_5 = QString("%1/.config/robomongo/robomongo.json").arg(QDir::homePath());
|
||||
const auto CONFIG_FILE_0_9 = QString("%1/.config/robomongo/0.9/robomongo.json").arg(QDir::homePath());
|
||||
const auto CONFIG_FILE_1_0_RC1 = QString("%1/.config/robomongo/1.0/robomongo.json").arg(QDir::homePath());
|
||||
// Change of path due to re-branding to 3T
|
||||
const auto CONFIG_FILE_1_0_0 = QString("%1/.3T/robomongo/1.0.0/robomongo.json").arg(QDir::homePath());
|
||||
const auto CONFIG_FILE_1_1_0_BETA = QString("%1/.3T/robomongo/1.1.0-Beta/robomongo.json").arg(QDir::homePath());
|
||||
|
||||
// Important Note: In order to import connections from the latest version found, config. file path of an
|
||||
// old version must be defined (i.e. CONFIG_FILE_1_0_0 seen above) and placed into the
|
||||
// vector initializer list below in order.
|
||||
std::vector<QString> const SettingsManager::_configFilesOfOldVersions
|
||||
{
|
||||
CONFIG_FILE_1_1_0_BETA,
|
||||
CONFIG_FILE_1_0_0,
|
||||
CONFIG_FILE_1_0_RC1,
|
||||
CONFIG_FILE_0_9,
|
||||
CONFIG_FILE_0_8_5,
|
||||
};
|
||||
|
||||
std::vector<ConnectionSettings*> SettingsManager::_connections;
|
||||
|
||||
// Temporarily disabling Recent Connections feature
|
||||
// std::vector<RecentConnection> SettingsManager::_recentConnections;
|
||||
|
||||
/**
|
||||
* Creates SettingsManager for config file in default location
|
||||
* ~/.config/robomongo/robomongo.json
|
||||
@@ -43,20 +97,28 @@ namespace Robomongo
|
||||
_timeZone(Utc),
|
||||
_viewMode(Robomongo::Tree),
|
||||
_autocompletionMode(AutocompleteAll),
|
||||
_batchSize(50),
|
||||
_loadMongoRcJs(false),
|
||||
_minimizeToTray(false),
|
||||
_lineNumbers(false),
|
||||
_disableConnectionShortcuts(false),
|
||||
_batchSize(50),
|
||||
_textFontFamily(""),
|
||||
_textFontPointSize(-1),
|
||||
_lineNumbers(false),
|
||||
_loadMongoRcJs(false)
|
||||
_mongoTimeoutSec(10),
|
||||
_shellTimeoutSec(15),
|
||||
_imported(false)
|
||||
{
|
||||
load();
|
||||
LOG_MSG("SettingsManager initialized in " + _configPath, mongo::logger::LogSeverity::Info(), false);
|
||||
if (!load()) { // if load fails (probably due to non-existing config. file or directory)
|
||||
save(); // create empty settings file
|
||||
load(); // try loading again for the purpose of import from previous Robomongo versions
|
||||
}
|
||||
|
||||
LOG_MSG("SettingsManager initialized in " + ConfigFilePath, mongo::logger::LogSeverity::Info(), false);
|
||||
}
|
||||
|
||||
SettingsManager::~SettingsManager()
|
||||
{
|
||||
std::for_each(_connections.begin() ,_connections.end(), stdutils::default_delete<ConnectionSettings *>());
|
||||
std::for_each(_connections.begin(), _connections.end(), stdutils::default_delete<ConnectionSettings *>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,10 +127,10 @@ namespace Robomongo
|
||||
*/
|
||||
bool SettingsManager::load()
|
||||
{
|
||||
if (!QFile::exists(_configPath))
|
||||
if (!QFile::exists(ConfigFilePath))
|
||||
return false;
|
||||
|
||||
QFile f(_configPath);
|
||||
QFile f(ConfigFilePath);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
@@ -91,14 +153,14 @@ namespace Robomongo
|
||||
{
|
||||
QVariantMap map = convertToMap();
|
||||
|
||||
if (!QDir().mkpath(_configDir)) {
|
||||
LOG_MSG("ERROR: Could not create settings path: " + _configDir, mongo::logger::LogSeverity::Error());
|
||||
if (!QDir().mkpath(ConfigDir)) {
|
||||
LOG_MSG("ERROR: Could not create settings path: " + ConfigDir, mongo::logger::LogSeverity::Error());
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile f(_configPath);
|
||||
QFile f(ConfigFilePath);
|
||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
LOG_MSG("ERROR: Could not write settings to: " + _configPath, mongo::logger::LogSeverity::Error());
|
||||
LOG_MSG("ERROR: Could not write settings to: " + ConfigFilePath, mongo::logger::LogSeverity::Error());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,11 +169,21 @@ namespace Robomongo
|
||||
s.setIndentMode(QJson::IndentFull);
|
||||
s.serialize(map, &f, &ok);
|
||||
|
||||
LOG_MSG("Settings saved to: " + _configPath, mongo::logger::LogSeverity::Info());
|
||||
LOG_MSG("Settings saved to: " + ConfigFilePath, mongo::logger::LogSeverity::Info());
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void SettingsManager::addCacheData(QString const& key, QVariant const& value)
|
||||
{
|
||||
_cacheData.insert(key, value);
|
||||
}
|
||||
|
||||
QVariant SettingsManager::cacheData(QString const& key) const
|
||||
{
|
||||
return _cacheData.value(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load settings from the map. Existings settings will be overwritten.
|
||||
*/
|
||||
@@ -125,7 +197,7 @@ namespace Robomongo
|
||||
if (encoding > 3 || encoding < 0)
|
||||
encoding = 0;
|
||||
|
||||
_uuidEncoding = (UUIDEncoding) encoding;
|
||||
_uuidEncoding = (UUIDEncoding)encoding;
|
||||
|
||||
|
||||
// 3. Load view mode
|
||||
@@ -133,36 +205,41 @@ namespace Robomongo
|
||||
int viewMode = map.value("viewMode").toInt();
|
||||
if (viewMode > 2 || viewMode < 0)
|
||||
viewMode = Custom; // Default View Mode
|
||||
_viewMode = (ViewMode) viewMode;
|
||||
} else {
|
||||
_viewMode = (ViewMode)viewMode;
|
||||
}
|
||||
else {
|
||||
_viewMode = Custom; // Default View Mode
|
||||
}
|
||||
|
||||
_autoExpand = map.contains("autoExpand") ?
|
||||
map.value("autoExpand").toBool() : true;
|
||||
|
||||
_autoExec = map.contains("autoExec") ?
|
||||
map.value("autoExec").toBool() : true;
|
||||
|
||||
_lineNumbers = map.contains("lineNumbers") ?
|
||||
map.value("lineNumbers").toBool() : false;
|
||||
_autoExpand = map.contains("autoExpand") ? map.value("autoExpand").toBool() : true;
|
||||
_autoExec = map.contains("autoExec") ? map.value("autoExec").toBool() : true;
|
||||
_minimizeToTray = map.contains("minimizeToTray") ? map.value("minimizeToTray").toBool() : false;
|
||||
_lineNumbers = map.contains("lineNumbers") ? map.value("lineNumbers").toBool() : false;
|
||||
_imported = map.contains("imported") ? map.value("imported").toBool() : false;
|
||||
|
||||
// 4. Load TimeZone
|
||||
int timeZone = map.value("timeZone").toInt();
|
||||
if (timeZone > 1 || timeZone < 0)
|
||||
timeZone = 0;
|
||||
|
||||
_timeZone = (SupportedTimes) timeZone;
|
||||
_timeZone = (SupportedTimes)timeZone;
|
||||
_loadMongoRcJs = map.value("loadMongoRcJs").toBool();
|
||||
_disableConnectionShortcuts = map.value("disableConnectionShortcuts").toBool();
|
||||
|
||||
if (map.contains("acceptedEulaVersions"))
|
||||
_acceptedEulaVersions = map.value("acceptedEulaVersions").toStringList().toSet();
|
||||
|
||||
// Load anonymousID
|
||||
_anonymousID = getOrCreateAnonymousID(map);
|
||||
|
||||
// Load AutocompletionMode
|
||||
if (map.contains("autocompletionMode")) {
|
||||
int autocompletionMode = map.value("autocompletionMode").toInt();
|
||||
if (autocompletionMode < 0 || autocompletionMode > 2)
|
||||
autocompletionMode = AutocompleteAll; // Default Mode
|
||||
_autocompletionMode = (AutocompletionMode) autocompletionMode;
|
||||
} else {
|
||||
_autocompletionMode = (AutocompletionMode)autocompletionMode;
|
||||
}
|
||||
else {
|
||||
_autocompletionMode = AutocompleteAll; // Default Mode
|
||||
}
|
||||
|
||||
@@ -170,6 +247,10 @@ namespace Robomongo
|
||||
_batchSize = map.value("batchSize").toInt();
|
||||
if (_batchSize == 0)
|
||||
_batchSize = 50;
|
||||
|
||||
if (map.contains("checkForUpdates"))
|
||||
_checkForUpdates = map.value("checkForUpdates").toBool();
|
||||
|
||||
_currentStyle = map.value("style").toString();
|
||||
if (_currentStyle.isEmpty()) {
|
||||
_currentStyle = AppStyle::StyleName;
|
||||
@@ -179,32 +260,59 @@ namespace Robomongo
|
||||
_textFontFamily = map.value("textFontFamily").toString();
|
||||
_textFontPointSize = map.value("textFontPointSize").toInt();
|
||||
|
||||
if (map.contains("mongoTimeoutSec")) {
|
||||
_mongoTimeoutSec = map.value("mongoTimeoutSec").toInt();
|
||||
}
|
||||
|
||||
if (map.contains("shellTimeoutSec")) {
|
||||
_shellTimeoutSec = map.value("shellTimeoutSec").toInt();
|
||||
}
|
||||
|
||||
// 5. Load connections
|
||||
_connections.clear();
|
||||
|
||||
QVariantList list = map.value("connections").toList();
|
||||
for (QVariantList::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
ConnectionSettings *record = new ConnectionSettings();
|
||||
record->fromVariant((*it).toMap());
|
||||
_connections.push_back(record);
|
||||
QVariantList const& list = map.value("connections").toList();
|
||||
for (auto const& conn : list) {
|
||||
auto connSettings = new ConnectionSettings(false);
|
||||
connSettings->fromVariant(conn.toMap());
|
||||
addConnection(connSettings);
|
||||
}
|
||||
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
// Load recent connections
|
||||
_recentConnections.clear();
|
||||
QVariantList const& rlist = map.value("recentConnections").toList();
|
||||
for (auto const& rconn : rlist) {
|
||||
_recentConnections.push_back(RecentConnection(rconn.toMap().value("uuid").toString(),
|
||||
rconn.toMap().value("name").toString().toStdString()));
|
||||
}
|
||||
*/
|
||||
|
||||
_toolbars = map.value("toolbars").toMap();
|
||||
ToolbarSettingsContainerType::const_iterator it = _toolbars.find("connect");
|
||||
if (_toolbars.end() == it)
|
||||
_toolbars["connect"] = true;
|
||||
|
||||
it = _toolbars.find("open_save");
|
||||
if (_toolbars.end() == it)
|
||||
_toolbars["open_save"] = true;
|
||||
|
||||
it = _toolbars.find("exec");
|
||||
if (_toolbars.end() == it)
|
||||
_toolbars["exec"] = true;
|
||||
|
||||
it = _toolbars.find("explorer");
|
||||
if (_toolbars.end() == it)
|
||||
_toolbars["explorer"] = true;
|
||||
|
||||
it = _toolbars.find("logs");
|
||||
if (_toolbars.end() == it)
|
||||
_toolbars["logs"] = false;
|
||||
|
||||
_cacheData = map.value("cacheData").toMap();
|
||||
|
||||
// Load connection settings from previous versions of Robomongo
|
||||
importConnections();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,36 +344,105 @@ namespace Robomongo
|
||||
|
||||
// 7. Save disableConnectionShortcuts
|
||||
map.insert("disableConnectionShortcuts", _disableConnectionShortcuts);
|
||||
|
||||
// 8. Save acceptedEulaVersions array
|
||||
QJsonArray arr;
|
||||
for (auto const& str : _acceptedEulaVersions)
|
||||
arr.push_back(str);
|
||||
|
||||
// 8. Save batchSize
|
||||
map.insert("acceptedEulaVersions", arr.toVariantList());
|
||||
|
||||
// 9. Save batchSize
|
||||
map.insert("batchSize", _batchSize);
|
||||
map.insert("checkForUpdates", _checkForUpdates);
|
||||
map.insert("mongoTimeoutSec", _mongoTimeoutSec);
|
||||
map.insert("shellTimeoutSec", _shellTimeoutSec);
|
||||
|
||||
// 9. Save style
|
||||
// 10. Save style
|
||||
map.insert("style", _currentStyle);
|
||||
|
||||
// 10. Save font information
|
||||
// 11. Save font information
|
||||
map.insert("textFontFamily", _textFontFamily);
|
||||
map.insert("textFontPointSize", _textFontPointSize);
|
||||
|
||||
// 11. Save connections
|
||||
// 12. Save connections
|
||||
QVariantList list;
|
||||
|
||||
for (ConnectionSettingsContainerType::const_iterator it = _connections.begin(); it!=_connections.end(); ++it) {
|
||||
QVariantMap rm = (*it)->toVariant().toMap();
|
||||
list.append(rm);
|
||||
}
|
||||
for (auto const conn : _connections)
|
||||
list.append(conn->toVariant().toMap());
|
||||
|
||||
map.insert("connections", list);
|
||||
|
||||
map.insert("autoExec", _autoExec);
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
// 13. Save recent connections
|
||||
QVariantList recentConnsList;
|
||||
QVariantMap recentConnMap;
|
||||
for (auto const& rconn : _recentConnections) {
|
||||
recentConnMap.insert("uuid", rconn.uuid);
|
||||
recentConnMap.insert("name", QString::fromStdString(rconn.name));
|
||||
recentConnsList.append(recentConnMap);
|
||||
}
|
||||
map.insert("recentConnections", recentConnsList);
|
||||
*/
|
||||
|
||||
map.insert("autoExec", _autoExec);
|
||||
map.insert("minimizeToTray", _minimizeToTray);
|
||||
map.insert("toolbars", _toolbars);
|
||||
map.insert("imported", _imported);
|
||||
map.insert("anonymousID", _anonymousID);
|
||||
map.insert("cacheData", _cacheData);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
QString SettingsManager::getOrCreateAnonymousID(QVariantMap const& map) const
|
||||
{
|
||||
QString anonymousID = "";
|
||||
|
||||
// If anonymousID has never been created or is empty, create a new one. Otherwise load the existing.
|
||||
if (map.contains("anonymousID")) {
|
||||
QUuid id = map.value("anonymousID").toString();
|
||||
if (!id.isNull())
|
||||
anonymousID = id.toString();
|
||||
}
|
||||
|
||||
// Search and import "anonymousID" from other Studio 3T config files
|
||||
for (auto const& zipFileAndConfigFile : S_3T_ZipFile_And_ConfigFile_List) {
|
||||
if (!anonymousID.isEmpty())
|
||||
break;
|
||||
|
||||
QUuid const& id = extractAnonymousIDFromZip(zipFileAndConfigFile.first, zipFileAndConfigFile.second);
|
||||
if (!id.isNull())
|
||||
anonymousID = id.toString();
|
||||
}
|
||||
|
||||
// Search and import "anonymousID" from other Robo 3T old config files starting from latest
|
||||
for (auto const& oldConfigFile : _configFilesOfOldVersions) {
|
||||
if (!anonymousID.isEmpty())
|
||||
break;
|
||||
|
||||
// Don't import from 1.1-Beta due to a problem where Beta might have redundantly created new UUID
|
||||
if (oldConfigFile == CONFIG_FILE_1_1_0_BETA)
|
||||
continue;
|
||||
|
||||
// Stop searching in 1_0_RC1 or older versions, "anonymousID" is introduced in version 1.0
|
||||
if (oldConfigFile == CONFIG_FILE_1_0_RC1)
|
||||
break;
|
||||
|
||||
anonymousID = extractAnonymousID(oldConfigFile);
|
||||
}
|
||||
|
||||
// Couldn't find/import any, create a new anonymousID
|
||||
if (anonymousID.isEmpty())
|
||||
anonymousID = QUuid::createUuid().toString();
|
||||
|
||||
anonymousID.remove('{');
|
||||
anonymousID.remove('}');
|
||||
|
||||
return anonymousID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds connection to the end of list
|
||||
* Adds connection to the end of list and set it's uniqueID
|
||||
*/
|
||||
void SettingsManager::addConnection(ConnectionSettings *connection)
|
||||
{
|
||||
@@ -277,13 +454,57 @@ namespace Robomongo
|
||||
*/
|
||||
void SettingsManager::removeConnection(ConnectionSettings *connection)
|
||||
{
|
||||
ConnectionSettingsContainerType::iterator it = std::find(_connections.begin(),_connections.end(),connection);
|
||||
if (it!=_connections.end()) {
|
||||
ConnectionSettingsContainerType::iterator it = std::find(_connections.begin(), _connections.end(), connection);
|
||||
if (it != _connections.end()) {
|
||||
_connections.erase(it);
|
||||
delete connection;
|
||||
}
|
||||
}
|
||||
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
void SettingsManager::addRecentConnection(ConnectionSettings *connection)
|
||||
{
|
||||
_recentConnections.push_back(RecentConnection(connection->uuid(), connection->connectionName()));
|
||||
}
|
||||
|
||||
void SettingsManager::deleteRecentConnection(ConnectionSettings *conn)
|
||||
{
|
||||
for (int i = 0; i < _recentConnections.size(); ++i) {
|
||||
if (_recentConnections[i].uuid == conn->uuid())
|
||||
_recentConnections.erase(_recentConnections.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsManager::setRecentConnections(std::vector<ConnectionSettings const*> const& recentConns)
|
||||
{
|
||||
_recentConnections.clear();
|
||||
|
||||
for(auto rconn : recentConns)
|
||||
_recentConnections.push_back(RecentConnection(rconn->uuid(), rconn->connectionName()));
|
||||
}
|
||||
|
||||
void SettingsManager::clearRecentConnections()
|
||||
{
|
||||
_recentConnections.clear();
|
||||
}
|
||||
*/
|
||||
|
||||
ConnectionSettings* SettingsManager::getConnectionSettingsByUuid(QString const& uuid) const
|
||||
{
|
||||
for (auto const connSettings : _connections){
|
||||
if (connSettings->uuid() == uuid)
|
||||
return connSettings;
|
||||
}
|
||||
|
||||
LOG_MSG("Failed to find connection settings object by UUID.", mongo::logger::LogSeverity::Warning());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ConnectionSettings* SettingsManager::getConnectionSettingsByUuid(std::string const& uuid) const
|
||||
{
|
||||
return getConnectionSettingsByUuid(QString::fromStdString(uuid));
|
||||
}
|
||||
|
||||
void SettingsManager::setCurrentStyle(const QString& style)
|
||||
{
|
||||
_currentStyle = style;
|
||||
@@ -308,4 +529,220 @@ namespace Robomongo
|
||||
_toolbars[toolbarName] = visible;
|
||||
}
|
||||
|
||||
void SettingsManager::importConnections()
|
||||
{
|
||||
// Do not import if already imported
|
||||
if (_imported)
|
||||
return;
|
||||
|
||||
// Find and import 'only' from the latest version to current version
|
||||
for (auto const& configFile : _configFilesOfOldVersions) {
|
||||
if (QFile::exists(configFile)) {
|
||||
importConnectionsFromOldVersion(configFile);
|
||||
setImported(true); // Mark as imported
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsManager::importConnectionsFrom_0_8_5()
|
||||
{
|
||||
// Load old configuration file (used till version 0.8.5)
|
||||
|
||||
if (!QFile::exists(CONFIG_FILE_0_8_5))
|
||||
return false;
|
||||
|
||||
QFile oldConfigFile(CONFIG_FILE_0_8_5);
|
||||
if (!oldConfigFile.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
bool ok;
|
||||
QJson::Parser parser;
|
||||
QVariantMap vmap = parser.parse(oldConfigFile.readAll(), &ok).toMap();
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
QVariantList vconns = vmap.value("connections").toList();
|
||||
for (QVariantList::iterator itconn = vconns.begin(); itconn != vconns.end(); ++itconn)
|
||||
{
|
||||
QVariantMap vconn = (*itconn).toMap();
|
||||
|
||||
auto conn = new ConnectionSettings(false);
|
||||
conn->setImported(true);
|
||||
conn->setConnectionName(QtUtils::toStdString(vconn.value("connectionName").toString()));
|
||||
conn->setServerHost(QtUtils::toStdString(vconn.value("serverHost").toString().left(300)));
|
||||
conn->setServerPort(vconn.value("serverPort").toInt());
|
||||
conn->setDefaultDatabase(QtUtils::toStdString(vconn.value("defaultDatabase").toString()));
|
||||
|
||||
// SSH settings
|
||||
if (vconn.contains("sshAuthMethod")) {
|
||||
SshSettings *ssh = conn->sshSettings();
|
||||
ssh->setHost(QtUtils::toStdString(vconn.value("sshHost").toString()));
|
||||
ssh->setUserName(QtUtils::toStdString(vconn.value("sshUserName").toString()));
|
||||
ssh->setPort(vconn.value("sshPort").toInt());
|
||||
ssh->setUserPassword(QtUtils::toStdString(vconn.value("sshUserPassword").toString()));
|
||||
ssh->setPublicKeyFile(QtUtils::toStdString(vconn.value("sshPublicKey").toString()));
|
||||
ssh->setPrivateKeyFile(QtUtils::toStdString(vconn.value("sshPrivateKey").toString()));
|
||||
ssh->setPassphrase(QtUtils::toStdString(vconn.value("sshPassphrase").toString()));
|
||||
|
||||
int auth = vconn.value("sshAuthMethod").toInt();
|
||||
ssh->setEnabled(auth == 1 || auth == 2);
|
||||
ssh->setAuthMethod(auth == 2 ? "publickey" : "password");
|
||||
}
|
||||
|
||||
// SSL settings
|
||||
if (vconn.contains("sshEnabled")) {
|
||||
SslSettings *ssl = conn->sslSettings();
|
||||
ssl->enableSSL(vconn.value("enabled").toBool());
|
||||
ssl->setPemKeyFile(QtUtils::toStdString(vconn.value("sslPemKeyFile").toString()));
|
||||
}
|
||||
|
||||
// Credentials
|
||||
QVariantList vcreds = vconn.value("credentials").toList();
|
||||
for (QVariantList::const_iterator itcred = vcreds.begin(); itcred != vcreds.end(); ++itcred) {
|
||||
QVariantMap vcred = (*itcred).toMap();
|
||||
|
||||
auto cred = new CredentialSettings();
|
||||
cred->setUserName(QtUtils::toStdString(vcred.value("userName").toString()));
|
||||
cred->setUserPassword(QtUtils::toStdString(vcred.value("userPassword").toString()));
|
||||
cred->setDatabaseName(QtUtils::toStdString(vcred.value("databaseName").toString()));
|
||||
cred->setMechanism("MONGODB-CR");
|
||||
cred->setEnabled(vcred.value("enabled").toBool());
|
||||
|
||||
conn->addCredential(cred);
|
||||
}
|
||||
|
||||
// Check that we didn't have similar connection
|
||||
bool matched = false;
|
||||
for (std::vector<ConnectionSettings*>::const_iterator it = _connections.begin(); it != _connections.end(); ++it) {
|
||||
ConnectionSettings *econn = *it; // Existing connection
|
||||
|
||||
if (conn->serverPort() != econn->serverPort() ||
|
||||
conn->serverHost() != econn->serverHost() ||
|
||||
conn->defaultDatabase() != econn->defaultDatabase())
|
||||
continue;
|
||||
|
||||
CredentialSettings *cred = conn->primaryCredential();
|
||||
CredentialSettings *ecred = econn->primaryCredential();
|
||||
if (cred->databaseName() != ecred->databaseName() ||
|
||||
cred->userName() != ecred->userName() ||
|
||||
cred->userPassword() != ecred->userPassword() ||
|
||||
cred->enabled() != ecred->enabled())
|
||||
continue;
|
||||
|
||||
SshSettings *ssh = conn->sshSettings();
|
||||
SshSettings *essh = econn->sshSettings();
|
||||
if (ssh->enabled() != essh->enabled() ||
|
||||
ssh->port() != essh->port() ||
|
||||
ssh->host() != essh->host() ||
|
||||
ssh->privateKeyFile() != essh->privateKeyFile() ||
|
||||
ssh->userPassword() != essh->userPassword() ||
|
||||
ssh->userName() != essh->userName())
|
||||
continue;
|
||||
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Import connection only if we didn't find similar one
|
||||
if (!matched)
|
||||
addConnection(conn);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SettingsManager::importConnectionsFromOldVersion(QString const& oldConfigFilePath)
|
||||
{
|
||||
if (oldConfigFilePath == CONFIG_FILE_0_8_5) {
|
||||
importConnectionsFrom_0_8_5();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!QFile::exists(oldConfigFilePath))
|
||||
return false;
|
||||
|
||||
QFile oldConfigFile(oldConfigFilePath);
|
||||
if (!oldConfigFile.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
bool ok;
|
||||
QJson::Parser parser;
|
||||
QVariantMap vmap = parser.parse(oldConfigFile.readAll(), &ok).toMap();
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
QVariantList const& vconns = vmap.value("connections").toList();
|
||||
for (auto const& vcon : vconns)
|
||||
{
|
||||
QVariantMap const& vconn = vcon.toMap();
|
||||
auto connSettings = new ConnectionSettings(false);
|
||||
connSettings->fromVariant(vconn);
|
||||
connSettings->setImported(true);
|
||||
|
||||
addConnection(connSettings);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int SettingsManager::importedConnectionsCount() {
|
||||
int count = 0;
|
||||
for (std::vector<ConnectionSettings*>::const_iterator it = _connections.begin(); it != _connections.end(); ++it) {
|
||||
ConnectionSettings *conn = *it;
|
||||
if (conn->imported())
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
QString extractAnonymousIDFromZip(QString const& zipFile, QString const& propfile)
|
||||
{
|
||||
QZipReader zipReader(zipFile);
|
||||
if (!zipReader.exists() || !zipReader.isReadable())
|
||||
return QString("");
|
||||
|
||||
QXmlStreamReader reader(zipReader.fileData(propfile));
|
||||
while (!reader.atEnd()) {
|
||||
reader.readNext();
|
||||
if (reader.text().toString() == "AnonymousID") {
|
||||
reader.readNext();
|
||||
reader.readNext();
|
||||
reader.readNext();
|
||||
reader.readNext();
|
||||
return reader.text().toString();
|
||||
}
|
||||
}
|
||||
|
||||
return QString("");
|
||||
}
|
||||
|
||||
QString extractAnonymousID(QString const& oldConfigFilePath)
|
||||
{
|
||||
if (!QFile::exists(oldConfigFilePath))
|
||||
return QString("");
|
||||
|
||||
QFile oldConfigFile(oldConfigFilePath);
|
||||
if (!oldConfigFile.open(QIODevice::ReadOnly))
|
||||
return QString("");
|
||||
|
||||
bool ok = false;
|
||||
QJson::Parser parser;
|
||||
QVariantMap const& map = parser.parse(oldConfigFile.readAll(), &ok).toMap();
|
||||
if (!ok)
|
||||
return QString("");
|
||||
|
||||
QString anonymousID;
|
||||
if (map.contains("anonymousID")) {
|
||||
QUuid const& id = map.value("anonymousID").toString();
|
||||
if (!id.isNull())
|
||||
anonymousID = id.toString();
|
||||
}
|
||||
|
||||
anonymousID.remove('{');
|
||||
anonymousID.remove('}');
|
||||
|
||||
return anonymousID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,49 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QVariantMap>
|
||||
#include <QSet>
|
||||
#include <QDir>
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "robomongo/core/Enums.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
class ConnectionSettings;
|
||||
struct ConfigFileAndImportFunction;
|
||||
|
||||
// Current cache directory
|
||||
QString const CacheDir = QString("%1/.3T/robo-3t/%2/cache/").arg(QDir::homePath())
|
||||
.arg(PROJECT_VERSION);
|
||||
// Current config file
|
||||
QString const ConfigFilePath = QString("%1/.3T/robo-3t/%2/robo3t.json").arg(QDir::homePath())
|
||||
.arg(PROJECT_VERSION);
|
||||
// Current config file directory
|
||||
QString const ConfigDir = QString("%1/.3T/robo-3t/%2/").arg(QDir::homePath())
|
||||
.arg(PROJECT_VERSION);
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
struct RecentConnection
|
||||
{
|
||||
RecentConnection(QString const& uuid, std::string const& name)
|
||||
: uuid(uuid), name(name) {}
|
||||
|
||||
// Not directly used but required by std::vector<T>::erase()
|
||||
RecentConnection& operator=(const RecentConnection& other)
|
||||
{
|
||||
uuid = other.uuid;
|
||||
name = other.name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QString uuid;
|
||||
std::string name;
|
||||
};
|
||||
*/
|
||||
|
||||
/* ----------------------------- SettingsManager ------------------------------ */
|
||||
|
||||
/**
|
||||
* @brief SettingsManager gives you access to all settings, that is used
|
||||
* by Robomongo. It can load() and save() them. Config file usually
|
||||
@@ -23,6 +60,7 @@ namespace Robomongo
|
||||
public:
|
||||
typedef std::vector<ConnectionSettings *> ConnectionSettingsContainerType;
|
||||
typedef QMap<QString, QVariant> ToolbarSettingsContainerType;
|
||||
|
||||
/**
|
||||
* @brief Creates SettingsManager for config file in default location
|
||||
* (usually ~/.config/robomongo/robomongo.json)
|
||||
@@ -50,13 +88,32 @@ namespace Robomongo
|
||||
* @brief Adds connection to the end of list.
|
||||
* Connection now will be owned by SettingsManager.
|
||||
*/
|
||||
void addConnection(ConnectionSettings *connection);
|
||||
static void addConnection(ConnectionSettings *connection);
|
||||
|
||||
/**
|
||||
* @brief Removes connection by index
|
||||
*/
|
||||
void removeConnection(ConnectionSettings *connection);
|
||||
|
||||
/**
|
||||
* @brief Functions of Recent Connections feature
|
||||
*/
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
static void addRecentConnection(ConnectionSettings *connection);
|
||||
static void deleteRecentConnection(ConnectionSettings *connection);
|
||||
static void setRecentConnections(std::vector<ConnectionSettings const*> const& recentConns);
|
||||
static void clearRecentConnections();
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Finds and returns original (non-clone) connection settings which is
|
||||
* loaded/saved from/into Robomongo config. file.
|
||||
* @return If uniqueID is valid returns original connection settings,
|
||||
* nullptr otherwise.
|
||||
*/
|
||||
ConnectionSettings* getConnectionSettingsByUuid(QString const& uuid) const;
|
||||
ConnectionSettings* getConnectionSettingsByUuid(std::string const& uuid) const;
|
||||
|
||||
void reorderConnections(const ConnectionSettingsContainerType &connections);
|
||||
|
||||
void setToolbarSettings(QString toolbarName, bool visible);
|
||||
@@ -65,6 +122,9 @@ namespace Robomongo
|
||||
* @brief Returns list of connections
|
||||
*/
|
||||
ConnectionSettingsContainerType connections() const { return _connections; }
|
||||
|
||||
// Temporarily disabling Recent Connections feature
|
||||
// std::vector<RecentConnection>& recentConnections() const { return _recentConnections; }
|
||||
|
||||
ToolbarSettingsContainerType toolbars() const { return _toolbars; }
|
||||
|
||||
@@ -72,7 +132,7 @@ namespace Robomongo
|
||||
UUIDEncoding uuidEncoding() const { return _uuidEncoding; }
|
||||
|
||||
void setTimeZone(SupportedTimes timeZ) { _timeZone = timeZ; }
|
||||
SupportedTimes timeZone() const { return _timeZone;}
|
||||
SupportedTimes timeZone() const { return _timeZone; }
|
||||
|
||||
void setViewMode(ViewMode viewMode) { _viewMode = viewMode; }
|
||||
ViewMode viewMode() const { return _viewMode; }
|
||||
@@ -86,6 +146,9 @@ namespace Robomongo
|
||||
void setAutoExec(bool isAutoExec) { _autoExec = isAutoExec; }
|
||||
bool autoExec() const { return _autoExec; }
|
||||
|
||||
void setMinimizeToTray(bool isMinimizingToTray) { _minimizeToTray = isMinimizingToTray; }
|
||||
bool minimizeToTray() const { return _minimizeToTray; }
|
||||
|
||||
void setLineNumbers(bool showLineNumbers) { _lineNumbers = showLineNumbers; }
|
||||
bool lineNumbers() const { return _lineNumbers; }
|
||||
|
||||
@@ -95,10 +158,16 @@ namespace Robomongo
|
||||
void setDisableConnectionShortcuts(bool isDisable) { _disableConnectionShortcuts = isDisable; }
|
||||
bool disableConnectionShortcuts() const { return _disableConnectionShortcuts; }
|
||||
|
||||
void addAcceptedEulaVersion(QString const& version) { _acceptedEulaVersions.insert(version); }
|
||||
QSet<QString> const& acceptedEulaVersions() const { return _acceptedEulaVersions; }
|
||||
|
||||
void setCheckForUpdates(bool checkForUpdates) { _checkForUpdates = checkForUpdates; }
|
||||
bool checkForUpdates() const { return _checkForUpdates; }
|
||||
|
||||
void setBatchSize(int batchSize) { _batchSize = batchSize; }
|
||||
int batchSize() const { return _batchSize; }
|
||||
|
||||
QString currentStyle() const {return _currentStyle; }
|
||||
QString currentStyle() const { return _currentStyle; }
|
||||
void setCurrentStyle(const QString& style);
|
||||
|
||||
QString textFontFamily() const { return _textFontFamily; }
|
||||
@@ -107,47 +176,103 @@ namespace Robomongo
|
||||
int textFontPointSize() const { return _textFontPointSize; }
|
||||
void setTextFontPointSize(int pointSize);
|
||||
|
||||
int mongoTimeoutSec() const { return _mongoTimeoutSec; }
|
||||
int shellTimeoutSec() const { return _shellTimeoutSec; }
|
||||
|
||||
void setShellTimeoutSec(int newValue) { _shellTimeoutSec = std::abs(newValue); }
|
||||
|
||||
// True when settings from previous versions of Robomongo are imported
|
||||
void setImported(bool imported) { _imported = imported; }
|
||||
bool imported() const { return _imported; }
|
||||
|
||||
QString anonymousID() const { return _anonymousID; }
|
||||
|
||||
void addCacheData(QString const& key, QVariant const& value);
|
||||
QVariant cacheData(QString const& key) const;
|
||||
|
||||
/**
|
||||
* Returns number of imported connections
|
||||
*/
|
||||
int importedConnectionsCount();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Load settings from the map. Existings settings will be overwritten.
|
||||
* Load settings from the map. Existing settings will be overwritten.
|
||||
*/
|
||||
void loadFromMap(QVariantMap &map);
|
||||
|
||||
/**
|
||||
* @brief Save all settings to map.
|
||||
* Save all settings to map.
|
||||
*/
|
||||
QVariantMap convertToMap() const;
|
||||
|
||||
// Find existing anonymousID from Robomongo and 3T config files, if not found create
|
||||
// a new anonymousID.
|
||||
QString getOrCreateAnonymousID(QVariantMap const& map) const;
|
||||
|
||||
/**
|
||||
* Load connection settings from previous versions of Robomongo
|
||||
*/
|
||||
void importConnections();
|
||||
|
||||
// Imports connections from oldConfigFilePath into current config file
|
||||
static bool importConnectionsFromOldVersion(QString const& oldConfigFilePath);
|
||||
|
||||
static bool importConnectionsFrom_0_8_5();
|
||||
|
||||
/**
|
||||
* @brief Version of settings schema currently loaded
|
||||
*/
|
||||
QString _version;
|
||||
|
||||
/**
|
||||
* @brief UUID encoding
|
||||
*/
|
||||
UUIDEncoding _uuidEncoding;
|
||||
SupportedTimes _timeZone;
|
||||
/**
|
||||
* @brief view mode
|
||||
*/
|
||||
ViewMode _viewMode;
|
||||
AutocompletionMode _autocompletionMode;
|
||||
bool _loadMongoRcJs;
|
||||
bool _autoExpand;
|
||||
bool _autoExec;
|
||||
bool _minimizeToTray;
|
||||
bool _lineNumbers;
|
||||
bool _disableConnectionShortcuts;
|
||||
QSet<QString> _acceptedEulaVersions;
|
||||
int _batchSize;
|
||||
bool _checkForUpdates = true;
|
||||
QString _currentStyle;
|
||||
QString _textFontFamily;
|
||||
int _textFontPointSize;
|
||||
|
||||
int _mongoTimeoutSec;
|
||||
int _shellTimeoutSec;
|
||||
|
||||
// True when settings from previous versions of Robomongo are imported
|
||||
bool _imported;
|
||||
|
||||
/**
|
||||
* @brief This is an anonymous string taken from QUuid that is generated when Robomongo
|
||||
* is first installed on a user's machine and then launched for the first time
|
||||
* It stays the same throughout all upgrades.
|
||||
*/
|
||||
QString _anonymousID;
|
||||
|
||||
// Various cache data
|
||||
QMap<QString, QVariant> _cacheData;
|
||||
|
||||
/**
|
||||
* @brief List of connections
|
||||
*/
|
||||
ConnectionSettingsContainerType _connections;
|
||||
static std::vector<ConnectionSettings*> _connections;
|
||||
|
||||
/* Temporarily disabling Recent Connections feature
|
||||
// List of recent connections that are shown on Welcome Tab
|
||||
static std::vector<RecentConnection> _recentConnections;
|
||||
*/
|
||||
|
||||
ToolbarSettingsContainerType _toolbars;
|
||||
|
||||
// List of config. file absolute paths of old versions
|
||||
// Must be updated with care and with every new version. Details on cpp file.
|
||||
static std::vector<QString> const _configFilesOfOldVersions;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ namespace Robomongo
|
||||
SshSettings::SshSettings() :
|
||||
_port(22),
|
||||
_authMethod("publickey"),
|
||||
_enabled(false) {
|
||||
_enabled(false),
|
||||
_askPassword(false),
|
||||
_logLevel(1) {
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +29,7 @@ namespace Robomongo
|
||||
map.insert("passphrase", QtUtils::toQString(passphrase()));
|
||||
map.insert("method", QtUtils::toQString(authMethod()));
|
||||
map.insert("enabled", enabled());
|
||||
map.insert("askPassword", askPassword());
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -40,5 +43,6 @@ namespace Robomongo
|
||||
setPassphrase(QtUtils::toStdString(map.value("passphrase").toString()));
|
||||
setAuthMethod(QtUtils::toStdString(map.value("method").toString()));
|
||||
setEnabled(map.value("enabled").toBool());
|
||||
setAskPassword(map.value("askPassword").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace Robomongo
|
||||
QVariant toVariant() const;
|
||||
void fromVariant(const QVariantMap &map);
|
||||
|
||||
/*
|
||||
* Domain or IPv4 or IPv6 address
|
||||
*/
|
||||
std::string host() const { return _host; }
|
||||
void setHost(const std::string &host) { _host = host; }
|
||||
|
||||
@@ -43,6 +46,7 @@ namespace Robomongo
|
||||
std::string passphrase() const { return _passphrase; }
|
||||
void setPassphrase(const std::string &passphrase) { _passphrase = passphrase; }
|
||||
|
||||
// "password" or "publickey"
|
||||
std::string authMethod() const { return _authMethod.empty() ? "publickey" : _authMethod; }
|
||||
void setAuthMethod(const std::string &method) { _authMethod = method; }
|
||||
|
||||
@@ -53,11 +57,17 @@ namespace Robomongo
|
||||
bool enabled() const { return _enabled; }
|
||||
void setEnabled(bool enabled) { _enabled = enabled; }
|
||||
|
||||
bool askPassword() const { return _askPassword; }
|
||||
void setAskPassword(bool ask) { _askPassword = ask; }
|
||||
|
||||
std::string askedPassword() const { return _askedPassword; }
|
||||
void setAskedPassword(const std::string &asked) { _askedPassword = asked; }
|
||||
|
||||
int logLevel() const { return _logLevel; }
|
||||
void setLogLevel(const int logLevel) { _logLevel = logLevel; }
|
||||
|
||||
private:
|
||||
std::string _host;
|
||||
std::string _host; // domain or IPv4/v6
|
||||
int _port;
|
||||
std::string _userName;
|
||||
std::string _userPassword;
|
||||
@@ -66,11 +76,16 @@ namespace Robomongo
|
||||
std::string _passphrase;
|
||||
std::string _authMethod; // "password" or "publickey"
|
||||
|
||||
// Should we ask user about password or passphrase
|
||||
// each time when we try to connect
|
||||
bool _askPassword;
|
||||
|
||||
/**
|
||||
* Flag, indicating whether we should use
|
||||
* this SSH tunnel or not.
|
||||
*/
|
||||
bool _enabled;
|
||||
int _logLevel; // this property is not persisted
|
||||
int _logLevel; // this property is not persisted
|
||||
std::string _askedPassword; // this property is not persisted
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "robomongo/core/settings/SslSettings.h"
|
||||
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
SslSettings::SslSettings() :
|
||||
_sslEnabled(false), _caFile(""), _pemKeyFile(""), _pemPassPhrase(""), _crlFile(""),
|
||||
_allowInvalidHostnames(false), _allowInvalidCertificates(false), _usePemFile(false),
|
||||
_useAdvancedOptions(false), _askPassphrase(false)
|
||||
{}
|
||||
|
||||
SslSettings *SslSettings::clone() const
|
||||
{
|
||||
SslSettings *cloned = new SslSettings(*this);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
QVariant SslSettings::toVariant() const
|
||||
{
|
||||
QVariantMap map;
|
||||
map.insert("sslEnabled", sslEnabled());
|
||||
map.insert("caFile", QtUtils::toQString(caFile()));
|
||||
map.insert("usePemFile", usePemFile());
|
||||
map.insert("pemKeyFile", QtUtils::toQString(pemKeyFile()));
|
||||
map.insert("pemPassPhrase", QtUtils::toQString(pemPassPhrase()));
|
||||
map.insert("useAdvancedOptions", useAdvancedOptions());
|
||||
map.insert("crlFile", QtUtils::toQString(crlFile()));
|
||||
map.insert("allowInvalidHostnames", allowInvalidHostnames());
|
||||
map.insert("allowInvalidCertificates", allowInvalidCertificates());
|
||||
map.insert("askPassphrase", askPassphrase());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void SslSettings::fromVariant(const QVariantMap &map)
|
||||
{
|
||||
enableSSL(map.value("sslEnabled").toBool());
|
||||
setCaFile(QtUtils::toStdString(map.value("caFile").toString()));
|
||||
setUsePemFile(map.value("usePemFile").toBool());
|
||||
setPemKeyFile(QtUtils::toStdString(map.value("pemKeyFile").toString()));
|
||||
setPemPassPhrase(QtUtils::toStdString(map.value("pemPassPhrase").toString()));
|
||||
setUseAdvancedOptions(map.value("useAdvancedOptions").toBool());
|
||||
setCrlFile(QtUtils::toStdString(map.value("crlFile").toString()));
|
||||
setAllowInvalidHostnames(map.value("allowInvalidHostnames").toBool());
|
||||
setAllowInvalidCertificates(map.value("allowInvalidCertificates").toBool());
|
||||
setAskPassphrase(map.value("askPassphrase").toBool());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace Robomongo
|
||||
{
|
||||
class SslSettings
|
||||
{
|
||||
public:
|
||||
SslSettings();
|
||||
|
||||
/**
|
||||
* Clones credential settings.
|
||||
*/
|
||||
SslSettings *clone() const;
|
||||
|
||||
/**
|
||||
* Converts to QVariantMap
|
||||
*/
|
||||
QVariant toVariant() const;
|
||||
void fromVariant(const QVariantMap &map);
|
||||
|
||||
|
||||
// Getters for mongo:: SSLGlobalParams related settings
|
||||
std::string pemKeyFile() const { return _pemKeyFile; }
|
||||
std::string caFile() const { return _caFile; }
|
||||
std::string pemPassPhrase() const { return _pemPassPhrase; }
|
||||
std::string crlFile() const { return _crlFile; }
|
||||
bool allowInvalidHostnames() const { return _allowInvalidHostnames; }
|
||||
bool allowInvalidCertificates() const { return _allowInvalidCertificates; }
|
||||
|
||||
// Getters for helper SSL settings
|
||||
bool usePemFile() const { return _usePemFile; }
|
||||
bool useAdvancedOptions() const { return _useAdvancedOptions; }
|
||||
bool askPassphrase() const { return _askPassphrase; }
|
||||
|
||||
// Setters for mongo:: SSLGlobalParams related settings
|
||||
void setPemKeyFile(const std::string &path) { _pemKeyFile = path; }
|
||||
void setCaFile(const std::string &path) { _caFile = path; }
|
||||
void setPemPassPhrase(const std::string &pemPassPhrase) { _pemPassPhrase = pemPassPhrase; }
|
||||
void setCrlFile(const std::string &path) { _crlFile = path; }
|
||||
void setAllowInvalidHostnames(const bool state) { _allowInvalidHostnames = state; }
|
||||
void setAllowInvalidCertificates(const bool state) { _allowInvalidCertificates = state; }
|
||||
|
||||
// Setters for helper SSL settings
|
||||
void setUsePemFile(const bool state) { _usePemFile = state; }
|
||||
void setUseAdvancedOptions(const bool state) { _useAdvancedOptions = state; }
|
||||
void setAskPassphrase(const bool state) { _askPassphrase = state; }
|
||||
|
||||
/**
|
||||
* Flag, indicating whether we should use
|
||||
* this SSL settings or not.
|
||||
*/
|
||||
bool sslEnabled() const { return _sslEnabled; }
|
||||
void enableSSL(bool enabled) { _sslEnabled = enabled; }
|
||||
|
||||
private:
|
||||
|
||||
// mongo:: SSL Global params related settings
|
||||
std::string _caFile;
|
||||
std::string _pemKeyFile;
|
||||
std::string _pemPassPhrase;
|
||||
std::string _crlFile;
|
||||
bool _allowInvalidHostnames;
|
||||
bool _allowInvalidCertificates;
|
||||
|
||||
// Helper settings indirectly effecting what to pass to SSL global params
|
||||
bool _usePemFile;
|
||||
bool _useAdvancedOptions;
|
||||
bool _askPassphrase;
|
||||
|
||||
/**
|
||||
* Flag, indicating whether SSL enabled for related connection
|
||||
*/
|
||||
bool _sslEnabled;
|
||||
};
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
#include <mongo/client/dbclientinterface.h>
|
||||
//#include <mongo/bson/bsonobjiterator.h>
|
||||
#include "mongo/util/base64.h"
|
||||
#include "mongo/util/stringutils.h"
|
||||
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
#include "robomongo/core/HexUtils.h"
|
||||
#include "mongo/util/base64.h"
|
||||
|
||||
// v0.9
|
||||
#include "robomongo/shell/db/ptimeutil.h"
|
||||
@@ -80,23 +82,25 @@ namespace Robomongo
|
||||
s << (isArray ? "[" : "{");
|
||||
BSONObjIterator i(obj);
|
||||
BSONElement e = i.next();
|
||||
if ( !e.eoo() ){
|
||||
|
||||
if ( !e.eoo() ) {
|
||||
while ( 1 ) {
|
||||
if ( pretty ) {
|
||||
s << '\n';
|
||||
for( int x = 0; x < pretty; x++ ){
|
||||
for( int x = 0; x < pretty; x++ ) {
|
||||
s << " ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
s << " ";
|
||||
}
|
||||
s << jsonString(e, format, true, pretty?pretty+1:0, uuidEncoding, timeFormat, isArray);
|
||||
|
||||
s << jsonString(e, format, true, pretty ? pretty + 1 : 0, uuidEncoding, timeFormat, isArray);
|
||||
e = i.next();
|
||||
|
||||
if (e.eoo()) {
|
||||
s << '\n';
|
||||
for( int x = 0; x < pretty - 1; x++ ){
|
||||
for( int x = 0; x < pretty - 1; x++ ) {
|
||||
s << " ";
|
||||
}
|
||||
s << (isArray ? "]" : "}");
|
||||
@@ -109,7 +113,8 @@ namespace Robomongo
|
||||
return s.str();
|
||||
}
|
||||
|
||||
std::string jsonString(const BSONElement &elem, JsonStringFormat format, bool includeFieldNames, int pretty, UUIDEncoding uuidEncoding, SupportedTimes timeFormat, bool isArray)
|
||||
std::string jsonString(const BSONElement &elem, JsonStringFormat format, bool includeFieldNames,
|
||||
int pretty, UUIDEncoding uuidEncoding, SupportedTimes timeFormat, bool isArray)
|
||||
{
|
||||
using namespace std;
|
||||
BSONType t = elem.type();
|
||||
@@ -130,15 +135,21 @@ namespace Robomongo
|
||||
s << "NumberLong(" << elem._numberLong() << ")";
|
||||
break;
|
||||
case NumberInt:
|
||||
s << elem._numberInt();
|
||||
break;
|
||||
case NumberDouble:
|
||||
{
|
||||
int sign=0;
|
||||
int sign = 0;
|
||||
if ( elem.number() >= -std::numeric_limits< double >::max() &&
|
||||
elem.number() <= std::numeric_limits< double >::max() ) {
|
||||
|
||||
// was 16
|
||||
s.precision(std::numeric_limits<double>::digits10);
|
||||
s << elem.number();
|
||||
|
||||
// Leave trailing zero if needed
|
||||
if (elem.number() == (long long)elem.number())
|
||||
s << ".0";
|
||||
}
|
||||
else if (std::isnan(elem.number()) ) {
|
||||
s << "NaN";
|
||||
@@ -156,7 +167,7 @@ namespace Robomongo
|
||||
break;
|
||||
}
|
||||
case NumberDecimal:
|
||||
s << "NumberDecimal(" << elem._numberDecimal().toString() << ")";
|
||||
s << "NumberDecimal(\"" << elem._numberDecimal().toString() << "\")";
|
||||
break;
|
||||
case mongo::Bool:
|
||||
s << ( elem.boolean() ? "true" : "false" );
|
||||
@@ -166,7 +177,7 @@ namespace Robomongo
|
||||
break;
|
||||
case Object: {
|
||||
BSONObj obj = elem.embeddedObject();
|
||||
s << jsonString(obj, format, pretty, uuidEncoding,timeFormat);
|
||||
s << jsonString(obj, format, pretty, uuidEncoding, timeFormat);
|
||||
}
|
||||
break;
|
||||
case mongo::Array: {
|
||||
@@ -180,7 +191,7 @@ namespace Robomongo
|
||||
if ( !e.eoo() ) {
|
||||
int count = 0;
|
||||
while ( 1 ) {
|
||||
if( pretty ) {
|
||||
if ( pretty ) {
|
||||
s << '\n';
|
||||
for( int x = 0; x < pretty; x++ )
|
||||
s << " ";
|
||||
@@ -190,7 +201,7 @@ namespace Robomongo
|
||||
s << "undefined";
|
||||
}
|
||||
else {
|
||||
s << jsonString(e, format, false, pretty?pretty+1:0, uuidEncoding, timeFormat, true);
|
||||
s << jsonString(e, format, false, pretty ? pretty + 1 : 0, uuidEncoding, timeFormat, true);
|
||||
e = i.next();
|
||||
}
|
||||
count++;
|
||||
@@ -260,13 +271,13 @@ namespace Robomongo
|
||||
case mongo::Date:
|
||||
{
|
||||
Date_t d = elem.date();
|
||||
long long ms = d.toMillisSinceEpoch();//static_cast<long long>(d.millis);
|
||||
long long ms = d.toMillisSinceEpoch(); //static_cast<long long>(d.millis);
|
||||
bool isSupportedDate = miutil::minDate < ms && ms < miutil::maxDate;
|
||||
|
||||
if ( format == Strict )
|
||||
s << "{ \"$date\" : ";
|
||||
else{
|
||||
if(isSupportedDate){
|
||||
if (isSupportedDate) {
|
||||
s << "ISODate(";
|
||||
}
|
||||
else{
|
||||
@@ -275,7 +286,7 @@ namespace Robomongo
|
||||
}
|
||||
|
||||
if ( pretty && isSupportedDate) {
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1));
|
||||
boost::posix_time::time_duration diff = boost::posix_time::millisec(ms);
|
||||
boost::posix_time::ptime time = epoch + diff;
|
||||
std::string timestr = miutil::isotimeString(time, true, timeFormat == LocalTime);
|
||||
@@ -325,12 +336,11 @@ namespace Robomongo
|
||||
break;
|
||||
|
||||
case bsonTimestamp:
|
||||
if ( format == TenGen ) {
|
||||
s << "Timestamp(" << ( elem.timestampValue() / 1000 ) << ", " << elem.timestampInc() << ")";
|
||||
}
|
||||
else {
|
||||
s << "{ \"$timestamp\" : { \"t\" : " << ( elem.timestampValue() / 1000 ) << ", \"i\" : " << elem.timestampInc() << " } }";
|
||||
}
|
||||
if ( format == TenGen )
|
||||
s << "Timestamp(" << elem.timestamp().getSecs() << ", " << elem.timestampInc() << ")";
|
||||
else
|
||||
s << "{ \"$timestamp\" : { \"t\" : " << elem.timestamp().getSecs() << ", \"i\" : "
|
||||
<< elem.timestampInc() << " } }";
|
||||
break;
|
||||
|
||||
case MinKey:
|
||||
@@ -426,7 +436,7 @@ namespace Robomongo
|
||||
/** double precision floating point value */
|
||||
case NumberDecimal:
|
||||
{
|
||||
return "Decimal";
|
||||
return "Decimal128";
|
||||
}
|
||||
/** character string, stored in utf8 */
|
||||
case String:
|
||||
@@ -563,13 +573,13 @@ namespace Robomongo
|
||||
con.append(e.fieldName());
|
||||
con.append("\"");
|
||||
con.append(" : ");
|
||||
buildJsonString(e,con,uuid,tz);
|
||||
buildJsonString(e, con, uuid, tz);
|
||||
con.append(", \n");
|
||||
}
|
||||
con.append("\n}\n\n");
|
||||
}
|
||||
|
||||
void buildJsonString(const mongo::BSONElement &elem,std::string &con, UUIDEncoding uuid, SupportedTimes tz)
|
||||
void buildJsonString(const mongo::BSONElement &elem, std::string &con, UUIDEncoding uuid, SupportedTimes tz)
|
||||
{
|
||||
switch (elem.type())
|
||||
{
|
||||
@@ -578,6 +588,11 @@ namespace Robomongo
|
||||
std::stringstream s;
|
||||
s.precision(std::numeric_limits<double>::digits10);
|
||||
s << elem.Double();
|
||||
|
||||
// Leave trailing zero if needed
|
||||
if (elem.Double() == (long long)elem.Double())
|
||||
s << ".0";
|
||||
|
||||
con.append(s.str());
|
||||
}
|
||||
break;
|
||||
@@ -626,13 +641,13 @@ namespace Robomongo
|
||||
long long ms = (long long) elem.Date().toMillisSinceEpoch();
|
||||
bool isSupportedDate = miutil::minDate < ms && ms < miutil::maxDate;
|
||||
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1));
|
||||
boost::posix_time::time_duration diff = boost::posix_time::millisec(ms);
|
||||
boost::posix_time::ptime time = epoch + diff;
|
||||
|
||||
std::string date;
|
||||
if(isSupportedDate)
|
||||
date = miutil::isotimeString(time,false,tz==LocalTime);
|
||||
if (isSupportedDate)
|
||||
date = miutil::isotimeString(time, false, tz == LocalTime);
|
||||
else
|
||||
date = boost::lexical_cast<std::string>(ms);
|
||||
|
||||
@@ -652,7 +667,7 @@ namespace Robomongo
|
||||
case 'g':
|
||||
case 'i':
|
||||
case 'm':
|
||||
con+=*f;
|
||||
con += *f;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -678,15 +693,15 @@ namespace Robomongo
|
||||
break;
|
||||
case NumberInt:
|
||||
{
|
||||
char num[16]={0};
|
||||
sprintf(num,"%d",elem.Int());
|
||||
char num[16] = {0};
|
||||
sprintf(num, "%d", elem.Int());
|
||||
con.append(num);
|
||||
break;
|
||||
}
|
||||
case bsonTimestamp:
|
||||
{
|
||||
Date_t date = elem.timestampTime();
|
||||
unsigned long long millis = date.toMillisSinceEpoch();// millis;
|
||||
unsigned long long millis = date.toMillisSinceEpoch(); // millis;
|
||||
if ((long long)millis >= 0 &&
|
||||
((long long)millis/1000) < (std::numeric_limits<time_t>::max)()) {
|
||||
con.append(date.toString());
|
||||
@@ -695,24 +710,29 @@ namespace Robomongo
|
||||
}
|
||||
case NumberLong:
|
||||
{
|
||||
char num[32]={0};
|
||||
sprintf(num,"%lld",elem.Long());
|
||||
char num[32] = {0};
|
||||
sprintf(num, "%lld", elem.Long());
|
||||
con.append(num);
|
||||
break;
|
||||
}
|
||||
case NumberDecimal:
|
||||
{
|
||||
con.append(elem.numberDecimal().toString());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
con.append("<unsupported>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mongo::BSONElement indexOf(const mongo::BSONObj &doc,int index)
|
||||
mongo::BSONElement indexOf(const mongo::BSONObj &doc, int index)
|
||||
{
|
||||
mongo::BSONObjIterator iterator(doc);
|
||||
for (int i = 0; iterator.more(); ++i)
|
||||
{
|
||||
mongo::BSONElement element = iterator.next();
|
||||
if(i==index){
|
||||
if (i == index) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
@@ -722,7 +742,7 @@ namespace Robomongo
|
||||
int elementsCount(const mongo::BSONObj &doc)
|
||||
{
|
||||
mongo::BSONObjIterator iterator(doc);
|
||||
int i=0;
|
||||
int i = 0;
|
||||
for (; iterator.more(); ++i)
|
||||
{
|
||||
iterator.next();
|
||||
|
||||
@@ -100,8 +100,8 @@ namespace Robomongo
|
||||
|
||||
const char* BSONTypeToString(mongo::BSONType type, mongo::BinDataType binDataType, UUIDEncoding uuidEncoding);
|
||||
|
||||
void buildJsonString(const mongo::BSONObj &obj,std::string &con, UUIDEncoding uuid, SupportedTimes tz);
|
||||
void buildJsonString(const mongo::BSONElement &elem,std::string &con, UUIDEncoding uuid, SupportedTimes tz);
|
||||
void buildJsonString(const mongo::BSONObj &obj, std::string &con, UUIDEncoding uuid, SupportedTimes tz);
|
||||
void buildJsonString(const mongo::BSONElement &elem, std::string &con, UUIDEncoding uuid, SupportedTimes tz);
|
||||
|
||||
mongo::BSONElement indexOf(const mongo::BSONObj &doc, int index);
|
||||
int elementsCount(const mongo::BSONObj &doc);
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "robomongo/core/utils/QtUtils.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string getLoggerPath()
|
||||
{
|
||||
static std::string path = Robomongo::QtUtils::toStdString(QString("%1/" PROJECT_NAME_LOWERCASE ".log").arg(QDir::tempPath()));
|
||||
static std::string path =
|
||||
Robomongo::QtUtils::toStdString(QString("%1/" PROJECT_NAME_LOWERCASE ".log").arg(QDir::tempPath()));
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +49,15 @@ namespace Robomongo
|
||||
{
|
||||
// v0.9
|
||||
// LOG(level) << "[" PROJECT_NAME_TITLE "] " << QtUtils::toStdString(mess) << std::endl;
|
||||
if (notify)
|
||||
emit printed(mess, level);
|
||||
if (notify) {
|
||||
// Make uniform log level strings e.g "Error: ", "Info: " etc...
|
||||
auto logLevelStr = QString::fromStdString(level.toStringData().toString());
|
||||
if (!logLevelStr.isEmpty()) {
|
||||
logLevelStr = logLevelStr.toLower();
|
||||
logLevelStr[0] = logLevelStr[0].toUpper();
|
||||
logLevelStr += ": ";
|
||||
}
|
||||
emit printed(logLevelStr + mess, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Robomongo
|
||||
|
||||
void cleanUpThread(QThread *const thread)
|
||||
{
|
||||
if (thread&&thread->isRunning()) {
|
||||
if (thread && thread->isRunning()) {
|
||||
//thread->stop();
|
||||
thread->wait();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ namespace Robomongo
|
||||
static const QString StyleName;
|
||||
virtual void drawControl(ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget) const;
|
||||
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
||||
virtual QRect subElementRect( SubElement element, const QStyleOption * option, const QWidget * widget=0 ) const;
|
||||
virtual QRect subElementRect( SubElement element, const QStyleOption * option, const QWidget * widget = 0 ) const;
|
||||
};
|
||||
}
|
||||
|
||||