aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
AgeCommit message (Collapse)Author
2018-11-22Add licenseTeddy Wing
2018-10-29Remove audio playing codeTeddy Wing
Remove code that was commented in 44f6a2d5544e3ad49e5e3c52167c045aed1d56b2. Since we weren't able to correctly link to the Core Audio framework from the Objective-C code using this Rust audio code, get rid of it. Instead, we play audio in the Objective-C application.
2018-10-29Turn off audio handling with 'rodio'Teddy Wing
I was getting the following error when building the Objective-C project with the latest audio playing code: ld: warning: object file (.../DomeKey/lib/dome-key-map/target/debug/libdome_key_map.a(minimp3.o)) was built for newer OSX version (10.12) than being linked (10.7) ld: warning: object file (.../DomeKey/lib/dome-key-map/target/debug/libdome_key_map.a(util_helpers.o)) was built for newer OSX version (10.12) than being linked (10.7) ld: warning: object file (.../DomeKey/lib/dome-key-map/target/debug/libdome_key_map.a(aesni_helpers.o)) was built for newer OSX version (10.12) than being linked (10.7) Undefined symbols for architecture x86_64: "_AudioComponentFindNext", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioComponentInstanceNew", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioObjectGetPropertyData", referenced from: cpal::cpal_impl::Device::name::h96cf527e96e03bec in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::Device::supported_formats::h9019a8aeda6b1a55 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::Device::default_format::h1cffda96edcf1b5f in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::EventLoop::build_input_stream::rate_listener::he669322d080b4fd0 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::enumerate::audio_devices::h35df9cd3ad61905a in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) cpal::cpal_impl::enumerate::default_input_device::h4d38066593597777 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) cpal::cpal_impl::enumerate::default_output_device::hfb207f3766c759d9 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) ... "_AudioObjectGetPropertyDataSize", referenced from: cpal::cpal_impl::Device::supported_formats::h9019a8aeda6b1a55 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::enumerate::audio_devices::h35df9cd3ad61905a in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) "_AudioOutputUnitStart", referenced from: coreaudio::audio_unit::AudioUnit::start::h0ceab6edb211b577 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioOutputUnitStop", referenced from: coreaudio::audio_unit::AudioUnit::stop::h2929fdfd118ee7be in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioUnitGetProperty", referenced from: coreaudio::audio_unit::get_property::h58ff3c44f7ccc617 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::get_property::habcd9010fa8dc136 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioUnitInitialize", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioUnitSetProperty", referenced from: coreaudio::audio_unit::set_property::h5e5a6451ac49ed54 in libdome_key_map.a(rodio-d252ad0025b836aa.rodio15.rcgu.o) coreaudio::audio_unit::set_property::h86353d3d091c7540 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::set_property::hbaa7f6c599c38fa2 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::set_property::hf450b8b66e374b66 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioUnitUninitialize", referenced from: _$LT$coreaudio..audio_unit..AudioUnit$u20$as$u20$core..ops..drop..Drop$GT$::drop::h0a1df660f851dad4 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) After setting: $ export MACOSX_DEPLOYMENT_TARGET=10.7 in the shell, the error changed to: Undefined symbols for architecture x86_64: "_AudioComponentFindNext", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioComponentInstanceNew", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioObjectGetPropertyData", referenced from: cpal::cpal_impl::Device::name::h96cf527e96e03bec in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::Device::supported_formats::h9019a8aeda6b1a55 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::Device::default_format::h1cffda96edcf1b5f in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::EventLoop::build_input_stream::rate_listener::he669322d080b4fd0 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::enumerate::audio_devices::h35df9cd3ad61905a in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) cpal::cpal_impl::enumerate::default_input_device::h4d38066593597777 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) cpal::cpal_impl::enumerate::default_output_device::hfb207f3766c759d9 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) ... "_AudioObjectGetPropertyDataSize", referenced from: cpal::cpal_impl::Device::supported_formats::h9019a8aeda6b1a55 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal0.rcgu.o) cpal::cpal_impl::enumerate::audio_devices::h35df9cd3ad61905a in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal8.rcgu.o) "_AudioOutputUnitStart", referenced from: coreaudio::audio_unit::AudioUnit::start::h0ceab6edb211b577 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioOutputUnitStop", referenced from: coreaudio::audio_unit::AudioUnit::stop::h2929fdfd118ee7be in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioUnitGetProperty", referenced from: coreaudio::audio_unit::get_property::h58ff3c44f7ccc617 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::get_property::habcd9010fa8dc136 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) "_AudioUnitInitialize", referenced from: coreaudio::audio_unit::AudioUnit::new_with_flags::hc9c3029c77a9ba1d in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioUnitSetProperty", referenced from: coreaudio::audio_unit::set_property::h5e5a6451ac49ed54 in libdome_key_map.a(rodio-d252ad0025b836aa.rodio15.rcgu.o) coreaudio::audio_unit::set_property::h86353d3d091c7540 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::set_property::hbaa7f6c599c38fa2 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) coreaudio::audio_unit::set_property::hf450b8b66e374b66 in libdome_key_map.a(cpal-b228ca6a35ab9c25.cpal12.rcgu.o) "_AudioUnitUninitialize", referenced from: _$LT$coreaudio..audio_unit..AudioUnit$u20$as$u20$core..ops..drop..Drop$GT$::drop::h0a1df660f851dad4 in libdome_key_map.a(coreaudio-b5e291d8855015a5.coreaudio3.rcgu.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Couldn't figure out how to get past this, so decided to move the audio playing into the Objective-C code. It's been something of a theme, where if something doesn't work in one language (like dome_key_event_source_simulator), write it in the other. Here we just comment out the audio-related code so I can work on connecting mode activation and deactivation and audio playing. I'll be completely removing this code soon.
2018-10-28Add `play_audio()` functionTeddy Wing
Create a new function that encapsulates the code we experimented with for playing audio. Clean up what we had and handle errors by passing them back in a `Result`. This allows us to encapsulate, audio playing so we can do it in a single action during mode switching.
2018-10-23error_chain!::foreign_links: Reorder `ErrorKind` definitionsTeddy Wing
Order them like imports, with `std` errors first, followed by extern crate errors, followed by local errors, alphabetically.
2018-10-23do_trial(): Fix unreachable `DurationError` patternsTeddy Wing
I was getting these warnings: warning: unreachable pattern --> src/trial.rs:41:17 | 40 | DurationError => return trial_expired(), | ------------- matches any value 41 | e => { | ^ unreachable pattern warning: unreachable pattern --> src/trial.rs:55:9 | 54 | DurationError => trial_expired(), | ------------- matches any value 55 | Err(e) => (), | ^^^^^^ unreachable pattern Wasn't correctly matching the `DurationError`s. Add an 'error-chain' `ErrorKind` for `DurationError` to make it the same type as the others matched in the first `match` pattern.
2018-10-22Fill in `get_trial_start()` functionTeddy Wing
Reads the encrypted timestamp from the trial file and returns a `DateTime`.
2018-10-22trial: Add a function to initialise a trial timestamp in a fileTeddy Wing
Save an encoded timestamp to a file. This function should be run once if no trial file is found. The encoded timestamp can then be read on subsequent launches to determine whether the trial period is still in effect. Also add a few function stubs for other actions that seem relevant.
2018-10-22decode_datetime(): Return a `Result`Teddy Wing
Make a custom error type because it's trickier to integrate with 'error-chain' given that 'magic-crypt''s `Error` type doesn't implement the `std::error::Error` trait. For the same reason, we can't use that as the `cause` for `DateCryptError::Decrypt`. This allows us to capture the errors without panicking. Include some additional cleanups as a result of removing the `use std::result` and `use errors::*` imports.
2018-10-21Add `trial` module, calculate days remainingTeddy Wing
This new module will contain functions to calculate trial days. Here we implement a function to calculate the days remaining in a trial period. If there are less than 0 days remaining, it returns an error result. Couldn't use 'error-chain' because it was complaining about `Debug` and `PartialEq` not being defined. Don't know if it's possible to implement those traits on 'error-chain''s ErrorKind`, but it was complicated enough that I ended up not bothering. Went with 'quick_error' instead to create a custom error type without having to `impl` all the required traits.
2018-10-20read_config_file(): Update to get the config from `config.toml`Teddy Wing
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.