-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing Additional Platform Support
In order to behave well on a given platform, OHR has to do certain things according to that platform's established conventions. Failure to do this will cause irritation to the user and possibly also mistakes because the app does not behave the way that the users expects.
I am aware of three ways in which OHR interacts with the host platform. These are summarised in the following table:
Interaction | Implementation |
---|---|
Files | the abstract class net.winnall.ohr.host.Host , which is overridden by platform-specific classes |
UI | the SASS files, from which the CSS files used by JavaFX are generated; and JavaFX itself, which has some platform specific awareness (order of buttons, file and folder choosers, etc.) |
Executable |
pom.xml contains instructions (de.perdian.maven.plugins:macosappbundler-maven-plugin ) to generate a MacOS application; something similar is needed for other platforms unless a simple JAR is adequate. |
The current version of OHR is aware of the the following platforms:
Platform | Overriding Class | Status |
---|---|---|
MacOS | MacOSHost | implemented |
iOS | IOSHost | stub |
Linux | LinuxHost | stub |
Unix | UnixHost | stub |
Windows | WindowsHost | stub |
Host
is implemented as a singleton and provides two general purpose methods and several methods for accessing application support files:
Method | Purpose |
---|---|
applyHostConventions |
do any necessary initialisation to set up platform conventions (e.g. location of menu on screen) |
getUserHome |
return the name of user's login folder |
--- | --- |
getInputSupportFile |
look for an application support file (also in JAR) and return it as an InputStream
|
getInputSupportFolderName |
look for an application support folder and return it as an String
|
getOutputSupportFile |
create an application support file and return it as an OutputStream
|
getInputHostSupportFile |
look for an application support file (but not in JAR) and return it as an InputStream
|
It is assumed that application support files can be in:
- user space
- system space
- OHR JAR file
and they are searched for in that order. This allows for system- and user-level overriding of the default settings in the OHR application. The following table illustrates how this works on MacOS and might work on other platforms:
OS | User Space | System Space |
---|---|---|
MacOS | ~/Library/Application Support/OpenHAB Reporter/ |
/Library/Application Support/OpenHAB Reporter/ |
Linux | ~/.ohr |
/etc/ohr |
Unix | ~/.ohr |
/etc/ohr |
Overriding Host
entails instantiating abstract methods, where necessary, and possibly overriding other methods to achieve an appropriate result as outlined above on the given platform whilst observing relevant platform conventions.