Commit Graph

296 Commits

Author SHA1 Message Date
Jfreegman
8e43ca834c Complete old groupchat conversion to new API 2016-09-17 19:11:28 -04:00
iphydf
c0397a0a46 ApiDSL'ing old group chats (now: conference). 2016-09-17 19:11:28 -04:00
Gregory Mullen (grayhatter)
21f8db12c4
Make ToxAV stateless 2016-09-17 14:05:51 -07:00
iphydf
1494e474dd
Ensure that all TODOs have an owner.
In the future, all TODOs added either need a bug number (TODO(#NN)) or a
person's github user name. By default, I made irungentoo the owner of
all toxcore TODOs, mannol the owner of toxav TODOs, and myself the owner
of API TODOs.
2016-09-16 12:06:02 +01:00
iphydf
37c041f815
Clean up Travis build a bit in preparation for osx/win. 2016-09-16 11:22:23 +01:00
iphydf
c0d84ab489
Remove format-source from travis script.
This test is already performed by `make test` later on. We originally
had it in the Travis script to make it fail fast when the format is
wrong, but there is also some value in running all tests despite format
errors.

Fixes #83. There are no more relevant phases that would benefit from the
padding lines proposed.
2016-09-16 11:05:54 +01:00
iphydf
a8823830d3
Add some astyle options to make it do more.
It now enforces a bit more formatting. In particular, padding inside
parentheses is removed. I would like it to remove padding after unary
operators, but there seems to be no option for that.
2016-09-13 01:07:02 +01:00
iphydf
2db31d95fd
Use "phase" script for travis build phases.
This is the first step towards unifying travis configs for toxcore,
hstox, and qtox.
2016-09-11 22:13:47 +01:00
iphydf
6683a4b284
Use TokTok's apidsl instead of the iphydf one. 2016-09-11 21:09:41 +01:00
michael bishop
05f474b4df
make the majority of the callbacks stateless and add some status to a testcase 2016-09-10 01:09:37 -03:00
iphydf
406d292107
Minor cleanups: header reordering, adding {}.
I hadn't done this for the "fun" code, yet. Also, we should include
system headers after our own headers.

"In general, a module should be implemented by one or more .cpp files.
Each of these .cpp files should include the header that defines their
interface first. This ensures that all of the dependences of the module
header have been properly added to the module header itself, and are not
implicit. System headers should be included after user headers for a
translation unit."
-- http://llvm.org/docs/CodingStandards.html#a-public-header-file-is-a-module
2016-09-09 19:30:50 +01:00
iphydf
59075ba325
Use const for version numbers.
ApiDSL generates the lowercase function declarations for us and puts them in the
right namespace (TOX_, TOXAV_).
2016-09-09 10:05:12 +01:00
iphydf
254feb0acd
Add address sanitizer option to cmake file. 2016-09-08 10:13:40 +01:00
iphydf
159dc3b6ab
Print a message about missing astyle in format-source. 2016-09-07 23:11:13 +01:00
iphydf
ad26560516
Improve static and const correctness.
- Any non-externally-visible declarations should be `static`.
- Casting away the `const` qualifier from pointers-to-const is
  dangerous. All but one instance of this are now correct. The one
  instance where we can't keep `const` is one where toxav code actually
  writes to a chunk of memory marked as `const`. This code also assumes
  4 byte alignment of data packets. I don't know whether that is a valid
  assumption, but it's likely unportable, and *not* obviously correct.
- Replaced empty parameter lists with `(void)` to avoid passing
  parameters to it. Empty parameter lists are old style declarations for
  unknown number and type of arguments.
- Commented out (as `#if DHT_HARDENING` block) the hardening code that
  was never executed.
- Minor style fix: don't use `default` in enum-switches unless the number
  of enumerators in the default case is very large. In this case, it was
  2, so we want to list them both explicitly to be warned about missing
  one if we add one in the future.
- Removed the only two function declarations from nTox.h and put them
  into nTox.c. They are not used outside and nTox is not a library.
2016-09-06 11:54:37 +01:00
iphydf
5b57ab6332
Improve C standard compliance.
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
  extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
  Folding integral constants like that as compile time constants is a GNU
  extension. Arrays allocated with `foo` as dimension are VLAs on strictly
  compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
  The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
  object pointer can be implicitly converted to and from `void *`, this
  conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
  is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
  `short`-derived) in bit fields with `int`-derived types. Using any type
  other than `int` or `unsigned int` (or any of their aliases) in bit
  fields is a GNU extension.
2016-09-06 11:09:10 +01:00
Gregory Mullen (grayhatter)
aad1e0ad3f
Make friend requests stateless
Messenger is slightly twisty when it comes to sending connection status
callbacks It will very likely need at the very least a partial refactor to
clean it up a bit. Toxcore shouldn't need void *userdata as deep as is
currently does.

(amend 1) Because of the nature of toxcore connection callbacks, I decided to
change this commit from statelessness for connections changes to statelessness
for friend requests. It's simpler this was and doesn't include doing anything
foolish in the time between commits.

group fixup because grayhatter doesn't want to do it

"arguably correct" is not how you write security sensitive code

Clear a compiler warning about types within a function.
2016-09-06 02:22:04 -07:00
iphydf
77db27331e
Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
576f130615
Remove redundant return statements. 2016-08-31 23:51:39 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
fa3b51266b
Add missing #includes to headers and rename tox_old to tox_group.
Also, no longer #include the group code into tox.c. Instead, compile it
separately in tox_group.c. This is a bit less surprising to someone looking
around the code. Having some implementations in a .h file is certainly a bit
surprising to a disciplined C programmer, especially when there is no technical
reason to do it.
2016-08-30 19:31:40 +01:00
iphydf
4692cea75e
Add getters/setters for options. 2016-08-29 23:15:39 +01:00
iphydf
13ae9e9a93
Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox
was killed, so other toxes would then stop logging). Various bits of the code
now carry a logger or pass it around. It's a bit less transparent now, but now
there is no need to have a global logger, and clients can decide what to log and
where.
2016-08-27 01:16:14 +01:00
iphydf
7075c3648a
Add cmake test for apidsl. 2016-08-24 09:41:40 +01:00
Gregory Mullen (grayhatter)
a6f2e9539b
Make Message received receipts stateless 2016-08-22 03:12:47 -07:00
Gregory Mullen (grayhatter)
3f0c101771
Make Friend User Status stateless 2016-08-22 02:10:18 -07:00
Gregory Mullen (grayhatter)
1f94c96266
Make the friend message callback stateless 2016-08-20 11:07:49 -07:00
iphydf
f9c83c1084
Build assoc DHT code on travis. 2016-08-20 00:59:22 +01:00
iphydf
c597f67012
Add format-source script.
This is easier to use from a precommit hook, so it can be used to ensure that
all formatting is correct before committing code.
2016-08-20 00:39:18 +01:00
Gregory Mullen (grayhatter)
0e18966a27
Make Typing change callback stateless
Moved a few #defines to the top of the header for better readability
2016-08-19 16:13:23 -07:00
iphydf
bdf5ac37b4
Make friend_status_message callback stateless.
See #40 for details.
2016-08-18 17:19:23 +01:00
iphydf
6935643f9a
Fix some compiler warnings. 2016-08-18 17:10:15 +01:00
iphydf
a5e35180c7
Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
iphydf
db22522741
Add missing DHT_bootstrap to CMakeLists.txt.
- This PR also adds a DEBUG cmake option that enables -DTOX_DEBUG.
- We also remove `-Wall`, because there are too many warnings, and nobody really
  looks at them at the moment. We'll see about fixing them soon. We'll also want
  to enable `-Werror` at some point.
- Finally, this PR enables `-O3` to make sure toxcore still works correctly
  under heavy compiler optimisations.
2016-08-17 22:12:39 +01:00
iphydf
2fc5449870
Try searching for libsodium with pkg-config in ./configure.
If libsodium can't be found with PKG_CHECK_MODULES, try AC_CHECK_LIB. If that
also fails, abort configure. If a user passes --with-libsodium-libs explicitly,
that overrides the pkg-config found location.
2016-08-17 21:28:44 +01:00
iphydf
c603c8c9e7
Merge remote-tracking branch 'irungentoo/master' 2016-08-17 20:52:10 +01:00
iphydf
dd8a568141
Make self_connection_status callback stateless.
**What are we doing?**

We are moving towards stateless callbacks. This means that when registering a
callback, you no longer pass a user data pointer. Instead, you pass a user data
pointer to tox_iterate. This pointer is threaded through the code, passed to
each callback. The callback can modify the data pointed at. An extra indirection
will be needed if the pointer itself can change.

**Why?**

Currently, callbacks are registered with a user data pointer. This means the
library has N pointers for N different callbacks. These pointers need to be
managed by the client code. Managing the lifetime of the pointee can be
difficult. In C++, it takes special effort to ensure that the lifetime of user
data extends at least beyond the lifetime of the Tox instance. For other
languages, the situation is much worse. Java and other garbage collected
languages may move objects in memory, so the pointers are not stable. Tox4j goes
through a lot of effort to make the Java/Scala user experience a pleasant one by
keeping a global array of Tox+userdata on the C++ side, and communicating via
protobufs. A Haskell FFI would have to do similarly complex tricks.

Stateless callbacks ensure that a user data pointer only needs to live during a
single function call. This means that the user code (or language runtime) can
move the data around at will, as long as it sets the new location in the
callback.

**How?**

We are doing this change one callback at a time. After each callback, we ensure
that everything still works as expected. This means the toxcore change will
require 15 Pull Requests.
2016-08-17 14:57:20 +01:00
iphydf
cebf64a588
Split toxcore into layers.
This allows us to more clearly define interfaces between modules, and have the
linker help us ensure that module boundaries are respected.

The onion/tcp/net_crypto layer is a bit too large. This is due to a cyclic
dependency (onion -> net_crypto -> TCP -> onion). We may or may not want to
break that cycle in the future to allow the onion library to exist on its own
without net_crypto.
2016-08-16 17:36:18 +01:00
iphydf
35932b5381
Add "make install" step to Travis build. 2016-08-12 20:49:50 +02:00
iphydf
f7324f997b
Only report coverage on clang, not on the GCC build. 2016-08-12 01:54:42 +01:00
iphydf
b5cfd33340
Add and use CMake build script
Also, fix the hstox build that was taking half an hour. It now takes 5 minutes.
Also, perform distcheck on travis to ensure that make dist works. It's not
actually failing the build at the moment due to broken tests.
2016-08-12 01:13:11 +01:00
iphydf
459f8f2013
Check code formatting on Travis.
We run astyle on Travis and check if there is a diff. The build terminates if
git finds a difference.
2016-08-12 01:00:00 +01:00
iphydf
8339e3449f
Run hstox test suite against toxcore on Travis. 2016-08-12 00:22:09 +01:00
iphydf
50921070ce
Move toxcore travis build scripts out of .travis.yml.
This is in preparation for having multiple types of build. One of the future
builds will be a hstox build, another may be frama-c or some other static
analyser. It makes sense to split these up into multiple builds, because each of
them can take a while, and running them in parallel will speed things up. Also,
the hstox test coverage should be reported separately from the toxcore auto_test
coverage.
2016-08-12 00:07:05 +01:00
Gregory Mullen (grayhatter)
6f3e689eeb
Fix a few issues with running Toxcore tests on Travis-CI
> increased the timeout for TCP tests because per @irungentoo the network on Travis-CI can be slow sometimes

> allowed groupchats test to restart on error until timeout This had to be done because current groupchats are fundamentally broken and 3/5 times they'll 'net-split' on connect

>> Drop group chat tests, add comment to the reason

> added some debugging information to TCP tests, and a #define to force IPV6 (Travis-CI only uses IPv4 on their containers) and decreased the itr interval

> Went crazy with timeouts for Tox network stuff on Travis. Tests on TCP will still randomly fail due to timeouts. I can't reproduce on any local system. So again per @irungentoo, Travis is slow, let's offer it a short bus.
2016-08-11 14:41:57 -07:00
LittleVulpix
88f29aaa9f Documentation: SysVInit workaround for <1024 ports
Update the manual to provide a command necessary to open <1024 ports for users on SysVinit
2016-07-11 11:34:32 +02:00
LittleVulpix
98446e0818 Documentation: SysVInit workaround for <1024 ports
Update the manual to provide a command necessary to open <1024 ports for users on SysVinit
2016-07-10 22:56:00 +02:00
iphydf
532435120a
Remove trailing whitespace from toxav.in.h. 2016-07-07 12:44:16 +02:00
iphydf
adc39b9ebd
Merge branch 'avswitch' of https://github.com/derivefh/toxcore 2016-07-07 12:42:58 +02:00
irungentoo
aafeb7ddd8
Merge branch 'make-dist' of https://github.com/roman-yepishev/toxcore 2016-03-13 22:07:50 -04:00