Mercurial > pidgin.yaz
changeset 4281:d956ac6157cd
[gaim-migrate @ 4532]
(17:42:36) Robot101: this patch sets up a function we'll need for
session management in the future, which also fixes the bug with the
-f/--file option not being retained for subsequent instances of
Gaim (either when cloning or logging in again), and replaces the
'discard' command with /bin/true for the moment.
(17:43:56) Robot101: thanks to Nicol?s Lichtmaier for pointing this
out and inspiring me, also in my last patch he spotted the current
directory wasn't being stored
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 10 Jan 2003 22:45:53 +0000 |
parents | 57ab8f0a4263 |
children | aa20cc16dc08 |
files | src/session.c |
diffstat | 1 files changed, 38 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/session.c Fri Jan 10 22:41:04 2003 +0000 +++ b/src/session.c Fri Jan 10 22:45:53 2003 +0000 @@ -133,6 +133,34 @@ debug_printf("Session Management: ICE initialised\n"); } +/* my magic utility function */ + +static gchar **session_make_command(gchar *client_id) { + gint i = 2; + gint j = 0; + gchar **ret; + + if (client_id) i += 2; + if (opt_rcfile_arg) i += 2; + + ret = g_new(gchar *, i); + ret[j++] = g_strdup(myself); + + if (client_id) { + ret[j++] = g_strdup("--session"); + ret[j++] = g_strdup(client_id); + } + + if (opt_rcfile_arg) { + ret[j++] = g_strdup("--file"); + ret[j++] = g_strdup(opt_rcfile_arg); + } + + ret[j++] = NULL; + + return ret; +} + /* SM callback handlers */ void session_save_yourself(SmcConn conn, SmPointer data, int save_type, @@ -247,7 +275,7 @@ gchar *client_id = NULL; gchar error[ERROR_LENGTH] = ""; gchar *tmp = NULL; - gchar *cmd[4] = { NULL, NULL, NULL, NULL }; + gchar **cmd = NULL; if (session != NULL) { /* session is already established, what the hell is going on? */ @@ -312,21 +340,23 @@ myself = g_strdup(argv0); debug_printf("Session Management: using %s as command\n", myself); - cmd[0] = myself; - cmd[1] = NULL; + cmd = session_make_command(NULL); session_set_array(session, SmCloneCommand, cmd); + g_strfreev(cmd); /* this is currently useless, but gnome-session warns 'the following applications will not save their current status' bla bla if we don't have it and the user checks 'Save Session' when they log out */ - cmd[1] = "-v"; - cmd[2] = NULL; + cmd = g_new(gchar *, 2); + cmd[0] = g_strdup("/bin/true"); + cmd[1] = NULL; session_set_array(session, SmDiscardCommand, cmd); + g_strfreev(cmd); - cmd[1] = "--session"; - cmd[2] = client_id; - cmd[3] = NULL; + cmd = session_make_command(client_id); session_set_array(session, SmRestartCommand, cmd); + g_strfreev(cmd); + g_free(client_id); #endif /* USE_SM */ }