1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
Commit Graph

53 Commits

Author SHA1 Message Date
Anthony Bilinski
6105af8279
fix(ipc): allow IPC under windows by not using std::random_device with mingw
https://en.cppreference.com/w/cpp/numeric/random/random_device
"A notable implementation where std::random_device is deterministic is old
versions of MinGW (bug 338, fixed since GCC 9.2)."

Although time is less random off Windows, we don't need a strongly random
number for this, and using time avoids having to use platform specific code.

Fix #2917
2020-04-30 19:26:18 -07:00
iphydf
e71225268f
chore: Various code cleanups.
* Reorder class data members and/or constructor initialisers to match,
  reducing confusion about when members will be initialised.
* Remove (most) unused variables. Not removed: some global variables with
  `TODO(sudden6)` on them for using them in the future. I don't know how
  far into the future sudden6 wants to use them, so I left them there for
  now.
* Distinguish different bootstrap nodes in the logs by index in the
  bootstrap node list. Originally, we used to log the address/port of the
  node we're bootstrapping to. This was removed out of privacy concerns
  (even though the bootstrap nodes are public). This made the logs much
  less useful when debugging why the client isn't connecting. Having
  indices makes it easier to see that different nodes are being selected,
  and makes it possible to determine which node was selected.
* Explicitly cast unused results of Tox API functions to `void` when all
  we want is to know whether the function succeeds or not.
* Don't try to `#include <unistd.h>` on Windows. It does not exist on
  MSVC.
* Remove extra `;` after function definitions.
* Remove reference indirection of QJsonValueRef, since a copy of that ref
  (small pointer-like object) has to be made anyway when iterating over
  QJsonArrays.
* Make some file-scope global state `static`.
* Use `nullptr` instead of `NULL`.
* Add `#if DESKTOP_NOTIFICATIONS` around the code that implements desktop
  notifications, so it becomes a bit easier to compile everything with a
  single compiler command - useful for manually running static analysers.
* Fix an error on MSVC where `disconnect` is looked up to be a non-static
  member function and the `this` capture is missing.
* Consistently use `struct` and `class` tags for types.
* Use references in ranged-for where it reduces copies.
* Move private static data members out of the Style class and into
  file-local scope. There is no need for them to be in the class. Also
  marked them `const` where possible.
* Removed unused lambda capture.
* Ensure qTox can compile under NDEBUG with `-Wunused-variable` by
  inlining the unused variable into the `assert` that was its only
  target.
* Minor reformatting in core_test.cpp.
2020-04-16 19:07:40 +00:00
Anthony Bilinski
2fe1918083
feat(ipc): make IPC user specific
This allows multiple users on a system each running qTox to use IPC at once.

Fix #6076
2020-04-14 20:32:12 -07:00
Anthony Bilinski
2c1a86482a
chore(style): remove old style casts and cross sign comparisons
Enable warnings for both. Favour casting to signed rather than casting to
unsigend for comparisons. Per isocpp's core guidelines ES.102, signed
arithmetic gives more expected results. If we need one extra bit of range,
using longer signed types achives that.

Fix #6010
Fix #6012
2020-03-21 20:29:10 -07:00
jenli669
04a9bc46f4
docs(copyright): update and add copyright info
zealously updates and adds qTox copyright information.

Fixes #5713
2019-06-28 01:18:26 +02:00
sudden6
5afa78cd4d
refactor(ipc): cleanup and improve debug messages 2019-01-25 11:16:06 +01:00
iphydf
52a5951d26
chore: Use nullptr instead of 0 for NULL pointer constants. 2018-09-07 21:38:59 +00:00
Anthony Bilinski
5dc4e6de81
chore(legal): update copyright date to 2018 for all source files 2018-04-25 17:33:38 -07:00
Diadlo
c274cec87e
fix(ipc): Add check if IPC init failed
Also add error code to debug message.

Partially fix #4785
2017-11-22 22:59:51 +03:00
sudden6
ab12555935
Merge pull request #4679
anthony.bilinski (1):
      fix(IPC): don't double lock shared memory
2017-09-28 18:42:53 +02:00
Diadlo
43c2308b7b
fix(ipc): Reorder initialize list 2017-09-26 21:00:39 +03:00
anthony.bilinski
0bf27a000a fix(IPC): don't double lock shared memory
Fixes #4678
2017-09-25 10:37:01 -07:00
Diadlo
c2140e21ad
fix(ipc): Call processEvent on timer timeout
Fix #4609
2017-09-02 12:10:55 +03:00
sudden6
a3b234e6dd
chore(formatting): run clang-format 2017-06-01 09:50:59 +02:00
Diadlo
c2f82f7808
fix(IPC): Add update profileId in to IPC
Fix #4384
2017-05-24 19:41:54 +03:00
Diadlo
7d3020cba3
refactor(IPC): Remove IPC singlton 2017-05-04 20:31:56 +03:00
Diadlo
f11860680b
refactor(IPC): Remove Settings from IPC 2017-05-04 20:31:56 +03:00
Yuri
e597d391fc fix(includes): Added missing #include <ctime>
time(3) requires this include. Found when qTox failed to build on the FreeBSD due to the missing include.
2017-04-11 00:04:48 -07:00
Zetok Zalbavar
80f5de31b3
style: reformat current C++ codebase using clang-format 2017-02-26 11:52:45 +00:00
tux3
c75ee8a661
fix: Various IPC event handling and related bugs on startup
Fixes #1926 : When an IPC event was processed locally, if the window was closed before the core could start, the event handler would be forever stuck in the background waiting for the core to start. We fix this by substituting QApplication::quit() by a Nexus::quit() function and a Nexus::isRunning() function, which gives us a condition for exiting blocking processEvents() loops. We cannot simply use QApplication::quit(), because this function has no effect before the start of the event loop.

The problem was further exacerbated by the Tox URI event handler being (incorrectly) blocking. The IPC owner would block in this event handler, and the sender of the event would give up waiting and process the event itself a second time, potentially triggering the first bug. We fix the event handlers accordingly to be (mostly) non-blocking.

Also fixes a related deadlock between ~Core and ~Profile in the case of an early exit
2017-02-17 17:18:52 +01:00
Zetok Zalbavar
d4ac13dbf4
revert: "refactor: Added to include path and exclude it from all includes"
Revert needed, since otherwise there is no way to do automatic sorting
of includes.
Also reverted change to the docs, as leaving it would make incorrect
docs.

In case of conflicts, includes were sorted according to the coding
standards from #3839.

This reverts commit b4a9f04f92.
This reverts commit 5921122960.
2016-12-29 16:10:53 +00:00
Zetok Zalbavar
7b60a5dd36
chore: explicitly mention that copyright belongs to qTox contributors 2016-11-29 11:12:06 +00:00
Diadlo
b4a9f04f92
refactor: Added to include path and exclude it from all includes 2016-11-28 23:28:42 +03:00
Zetok Zalbavar
64bbc6cfbb
style: change postfix increment to prefix increment 2016-11-03 07:57:14 +00:00
Diadlo
9a62f44c33
docs(core): Added leading stars 2016-08-19 00:20:23 +03:00
Diadlo
2696a9265a
docs(core): Change comment style 2016-07-27 23:39:22 +03:00
Diadlo
6ed16db5fd
refactor(android): All android code is removed
Closes #3168.
2016-05-15 02:42:20 +03:00
Polshakov Dmitry
2143e21e89
style(ipc, widgets, genericcharitemlayout): Small style changes 2016-04-20 22:53:27 +03:00
rku
056a77d4dd Cleaned up all the ipc/startup code:
* Removed duplicate code of ipc event sending
 * Removed duplicate code of profile loading
 * Fixed bug where activating existing instance still started new instance of qtox asking to select a profile
 * IPC messages are now profile-aware and are sent to instance that runs specified profile in -p flag or to ipc owner if -p is not specified.

If -p flag is specified ipc events will be send to instance which runs specified profile. If instance using that profile does not run - new qTox instance will be started. This works with password-protected profiles too - new instance will handle "uri" or "save" events after accepting user password.
2015-12-22 14:59:55 +02:00
tux3
af59b5b45a
Fix IPC not taking ownership after crash
In case a previous instance crashed, we were trying to activate the current owner before even checking if it was still alive, this resulted in qTox needing to be restarted twice after a crash.
2015-12-15 21:06:55 +01:00
Nils Fenner
a8725729bf
readd msleep with lowest possible sleep time 2015-10-12 20:28:03 +02:00
Nils Fenner
5ddfc2eefe
cleanup inheritance QThread --> QObject and includes
IPC is actually not running in a thread; And if, QThread should not be inherited.
2015-10-11 13:49:22 +02:00
Nils Fenner
42a917fc58
remove obsolete QThread::msleep completely 2015-10-11 13:47:19 +02:00
tux3
59e0692069 Sleep 10ms in IPC wait loop, not 10 SECONDS!
Fixes #2334
2015-10-08 19:54:06 +02:00
tux3
8fbc0c8b59
Remove some debug output fluff 2015-09-06 00:11:47 +02:00
tux3
8d1a3b7357
Sleep while waiting for IPC events 2015-06-29 11:39:19 +02:00
Zetok Zalbavar
67e9aeec63
Fix incorrect copyright headers
The qTox Project is not associated with the Tox Project in any way, with the
exception of "qTox" using the Tox Projet's "toxcore" collection of libraries.
In particular, the Tox Projet does not own copyright over the qTox Project's
"qTox" collection of software, source code, and assets.
The qTox Project's assets are under the sole copyright of the qTox
contributors, and no partiular rights are granted to the Tox Project.
2015-06-06 14:51:28 +01:00
tux3
20f254651d
Reorganize files 2015-06-06 01:44:47 +02:00
tux3
510b8d7d51
Remove some spammy debug output
If there are permission errors (e.g. root owns the shared memory), this would spam the log with hundreds of messages/s. isCurrentOwner still warns a couple of times if we fail to lock, so this message isn't necessary
2015-06-05 12:49:03 +02:00
Ansa89
f716027180 Fix needed to compile on slackware64 14.1 (with multilib) 2015-05-24 14:33:51 +02:00
tux3
a841224683
Use proper random for IPC 2015-05-19 20:37:42 +02:00
tux3
76cbaf18f1
Fix incorrect copyright headers
The qTox Project is not associated with the Tox Project in any ways, with the exception of "qTox" using the Tox Projet's "toxcore" collection of libraries.
In particular, the Tox Projet does not own copyright over the qTox Project's "qTox" collection of software, source code, and assets.
The qTox Project's assets are under the sole copyright of the qTox contributors, and no partiular rights are granted to the Tox Project.
2015-05-12 04:12:53 +02:00
sudden6
1506a9a30e Change log messages to fit new log format 2015-05-11 15:37:56 +02:00
tux3
66314bc38d
Fix nullptr dereference in IPC::isCurrentOwner
It would only trigger when multiple instances where running in parallel,
with one having enough privilege to block the other from accessing the shared memory (e.g. root)
2015-04-24 15:38:34 +02:00
tux3
9dedd22bb2
Port file transfers to the new API
Parallel, extremely large, and other edge case transfers have not been tested, but the common path should work well.
2015-04-24 15:31:30 +02:00
novist
a8cd541cb5 IPC improvements
* Removed waitUntilProcessed() because waitUntilAccepted() fits the job. They were nearly identical too so decreased code duplication
* Global events are set as processed only by instance that accepts them. Solves issue where global event would be consumed by first instance that saw it even if that instance ignored that event
* Fixed bug where running qtox instance would not properly exit after sending window activation event that was accepted by already running instance
2015-03-19 12:06:05 +02:00
novist
41fd5ab558 Allow only main (IPC owner) instance to save global settings 2015-02-22 16:33:15 +02:00
novist
9523484bfe Reworked IPC class:
* Simpler design
  * Suport for named events
  * Support for checking if events were handled
  * Support for sending events to specific application instance
2015-02-22 16:31:48 +02:00
Tux3 / Mlkj / !Lev.uXFMLA
a3b4198270
Fix possible crash on ~IPC 2014-11-13 19:43:03 +01:00
Tux3 / Mlkj / !Lev.uXFMLA
ae91311241
Silence IPC:processEvents failed to lock 2014-11-13 19:29:56 +01:00