Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop integration for macos #288

Merged
merged 18 commits into from
Jul 16, 2020
Merged

Desktop integration for macos #288

merged 18 commits into from
Jul 16, 2020

Conversation

vnashkev
Copy link
Contributor

@vnashkev vnashkev commented Jul 6, 2020

  1. Application bundle is installed in ~/Applications and not in /Applications folder. Generally, not all users have permissions to install into /Applications.
  2. Application start script [start.sh] does not refer [OpenWebstart] installation but simply calls open with jnlp-url allowing operating system to decide how to open given url. This keeps app-bundle working even if OpenWebStart installation folder has changed. It will work with any available jnlp-url-handler for example with oracle webstart.
  3. Application bundle is installed in ~/.cache/applications.
  4. Application menu link is created in ~/Application folder and is just a symbolic link to app-bundle from ~/.cache/application folder.
  5. Desktop link is just a symbolic link to app-bundle from ~/.cache/applications folder.

vnashkev added 4 commits July 6, 2020 13:35
Start scripts tries to open jnlp-url without explicit reference to
openwebstart.
App-bundle is created in ~/.cache/applications.
Corresponding symbolic link is created in ~/Applications
@sclassen
Copy link
Member

sclassen commented Jul 6, 2020

Will this fix #256 ?

Copy link
Contributor

@hendrikebbers hendrikebbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reformate the code? Will do a more detailed review later.

public void testCreateDesktopLink()
throws Exception
{
if ( !OperationSystem.getLocalSystem().equals(OperationSystem.MAC64) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

FileUtils.recursiveDelete(new File(userHome), new File("/tmp"));
assert new File(userHome).exists()==false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Junit Assert

System.setProperty(JavaSystemPropertiesConstants.USER_HOME, userHome);
assert userHome.equals(JavaSystemProperties.getUserHome());
updateCacheHome(userCache);
assert userCache.equals(FilesystemConfiguration.getCacheHome());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Junit Assert

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 6, 2020

Will this fix #256 ?

Yes, this fixes #256

@sclassen sclassen linked an issue Jul 6, 2020 that may be closed by this pull request
@hendrikebbers
Copy link
Contributor

@vnashkev are you familiar with Pull Requests?

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 6, 2020

@vnashkev are you familiar with Pull Requests?

sorry, not at all

@hendrikebbers
Copy link
Contributor

No problem :) If you have any questions just ask them and we will try to help you ;)

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 6, 2020

ok, do you have any guideline for source code format?

@hendrikebbers
Copy link
Contributor

I have seen that you did the Pull Request based on a master branch of your fork. While this is ok for us it will be much easier for you to create a branch in your fork and create the Pull request based on that branch instead of the master branch.

@hendrikebbers
Copy link
Contributor

Anything that you change in your branch (currently the master branch) before this PR is closed will be reflected in this PR. You can do improvements based on discussions on the master branch of you fork, commit and push it. Once this is done the change should be in this PR, too.

@hendrikebbers
Copy link
Contributor

I would say that we are using the default format that comes with IntelliJ / Eclipse. Maybe you can just check to auto format the new and mutated classes by your IDE?

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 6, 2020

I have just applied default Eclipse format for AppFactoryTest. Is it ok?

@hendrikebbers
Copy link
Contributor

YES :) Let's do it for all the files

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 6, 2020

formatting & assert done

@hendrikebbers
Copy link
Contributor

ok, as a next step we should refactor the tests:

  • Please replace all assert calls with the JUnit Assert
  • As already mentioned we can define the tests to be MacOnly. Be doing so we can remove the initial checks in the methods.
  • By using a @BeforeEach you can remove the restoreOrigins in each method.

Files.delete(link);
}
} finally {
restoreOrigins();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add restoreOrigins(); in a method that is called before each test. See https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/BeforeEach.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For each test i change user.home system property & update FilesystemConfiguration.cacheHome via reflection. This could be moved into @beforeeach. This change may have an effect of other tests outside of AppFactoryTests. I would suggest to annotate restoreOrigins with @afterall.

Copy link
Contributor

@hendrikebbers hendrikebbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional changes

final URL srcUrl = jnlpFile.getSourceLocation();
final String schema = srcUrl.getProtocol();
final String url;
if ("http".equalsIgnoreCase(schema) || "https".equalsIgnoreCase(schema)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please externalise "http", "https" and "jnlp" as constants. I assume that we already have defined them in a global constant class / interface but can not check at the moment.

private final static Path ensureUserApplicationFolder()
{
final String userHome = JavaSystemProperties.getUserHome();
final File appFolder = new File( new File(userHome), "Applications");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Applications" <- CONST

}

private final static Path ensureUserApplicationCacheFolder() {
final Path appcache = Paths.get(FilesystemConfiguration.getCacheHome(), "applications");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Applications" <- CONST

final Path linkRealPath = link.toRealPath();
return cache.toRealPath().equals(linkRealPath);
} catch (final Exception e) {
/* ignore this error */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should at least log this?


private final static Path getDesktopLink(final String appname)
{
return Paths.get(JavaSystemProperties.getUserHome(), "Desktop", appname + APP_EXTENSION );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Desktop" <- Const

return false;
public boolean supportsDesktopEntry()
{
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch this back to false. By doing so we can test the behaviour internally and activate the support with a Pull Request in near future :)

@hendrikebbers
Copy link
Contributor

@vnashkev we are on a very good way here :) I really like this PR and it will provide much better native support for MacOS. Great work! I would love to deactivate the feature by default with this PR. By doing so we can test it internally and activate it once we have checked that everything is working.

@@ -25,29 +25,38 @@
public class MacEntryFactory implements MenuAndDesktopEntriesFactory {

@Override
public boolean supportsDesktopEntry() {
public boolean supportsDesktopEntry()
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnashkev Looks like the format is broken again ;)

@hendrikebbers
Copy link
Contributor

@vnashkev this PR looks very good now :) Only the format in 1 file is broken again. Can you fix this? Once this is done I will be more than happy to merge this PR in OpenWebStart. Thank you very much for this good work!

@hendrikebbers hendrikebbers merged commit 42e4889 into karakun:master Jul 16, 2020
@hendrikebbers
Copy link
Contributor

@vnashkev merged :) Thank you very much for your participation. The fix will be part of the next OWS release

@vnashkev
Copy link
Contributor Author

vnashkev commented Jul 16, 2020 via email

@hendrikebbers hendrikebbers added this to the 1.2.0 milestone Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSX Shortcut never creates
3 participants