Commit Graph

848 Commits

Author SHA1 Message Date
iphydf
515196dfa2
Include necessary opencv2 header on OSX.
opencv2 is deprecated and homebrew ships with opencv3 now.
2018-08-30 21:11:17 +00:00
iphydf
473cde24d8
Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf
a1035cf814
Add some tests for ping_array.
No timeout test here yet, because we don't yet have the ability to
manipulate time at will, so we would have to actually sleep.
2018-08-26 17:32:19 +00:00
zugz (tox)
8e0aea1add
handle libsodium dependency of misc_tools correctly for autotools 2018-08-20 22:36:15 +02:00
zugz (tox)
14484c6879
make Mono_Time an argument to current_time_monotonic 2018-08-19 23:41:43 +02:00
endoffile78
30960dcc7e
Add save file generator, save compatibility test, and generate a save file 2018-08-19 10:38:51 +00:00
iphydf
9fb87056bc
Set _POSIX_C_SOURCE to 200112L. We need it for C99 compat.
It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
or a POSIX.1-2001 application with anything other than a c99 or later
compiler.  Therefore, Solaris libc forces an error in both cases.
2018-08-17 22:43:24 +00:00
iphydf
d6d305feeb
Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf
54066f338f
Reduce the number of times unix_time_update is called.
Reduced by, e.g.:
* `file_transfer_test`: 33% of the `clock_gettime` calls.
* `tox_many_test`: 53% of the `clock_gettime` calls.

Other tests will see similar improvements. Real world applications will
be closer to 40-50% improvement, since tox_many_test has 100 nodes, while
file_transfer_test has 2 nodes.
2018-08-16 21:01:38 +00:00
crypto-universe
3036cc1f23
Fix possible resource leaks in test 2018-08-15 22:50:24 +00:00
iphydf
a509d25324
Fix some printf format specifiers. 2018-08-13 11:02:32 +00:00
zugz (tox)
fb89c03dd2
Add simple deterministic random number generator for tests 2018-08-12 15:22:34 +00:00
iphydf
3fe0551417
Assert that we don't divide by 0 in random_testing.cc.
This is always true due to the condition function, but if we introduce a
bug that makes the condition not be applied, this causes undefined
behaviour.
2018-08-12 14:52:52 +00:00
iphydf
d92c96e783
Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00
iphydf
f627a26a7b
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
2018-07-22 02:34:30 +00:00
iphydf
7245ac11ef
Avoid implementations in .h files or #including .c files.
Also, avoid the need for putting `_XOPEN_SOURCE` in every test file.
2018-07-21 20:44:26 +00:00
iphydf
abc17b0f89
Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've
renamed the new functions to `mono_time_*`.

2018-07-08:
```
00:01 <@irungentoo> the idea used to be that the unix_time() function
  could go backward in time but I think I might have started using it like
  if it could not after I changed it so that it would never go back in time
```
2018-07-09 21:04:50 +00:00
iphydf
8739f7fccb
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum
2018-07-05 23:09:28 +00:00
iphydf
64d0297acc
Add #include <cstdio> for std::printf. 2018-07-04 14:21:12 +00:00
iphydf
b9a75d98b2
Remove broken conference tests.
These display some idea, but the tests are not implemented correctly. We
will need to implement the idea correctly later, but for now we can't use
these.
2018-06-29 18:25:44 +00:00
iphydf
29b2dd6315
Use clang-format for C++ code.
`clang-format -style='{BasedOnStyle: Google, ColumnLimit: 100}'`
2018-06-24 20:17:53 +00:00
iphydf
5c2600d87b
Add new Circle CI configuration.
This one has ASAN enabled, unlike Travis.
2018-06-24 19:51:34 +00:00
iphydf
cfff361679
Add random testing program.
This can be used as a random stress test for toxcore.
Adjust the weights to make certain actions more or less likely.
2018-06-23 12:43:09 +00:00
Maxim Biro
7d399cedcf
Improve network error reporting on Windows
Windows doesn't report network errors though errno, it has its own facilities.
2018-04-17 19:07:50 -04:00
iphydf
fa8927aa0f
Move struct DHT_Friend into DHT.c. 2018-03-16 02:07:39 +00:00
iphydf
aa05095419
Remove the use of the 'hh' format specifier.
It's not supported in mingw.

See https://github.com/TokTok/c-toxcore/issues/786.
2018-03-16 01:57:26 +00:00
iphydf
d3b286cb43
Fix a bunch of compiler warnings and remove suppressions. 2018-02-24 22:20:22 +00:00
zoff99
721358208b
Improve video key frame sending.
This change does not include the addition of VP9. We do that in a
separate pull request.

Changes:

* fix the video bug (video frames larger than 65KBytes) by sending full
  frame length in alternate header field
* improve video frame reconstruction logic with slots
* configure video encoder and decoder to be multihtreaded
* set error resilience flags on video codec
* change encoder and decoder softdeadline
2018-02-11 23:31:46 +00:00
iphydf
36ba80aacb
Remove csrc from the RTPHeader struct.
This is not used by anything in the code, so we shouldn't have it in the
header.
2018-02-08 13:20:40 +00:00
iphydf
52f6e4e7c5
Move tox_shell program to the toxins repository.
https://github.com/TokTok/toxins/tree/master/tox_shell
2018-02-06 13:06:22 +00:00
iphydf
a3a0e553f3
Move irc_syncbot to the toxins repository. 2018-02-06 11:45:50 +00:00
iphydf
f71ec8dd02
Move the tox_sync tool to the toxins repository. 2018-02-05 18:15:31 +00:00
iphydf
92ffad1a72
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
6e0ac337c9
Avoid clashes with "build" directories on case-insensitive file systems. 2018-01-28 15:17:34 +00:00
xhe
651ef3adb6
Make audio/video bit rates "properties"
follow TokTok#731. This commit
completely removed all things in namespace bit_rate, and deprecated
functions are to be added back in another commit. set_xxx() is treadted
as a property of namespace audio&video, same as bit_rate change event.

toxav_basic_test is fixed, either.
2018-01-28 13:21:57 +00:00
iphydf
9c03439ad0
Fix out of bounds read in error case in messenger_test.
Also got rid of two VLAs. They are overused a bit in toxcore. In
irc_syncbot, the array was uninitialised and then filled by a recv system
call. This can cause uninitialised reads if recv doesn't fill the entire
array. It could not cause out of bounds read directly, because a
NUL-terminator was in place, but both cases are undefined behaviour.
2018-01-26 01:30:06 +00:00
iphydf
42636861d8
Publish a single public BUILD target for c-toxcore. 2018-01-22 21:18:24 +00:00
iphydf
e6c04ef028
Use self-built portaudio instead of system-provided. 2018-01-22 00:44:19 +00:00
iphydf
52778aed93
Make BUILD files more finely-grained.
This allows us to precisely see which libraries depend on which and lets
us split them up more, if necessary.
2018-01-21 19:44:09 +00:00
iphydf
1cecb6c87a
Add BUILD files for all the little tools in the repo.
Also, fix av_test.c, since I broke it last time.
2018-01-21 01:31:11 +00:00
iphydf
822dd2fac2
Don't allocate or dereference Tox_Options in tests.
This struct will soon become opaque.
2018-01-21 00:14:43 +00:00
iphydf
98febe0589
Add testing/*.c (except av_test) to bazel build. 2018-01-20 19:32:12 +00:00
iphydf
d7583a719a
Remove nTox from the repo.
It's a maintenance burden nobody uses. Let's make toxic the official
console client, instead.
2018-01-20 19:05:53 +00:00
iphydf
18a33169b8
Add bazel build scripts for c-toxcore.
This allows us and users to reproducibly build verified versions of the
library with checksums. It will power the toktok-stack continuous build
with checked-in checksums at specific git revisions.
2018-01-18 16:11:52 +00:00
iphydf
643eea60bb
Make DHT a module-private type. 2018-01-16 20:06:07 +00:00
iphydf
cec5fea71b
Remove hstox test for now.
This isn't adding value. We're going to redo the whole rpc test framework
in the future, after a lot of refactoring that the hstox test currently
just stands in the way of.
2018-01-15 11:29:51 +00:00
iphydf
1eea3f0ab6
Fix some memory or file descriptor leaks in test code.
Also some missing return value checks for `fopen`.
2018-01-14 19:15:28 +00:00
iphydf
54ec162558
Fix formatting in some C files.
Also replace &(x) with &x for consistency.
2018-01-10 18:57:37 +00:00
iphydf
a3079e82dd
Fix file descriptor leak in hstox test.
We return E_WRITE because closing only fails when an I/O error occurs,
which is likely an error from the write() call above. See close(2) for
details.

http://man7.org/linux/man-pages/man2/close.2.html
2018-01-10 18:57:29 +00:00
iphydf
2e33ab26df
Zero-initialise stack-allocated objects in hstox driver.
These potentially cause uninitialised reads on some platforms or msgpack
library versions.
2018-01-10 18:57:25 +00:00
iphydf
2c8fb05f6e Remove deprecated ToxDNS
Based on #331.

Fixes #42.
2017-12-29 00:32:18 +00:00
iphydf
f2b6090eca Generate only one large library "libtoxcore".
This library contains all the code for the old libtoxcore, libtoxav,
libtoxdns, and libtoxencryptsave. The build for toxav is still optional,
and disabling it causes libtoxcore to simply not contain those symbols
and the pkg-config file to not include opus and vpx as dependencies.
2017-12-28 23:01:41 +00:00
endoffile78
83377e6865
Fix include for endian.h and add includes for sys/stat.h and
netinet/in.h
2017-12-28 10:29:42 -06:00
Diadlo
66b8a7685e
AF_INET -> TOX_AF_INET 2017-08-24 20:09:08 +03:00
iphydf
cb69b8a986
Build tests on appveyor, the MSVC build.
Tests are not actually ran on appveyor for now, since they all fault for
some reason. For now, we just build them. Also, some tests are disabled
on msvc entirely, because they don't even compile. We'll need to look
into those, later. They are disabled using `MSVC_DONT_BUILD`.
2017-06-05 13:45:20 +00:00
iphydf
b782ef5d8e
Fix formatting and spelling in version-sync script.
Also some minor reformatting and fixes to the hstox sut driver.
2017-06-04 12:07:43 +00:00
iphydf
d4be41a3ad
Use new encoding of Maybe in msgpack results.
The new encoding is `0` for `Nothing` and `[1, x]` for `Just x`.
2017-06-03 23:32:46 +00:00
Diadlo
50c526e1a5
Move c_sleep to helpers.h and misc_tools.h
Also fix a mistake with forgotten braces around parameter
2017-03-25 20:40:34 +03:00
Diadlo
c1e3358dcd
Fix formatting with astyle
Fix #494
2017-03-04 15:32:00 +03:00
Maxim Biro
aaca8251c8 Remove dependency on strings.h 2017-03-01 20:43:30 -05:00
Diadlo
b19a9e5464
Add part of platform-independent network API implementation
socket      -> net_socket
htons       -> net_htons
htonl       -> net_htonl
connect     -> net_connect
sendto      -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
2017-02-26 23:16:16 +03:00
iphydf
6ae33c16cf
Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
Diadlo
f00006cf1d
Add platform-independent Socket and IP implementation 2017-01-26 23:11:15 +03:00
zugz
b630121f2f reduce thread-unsafe use of static variables
- rework ip_ntoa() to avoid use of static variables
- rework sort_client_list() to avoid use of static variables
- move static 'lastdump' into Messenger struct
- rework ID2String() to avoid use of static variables; rename to id_to_string()
- fetch_broadcast_info(): attempt to mitigate risks from concurrent execution
- current_time_monotonic(): attempt to mitigate risks from concurrent execution
- comment on non-thread-safety of unix_time_update
2017-01-21 22:08:52 +01:00
iphydf
8f96ca6d86
Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
Yuri
68f80d260b Fixed FreeBSD build failure due to undefined MSG_NOSIGNAL. 2017-01-13 00:24:00 -08:00
iphydf
8b4eae4038
Remove TOX_DEBUG and have asserts always enabled.
These are cheap asserts. I've also replaced the fprintf's with
`LOGGER_ERROR` calls.
2017-01-11 19:43:08 +00:00
David Zero
8ef1f35ca7 Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0, and
defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-06 04:20:00 -08:00
endoffile78
59e2a844f0 Revert "Portability fixes"
This reverts commit f3469070fe.
2017-01-05 15:16:56 -06:00
David Zero
f3469070fe Portability fixes
- CFLAG gnu99 was changed to c99.
- CXXFLAG c++98 was changed to c++11.
- CFLAG -pedantic-errors was added so that non-ISO C now throws errors.
- _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3
  and c99 definitions in modules that required them.
- Fixed tests (and bootstrap daemon logging) that were failing due to
  the altered build flags.
- Avoid string suffix misinterpretation; explicit narrowing conversion.
- Misc. additions to .gitignore to make sure build artifacts don't wind
  up in version control.
2017-01-04 13:44:39 -08:00
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
Gregory Mullen (grayhatter)
ad517eb1df
add NAT hole punching level to Tox API 2016-11-24 17:38:34 -08:00
iphydf
656f0b9112 Support float32 and float64 in msgpack type printer. 2016-11-21 02:25:11 +00:00
Maxim Biro
a403c996b5 Fix a memory leak in hstox interface 2016-11-20 20:14:53 -05:00
Mikhael-Danilov
06ad5613bc Support arbitrary video resolutions in av_test 2016-11-12 20:10:56 +03:00
iphydf
fe1fea82c3
Add decode/encode PlainText test support.
These are implemented in terms of decode/encode CipherText. They do the
exact same thing, since they are both simple length-prefixed byte arrays.
2016-11-11 00:00:37 +00:00
iphydf
aed24408db
Remove new_nonce function in favour of random_nonce.
`new_nonce` has been an alias for `random_nonce` for a while now. Having
two names for the same operation is confusing. `random_nonce` better
expresses the intent. The documentation for `new_nonce` talks about
guaranteeing that the nonce is different from previous ones, which is
incorrect, it's just quite likely to be different.
2016-11-09 22:30:49 +00:00
iphydf
42dfdf73c1
Add spectest to the cmake test suite.
This allows for easier development. It is not used on travis (yet).
2016-11-08 21:58:26 +00:00
iphydf
82515f92ee
Move log callback to options.
Previously, all log messages generated by tox_new (which is quite a lot)
were dropped, because client code had no chance to register a logging
callback, yet. This change allows setting the log callback from the
beginning and removes the ability to unset it.

Since the log callback is forever special, since it can't be stateless,
we don't necessarily need to treat it uniformly (with `event`).
2016-11-06 20:35:09 +00:00
iphydf
cf94537266
Enable all possible C compiler warning flags.
We disable the ones that fire, so we can use -Werror. We can then
investigate each warning individually and see whether to fix it or to
keep silencing it.
2016-11-06 01:32:10 +00:00
iphydf
96c672aef5
Compile as C++ for windows builds.
Compiling as C++ changes nothing semantically, but ensures that we don't
break C++ compatibility while also retaining C compatibility.

C++ compatibility is useful for tooling and additional diagnostics and
analyses.
2016-11-02 18:50:41 +00:00
iphydf
c037100747
Import the hstox SUT interface from hstox.
We'll maintain it in the c-toxcore repo, where it belongs.
2016-10-01 02:13:34 +01:00
iphydf
1977d56caa
Remove return after no-return situation (and other cleanups).
Cleanups:
- Fix header guards to not use reserved names.
- Avoid name shadowing.
- Removed an unused variable found by avoiding name shadowing.
2016-09-30 19:06:44 +01:00
iphydf
d369448ace
Work around bug in opencv3 headers.
OpenCV 3.1 doesn't define cvRound in C, only in C++. Thus, we now need
to compile av_test as C++ code.
2016-09-25 01:58:51 +01:00
iphydf
f60900c4b8
Move ring buffer out of toxcore/util into toxav.
Toxcore itself doesn't use this data structure. Only toxav does, so now
toxav owns the code for it.
2016-09-24 23:36:50 +01:00
iphydf
15cb426166
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf
0d347c2b2e
Minor cleanups: unused vars, unreachable code, static globals.
- All global variables should be static unless they have an explicit
  extern declaration in a header file.
- `to_compare` was not used in encryptsave and toxav tests.
- `break` in switch cases is not required directly after `return`,
  `goto`, or a noreturn function like `abort`.
2016-09-24 20:52:09 +01:00
Jfreegman
dd2965a58f Make group callbacks stateless 2016-09-21 15:33:55 -04:00
iphydf
51d18236c8
Revert "Make ToxAV stateless"
This reverts commit 21f8db12c4.

It is currently broken. Incoming call callbacks are not invoked, and
instead the client goes offline immediately.
2016-09-19 21:53:40 +01:00
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
80cc32a79d
Use C99 %zu format conversion in printf for size_t.
size_t is unsigned long long on LLP64 and %lu prints unsigned long (32
bit), potentially causing problems.
2016-09-17 10:19:49 +01: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
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
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
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
aa0e3974c5
Add TODO for @mannol. 2016-09-05 22:44:06 +01:00
iphydf
a9fbdaf46b
Do not use else after return.
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-02 11:02:56 +01:00
iphydf
6f42eadc54
Replace pthread_yield with sched_yield.
The former is a non-standard glibc extension. On linux, it is implemented as a
call to sched_yield, so this change does nothing there. On OSX, pthread_yield
doesn't exist, and we already use sched_yield.
2016-09-02 09:55:00 +01:00
iphydf
77db27331e
Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
ad13518153
Add missing #include <pthread.h> to av_test.c.
It was an undefined function before.
2016-09-01 15:22:03 +01:00
iphydf
3a9300368d
Add newlines because astyle wants them.
We'll revert this once we move to clang-format.
2016-08-31 20:54:20 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
6356eb4e4f
Enable build of av_test.
It has not been built in a while. We do want to keep this one working (or at
least compiling).
2016-08-31 20:02:41 +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
Gregory Mullen (grayhatter)
1f94c96266
Make the friend message callback stateless 2016-08-20 11:07:49 -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
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
Roman Proskuryakov
ed3a794c9b fix: compare sensitive data with sodium_memcmp
fix: make increment_nonce & increment_nonce_number independent of user-controlled input
	fix: make crypto_core more stable agains null ptr dereference
2016-01-27 02:14:59 +03:00
irungentoo
6a494e2cbd
Astyle. 2015-11-03 13:42:05 -05:00
Eniz Vukovic
d6fdf16520 New Adaptive BR algorithm, cleanups and fixes 2015-10-10 23:54:23 +02:00
mannol
c641b0fceb Updated with upstream 2015-08-09 12:39:21 +02:00
irungentoo
2ab3b14731
Merge branch 'dragonfly' of https://github.com/mneumann/toxcore 2015-08-08 21:38:23 -04:00
mannol
3c8cae72d0 Removed redundant function from video.[h|c] 2015-08-08 17:45:24 +02:00
irungentoo
6cb8ff4d65
Removed a useless define. 2015-08-07 20:53:53 -04:00
Michael Neumann
caebc5303a Fix for DragonFlyBSD 2015-08-08 01:45:55 +02:00
mannol
657a57b406 Fixed memory leak during session cleanup and fixed naming. 2015-08-07 02:04:04 +02:00
irungentoo
dfc154cc9e
client_id -> public_key 2015-07-29 22:39:56 -04:00
mannol
2ecb71bb1e Renamed TOXAV_CALL_STATE to TOXAV_FRIEND_CALL_STATE 2015-06-27 17:28:07 +02:00
mannol
a3132feddb Fixed sample size in callback and other stuff 2015-06-13 15:00:34 +02:00
mannol
d694839d60 Rebased on master and removed alpha channel (again) 2015-06-05 22:14:37 +02:00
irungentoo
8e80ced6ce
Move savedata to options struct.
Add a way to select the type of savedata (normal savedata, load a
secret key, potentially others?) to load.
2015-05-22 18:23:56 -04:00
mannol
3100042a2b Updated with master 2015-05-22 23:22:31 +02:00
irungentoo
782d68cdc3
Syncbot fixes. 2015-05-20 14:09:05 -04:00
mannol
73fbc22961 Fixed inconsistencies 2015-05-07 23:14:03 +02:00
mannol
9bba7a0434 Done 2015-04-29 01:01:25 +02:00
irungentoo
b0983104d5
Renamed tox_file_send_control to tox_file_control.
Renamed tox_file_send_seek to tox_file_seek.
2015-03-21 08:58:54 -04:00
Dubslow
d8da9bf709
callback_file_request_chunk -> callback_file_chunk_request
A couple of minor reasons, combined warrant a PR imo:
a) fileChunkRequested is a better signal name than fileRequestChunkReceived, and I don't want to break consistency by reordering words for just this signal
b) "request chunk" is parsed by English speakers as a verb-object combination,
   implying sending the request, not receiving, whereas "chunk requested" is
   parsed (more correctly) as an adjective-noun combo (in particular, request is
   a noun not a verb), and thus reads far more like "hey heads up we just got a request"

For instance some tests/testing code had some callbacks to *receive* chunk requests, and they were called "tox_file_request_chunk"... to receive a chunk, not request it. Now they're called "tox_file_chunk_request".

So yeah...
2015-03-19 08:38:27 -05:00
irungentoo
e0bd6ef4e0
Renamed TOX_MESSAGE_TYPE_MESSAGE to TOX_MESSAGE_TYPE_NORMAL. 2015-03-18 17:14:57 -04:00
irungentoo
45cf8a744c
Merge branch 'one_more_rename' of https://github.com/dubslow/toxcore into new_api 2015-03-18 16:15:36 -04:00
irungentoo
d711362622
Merged normal message function and send action function into one
messaging function.

This removes code duplication and allows us to easily add new message
types to the api without having to add new functions.
2015-03-18 15:32:53 -04:00
Dubslow
2f65de6fd1
Move get_connection_status to self pseudonamespace, to contrast friend_get_connection_status 2015-03-18 14:18:36 -05:00
irungentoo
b9e747fd50
When friend goes offline all his file transfers get removed.
This is now documented in the API.

Ported programs in testing/ to this behaviour.
2015-03-18 14:39:52 -04:00
irungentoo
5b7cbc8956
Api changes.
receive to recv in file receive functions.

Added TOX_MAX_FILENAME_LENGTH define.
2015-03-18 12:54:00 -04:00
irungentoo
8286c2c22f
Save function renamed to tox_get_savedata() 2015-03-17 16:20:38 -04:00
irungentoo
24c70c9e84
Added and implemented file_id parameter to file tranfers.
file_id is a 32byte identifier that can be used by users to identify
file tranfers across core/client restarts in order to resume broken
file tranfers.

In avatar tranfers it corresponds to the hash of the avatar.

Added tox_file_get_file_id() function to api to obtain the file_id
of an ongoing file transfer.

If not set, core will generate a random one.
2015-03-17 13:44:48 -04:00
irungentoo
6cf7270638
Make nTox save on exit. 2015-03-14 10:05:39 -04:00
irungentoo
c3e07b73d3
Remove TOX_FILE_KIND typedef. 2015-03-13 15:38:44 -04:00
irungentoo
8e2957ec50
Merge branch 'newer_api' of https://github.com/dubslow/toxcore into new_api 2015-03-13 15:29:34 -04:00
Dubslow
64fefb6f43
revert to TOX_FILE_KIND 2015-03-13 12:34:14 -05:00
Dubslow
3bf259f69d Convert core code depending on the api 2015-03-12 18:23:14 -05:00
irungentoo
8dc2db2025
Added position parameter to tox_file_send_chunk().
This is done so that the function now has the same parameters as the
request chunk callback.
2015-03-12 15:17:34 -04:00
irungentoo
7afab000f7
tox_new now sets error to TOX_ERR_NEW_PORT_ALLOC when binding to port fails. 2015-03-12 13:03:14 -04:00
irungentoo
8e55d96381
Ported nTox to new file transfer api. 2015-03-10 18:49:06 -04:00