MozillaThunderbird/mozilla-xsmp.patch

193 lines
7.2 KiB
Diff
Raw Normal View History

From: Wolfgang Rosenauer <wr@rosenauer.org>
Subject: XSMP restore doesn't work for Thunderbird
References:
https://bugzilla.mozilla.org/show_bug.cgi?id=508986
https://bugzilla.novell.com/show_bug.cgi?id=528406
diff --git a/toolkit/xre/nsNativeAppSupportUnix.cpp b/toolkit/xre/nsNativeAppSupportUnix.cpp
--- a/toolkit/xre/nsNativeAppSupportUnix.cpp
+++ b/toolkit/xre/nsNativeAppSupportUnix.cpp
@@ -89,108 +89,52 @@ typedef enum {
GNOME_DIALOG_NORMAL
} GnomeDialogType;
typedef GnomeProgram * (*_gnome_program_init_fn)(const char *, const char *,
const GnomeModuleInfo *, int,
char **, const char *, ...);
typedef const GnomeModuleInfo * (*_libgnomeui_module_info_get_fn)();
typedef GnomeClient * (*_gnome_master_client_fn)(void);
-typedef void (*GnomeInteractFunction)(GnomeClient *, gint, GnomeDialogType,
- gpointer);
-typedef void (*_gnome_client_request_interaction_fn)(GnomeClient *,
- GnomeDialogType,
- GnomeInteractFunction,
- gpointer);
-typedef void (*_gnome_interaction_key_return_fn)(gint, gboolean);
typedef void (*_gnome_client_set_restart_command_fn)(GnomeClient*, gint, gchar*[]);
-static _gnome_client_request_interaction_fn gnome_client_request_interaction;
-static _gnome_interaction_key_return_fn gnome_interaction_key_return;
static _gnome_client_set_restart_command_fn gnome_client_set_restart_command;
-void interact_cb(GnomeClient *client, gint key,
- GnomeDialogType type, gpointer data)
-{
- nsCOMPtr<nsIObserverService> obsServ =
- do_GetService("@mozilla.org/observer-service;1");
- nsCOMPtr<nsISupportsPRBool> cancelQuit =
- do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
-
- cancelQuit->SetData(PR_FALSE);
-
- obsServ->NotifyObservers(cancelQuit, "quit-application-requested", nsnull);
-
- PRBool abortQuit;
- cancelQuit->GetData(&abortQuit);
-
- gnome_interaction_key_return(key, abortQuit);
-}
-
gboolean save_yourself_cb(GnomeClient *client, gint phase,
GnomeSaveStyle style, gboolean shutdown,
GnomeInteractStyle interact, gboolean fast,
gpointer user_data)
{
- if (!shutdown)
- return TRUE;
-
nsCOMPtr<nsIObserverService> obsServ =
do_GetService("@mozilla.org/observer-service;1");
nsCOMPtr<nsISupportsPRBool> didSaveSession =
do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
if (!obsServ || !didSaveSession)
return TRUE; // OOM
+ // Notify observers to save the session state
didSaveSession->SetData(PR_FALSE);
obsServ->NotifyObservers(didSaveSession, "session-save", nsnull);
PRBool status;
didSaveSession->GetData(&status);
- // Didn't save, or no way of saving. So signal for quit-application.
- if (!status) {
- if (interact == GNOME_INTERACT_ANY)
- gnome_client_request_interaction(client, GNOME_DIALOG_NORMAL,
- interact_cb, nsnull);
- return TRUE;
- }
-
- // Is there a request to suppress default binary launcher?
- char* argv1 = getenv("MOZ_APP_LAUNCHER");
+ // If there was no session saved and the save_yourself request is
+ // caused by upcoming shutdown we like to prepare for it
+ if (!status && shutdown) {
+ nsCOMPtr<nsISupportsPRBool> cancelQuit =
+ do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
- if(!argv1) {
- // Tell GNOME the command for restarting us so that we can be part of XSMP session restore
- NS_ASSERTION(gDirServiceProvider, "gDirServiceProvider is NULL! This shouldn't happen!");
- nsCOMPtr<nsIFile> executablePath;
- nsresult rv;
+ cancelQuit->SetData(PR_FALSE);
+ obsServ->NotifyObservers(cancelQuit, "quit-application-requested", nsnull);
- PRBool dummy;
- rv = gDirServiceProvider->GetFile(XRE_EXECUTABLE_FILE, &dummy, getter_AddRefs(executablePath));
-
- if (NS_SUCCEEDED(rv)) {
- nsCAutoString path;
-
- // Strip off the -bin suffix to get the shell script we should run; this is what Breakpad does
- nsCAutoString leafName;
- rv = executablePath->GetNativeLeafName(leafName);
- if (NS_SUCCEEDED(rv) && StringEndsWith(leafName, NS_LITERAL_CSTRING("-bin"))) {
- leafName.SetLength(leafName.Length() - strlen("-bin"));
- executablePath->SetNativeLeafName(leafName);
- }
-
- executablePath->GetNativePath(path);
- argv1 = (char*)(path.get());
- }
- }
-
- if(argv1) {
- gnome_client_set_restart_command(client, 1, &argv1);
+ PRBool abortQuit;
+ cancelQuit->GetData(&abortQuit);
}
return TRUE;
}
void die_cb(GnomeClient *client, gpointer user_data)
{
nsCOMPtr<nsIAppStartup> appService =
@@ -383,29 +327,59 @@ nsNativeAppSupportUnix::Start(PRBool *aR
}
#endif
// Careful! These libraries cannot be unloaded after this point because
// gnome_program_init causes atexit handlers to be registered. Strange
// crashes will occur if these libraries are unloaded.
#ifdef MOZ_X11
- gnome_client_request_interaction = (_gnome_client_request_interaction_fn)
- PR_FindFunctionSymbol(gnomeuiLib, "gnome_client_request_interaction");
- gnome_interaction_key_return = (_gnome_interaction_key_return_fn)
- PR_FindFunctionSymbol(gnomeuiLib, "gnome_interaction_key_return");
gnome_client_set_restart_command = (_gnome_client_set_restart_command_fn)
PR_FindFunctionSymbol(gnomeuiLib, "gnome_client_set_restart_command");
_gnome_master_client_fn gnome_master_client = (_gnome_master_client_fn)
PR_FindFunctionSymbol(gnomeuiLib, "gnome_master_client");
GnomeClient *client = gnome_master_client();
g_signal_connect(client, "save-yourself", G_CALLBACK(save_yourself_cb), NULL);
g_signal_connect(client, "die", G_CALLBACK(die_cb), NULL);
+
+ // Set the correct/requested restart command in any case.
+
+ // Is there a request to suppress default binary launcher?
+ char* argv1 = getenv("MOZ_APP_LAUNCHER");
+
+ if(!argv1) {
+ // Tell the desktop the command for restarting us so that we can be part of XSMP session restore
+ NS_ASSERTION(gDirServiceProvider, "gDirServiceProvider is NULL! This shouldn't happen!");
+ nsCOMPtr<nsIFile> executablePath;
+ nsresult rv;
+
+ PRBool dummy;
+ rv = gDirServiceProvider->GetFile(XRE_EXECUTABLE_FILE, &dummy, getter_AddRefs(executablePath));
+
+ if (NS_SUCCEEDED(rv)) {
+ nsCAutoString path;
+
+ // Strip off the -bin suffix to get the shell script we should run; this is what Breakpad does
+ nsCAutoString leafName;
+ rv = executablePath->GetNativeLeafName(leafName);
+ if (NS_SUCCEEDED(rv) && StringEndsWith(leafName, NS_LITERAL_CSTRING("-bin"))) {
+ leafName.SetLength(leafName.Length() - strlen("-bin"));
+ executablePath->SetNativeLeafName(leafName);
+ }
+
+ executablePath->GetNativePath(path);
+ argv1 = (char*)(path.get());
+ }
+ }
+
+ if (argv1) {
+ gnome_client_set_restart_command(client, 1, &argv1);
+ }
#endif /* MOZ_X11 */
return NS_OK;
}
NS_IMETHODIMP
nsNativeAppSupportUnix::Stop( PRBool *aResult )
{