Mercurial > pidgin
comparison src/session.c @ 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 | 65a859488240 |
children | 96a2a6c9affc |
comparison
equal
deleted
inserted
replaced
4280:57ab8f0a4263 | 4281:d956ac6157cd |
---|---|
129 ice_installed_io_error_handler = NULL; | 129 ice_installed_io_error_handler = NULL; |
130 | 130 |
131 IceAddConnectionWatch(ice_connection_watch, NULL); | 131 IceAddConnectionWatch(ice_connection_watch, NULL); |
132 | 132 |
133 debug_printf("Session Management: ICE initialised\n"); | 133 debug_printf("Session Management: ICE initialised\n"); |
134 } | |
135 | |
136 /* my magic utility function */ | |
137 | |
138 static gchar **session_make_command(gchar *client_id) { | |
139 gint i = 2; | |
140 gint j = 0; | |
141 gchar **ret; | |
142 | |
143 if (client_id) i += 2; | |
144 if (opt_rcfile_arg) i += 2; | |
145 | |
146 ret = g_new(gchar *, i); | |
147 ret[j++] = g_strdup(myself); | |
148 | |
149 if (client_id) { | |
150 ret[j++] = g_strdup("--session"); | |
151 ret[j++] = g_strdup(client_id); | |
152 } | |
153 | |
154 if (opt_rcfile_arg) { | |
155 ret[j++] = g_strdup("--file"); | |
156 ret[j++] = g_strdup(opt_rcfile_arg); | |
157 } | |
158 | |
159 ret[j++] = NULL; | |
160 | |
161 return ret; | |
134 } | 162 } |
135 | 163 |
136 /* SM callback handlers */ | 164 /* SM callback handlers */ |
137 | 165 |
138 void session_save_yourself(SmcConn conn, SmPointer data, int save_type, | 166 void session_save_yourself(SmcConn conn, SmPointer data, int save_type, |
245 #ifdef USE_SM | 273 #ifdef USE_SM |
246 SmcCallbacks callbacks; | 274 SmcCallbacks callbacks; |
247 gchar *client_id = NULL; | 275 gchar *client_id = NULL; |
248 gchar error[ERROR_LENGTH] = ""; | 276 gchar error[ERROR_LENGTH] = ""; |
249 gchar *tmp = NULL; | 277 gchar *tmp = NULL; |
250 gchar *cmd[4] = { NULL, NULL, NULL, NULL }; | 278 gchar **cmd = NULL; |
251 | 279 |
252 if (session != NULL) { | 280 if (session != NULL) { |
253 /* session is already established, what the hell is going on? */ | 281 /* session is already established, what the hell is going on? */ |
254 debug_printf("Session Management: duplicated call to session_init!\n"); | 282 debug_printf("Session Management: duplicated call to session_init!\n"); |
255 return; | 283 return; |
310 session_set_string(session, SmProgram, g_get_prgname()); | 338 session_set_string(session, SmProgram, g_get_prgname()); |
311 | 339 |
312 myself = g_strdup(argv0); | 340 myself = g_strdup(argv0); |
313 debug_printf("Session Management: using %s as command\n", myself); | 341 debug_printf("Session Management: using %s as command\n", myself); |
314 | 342 |
315 cmd[0] = myself; | 343 cmd = session_make_command(NULL); |
316 cmd[1] = NULL; | |
317 session_set_array(session, SmCloneCommand, cmd); | 344 session_set_array(session, SmCloneCommand, cmd); |
345 g_strfreev(cmd); | |
318 | 346 |
319 /* this is currently useless, but gnome-session warns 'the following applications will not | 347 /* this is currently useless, but gnome-session warns 'the following applications will not |
320 save their current status' bla bla if we don't have it and the user checks 'Save Session' | 348 save their current status' bla bla if we don't have it and the user checks 'Save Session' |
321 when they log out */ | 349 when they log out */ |
322 cmd[1] = "-v"; | 350 cmd = g_new(gchar *, 2); |
323 cmd[2] = NULL; | 351 cmd[0] = g_strdup("/bin/true"); |
352 cmd[1] = NULL; | |
324 session_set_array(session, SmDiscardCommand, cmd); | 353 session_set_array(session, SmDiscardCommand, cmd); |
325 | 354 g_strfreev(cmd); |
326 cmd[1] = "--session"; | 355 |
327 cmd[2] = client_id; | 356 cmd = session_make_command(client_id); |
328 cmd[3] = NULL; | |
329 session_set_array(session, SmRestartCommand, cmd); | 357 session_set_array(session, SmRestartCommand, cmd); |
358 g_strfreev(cmd); | |
359 | |
330 g_free(client_id); | 360 g_free(client_id); |
331 #endif /* USE_SM */ | 361 #endif /* USE_SM */ |
332 } | 362 } |
333 | 363 |
334 void session_end() { | 364 void session_end() { |