static gboolean libnotify_notify_new (const char *title, const char *text, GtkStatusIcon *icon) { void *noti; if (!nn_mod) { nn_mod = g_module_open ("libnotify", G_MODULE_BIND_LAZY); if (!nn_mod) { nn_mod = g_module_open ("libnotify.so.1", G_MODULE_BIND_LAZY); if (!nn_mod) return FALSE; } if (!g_module_symbol (nn_mod, "notify_init", (gpointer)&nn_init)) goto bad; if (!g_module_symbol (nn_mod, "notify_uninit", (gpointer)&nn_uninit)) goto bad; if (!g_module_symbol (nn_mod, "notify_notification_new_with_status_icon", (gpointer)&nn_new_with_status_icon)) goto bad; if (!g_module_symbol (nn_mod, "notify_notification_new", (gpointer)&nn_new)) goto bad; if (!g_module_symbol (nn_mod, "notify_notification_show", (gpointer)&nn_show)) goto bad; if (!g_module_symbol (nn_mod, "notify_notification_set_timeout", (gpointer)&nn_set_timeout)) goto bad; if (!nn_init (PACKAGE_NAME)) goto bad; } text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP); title = strip_color (title, -1, STRIP_ALL); noti = nn_new (title, text, XCHATSHAREDIR"/pixmaps/xchat.png", NULL); g_free ((char *)title); g_free ((char *)text); nn_set_timeout (noti, prefs.input_balloon_time*1000); nn_show (noti, NULL); g_object_unref (G_OBJECT (noti)); return TRUE; bad: g_module_close (nn_mod); nn_mod = NULL; return FALSE; }
void RemoveApplication(nsINIParser& parser, const char* curExeDir, const char* profile) { if (!isProfileOverridden) { // Remove the desktop entry file. char desktopEntryFilePath[MAXPATHLEN]; char* dataDir = getenv("XDG_DATA_HOME"); if (dataDir && *dataDir) { snprintf(desktopEntryFilePath, MAXPATHLEN, "%s/applications/owa-%s.desktop", dataDir, profile); } else { char* home = getenv("HOME"); snprintf(desktopEntryFilePath, MAXPATHLEN, "%s/.local/share/applications/owa-%s.desktop", home, profile); } unlink(desktopEntryFilePath); } // Remove the files from the installation directory. char webAppIniPath[MAXPATHLEN]; snprintf(webAppIniPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_INI); unlink(webAppIniPath); char curExePath[MAXPATHLEN]; snprintf(curExePath, MAXPATHLEN, "%s/%s", curExeDir, kAPP_RT); unlink(curExePath); char webAppJsonPath[MAXPATHLEN]; snprintf(webAppJsonPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_JSON); unlink(webAppJsonPath); 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)(const char*); typedef void* (*notify_notification_new_t)(const char*, const char*, const char*, const char*); typedef void (*notify_notification_show_t)(void*, void**); 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)(uintptr_t)dlsym(handle, "notify_init"); notify_notification_new_t nn_new = (notify_notification_new_t)(uintptr_t)dlsym(handle, "notify_notification_new"); notify_notification_show_t nn_show = (notify_notification_show_t)(uintptr_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); } }