Bug 780530 - Notification after webapp uninstallation. r=mhommey

This commit is contained in:
Marco Castelluccio 2012-08-18 08:25:48 -04:00
parent f339e39c43
commit e04562f81c
3 changed files with 49 additions and 2 deletions

View File

@ -358,6 +358,8 @@ webapps.install.accesskey = I
#LOCALIZATION NOTE (webapps.requestInstall) %1$S is the web app name, %2$S is the site from which the web app is installed
webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)?
webapps.install.success = Application Installed
# LOCALIZATION NOTE (webapps.uninstall.notification): %S will be replaced with the name of the uninstalled web app
webapps.uninstall.notification = %S has been uninstalled from your computer.
# Telemetry opt-out prompt for Aurora and Nightly
# LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by

View File

@ -801,10 +801,13 @@ LinuxNativeApp.prototype = {
let factory = Cc["@mozilla.org/xpcom/ini-processor-factory;1"]
.getService(Ci.nsIINIParserFactory);
let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
// ${InstallDir}/webapp.ini
let writer = factory.createINIParser(this.webappINI).QueryInterface(Ci.nsIINIParserWriter);
writer.setString("Webapp", "Name", this.appName);
writer.setString("Webapp", "Profile", this.uniqueName);
writer.setString("Webapp", "UninstallMsg", browserBundle.formatStringFromName("webapps.uninstall.notification", [this.appName], 1));
writer.setString("WebappRT", "InstallDir", this.runtimeFolder.path);
writer.writeFile();

View File

@ -10,6 +10,7 @@
// Linux headers
#include <fcntl.h>
#include <unistd.h>
#include <dlfcn.h>
// Mozilla headers
#include "nsIFile.h"
@ -224,7 +225,7 @@ void CopyAndRelaunch(const char* firefoxDir, const char* curExePath)
ErrorDialog("Couldn't execute the new webapprt-stub executable");
}
void RemoveApplication(const char* curExeDir, const char* profile) {
void RemoveApplication(nsINIParser& parser, const char* curExeDir, const char* profile) {
if (!isProfileOverridden) {
// Remove the desktop entry file.
char desktopEntryFilePath[MAXPATHLEN];
@ -257,6 +258,47 @@ void RemoveApplication(const char* curExeDir, const char* profile) {
char iconPath[MAXPATHLEN];
snprintf(iconPath, MAXPATHLEN, "%s/icon.png", curExeDir);
unlink(iconPath);
char appName[MAXPATHLEN];
if (NS_FAILED(parser.GetString("Webapp", "Name", appName, MAXPATHLEN))) {
strcpy(appName, profile);
}
char uninstallMsg[MAXPATHLEN];
if (NS_SUCCEEDED(parser.GetString("Webapp", "UninstallMsg", uninstallMsg, MAXPATHLEN))) {
/**
* The only difference between libnotify.so.4 and libnotify.so.1 for these symbols
* is that notify_notification_new takes three arguments in libnotify.so.4 and
* four in libnotify.so.1.
* Passing the fourth argument as NULL is binary compatible.
*/
typedef void (*notify_init_t)(char*);
typedef void* (*notify_notification_new_t)(char*, char*, char*, char*);
typedef void (*notify_notification_show_t)(void*, char*);
void *handle = dlopen("libnotify.so.4", RTLD_LAZY);
if (!handle) {
handle = dlopen("libnotify.so.1", RTLD_LAZY);
if (!handle)
return;
}
notify_init_t nn_init = (notify_init_t)dlsym(handle, "notify_init");
notify_notification_new_t nn_new = (notify_notification_new_t)dlsym(handle, "notify_notification_new");
notify_notification_show_t nn_show = (notify_notification_show_t)dlsym(handle, "notify_notification_show");
if (!nn_init || !nn_new || !nn_show) {
dlclose(handle);
return;
}
nn_init(appName);
void* n = nn_new(uninstallMsg, NULL, "dialog-information", NULL);
nn_show(n, NULL);
dlclose(handle);
}
}
int main(int argc, char *argv[])
@ -319,7 +361,7 @@ int main(int argc, char *argv[])
}
if (removeApp) {
RemoveApplication(curExeDir, profile);
RemoveApplication(parser, curExeDir, profile);
return 0;
}