Mimetype Support (Apple) #665

Open
tresf opened this Issue May 1, 2014 · 38 comments

Projects

None yet

5 participants

@tresf
Member
tresf commented May 1, 2014

The current OS X build does not register the MMP/MMPZ file extension with the Apple OS X operating system.

image

This bug report is a placeholder for this feature as it applies to the OS X DMG installer.

@tresf tresf closed this May 1, 2014
@tresf tresf reopened this May 1, 2014
@tresf
Member
tresf commented May 6, 2014

@eagles051387, do you have any experience with the file association?

I've made some changes (1c4ab56) to the Info.plist to no avail. Does this require some custom C++ code? Is there a "refresh my darn plists" option in the OS? Any help is appreciated as this is very close to being closed.

Edit: There DOES seem to be a way to refresh this, although it seems to do nothing for our bundle.

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister \
-kill -r -domain local -domain system -domain user

Edit2:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>

    <key>CFBundleIconFile</key>
    <string>lmms.icns</string>

    <key>CFBundlePackageType</key>
    <string>APPL</string>

    <key>CFBundleGetInfoString</key>
    <string>LMMS 1.0.0</string>

    <key>CFBundleSignature</key>
    <string>mmpz</string>

    <key>CFBundleExecutable</key>
    <string>lmms</string>

    <key>CFBundleVersion</key>
    <string>1.0.0</string>

    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>

    <key>CFBundleName</key>
    <string>LMMS</string>

    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>

    <key>CFBundleIdentifier</key>
    <string>net.sourceforge.lmms</string>

    <key>CFBundleDocumentTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeExtensions</key>
          <array>
            <string>mmpz</string>
          </array>
        <key>CFBundleTypeIconFile</key>
        <string>project.icns</string>
        <key>CFBundleTypeName</key>
        <string>LMMS Project</string>
        <key>CFBundleTypeOSTypes</key>
           <array>
             <string>mmpz</string>
           </array>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
      </dict>
    </array>

    <key>UTExportedTypeDeclarations</key>
        <array>
            <dict>
                <key>UTTypeIdentifier</key>
                <string>net.sourceforge.lmms.mmpz</string>
                <key>UTTypeReferenceURL</key>
                <string>http://lmms.sourceforge.net/</string>
                <key>UTTypeDescription</key>
                <string>LMMS Project</string>
                <key>UTTypeIconFile</key>
                <string>project.icns</string>
                <key>UTTypeConformsTo</key>
                <array>
                    <string>public.data</string>
                </array>
                <key>UTTypeTagSpecification</key>
                <dict>
                    <key>net.sourceforge.lmms</key>
                    <string>MMPZ</string>
                    <key>public.filename-extension</key>
                    <array>
                        <string>mmpz</string>
                    </array>
                    <key>public.mime-type</key>
                    <string>application/x-lmms-project</string>
                </dict>
            </dict>

            <dict>
                <key>UTTypeIdentifier</key>
                <string>net.sourceforge.lmms.mmp</string>
                <key>UTTypeReferenceURL</key>
                <string>http://lmms.sourceforge.net/</string>
                <key>UTTypeDescription</key>
                <string>LMMS Project</string>
                <key>UTTypeIconFile</key>
                <string>project.icns</string>
                <key>UTTypeConformsTo</key>
                <array>
                    <string>public.xml</string>
                    <string>public.data</string>
                </array>
                <key>UTTypeTagSpecification</key>
                <dict>
                    <key>net.sourceforge.lmms</key>
                    <string>MMP</string>
                    <key>public.filename-extension</key>
                    <array>
                        <string>mmpz</string>
                    </array>
                    <key>public.mime-type</key>
                    <string>application/x-lmms-project</string>
                </dict>
            </dict>
        </array>
  </dict>
</plist>

-Tres

@eagles051387
Contributor

https://developer.apple.com/library/ios/documentation/filemanagement/conceptual/documentinteraction_topicsforios/Articles/RegisteringtheFileTypesYourAppSupports.html

This contains a code snippit which only requires you to modify the
info.plist file.

On Tue, May 6, 2014 at 3:47 PM, Tres Finocchiaro
notifications@github.comwrote:

@eagles051387 https://github.com/eagles051387, do you have any
experience with the file association?

I've made some changes (1c4ab561c4ab56)
to the Info.plist to no avail. Does this require some custom C++ code? Is
there a "refresh my darn plists" option in the OS? Any help is appreciated
as this is very close to being closed.

-Tres


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42303704
.

Jonathan Aquilina

@tresf
Member
tresf commented May 6, 2014

Yes, if you actually read the commit (1c4ab56) you would have noticed we've already done that.

Here it is in black and white. If you notice a problem can you please let me know? I've tried an array for the icons as well as the LSHandlerRank setting to no avail.

Wait.. scratch that, you sent an iOS link. We would need this for OS X.

OUR Info.plist

<array>
   <dict>
      <key>CFBundleTypeIconFile</key>
      <string>project.icns</string>
      <key>CFBundleTypeName</key>
      <string>@MACOSX_BUNDLE_GUI_IDENTIFIER@ Project</string>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>LSIsAppleDefaultForType</key>
      <true/>
      <key>LSItemContentTypes</key>
      <array>
         <string>public.mmp</string>
         <string>public.mmpz</string>
      </array>
      <key>CFBundleTypeExtensions</key>
      <array>
         <string>mmp</string>
         <string>mmpz</string>
      </array>
   </dict>
</array>

APPLE'S Info.plist

<dict>
   <key>CFBundleTypeName</key>
   <string>My File Format</string>
   <key>CFBundleTypeIconFiles</key>
       <array>
           <string>MySmallIcon.png</string>
           <string>MyLargeIcon.png</string>
       </array>
   <key>LSItemContentTypes</key>
       <array>
           <string>com.example.myformat</string>
       </array>
   <key>LSHandlerRank</key>
   <string>Owner</string>
</dict>
@eagles051387
Contributor

I was suggested by a dev in macdev on freenode for you to try lsregister

http://ss64.com/osx/lsregister.html

On Tue, May 6, 2014 at 4:04 PM, Tres Finocchiaro
notifications@github.comwrote:

Yes, if you actually read my commit (1c4ab561c4ab56)
you would have noticed I've already done that.

Here is is in black and white. If you notice a problem can you please let
me know?

CFBundleTypeIconFile project.icns CFBundleTypeName @MACOSX_BUNDLE_GUI_IDENTIFIER@ Project CFBundleTypeRole Editor LSIsAppleDefaultForType LSItemContentTypes public.mmp public.mmpz CFBundleTypeExtensions mmp mmpz


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42305750
.

Jonathan Aquilina

@tresf
Member
tresf commented May 6, 2014

Yes, I'm trying that now. It doesn't report any errors.

#665 (comment)

@eagles051387
Contributor

So I have found an issue of using what I believe from what I understand is a depreciated part of the api in particular LSItemContentTypes

As well looking at the below link CFBundleTypeIconFiles is IOS specific for OSX according to the below link its CFBundleTypeIconFile

In the link below I am not sure what you should be using to actually out of this part of the API.

https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685

@tresf
Member
tresf commented May 6, 2014

Some clarification, when I asked for API I was referring to the actual Objective-C API. I was alluding to a platform-dependant #ifdef that we might be missing?

-Tres

@tresf
Member
tresf commented May 6, 2014

Found a simple sample from KeyPassX
I copied this verbatim into our project, only changing our stuff and it still won't show the icon or associate the software.... :(

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>

    <!-- For a full list of properties, see
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html
    -->



    <key>CFBundleIconFile</key>
    <string>icon.icns</string>

    <key>CFBundlePackageType</key>
    <string>APPL</string>

    <key>CFBundleGetInfoString</key>
    <string>KeePassX 0.4.3</string>

    <key>CFBundleSignature</key>
    <string>kpsx</string>

    <key>CFBundleExecutable</key>
    <string>KeePassX</string>

    <key>CFBundleVersion</key>
    <string>0.4.3</string>

    <key>CFBundleShortVersionString</key>
    <string>0.4.3</string>

    <key>CFBundleName</key>
    <string>KeePassX</string>

    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>

    <key>CFBundleIdentifier</key>
    <string>org.keepassx.keepassx</string>

    <key>CFBundleDocumentTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeExtensions</key>
          <array>
            <string>kdb</string>
          </array>
        <key>CFBundleTypeIconFile</key>
        <string>icon</string>
        <key>CFBundleTypeName</key>
        <string>KeePassX Password Database</string>
        <key>CFBundleTypeOSTypes</key>
           <array>
             <string>kpsx</string>
           </array>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
      </dict>
    </array>

  </dict>
</plist>
@eagles051387
Contributor

Did that actually solve the problem or are we still no closer on this
regard?

On Tue, May 6, 2014 at 10:58 PM, Tres Finocchiaro
notifications@github.comwrote:

Found a simple sample from KeyPassX

<!-- For a full list of properties, see    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html    -->



<key>CFBundleIconFile</key>
<string>icon.icns</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleGetInfoString</key>
<string>KeePassX 0.4.3</string>

<key>CFBundleSignature</key>
<string>kpsx</string>

<key>CFBundleExecutable</key>
<string>KeePassX</string>

<key>CFBundleVersion</key>
<string>0.4.3</string>

<key>CFBundleShortVersionString</key>
<string>0.4.3</string>

<key>CFBundleName</key>
<string>KeePassX</string>

<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

<key>CFBundleIdentifier</key>
<string>org.keepassx.keepassx</string>

<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeExtensions</key>
      <array>
        <string>kdb</string>
      </array>
    <key>CFBundleTypeIconFile</key>
    <string>icon</string>
    <key>CFBundleTypeName</key>
    <string>KeePassX Password Database</string>
    <key>CFBundleTypeOSTypes</key>
       <array>
         <string>kpsx</string>
       </array>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
  </dict>
</array>


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42358023
.

Jonathan Aquilina

@eagles051387
Contributor

I found someone who might have figured out what our issue is.

eagles0513875: that looks like you've registered that your app handles the UTI, but not what the UTI is

Also its suggested using reverse DNS method starting with com as well as suggested in the document below.

https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html

@tresf
Member
tresf commented May 7, 2014

KeypassX works out of the box without any of this added, but I'll try it today. Thanks for the research.

-Tres

@eagles051387
Contributor

No problem. I am glad im helping out the community in my rather limited way.

On 07/05/2014 17:39, Tres Finocchiaro wrote:

KeypassX works out of the box without any of this added, but I'll try it
today. Thanks for the research.

-Tres


Reply to this email directly or view it on GitHub
#665 (comment).

@tresf tresf closed this May 7, 2014
@tresf tresf reopened this May 7, 2014
@tresf
Member
tresf commented May 7, 2014

Yes, that did it. Thank you.
image

@eagles051387
Contributor

Yay I think that the solution is worth documenting somewhere for future
reference not only for you but for other would be mac devs.

On Wed, May 7, 2014 at 8:34 PM, Tres Finocchiaro
notifications@github.comwrote:

Reopened #665 #665.


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#event-118811913
.

Jonathan Aquilina

@tresf
Member
tresf commented May 7, 2014

It will be documented once the issue is closed. It will be in the source
code commit that closes this bug.

I've implemented it but it's only working for MMP icons now. Hopefully I
can figure out why...

https://github.com/tresf/lmms/blob/stable-1.0/data/lmms.plist.in

@eagles051387
Contributor

What is the difference between normal mmp and mmpz?

On Wed, May 7, 2014 at 11:02 PM, Tres Finocchiaro
notifications@github.comwrote:

It will be documented once the issue is closed. It will be in the source
code commit that closes this bug.

I've implemented it but it's only working for MMP icons now. Hopefully I
can figure out why...

https://github.com/tresf/lmms/blob/stable-1.0/data/lmms.plist.in


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42482798
.

Jonathan Aquilina

@tresf
Member
tresf commented May 7, 2014

Not much. Worst part is mmpz worked on the build machine. I'll keep
investigating.

@eagles051387
Contributor

Are you implementing them in a single definition. It could be they need to
be separate.

On Wed, May 7, 2014 at 11:53 PM, Tres Finocchiaro
notifications@github.comwrote:

Not much. Worst part is mmpz worked on the build machine. I'll keep
investigating.


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42488291
.

Jonathan Aquilina

@tresf
Member
tresf commented May 8, 2014

Closed per #694

@tresf tresf closed this May 8, 2014
@tresf
Member
tresf commented May 8, 2014

FYI - Turns out despite many recommendations to clear the icon cache using various commands, rebooting the computer seems to be the proper test for new mimetype icons.

@tresf tresf reopened this May 13, 2014
@tresf
Member
tresf commented May 13, 2014

Although file associations and icons work, the projects don't actually open when double clicked (they open to a blank project) suggesting I've missed something. Re-opening.

@eagles051387 If you figure something out please let me know. The projects launch LMMS but always open to a blank project.

@eagles051387
Contributor

I think the biggest question is are the saved files empty ones or have
content in them.

On Tue, May 13, 2014 at 5:37 AM, Tres Finocchiaro
notifications@github.comwrote:

Although file associations and icons work, the projects don't actually
open when double clicked (they open to a blank project) suggesting I've
missed something. Re-opening.

@eagles051387 https://github.com/eagles051387 If you figure something
out please let me know. The projects launch LMMS but always open to a blank
project.


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42914092
.

Jonathan Aquilina

@tresf
Member
tresf commented May 13, 2014

They have content in them. Next biggest question.

@eagles051387
Contributor

The only next logical thing i can think of at this stage is there is some
quirk in the way mac reads and loads the files. I would take a look at the
loading mechanism could it be we need some OS specific checks?

On Tue, May 13, 2014 at 7:28 AM, Tres Finocchiaro
notifications@github.comwrote:

They have content in them. Next biggest question.


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-42918534
.

Jonathan Aquilina

@tresf
Member
tresf commented May 13, 2014

No OS specific hacks should be need I would think as it works fine via command line, i.e.
$ /Applications/LMMS.app/Contents/MacOS/lmms test.mmpz

It does not work when double-clicking the file, suggesting it's our Info.plist association settings.

If you don't have time to look into this, just say so, I would prefer we don't keep going back and forth with speculation, it's a waste of time.

-Tres

@tresf
Member
tresf commented May 14, 2014

Ok, finally found the double-click support here:
http://doc.qt.digia.com/qq/qq12-mac-events.html

Coding this is a bit over my head. @tobydox, any interest? :)

@eagles051387
Contributor

Will see what I do on this when I get home
On 14 May 2014 07:32, "Tres Finocchiaro" notifications@github.com wrote:

Ok, finally found the double-click support here:
http://doc.qt.digia.com/qq/qq12-mac-events.html

Coding this is a bit over my head. @tobydox https://github.com/tobydox,
any interest? :)


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-43043828
.

@tobydox
Member
tobydox commented May 14, 2014

WTF? Why can't OS X simply behave like any other operating system, i.e. pass a file to be opened via command line?? Now we would have to add lots of quirky code for this stupid OS! Is there no setting to enforce a sane behaviour?

@eagles051387
Contributor

If you like Toby I can ask on irc about this as I am sure there is a
simpler way to get things done.

On Wed, May 14, 2014 at 3:07 PM, Tobias Doerffel
notifications@github.comwrote:

WTF? Why can't OS X simply behave like any other operating system, i.e.
pass a file to be opened via command line?? Now we would have to add lots
of quirky code for this stupid OS! Is there no setting to enforce a sane
behaviour?


Reply to this email directly or view it on GitHubhttps://github.com/LMMS/lmms/issues/665#issuecomment-43077380
.

Jonathan Aquilina

@tresf
Member
tresf commented May 14, 2014

WTF? Why can't OS X simply behave like any other operating system, i.e. pass a file to be opened via command line?? Now we would have to add lots of quirky code for this stupid OS! Is there no setting to enforce a sane behaviour?

Agreed. What's rather frustrating is that it works fine via command line LMMS.app/Contents/MacOS/lmms myproject.mmpz.

To add insult to injury, the open command (simulates the double-click) supports the --args switch [link] which opens the mmpz files fine, but I can't find documentation on making this behavior default for double-clicked items.

Since software such as VLC and KeyPassX have this support built-in, observing their main() functions might shed some more light on this.

Edit:

Take a look at how KeyPassX is doing this:
https://www.keepassx.org/dev/projects/keepassx/repository/revisions/master/entry/src/main.cpp#L77 which looks much simpler than the example QT provides.

-Tres

@tresf
Member
tresf commented May 17, 2014

I had linked the wrong source code for KeyPassX. Here is the code which handles the OSX open event:
https://www.keepassx.org/dev/projects/keepassx/repository/revisions/master/entry/src/gui/Application.cpp

-Tres

@tobydox
Member
tobydox commented May 17, 2014

Looks much simpler/better and I could live with that. Feel free to provide a patch :-)

@tresf
Member
tresf commented May 17, 2014

Thanks for the feedback. I'll take a swing at it. Disclaimer... I don't
know CPP. :)

@eagles051387
Contributor

I am seeing this has been reopened again is this still an issue?

@tresf
Member
tresf commented Sep 6, 2014

Yes, read the history please.

@eagles051387 eagles051387 self-assigned this Sep 6, 2014
@tresf tresf added the bug label Sep 8, 2014
@tresf tresf added this to the 1.2.0 milestone Sep 8, 2014
@tresf
Member
tresf commented Sep 8, 2014

@eagles051387 Please note, the icons show up and association works (lmms launches) the issue now is that we need a custom C++ class to listen for the file-name and process accordingly. If you don't have intentions of writing some C++ code, please unassign yourself. 👙

@DeRobyJ
Contributor
DeRobyJ commented Dec 24, 2014

On the changelog for 1.1, "Saved projects open to a blank project every time on Apple (Please see bug #665)" is written.
When I first read it, I tought that you couldn't open saved project with LMMS .-.

@tresf
Member
tresf commented Dec 24, 2014

On the changelog for 1.1, "Saved projects open to a blank project every time on Apple (Please see bug #665)" is written.
When I first read it, I tought that you couldn't open saved project with LMMS .-.

Thanks. Changed wording to:

Projects open to a blank project every time when opened from Finder or Desktop (Please see bug #665)

👍

@tresf tresf modified the milestone: 1.3.0, 1.2.0 Mar 8, 2015
@eagles051387 eagles051387 was unassigned by Umcaruje Jun 29, 2015
@tresf tresf added a commit to tresf/lmms that referenced this issue Jan 8, 2017
@tresf tresf Fix opening of project files on macOS
Per #665
7e414d4
@tresf tresf added a commit to tresf/lmms that referenced this issue Jan 8, 2017
@tresf tresf Fix opening of project files on macOS
Per #665
91a4851
@tresf tresf added a commit to tresf/lmms that referenced this issue Jan 8, 2017
@tresf tresf Fix opening of project files on macOS
Per #665
50e8001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment