Age | Commit message (Collapse) | Author |
|
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.
|
|
Includes a small Makefile change, removes audio playing functionality,
and introduces a callback function argument that gets called when the
current mode changes.
|
|
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.
|
|
This will be used to play the mode activated & deactivated sounds via
`NSSound` (hopefully).
|
|
I want to make a Cocoa class called `Sounds`, but `Sounds.h` would
conflict with this file.
|
|
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
|
|
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
|
|
|
|
Use the new function names.
|
|
Code cleanups, C function API cleaned up, audio, lots of under the hood
code improvements.
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
* The protocol definition was for an `NSXPCConnection`
* Remove the XPCConnection method as we're using BSD notifications
instead
|
|
Ensure it's scoped to this file.
|
|
|
|
|
|
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.
|
|
|
|
|
|
Make things a bit more organised by splitting off this functionality and
giving it a name.
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
When a license path is passed in with `--license`, call `addLicense:`.
Otherwise we run the license validator.
|
|
|
|
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.
|
|
|
|
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
|
|
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`.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
For interacting with XDG directories.
|
|
|
|
This class will encapsulate all license and trial handling.
|
|
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.
|
|
|
|
Include support for older OSes. The build currently fails with this
target, so I'm going to look into what's going on. Unlikely to actually
work on 10.6 since the Rust toolchain is built against 10.7, but should
hopefully work from there.
|
|
Add the files to the project to compile them into the build.
|
|
Will be using the `CoreFoundation` library code to handle licensing for
DomeKey.
Set this up as a sparse checkout to only checkout the
`Source/CoreFoundation/` path from the repository. Doesn't seem like
this is going to carry over for other people who `git submodule init`
though. Not sure how this works.
Found these resources on how to set up a sparse checkout:
- https://briancoyner.github.io/2013/06/05/git-sparse-checkout.html
- https://stackoverflow.com/questions/6238590/set-git-submodule-to-shallow-clone-sparse-checkout
Followed a Stack Overflow post by 'max630'
(https://stackoverflow.com/users/2303202/max630) to set up the submodule
as a sparse checkout:
git init
# I did not find a way to add submodule in 1 step without checking out
git clone --depth=1 --no-checkout ../sub sub
git submodule add ../sub sub
git submodule absorbgitdirs
# note there is no "submodule.sub.sparsecheckout" key
git -C sub config core.sparseCheckout true
# note quoted wildcards to avoid their expansion by shell
echo 'foo/*' >>.git/modules/sub/info/sparse-checkout
git submodule update --force --checkout sub
(https://stackoverflow.com/questions/45688121/how-to-do-submodule-sparse-checkout-with-git/45689692#45689692)
Ran the following commands to set up the sparse checkout submodule based
on the instructions in the post:
$ git clone --no-checkout https://github.com/bdrister/AquaticPrime.git lib/AquaticPrime
Cloning into 'lib/AquaticPrime'...
remote: Enumerating objects: 797, done.
remote: Total 797 (delta 0), reused 0 (delta 0), pack-reused 797
Receiving objects: 100% (797/797), 829.07 KiB | 599.00 KiB/s, done.
Resolving deltas: 100% (343/343), done.
$ git submodule add https://github.com/bdrister/AquaticPrime.git lib/AquaticPrime
Adding existing repo at 'lib/AquaticPrime' to the index
$ git submodule absorbgitdirs
Migrating git directory of 'lib/AquaticPrime' from
'.../DomeKey/lib/AquaticPrime/.git' to
'.../DomeKey/.git/modules/lib/AquaticPrime'
$ git -C lib/AquaticPrime config core.sparsecheckout true
$ echo 'Source/CoreFoundation/' > .git/modules/lib/AquaticPrime/info/sparse-checkout
$ git submodule update --force --checkout lib/AquaticPrime
|
|
This function was renamed.
|
|
Not permitting a custom config file or log file. They might be things
that get added later, but don't feel necessary for launch.
|