+#if MOZ_GIO_VERSION >= 220 + // For Glib >= 2.20 we can get commandline: + const char *cmd = g_app_info_get_commandline(mApp);
So if you build with Glib > 2.20, your build won't run on anything less than 2.20? That seems bad. Seems like we should do the dlsym dance here.
+nsGIOService::GetMimeTypeFromExtension(const nsACString &aExtension, + nsACString& aMimeType)
Please be consistent, I suggest nsACString&.
+ char *content_type = g_content_type_guess(fileExtToUse.get(), + NULL, + 0, + &result_uncertain); + if (!content_type) + return NS_ERROR_FAILURE; + + char *mime_type = g_content_type_get_mime_type(content_type); + if (!mime_type) + return NS_ERROR_FAILURE;
You leak content_type if mime_type is null.
+nsGIOService::GetAppForMimeType(const nsACString &aMimeType, + nsIGIOMimeApp** aApp)
Unnecessary whitespace.
+ if (app_info) { + nsGIOMimeApp *mozApp = new nsGIOMimeApp(app_info); + NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(*aApp = mozApp); + } else { + return NS_ERROR_FAILURE; + } + g_free(content_type);
You leak content_type if app_info is null.
+ char *content_type = + g_content_type_from_mime_type(PromiseFlatCString(aMimeType).get()); + if (!content_type) + return NS_ERROR_FAILURE; + + char *desc = g_content_type_get_description(content_type); + if (!desc) + return NS_ERROR_FAILURE;
You leak content_type if desc is null.
+ if (file) + g_object_unref(file); + if (spec) + g_free(spec);
Are these functions not null-safe?
+nsGIOService::CreateAppFromCommand(nsACString const &cmd, + nsACString const &appName,
Unnecessary whitespace
+#if MOZ_GIO_VERSION >= 220 + // For Glib >= 2.20 we can compare commandline: + if (strcmp(g_app_info_get_commandline(app_info_from_list), + PromiseFlatCString(cmd).get()) == 0)
Again, it doesn't seem good to not run on glib < 2.20
Otherwise the patch looks good, modulo the issues about dependencies.
This would be a lot easier to take if we could at least support both GVFS and GIO in our source tree for an interim period.
+#if MOZ_GIO_VERSION >= 220 get_commandline (mApp);
+ // For Glib >= 2.20 we can get commandline:
+ const char *cmd = g_app_info_
So if you build with Glib > 2.20, your build won't run on anything less than 2.20? That seems bad. Seems like we should do the dlsym dance here.
+nsGIOService: :GetMimeTypeFro mExtension( const nsACString &aExtension,
+ nsACString& aMimeType)
Please be consistent, I suggest nsACString&.
+ char *content_type = g_content_ type_guess( fileExtToUse. get(), type_get_ mime_type( content_ type);
+ NULL,
+ 0,
+ &result_uncertain);
+ if (!content_type)
+ return NS_ERROR_FAILURE;
+
+ char *mime_type = g_content_
+ if (!mime_type)
+ return NS_ERROR_FAILURE;
You leak content_type if mime_type is null.
+nsGIOService: :GetAppForMimeT ype(const nsACString &aMimeType,
+ nsIGIOMimeApp** aApp)
Unnecessary whitespace.
+ if (app_info) { app_info) ; TRUE(mozApp, NS_ERROR_ OUT_OF_ MEMORY) ; content_ type);
+ nsGIOMimeApp *mozApp = new nsGIOMimeApp(
+ NS_ENSURE_
+ NS_ADDREF(*aApp = mozApp);
+ } else {
+ return NS_ERROR_FAILURE;
+ }
+ g_free(
You leak content_type if app_info is null.
+ char *content_type = type_from_ mime_type( PromiseFlatCStr ing(aMimeType) .get()) ; type_get_ description( content_ type);
+ g_content_
+ if (!content_type)
+ return NS_ERROR_FAILURE;
+
+ char *desc = g_content_
+ if (!desc)
+ return NS_ERROR_FAILURE;
You leak content_type if desc is null.
+ if (file) unref(file) ;
+ g_object_
+ if (spec)
+ g_free(spec);
Are these functions not null-safe?
+nsGIOService: :CreateAppFromC ommand( nsACString const &cmd,
+ nsACString const &appName,
Unnecessary whitespace
+#if MOZ_GIO_VERSION >= 220 g_app_info_ get_commandline (app_info_ from_list) , ing(cmd) .get()) == 0)
+ // For Glib >= 2.20 we can compare commandline:
+ if (strcmp(
+ PromiseFlatCStr
Again, it doesn't seem good to not run on glib < 2.20
Otherwise the patch looks good, modulo the issues about dependencies.
This would be a lot easier to take if we could at least support both GVFS and GIO in our source tree for an interim period.