X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgwin32appinfo.c;h=f1697c8a19c9cdac08dd9591fb8d566a1678f82c;hb=51fac05d73f8363de821eb0d6940dedca13a8c0f;hp=cb0093f5651ae0050ed4ddffc201fb83aa27aac4;hpb=d85b722734a6fcfe94032f6113de9e5c190fd7c3;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
index cb0093f..f1697c8 100644
--- a/gio/gwin32appinfo.c
+++ b/gio/gwin32appinfo.c
@@ -13,9 +13,7 @@
* 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., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: Alexander Larsson
*/
@@ -24,7 +22,7 @@
#include
-#include "gcontenttypeprivate.h"
+#include "gcontenttype.h"
#include "gwin32appinfo.h"
#include "gappinfo.h"
#include "gioerror.h"
@@ -248,10 +246,10 @@ g_win32_app_info_get_icon (GAppInfo *appinfo)
}
static gboolean
-g_win32_app_info_launch (GAppInfo *appinfo,
- GList *files,
- GAppLaunchContext *launch_context,
- GError **error)
+g_win32_app_info_launch_locations (GAppInfo *appinfo,
+ GList *locations,
+ GAppLaunchContext *launch_context,
+ GError **error)
{
GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
#ifdef AssocQueryString
@@ -287,17 +285,14 @@ g_win32_app_info_launch (GAppInfo *appinfo,
* instead.
*/
- for (l = files; l != NULL; l = l->next)
+ for (l = locations; l != NULL; l = l->next)
{
- char *path = g_file_get_path (l->data);
- wchar_t *wfilename = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
-
- g_free (path);
+ wchar_t *wloc = g_utf8_to_utf16 (l->data, -1, NULL, NULL, NULL);
memset (&exec_info, 0, sizeof (exec_info));
exec_info.cbSize = sizeof (exec_info);
exec_info.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_CLASSKEY;
- exec_info.lpFile = wfilename;
+ exec_info.lpFile = wloc;
exec_info.nShow = SW_SHOWNORMAL;
exec_info.hkeyClass = class_key;
@@ -308,12 +303,12 @@ g_win32_app_info_launch (GAppInfo *appinfo,
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Error launching application: %s"), message_utf8);
g_free (message_utf8);
- g_free (wfilename);
+ g_free (wloc);
RegCloseKey (class_key);
return FALSE;
}
- g_free (wfilename);
+ g_free (wloc);
}
RegCloseKey (class_key);
@@ -324,7 +319,8 @@ g_win32_app_info_launch (GAppInfo *appinfo,
static gboolean
g_win32_app_info_supports_uris (GAppInfo *appinfo)
{
- return FALSE;
+ /* TODO: is there some way to determine this on windows? */
+ return TRUE;
}
static gboolean
@@ -334,15 +330,31 @@ g_win32_app_info_supports_files (GAppInfo *appinfo)
}
static gboolean
+g_win32_app_info_launch (GAppInfo *appinfo,
+ GList *files,
+ GAppLaunchContext *launch_context,
+ GError **error)
+{
+ gboolean success;
+ GList *paths = g_list_copy_deep (files, (GCopyFunc) g_file_get_path,
+ NULL);
+
+ success = g_win32_app_info_launch_locations (appinfo, paths,
+ launch_context, error);
+
+ g_list_free_full (paths, g_free);
+
+ return success;
+}
+
+static gboolean
g_win32_app_info_launch_uris (GAppInfo *appinfo,
GList *uris,
GAppLaunchContext *launch_context,
GError **error)
{
- g_set_error_literal (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("URIs not supported"));
- return FALSE;
+ return g_win32_app_info_launch_locations (appinfo, uris,
+ launch_context, error);
}
static gboolean
@@ -618,15 +630,19 @@ g_app_info_get_fallback_for_type (const char *content_type)
return g_app_info_get_all_for_type (content_type);
}
-GAppInfo *
-g_app_info_get_default_for_type (const char *content_type,
- gboolean must_support_uris)
+/*
+ * The windows api (AssocQueryString) doesn't distinguish between uri schemes
+ * and file type extensions here, so we use the same implementation for both
+ * g_app_info_get_default_for_type and g_app_info_get_default_for_uri_scheme
+ */
+static GAppInfo *
+get_default_for_association (const char *association)
{
wchar_t *wtype;
wchar_t buffer[1024];
DWORD buffer_size;
- wtype = g_utf8_to_utf16 (content_type, -1, NULL, NULL, NULL);
+ wtype = g_utf8_to_utf16 (association, -1, NULL, NULL, NULL);
/* Verify that we have some sort of app registered for this type */
#ifdef AssocQueryString
@@ -646,10 +662,16 @@ g_app_info_get_default_for_type (const char *content_type,
}
GAppInfo *
+g_app_info_get_default_for_type (const char *content_type,
+ gboolean must_support_uris)
+{
+ return get_default_for_association (content_type);
+}
+
+GAppInfo *
g_app_info_get_default_for_uri_scheme (const char *uri_scheme)
{
- /* TODO: Implement */
- return NULL;
+ return get_default_for_association (uri_scheme);
}
GList *