[4/10] winemenubuilder: Create appbundle dispatch empty shell.

Per Johansson per at morth.org
Sun Mar 17 12:18:36 CDT 2013


---
 programs/winemenubuilder/Makefile.in       |   2 +
 programs/winemenubuilder/appbundle.c       | 130 +++++++++++++++++++++++++++++
 programs/winemenubuilder/winemenubuilder.c |  16 ++++
 3 files changed, 148 insertions(+)
 create mode 100644 programs/winemenubuilder/appbundle.c

diff --git a/programs/winemenubuilder/Makefile.in b/programs/winemenubuilder/Makefile.in
index fd68ae2..36f7de0 100644
--- a/programs/winemenubuilder/Makefile.in
+++ b/programs/winemenubuilder/Makefile.in
@@ -1,8 +1,10 @@
 MODULE    = winemenubuilder.exe
 APPMODE   = -mwindows -municode
 IMPORTS   = uuid windowscodecs shell32 shlwapi ole32 user32 advapi32
+EXTRALIBS = @COREFOUNDATIONLIB@ @APPLICATIONSERVICESLIB@
 
 C_SRCS = \
+	appbundle.c \
 	winemenubuilder.c \
 	xdg.c
 
diff --git a/programs/winemenubuilder/appbundle.c b/programs/winemenubuilder/appbundle.c
new file mode 100644
index 0000000..c431976
--- /dev/null
+++ b/programs/winemenubuilder/appbundle.c
@@ -0,0 +1,130 @@
+/*
+ * Winemenubuilder support for Mac OS X Application Bundles
+ *
+ * Copyright 2011 Steven Edwards
+ * Copyright 2011 - 2013 Per Johansson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ *
+ * NOTES: An Application Bundle generally has the following layout
+ *
+ * foo.app/Contents
+ * foo.app/Contents/Info.plist
+ * foo.app/Contents/MacOS/foo (can be script or real binary)
+ * foo.app/Contents/Resources/appIcon.icns (Apple Icon format)
+ * foo.app/Contents/Resources/English.lproj/infoPlist.strings
+ *
+ * There can be more to a bundle depending on the target, what resources
+ * it contains and what the target platform but this simplifed format
+ * is all we really need for now for Wine.
+ */
+
+#ifdef __APPLE__
+
+#include "config.h"
+#include "wine/port.h"
+
+#define COBJMACROS
+#define NONAMELESSUNION
+
+#include <windows.h>
+#include <shlobj.h>
+#include <objidl.h>
+#include <shlguid.h>
+#include <appmgmt.h>
+#include <tlhelp32.h>
+#include <intshcut.h>
+#include <shlwapi.h>
+
+#include "wine/debug.h"
+#include "wine/library.h"
+
+#include "winemenubuilder.h"
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(menubuilder);
+
+extern HRESULT osx_write_icon(IStream *icoStream, int exeIndex, LPCWSTR icoPathW,
+                                   const char *destFilename, char **nativeIdentifier);
+
+int appbundle_build_desktop_link(const char *unix_link, const char *link, const char *link_name, const char *path,
+        const char *args, const char *descr, const char *workdir, char *icon)
+{
+    return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+int appbundle_build_menu_link(const char *unix_link, const char *link, const char *link_name, const char *path,
+        const char *args, const char *descr, const char *workdir, char *icon)
+{
+    return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+void *appbundle_refresh_file_type_associations_init(void)
+{
+    static int ok;
+
+    return &ok;
+}
+
+BOOL appbundle_mime_type_for_extension(void *user, const char *extensionA, LPCWSTR extensionW, char **mime_type)
+{
+    return FALSE;
+}
+
+BOOL appbundle_write_mime_type_entry(void *user, const char *extensionA, const char *mimeTypeA, const char *friendlyDocNameA)
+{
+    return FALSE;
+}
+
+BOOL appbundle_write_association_entry(void *user, const char *extensionA, const char *friendlyAppNameA,
+        const char *friendlyDocNameA, const char *mimeTypeA, const char *progIdA,
+        const char *appIconA)
+{
+    return FALSE;
+}
+
+BOOL appbundle_remove_file_type_association(void *user, const char *extensionA, LPCWSTR extensionW)
+{
+    return FALSE;
+}
+
+void appbundle_refresh_file_type_associations_cleanup(void *user, BOOL hasChanged)
+{
+}
+
+BOOL appbundle_init(void)
+{
+    return TRUE;
+}
+
+const struct winemenubuilder_dispatch appbundle_dispatch =
+{
+    appbundle_init,
+
+    appbundle_build_desktop_link,
+    appbundle_build_menu_link,
+
+    osx_write_icon,
+
+    appbundle_refresh_file_type_associations_init,
+    appbundle_mime_type_for_extension,
+    appbundle_write_mime_type_entry,
+    appbundle_write_association_entry,
+    appbundle_remove_file_type_association,
+    appbundle_refresh_file_type_associations_cleanup
+};
+
+#endif
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 364945e..bc1bae3 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -2824,6 +2824,9 @@ static BOOL dispatch_init(void)
     unsigned char buffer[256];
     HKEY hkey;
     extern const struct winemenubuilder_dispatch xdg_dispatch;
+#ifdef __APPLE__
+    extern const struct winemenubuilder_dispatch appbundle_dispatch;
+#endif
 
     if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\MenuBuilder", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
     {
@@ -2848,6 +2851,14 @@ static BOOL dispatch_init(void)
         if (strcmp(dispatch, "none") == 0)
             return FALSE;
 
+#ifdef __APPLE__
+        if (strcmp(dispatch, "appbundle") == 0)
+        {
+            wmb_dispatch = &appbundle_dispatch;
+            return TRUE;
+        }
+#endif
+
         if (strcmp(dispatch, "xdg") == 0)
         {
             wmb_dispatch = &xdg_dispatch;
@@ -2857,8 +2868,13 @@ static BOOL dispatch_init(void)
         WINE_WARN("Unknown Wine MenuBuilder Dispatch \"%s\"\n", dispatch);
     }
 
+#ifdef __APPLE__
+    wmb_dispatch = &appbundle_dispatch;
+    WINE_TRACE("Dispatch set to appbundle by default\n");
+#else
     wmb_dispatch = &xdg_dispatch;
     WINE_TRACE("Dispatch set to xdg by default\n");
+#endif
     return TRUE;
 }
 
-- 
1.8.0.2




More information about the wine-patches mailing list