| Age | Commit message (Collapse) | Author | 
|---|
|  |  | 
|  | This argument is meant to be use in conjunction with the `--daemon`
argument. What we had before was preventing audio from getting turned on
if `--daemon` was passed first and vice versa.
I just added to the existing if-else block without thinking. This makes
the condition separate. | 
|  | Including this flag will tell the program to play interface audio
(namely the sounds for mode activated & deactivated). | 
|  |  | 
|  | Otherwise we might end up printing things like error messages from the
license check. Not very nice-looking to have that after the help message
output. | 
|  | Should print the version of the program. Doesn't actually do any
printing in Rust, because the Rust library's version number is different
from the DomeKey program version. We just indicate to the Objective-C
code that it should print the version number. | 
|  | Add a new argument that allows users to pass in the path to a license
file. Doing so should get picked up by the Objective-C code which will
copy and validate the license.
In order for the Objective-C code to pick up the path string, we add a
`license` field to the `Config.Args` struct.
The new `license` field is a `*mut c_char`, which means we can't derive
Default any more and need to implement a custom `Default` impl for
`Args`.
Additionally, 'getopts' gives us a Rust string (of course), which needs
to be converted into a raw `CString` before we can stick it in the
`license` field in `Args`. I previously wrote `dkeprintln` to be able to
print an error here at the conversion point between `CString` and raw C
string.
Since we used `CString#into_raw()`, we need to call `from_raw()` on the
pointer to free it, otherwise we end up with a memory leak. This
necessitated adding some additional code to `config_free()` to free the
`license` field if non-null.
In order to access `config.args.license` from within `config_free()`, I
also needed to make the `args` and `license` struct fields public, since
the free function is in a different module. Instead of making only those
two fields public, I decided to make them all public, as all the fields
are technically accessible from C code, and are needed by that C code.
Finally, move the module declaration of `prefix_println` to the top of
the module list instead of listing it alphabetically, because otherwise
any modules declared before it (like `config`) don't get access to its
macro. Also add a `#[macro_use]` attribute to the module declaration
because we do want to export its macro.
(https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files#comment78329437_31749071) | 
|  | In that case, we should return the default config. | 
|  | The only config option we have is `timeout`, which has a default value.
Any future config options, it seems, should have default values also.
We shouldn't force users to create a config file, as the prior code
would do. They should be able to rely on the default, and create a
`config.toml` only if they want to change it.
If no config file is found, we should create a default `Config`.
Rename the method because now it still works without reading the config
file. | 
|  | Use XDG handling from `state_load_map_group()` to do basically the same
thing here for reading the config from a `config.toml` file.
Use 'error-chain' to handle the `Result`s more easily. No more nested
pattern matching, we'll just have to unwrap one `Result` and write the
error to stderr in an FFI function. | 
|  | A new function that will read a TOML config file. Doesn't currently
access the filesystem. This commit is mostly supporting code to allow
that to work.
* Add the 'toml' crate
* `parse_args()`: Take a mutable `Config` and return that config instead
  of creating a new one. The recipe will now be to read the config from
  a file first and then pass that config to this function to be updated.
* Modify `c_parse_args()` to take a `*Config` and mirror the new method
  signature of `parse_args()` | 
|  | This new field will be used by the calling Objective-C code as the
timeout between multi-button maps.
It will be defined in a `config.toml` file in the XDG config directory,
with a default if unspecified. That part of the code hasn't been written
yet, but we've prepared by deriving Serde `Deserialize` on the `Config`
struct in order to deserialise a TOML config file.
The latest Serde is v1.0.80, but we can't use it because 'cbindgen'
depends on an older version. We had been using 'cbindgen' v0.6.3, which
depends on serde v1.0.21. Decided to update 'cbindgen' in order to use a
newer version of Serde, but that puts us at v1.0.58 instead of the
latest:
    error: failed to select a version for `serde_derive`.
        ... required by package `cbindgen v0.6.6`
        ... which is depended on by `dome-key-map v0.0.1 (file:///Users/tw/Documents/Development/dome-key-map)`
    versions that meet the requirements `= 1.0.58` are: 1.0.58
    all possible versions conflict with previously selected packages.
      previously selected package `serde_derive v1.0.80`
        ... which is depended on by `dome-key-map v0.0.1 (file:///Users/tw/Documents/Development/dome-key-map)`
    failed to select a version for `serde_derive` which could resolve this conflict | 
|  | I was getting this error when I brought the library into the Objective-C
application:
    Undefined symbols for architecture x86_64:
      "_parse_args", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
Ended up renaming my FFI function to `c_parse_args()` (like with
`c_run_key_action()`) which fixed this. Going to have to rename those to
use a `dome_key_` prefix eventually.
Then, my `args` argument didn't have the right type. It had a `*const
c_char` type, which is a string, when it should have been an array of
strings. We just needed a double pointer. A Stack Overflow answer from
Tibor Benke (https://stackoverflow.com/users/3989982/tibor-benke) proved
helpful in this regard:
    fn foo(argc: c_int, argv: *const *const c_char);
https://stackoverflow.com/questions/34379641/how-do-i-convert-rust-args-into-the-argc-and-argv-c-equivalents/34379937#34379937
Update the `map()` call to account for the new type, and check that we
don't have any null pointers within the array.
Finally, shift the first (command name) argument off the list when
parsing options as suggested in the 'getopts' doc example. | 
|  | We want to be able to access the fields in `Config`, so make them
accessible across the FFI boundary.
* Return a regular, not boxed, `Config` from `parse_args()`.
* Add `repr(C)`s on our structs (had forgotten how this worked in
  961b3b0b2d33a2c632fbc093b61e2c2d4dc07f70).
* Delete the `config_free()` function as I think the stuct doesn't need
  to be freed being a POD struct. Hopefully that's the case. | 
|  | Parse command line options in this library. Need to figure out how to
communicate these over FFI to the Objective-C code. |