Mercurial > pidgin
annotate src/session.c @ 8277:e6ed38d28636
[gaim-migrate @ 9001]
"Wintry" really seems like it should be "Wintery," to me.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Tue, 17 Feb 2004 04:46:53 +0000 |
| parents | f24172f53650 |
| children | 084ed9f7ac19 |
| rev | line source |
|---|---|
| 4158 | 1 /* |
| 2 * session management for Gaim | |
| 3 * | |
| 8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 * source distribution. | |
| 4158 | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 * | |
| 22 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
23 #include "internal.h" |
| 4158 | 24 |
| 6245 | 25 #include "core.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
26 #include "debug.h" |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
27 #include "eventloop.h" |
| 4158 | 28 |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
29 extern char *opt_rcfile_arg; |
| 4158 | 30 |
| 31 #ifdef USE_SM | |
| 32 | |
| 33 #include <X11/ICE/ICElib.h> | |
| 34 #include <X11/SM/SMlib.h> | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
35 #include <gdk/gdkx.h> |
| 4158 | 36 #include <unistd.h> |
| 37 #include <fcntl.h> | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
38 |
| 4158 | 39 #define ERROR_LENGTH 512 |
| 40 | |
| 41 static IceIOErrorHandler ice_installed_io_error_handler; | |
| 42 static SmcConn session = NULL; | |
| 43 static gchar *myself = NULL; | |
| 44 static gboolean had_first_save = FALSE; | |
| 45 gboolean session_managed = FALSE; | |
| 46 | |
| 47 /* ICE belt'n'braces stuff */ | |
| 48 | |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
49 static void ice_process_messages(gpointer data, gint fd, |
|
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
50 GaimInputCondition condition) { |
| 4158 | 51 IceConn connection = (IceConn)data; |
| 52 IceProcessMessagesStatus status; | |
| 53 | |
| 54 /* please don't block... please! */ | |
| 55 status = IceProcessMessages(connection, NULL, NULL); | |
| 56 | |
| 57 if (status == IceProcessMessagesIOError) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
58 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
59 "ICE IO error, closing connection... "); |
| 4158 | 60 |
| 61 /* IO error, please disconnect */ | |
| 62 IceSetShutdownNegotiation(connection, False); | |
| 63 IceCloseConnection(connection); | |
| 64 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
65 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); |
| 4158 | 66 |
| 67 /* cancel the handler */ | |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
68 gaim_input_remove(IceConnectionNumber(connection)); |
| 4158 | 69 } |
| 70 } | |
| 71 | |
| 72 static void ice_connection_watch(IceConn connection, IcePointer client_data, | |
| 73 Bool opening, IcePointer *watch_data) { | |
| 74 if (opening) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
75 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
76 "Handling new ICE connection... "); |
| 4158 | 77 |
| 78 /* ensure ICE connection is not passed to child processes */ | |
| 79 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); | |
| 80 | |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
81 /* watch the connection */ |
|
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
82 gaim_input_add(IceConnectionNumber(connection), GAIM_INPUT_READ, |
|
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
83 ice_process_messages, connection); |
| 4158 | 84 } else { |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
85 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
86 "Handling closed ICE connection... "); |
| 4158 | 87 |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
88 /* stop watching it */ |
|
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
89 gaim_input_remove(IceConnectionNumber(connection)); |
| 4158 | 90 } |
| 91 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
92 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); |
| 4158 | 93 } |
| 94 | |
| 95 /* We call any handler installed before (or after) ice_init but | |
| 96 * avoid calling the default libICE handler which does an exit(). | |
| 97 * | |
| 98 * This means we do nothing by default, which is probably correct, | |
| 99 * the connection will get closed by libICE | |
| 100 */ | |
| 101 | |
| 102 static void ice_io_error_handler(IceConn connection) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
103 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
104 "Handling ICE IO error... "); |
| 4158 | 105 |
| 106 if (ice_installed_io_error_handler) | |
| 107 (*ice_installed_io_error_handler)(connection); | |
| 108 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
109 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); |
| 4158 | 110 } |
| 111 | |
| 112 static void ice_init() { | |
| 113 IceIOErrorHandler default_handler; | |
| 114 | |
| 115 ice_installed_io_error_handler = IceSetIOErrorHandler(NULL); | |
| 116 default_handler = IceSetIOErrorHandler(ice_io_error_handler); | |
| 117 | |
| 118 if (ice_installed_io_error_handler == default_handler) | |
| 119 ice_installed_io_error_handler = NULL; | |
| 120 | |
| 121 IceAddConnectionWatch(ice_connection_watch, NULL); | |
| 122 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
123 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
124 "ICE initialized.\n"); |
| 4158 | 125 } |
| 126 | |
| 4281 | 127 /* my magic utility function */ |
| 128 | |
| 129 static gchar **session_make_command(gchar *client_id) { | |
| 130 gint i = 2; | |
| 131 gint j = 0; | |
| 132 gchar **ret; | |
| 133 | |
| 134 if (client_id) i += 2; | |
| 135 if (opt_rcfile_arg) i += 2; | |
| 136 | |
| 137 ret = g_new(gchar *, i); | |
| 138 ret[j++] = g_strdup(myself); | |
| 139 | |
| 140 if (client_id) { | |
| 141 ret[j++] = g_strdup("--session"); | |
| 142 ret[j++] = g_strdup(client_id); | |
| 143 } | |
| 144 | |
| 145 if (opt_rcfile_arg) { | |
| 146 ret[j++] = g_strdup("--file"); | |
| 147 ret[j++] = g_strdup(opt_rcfile_arg); | |
| 148 } | |
| 149 | |
| 150 ret[j++] = NULL; | |
| 151 | |
| 152 return ret; | |
| 153 } | |
| 154 | |
| 4158 | 155 /* SM callback handlers */ |
| 156 | |
| 157 void session_save_yourself(SmcConn conn, SmPointer data, int save_type, | |
| 158 Bool shutdown, int interact_style, Bool fast) { | |
| 159 if (had_first_save == FALSE && save_type == SmSaveLocal && | |
| 160 interact_style == SmInteractStyleNone && !shutdown && | |
| 161 !fast) { | |
| 162 /* this is just a dry run, spit it back */ | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
163 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
164 "Received first save_yourself\n"); |
| 4158 | 165 SmcSaveYourselfDone(conn, True); |
| 166 had_first_save = TRUE; | |
| 167 return; | |
| 168 } | |
| 169 | |
| 170 /* tum ti tum... don't add anything else here without * | |
| 171 * reading SMlib.PS from an X.org ftp server near you */ | |
| 172 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
173 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
174 "Received save_yourself\n"); |
| 4158 | 175 |
| 176 if (save_type == SmSaveGlobal || save_type == SmSaveBoth) { | |
| 177 /* may as well do something ... */ | |
|
5593
b07aa997ddd8
[gaim-migrate @ 5997]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
178 /* or not -- save_prefs(); */ |
| 4158 | 179 } |
| 180 | |
| 181 SmcSaveYourselfDone(conn, True); | |
| 182 } | |
| 183 | |
| 184 void session_die(SmcConn conn, SmPointer data) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
185 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
186 "Received die\n"); |
|
6179
16e384bb7fbf
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
187 gaim_core_quit(); |
| 4158 | 188 } |
| 189 | |
| 190 void session_save_complete(SmcConn conn, SmPointer data) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
191 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
192 "Received save_complete\n"); |
| 4158 | 193 } |
| 194 | |
| 195 void session_shutdown_cancelled(SmcConn conn, SmPointer data) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
196 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
197 "Received shutdown_cancelled\n"); |
| 4158 | 198 } |
| 199 | |
| 200 /* utility functions stolen from Gnome-client */ | |
| 201 | |
| 202 static void session_set_value(SmcConn conn, gchar *name, char *type, | |
| 203 int num_vals, SmPropValue *vals) { | |
| 204 SmProp *proplist[1]; | |
| 205 SmProp prop; | |
| 206 | |
| 207 g_return_if_fail(conn); | |
| 208 | |
| 209 prop.name = name; | |
| 210 prop.type = type; | |
| 211 prop.num_vals = num_vals; | |
| 212 prop.vals = vals; | |
| 213 | |
| 214 proplist[0] = ∝ | |
| 215 SmcSetProperties(conn, 1, proplist); | |
| 216 } | |
| 217 | |
| 218 static void session_set_string(SmcConn conn, gchar *name, gchar *value) { | |
| 219 SmPropValue val; | |
| 220 | |
| 221 g_return_if_fail(name); | |
| 222 | |
| 223 val.length = strlen (value)+1; | |
| 224 val.value = value; | |
| 225 | |
| 226 session_set_value(conn, name, SmARRAY8, 1, &val); | |
| 227 } | |
| 228 | |
| 229 static void session_set_gchar(SmcConn conn, gchar *name, gchar value) { | |
| 230 SmPropValue val; | |
| 231 | |
| 232 g_return_if_fail(name); | |
| 233 | |
| 234 val.length = 1; | |
| 235 val.value = &value; | |
| 236 | |
| 237 session_set_value(conn, name, SmCARD8, 1, &val); | |
| 238 } | |
| 239 | |
| 240 static void session_set_array(SmcConn conn, gchar *name, gchar *array[]) { | |
| 241 gint argc; | |
| 242 gchar **ptr; | |
| 243 gint i; | |
| 244 | |
| 245 SmPropValue *vals; | |
| 246 | |
| 247 g_return_if_fail (name); | |
| 248 | |
| 249 /* We count the number of elements in our array. */ | |
| 250 for (ptr = array, argc = 0; *ptr ; ptr++, argc++) /* LOOP */; | |
| 251 | |
| 252 /* Now initialize the 'vals' array. */ | |
| 253 vals = g_new (SmPropValue, argc); | |
| 254 for (ptr = array, i = 0 ; i < argc ; ptr++, i++) { | |
| 255 vals[i].length = strlen (*ptr); | |
| 256 vals[i].value = *ptr; | |
| 257 } | |
| 258 | |
| 259 session_set_value(conn, name, SmLISTofARRAY8, argc, vals); | |
| 260 | |
| 261 g_free (vals); | |
| 262 } | |
| 263 | |
| 264 #endif /* USE_SM */ | |
| 265 | |
| 266 /* setup functions */ | |
| 267 | |
| 268 void session_init(gchar *argv0, gchar *previous_id) { | |
| 269 #ifdef USE_SM | |
| 270 SmcCallbacks callbacks; | |
| 271 gchar *client_id = NULL; | |
| 272 gchar error[ERROR_LENGTH] = ""; | |
| 273 gchar *tmp = NULL; | |
| 4281 | 274 gchar **cmd = NULL; |
| 4158 | 275 |
| 276 if (session != NULL) { | |
| 277 /* session is already established, what the hell is going on? */ | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
278 gaim_debug(GAIM_DEBUG_WARNING, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
279 "Duplicated call to session_init!\n"); |
| 4158 | 280 return; |
| 281 } | |
| 282 | |
| 283 if (g_getenv("SESSION_MANAGER") == NULL) { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
284 gaim_debug(GAIM_DEBUG_ERROR, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
285 "No SESSION_MANAGER found, aborting.\n"); |
| 4158 | 286 return; |
| 287 } | |
| 288 | |
| 289 ice_init(); | |
| 290 | |
| 291 callbacks.save_yourself.callback = session_save_yourself; | |
| 292 callbacks.die.callback = session_die; | |
| 293 callbacks.save_complete.callback = session_save_complete; | |
| 294 callbacks.shutdown_cancelled.callback = session_shutdown_cancelled; | |
| 295 | |
| 296 callbacks.save_yourself.client_data = NULL; | |
| 297 callbacks.die.client_data = NULL; | |
| 298 callbacks.save_complete.client_data = NULL; | |
| 299 callbacks.shutdown_cancelled.client_data = NULL; | |
| 300 | |
| 4544 | 301 if (previous_id) { |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
302 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
303 "Connecting with previous ID %s\n", previous_id); |
| 4544 | 304 } else { |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
305 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
306 "Connecting with no previous ID\n"); |
| 4544 | 307 } |
| 4158 | 308 |
| 309 session = SmcOpenConnection(NULL, "session", SmProtoMajor, SmProtoMinor, SmcSaveYourselfProcMask | | |
| 310 SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, | |
| 311 &callbacks, previous_id, &client_id, ERROR_LENGTH, error); | |
| 312 | |
| 313 if (session == NULL) { | |
| 314 if (error[0] != '\0') { | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
315 gaim_debug(GAIM_DEBUG_ERROR, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
316 "Connection failed with error: %s\n", error); |
| 4158 | 317 } else { |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
318 gaim_debug(GAIM_DEBUG_ERROR, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
319 "Connetion failed with unknown error.\n"); |
| 4158 | 320 } |
| 321 return; | |
| 322 } | |
| 323 | |
| 324 tmp = SmcVendor(session); | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
325 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
326 "Connected to manager (%s) with client ID %s\n", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
327 tmp, client_id); |
| 4158 | 328 g_free(tmp); |
| 329 | |
| 330 session_managed = TRUE; | |
| 331 gdk_set_sm_client_id(client_id); | |
| 332 | |
| 4265 | 333 tmp = g_get_current_dir(); |
| 334 session_set_string(session, SmCurrentDirectory, tmp); | |
| 335 g_free(tmp); | |
| 336 | |
| 4210 | 337 tmp = g_strdup_printf("%d", (int) getpid()); |
| 4158 | 338 session_set_string(session, SmProcessID, tmp); |
| 339 g_free(tmp); | |
| 340 | |
| 4210 | 341 tmp = g_strdup(g_get_user_name()); |
| 4158 | 342 session_set_string(session, SmUserID, tmp); |
| 343 g_free(tmp); | |
| 344 | |
| 345 session_set_gchar(session, SmRestartStyleHint, (gchar) SmRestartIfRunning); | |
| 346 session_set_string(session, SmProgram, g_get_prgname()); | |
| 347 | |
| 348 myself = g_strdup(argv0); | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
349 gaim_debug(GAIM_DEBUG_MISC, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
350 "Using %s as command\n", myself); |
| 4158 | 351 |
| 4281 | 352 cmd = session_make_command(NULL); |
| 4158 | 353 session_set_array(session, SmCloneCommand, cmd); |
| 4281 | 354 g_strfreev(cmd); |
| 4158 | 355 |
| 4265 | 356 /* this is currently useless, but gnome-session warns 'the following applications will not |
| 357 save their current status' bla bla if we don't have it and the user checks 'Save Session' | |
| 358 when they log out */ | |
| 4281 | 359 cmd = g_new(gchar *, 2); |
| 360 cmd[0] = g_strdup("/bin/true"); | |
| 361 cmd[1] = NULL; | |
| 4158 | 362 session_set_array(session, SmDiscardCommand, cmd); |
| 4281 | 363 g_strfreev(cmd); |
| 4158 | 364 |
| 4281 | 365 cmd = session_make_command(client_id); |
| 4158 | 366 session_set_array(session, SmRestartCommand, cmd); |
| 4281 | 367 g_strfreev(cmd); |
| 368 | |
| 4158 | 369 g_free(client_id); |
| 370 #endif /* USE_SM */ | |
| 371 } | |
| 372 | |
| 373 void session_end() { | |
| 374 #ifdef USE_SM | |
| 375 if (session == NULL) /* no session to close */ | |
| 376 return; | |
| 377 | |
| 378 SmcCloseConnection(session, 0, NULL); | |
| 379 | |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
380 gaim_debug(GAIM_DEBUG_INFO, "Session Management", |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
4544
diff
changeset
|
381 "Connection closed.\n"); |
| 4158 | 382 #endif /* USE_SM */ |
| 383 } |
