aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2018-10-30Update TODOTeddy Wing
2018-10-30lib/dome-key-map: Update to include default mappingsTeddy Wing
2018-10-29Update TODOTeddy Wing
2018-10-29HeadphoneKey: Play audio only with the `--audio` command line flagTeddy Wing
Allow users to decide whether interface audio (mode activated & deactivated) should play. The flag value is in a `Config`, so to make it easier to pass both the audio flag and the timeout config value to `HeadphoneKey`, rename `initWithTimeout:` to `initWithConfig:`. Only allocate a `Sounds` instance if `--audio` is passed, because there's no reason to allocate memory for it otherwise. Add a `_play_audio` flag as a static variable to make it accessible to the `on_mode_change()` function, just like we did for `sounds_inst`. In `on_mode_change()`, don't play any audio if `_play_audio` is on.
2018-10-29lib/dome-key-map: Update to get `--audio` flag handlingTeddy Wing
2018-10-29HeadphoneKey: Remove unused `_in_mode` instance variableTeddy Wing
This was for when I was trying to store the current mode in this class. It's now stored in a `State` variable.
2018-10-29Play sounds when a mode is activated & deactivatedTeddy Wing
Use the new function pointer argument on `dome_key_run_key_action()` to play our interface sounds. Store the `Sounds` instance in a static constant variable in order to make it accessible to our callback function's scope. At first I had put it in an instance variable, but this obviously didn't work.
2018-10-29lib/dome-key-map: Update to latestTeddy Wing
Includes a small Makefile change, removes audio playing functionality, and introduces a callback function argument that gets called when the current mode changes.
2018-10-29Sounds: Add methods for playing the mode activated & deactivated soundsTeddy Wing
Initialise `NSSound`s using the data arrays in `sound_data.h`. HeadphoneKey: Add a `_sounds` instance variable and test playing the "mode activated" sound. It works.
2018-10-29Add `Sounds` classTeddy Wing
This will be used to play the mode activated & deactivated sounds via `NSSound` (hopefully).
2018-10-29Rename `sounds.h` to `sound_data.h`Teddy Wing
I want to make a Cocoa class called `Sounds`, but `Sounds.h` would conflict with this file.
2018-10-29Add `sounds.h`, C array versions of sound filesTeddy Wing
This enables us to compile the sound files into our binary. Makefile: Add a target to build the `sounds.h` file, by running `xxd -i` on both sound files. Thanks to Matteo Italia (https://stackoverflow.com/users/214671/matteo-italia) on Stack Overflow for describing how to use `xxd -i` to create a C array from a binary file: https://stackoverflow.com/questions/8707183/script-tool-to-convert-file-to-c-c-source-code-array/8707241#8707241 An to John Marshall (https://stackoverflow.com/users/280577/john-marshall) on Stack Overflow for showing me the Make `foreach` function: https://stackoverflow.com/questions/7918511/make-execute-an-action-for-each-prerequisite/7921168#7921168
2018-10-29Add mode activated & deactivated soundsTeddy Wing
Sounds to play when a mode is activated or deactivated. Use the MP3 versions of the audio files because Core Audio doesn't support Ogg/Vorbis: https://developer.apple.com/library/archive/documentation/MusicAudio/Conceptual/CoreAudioOverview/SupportedAudioFormatsMacOSX/SupportedAudioFormatsMacOSX.html#//apple_ref/doc/uid/TP40003577-CH7-SW1
2018-10-29Update TODOTeddy Wing
2018-10-29Update Rust library function calls to new API namesTeddy Wing
Use the new function names.
2018-10-29lib/dome-key-map: Update to latestTeddy Wing
Code cleanups, C function API cleaned up, audio, lots of under the hood code improvements.
2018-10-28Update TODOTeddy Wing
2018-10-28Update TODOTeddy Wing
2018-10-27Update TODOTeddy Wing
2018-10-27HeadphoneKey: Only print `NSLog`s in a debug modeTeddy Wing
Add a new `LogDebug` macro that `NSLog`s when a `DOME_KEY_DEBUG` environment variable is set to "1". This gets rid of the verbose output every time a headphone key is pressed. But it enables you to see it if needed for debugging purposes.
2018-10-27HeadphoneKey: Delete `startMonitoringBluetoothEvents` methodTeddy Wing
From what I could tell, this didn't work for handling Bluetooth button press events. Delete it since it's not being used. We'll have to come back to Bluetooth again later.
2018-10-27AppDelegate: Get rid of `MPRemoteCommandCenter` codeTeddy Wing
This code was a test for Bluetooth event handling. It didn't work for that purpose as far as I could tell. Since it's not being used, delete it.
2018-10-27Delete `KeyboardSimulator`Teddy Wing
We're no longer using this code. Keyboard simulation has been moved since a long while ago to the Rust library using the 'autopilot' library.
2018-10-27Delete `DKApplication`Teddy Wing
This was a test to see if we could get Bluetooth headphone events using media key events. I wasn't successful. Get rid of the code now that it isn't being used.
2018-10-27Mappings: Remove old unused codeTeddy Wing
* The protocol definition was for an `NSXPCConnection` * Remove the XPCConnection method as we're using BSD notifications instead
2018-10-27Mappings: Make `const` `static`Teddy Wing
Ensure it's scoped to this file.
2018-10-27errors.h: Add include guardsTeddy Wing
2018-10-27LicenseHandler,XDG: Remove some unneeded commentsTeddy Wing
2018-10-27LicenseHandler(addLicense:): Delete license file at the startTeddy Wing
Previously, you couldn't replace the existing license file using the `--license` flag. If you somehow got an invalid license installed, you'd get an error message asking you to add your license again: "Try adding your license again using the `--license` flag." But this wouldn't work to replace the existing license. The copy operation would fail complaining about the file already existing. The behaviour of the method now is to always replace the license file, just in case it's necessary. We use the existing "move to trash" method, and make sure we ignore "does not exist" errors, because typically when you run `--license`, you're not going to have a `license.plist` file installed at the start, so for our purposes, that's not an error.
2018-10-27LicenseHandler: Run trial initialiser when license validation failsTeddy Wing
2018-10-27lib/dome-key-map: Update for trial FFI functionTeddy Wing
2018-10-26LicenseHandler: Move trashing code to a new methodTeddy Wing
Make things a bit more organised by splitting off this functionality and giving it a name.
2018-10-26LicenseHandler: Use current date string in file moved to trashTeddy Wing
To prevent errors resulting from trying to move the license file to the trash when a file with the same name already exists there, use a custom file name with a time stamp. Instead of naming the trashed file "license.plist", prepend "dome-key-" to the filename to make it clear to users that the file came from DomeKey. Append the current date in the format "2018-10-26-19.28.13" before the file extension.
2018-10-26LicenseHandler(addLicense:): Move license file to trash manuallyTeddy Wing
Get the trash directory and move the file there manually. Unfortunately, this doesn't do the renaming of the file if there's a name conflict, so we still need to look into how to deal with that. Thanks to Vincent Tourraine (https://stackoverflow.com/users/135712/vincent-tourraine) on Stack Overflow (https://stackoverflow.com/questions/46089964/how-do-i-get-rid-of-ios-version-is-partial-introduced-in-ios-x-warnings-in-xc/46274231#46274231) for explaining how to get rid of the `-Wunguarded-availability` warnings I was getting as a result of using `NSTrashDirectory`. Apparently using the availability macros doesn't silence the error. Since we're already checking for availability without `@available`, forcibly silence the warning here.
2018-10-26LicenseHandler(addLicense:): Delete license file instead of trashing itTeddy Wing
The trash/recycle method wasn't working because it was asynchronous. As a result, the file never got moved. Using `removeItemAtURL:error:` does work, and is available starting in OS 10.6. But I still don't like the idea of forcibly deleting files. What if the user licenses the program and deletes their license file, then somehow gets their only local copy deleted? Need to work out a different way of doing this.
2018-10-26main: Use `sysexits.h` constants as return valuesTeddy Wing
2018-10-26Add license file using `--license` argumentTeddy Wing
When a license path is passed in with `--license`, call `addLicense:`. Otherwise we run the license validator.
2018-10-26lib/dome-key-map: Update to exit after help outputTeddy Wing
2018-10-26main: Print version string when the `version` command line arg is passedTeddy Wing
Store the version string in code, as otherwise the only way to get it appears to be from Info.plist, and we don't have one of those in this application.
2018-10-26lib/dome-key-map: Update to include trial and command line updatesTeddy Wing
2018-10-25LicenseHandler: Move invalid license error message to a new methodTeddy Wing
This enables us to print the error message in both of the following cases: 1. Validating an existing key 2. Adding a new license key
2018-10-25LicenseHandler(addLicense:): Use `NSWorkspace` to move to trashTeddy Wing
The `trashItemAtURL:resultingItemURL:error:` method in `NSFileManager` is only available starting from Mac OS X 10.8. Replace this with a more compatible API call. At first I was thinking about using `NSWorkspace` `performFileOperation:source:destination:files:tag:`, since it works starting from 10.0. However, I'd need to remove the `license.plist` path component from the `NSURL` from `licensePath` in order to pass it to the `source:` argument. I found `NSURL` `URLByDeletingLastPathComponent`, which would make perfect sense, except it's only implemented starting in 10.6. At that point, I figured why not use `NSWorkspace` `recycleURLs:completionHandler:`, which exists starting in 10.6, and has a simpler interface than `performFileOperation:source:destination:files:tag:`. Import AppKit in order to be able to use `NSWorkspace`.
2018-10-25LicenseHandler: Implement `addLicense:` methodTeddy Wing
Copies the given license into XDG_DATA_HOME and validates it. This allows us to keep the user's license in a consistent location where it can be validated on every launch. Errors are printed to stderr. If the license file fails validation, it gets moved to the trash. The original license file passed in by the user will remain intact, only the one copied to XDG_DATA_HOME gets removed. Call the function from `main` with a temporary hard-coded value to test out the function. The real path value will come from a command-line argument. We may end up removing the `validateLicense` call and subsequent related code here if it always gets called anyway. Still not sure if it should look like: if (--license passed in) { [LicenseHandler addLicense:l]; } else { [LicenseHandler check]; } or if (--license passed in) { [LicenseHandler addLicense:l]; } [LicenseHandler check]; If the second, we should keep some kind of trashing functionality as otherwise a subsequent `addLicense:` call will result in an error like this: dome-key: error: “dome-key-license.plist” couldn’t be copied to “dome-key” because an item with the same name already exists. TODO: `trashItemAtURL:resultingItemURL:error:` was introduced in OS X 10.8. We need to change this to use an `NSWorkspace` method.
2018-10-25LicenseHandler: Handle `APSetKey` returning falseTeddy Wing
If `APSetKey()` returns false, the public key failed to get loaded by the AquaticPrime library, and we won't subsequently be able to `APVerifyLicenseFile()`. If `APSetKey()` fails, return `NO` from this `validateLicense` method.
2018-10-25LicenseHandler: Validate license filesTeddy Wing
Fill in the `check` method to have it validate a license file. If the file doesn't validate, prints an error message. A bunch of supporting methods to check if the license file at the program's prescribed path exists. Use AquaticPrime's CoreFoundation functions to validate the license file. Include my public key, generated by the "AquaticPrime Developer" app, with the CFStringAppend calls copied from the program's generated "Obfuscated Public Key" text box. Run the validation check on launch in `main.m`. Add an `eprintf` macro to print to stderr with a prepended program identifier.
2018-10-25XDG: Add methods to get the XDG_DATA_HOME pathTeddy Wing
Gets the path from the environment variable or uses the default path. Additionally provides a method for getting the "dome-key" subdirectory in XDG_DATA_HOME.
2018-10-24Add an `XDG` classTeddy Wing
For interacting with XDG directories.
2018-10-24LicenseHandler: Add method stubsTeddy Wing
2018-10-24Add `LicenseHandler`Teddy Wing
This class will encapsulate all license and trial handling.
2018-10-24DomeKey.xcodeproj: Change deployment target to 10.7Teddy Wing
Turns out the build had failed previously because the linked Rust library expects 10.7. Change the deployment target to match and now it works.