Tue, 16 Feb 2016 18:37:01 -0600
Cleanup the plugin pref stuff so it works and doesn't crash
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* Pidgin is the legal property of its developers, whose names are too numerous |
| 12246 | 2 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 3 | * source distribution. | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or modify | |
| 6 | * it under the terms of the GNU General Public License as published by | |
| 7 | * the Free Software Foundation; either version 2 of the License, or | |
| 8 | * (at your option) any later version. | |
| 9 | * | |
| 10 | * This program is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16254
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 12246 | 18 | * |
| 19 | */ | |
| 20 | #include "internal.h" | |
| 21 | ||
| 22 | #include "core.h" | |
| 23 | #include "debug.h" | |
| 24 | #include "eventloop.h" | |
|
12410
98d8abd3db98
[gaim-migrate @ 14717]
Richard Laager <rlaager@pidgin.im>
parents:
12246
diff
changeset
|
25 | #include "gtksession.h" |
| 12246 | 26 | |
| 27 | #ifdef USE_SM | |
| 28 | ||
| 29 | #include <X11/ICE/ICElib.h> | |
| 30 | #include <X11/SM/SMlib.h> | |
| 31 | #include <gdk/gdkx.h> | |
| 32 | #include <unistd.h> | |
| 33 | #include <fcntl.h> | |
|
20347
b7de12671217
Save default Gtk+ display in the command line for session restoration.
Ethan Blanton <elb@pidgin.im>
parents:
20147
diff
changeset
|
34 | #include <gdk/gdk.h> |
|
22637
26a7edb3cc75
gdk_display_get_name() and gdk_display_get_default() are new in Gtk 2.2
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22104
diff
changeset
|
35 | #include <gtk/gtk.h> |
| 12246 | 36 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
37 | #include "gtk3compat.h" |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33133
diff
changeset
|
38 | |
| 12246 | 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 | static gboolean session_managed = FALSE; | |
| 46 | ||
| 47 | /* ICE belt'n'braces stuff */ | |
| 48 | ||
| 49 | struct ice_connection_info { | |
| 50 | IceConn connection; | |
| 51 | guint input_id; | |
| 52 | }; | |
| 53 | ||
| 54 | static void ice_process_messages(gpointer data, gint fd, | |
| 15884 | 55 | PurpleInputCondition condition) { |
| 12246 | 56 | struct ice_connection_info *conninfo = (struct ice_connection_info*) data; |
| 57 | IceProcessMessagesStatus status; | |
| 58 | ||
| 59 | /* please don't block... please! */ | |
| 60 | status = IceProcessMessages(conninfo->connection, NULL, NULL); | |
| 61 | ||
| 62 | if (status == IceProcessMessagesIOError) { | |
| 15884 | 63 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 64 | "ICE IO error, closing connection... "); |
| 65 | ||
| 66 | /* IO error, please disconnect */ | |
| 67 | IceSetShutdownNegotiation(conninfo->connection, False); | |
| 68 | IceCloseConnection(conninfo->connection); | |
| 69 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
70 | if (purple_debug_is_verbose()) { |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
71 | purple_debug_misc("Session Management", |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
72 | "Connection closed."); |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
73 | } |
| 12246 | 74 | |
| 75 | /* cancel the handler */ | |
| 15884 | 76 | purple_input_remove(conninfo->input_id); |
| 12246 | 77 | } |
| 78 | } | |
| 79 | ||
| 80 | static void ice_connection_watch(IceConn connection, IcePointer client_data, | |
| 81 | Bool opening, IcePointer *watch_data) { | |
| 82 | struct ice_connection_info *conninfo = NULL; | |
| 83 | ||
| 84 | if (opening) { | |
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
85 | purple_debug_misc("Session Management", |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
86 | "Handling new ICE connection..."); |
| 12246 | 87 | |
| 88 | /* ensure ICE connection is not passed to child processes */ | |
|
35991
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35986
diff
changeset
|
89 | if (fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC) != 0) |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35986
diff
changeset
|
90 | purple_debug_warning("gtksession", "couldn't set FD_CLOEXEC\n"); |
| 12246 | 91 | |
| 92 | conninfo = g_new(struct ice_connection_info, 1); | |
| 93 | conninfo->connection = connection; | |
| 94 | ||
| 95 | /* watch the connection */ | |
| 15884 | 96 | conninfo->input_id = purple_input_add(IceConnectionNumber(connection), PURPLE_INPUT_READ, |
| 12246 | 97 | ice_process_messages, conninfo); |
| 98 | *watch_data = conninfo; | |
| 99 | } else { | |
| 15884 | 100 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
|
21124
c293f3c40d4a
Add some missing debugging newlines.
Daniel Atallah <datallah@pidgin.im>
parents:
20347
diff
changeset
|
101 | "Handling closed ICE connection... \n"); |
| 12246 | 102 | |
| 103 | /* get the input ID back and stop watching it */ | |
| 104 | conninfo = (struct ice_connection_info*) *watch_data; | |
| 15884 | 105 | purple_input_remove(conninfo->input_id); |
| 12246 | 106 | g_free(conninfo); |
| 107 | } | |
| 108 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
109 | if (purple_debug_is_verbose()) { |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
110 | purple_debug_misc("Session Management", |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
111 | "ICE connection handled."); |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
112 | } |
| 12246 | 113 | } |
| 114 | ||
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
22637
diff
changeset
|
115 | /* We call any handler installed before (or after) ice_init but |
| 12246 | 116 | * avoid calling the default libICE handler which does an exit(). |
| 117 | * | |
| 118 | * This means we do nothing by default, which is probably correct, | |
| 119 | * the connection will get closed by libICE | |
| 120 | */ | |
| 121 | ||
| 122 | static void ice_io_error_handler(IceConn connection) { | |
| 15884 | 123 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 124 | "Handling ICE IO error... "); |
| 125 | ||
| 126 | if (ice_installed_io_error_handler) | |
| 127 | (*ice_installed_io_error_handler)(connection); | |
| 128 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
129 | if (purple_debug_is_verbose()) { |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
130 | purple_debug_misc("Session Management", |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
131 | "ICE IO error handled."); |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
132 | } |
| 12246 | 133 | } |
| 134 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21124
diff
changeset
|
135 | static void ice_init(void) { |
| 12246 | 136 | IceIOErrorHandler default_handler; |
| 137 | ||
| 138 | ice_installed_io_error_handler = IceSetIOErrorHandler(NULL); | |
| 139 | default_handler = IceSetIOErrorHandler(ice_io_error_handler); | |
| 140 | ||
| 141 | if (ice_installed_io_error_handler == default_handler) | |
| 142 | ice_installed_io_error_handler = NULL; | |
| 143 | ||
| 144 | IceAddConnectionWatch(ice_connection_watch, NULL); | |
| 145 | ||
|
34297
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
146 | if (purple_debug_is_verbose()) { |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
147 | purple_debug_misc("Session Management", "ICE initialized."); |
|
0f1f0b8c84f8
Fix some debug log warnings, adjust verbosity level
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
148 | } |
| 12246 | 149 | } |
| 150 | ||
| 151 | /* my magic utility function */ | |
| 152 | ||
| 153 | static gchar **session_make_command(gchar *client_id, gchar *config_dir) { | |
|
20347
b7de12671217
Save default Gtk+ display in the command line for session restoration.
Ethan Blanton <elb@pidgin.im>
parents:
20147
diff
changeset
|
154 | gint i = 4; |
| 12246 | 155 | gint j = 0; |
| 156 | gchar **ret; | |
| 157 | ||
| 158 | if (client_id) i += 2; | |
| 15884 | 159 | if (config_dir) i += 2; /* we will specify purple's user dir */ |
| 12246 | 160 | |
| 161 | ret = g_new(gchar *, i); | |
| 162 | ret[j++] = g_strdup(myself); | |
| 163 | ||
| 164 | if (client_id) { | |
| 165 | ret[j++] = g_strdup("--session"); | |
| 166 | ret[j++] = g_strdup(client_id); | |
| 167 | } | |
| 168 | ||
| 169 | if (config_dir) { | |
| 170 | ret[j++] = g_strdup("--config"); | |
| 171 | ret[j++] = g_strdup(config_dir); | |
| 172 | } | |
| 173 | ||
|
20347
b7de12671217
Save default Gtk+ display in the command line for session restoration.
Ethan Blanton <elb@pidgin.im>
parents:
20147
diff
changeset
|
174 | ret[j++] = g_strdup("--display"); |
|
b7de12671217
Save default Gtk+ display in the command line for session restoration.
Ethan Blanton <elb@pidgin.im>
parents:
20147
diff
changeset
|
175 | ret[j++] = g_strdup((gchar *)gdk_display_get_name(gdk_display_get_default())); |
|
b7de12671217
Save default Gtk+ display in the command line for session restoration.
Ethan Blanton <elb@pidgin.im>
parents:
20147
diff
changeset
|
176 | |
|
30702
8a1938367841
These are dead increments.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30269
diff
changeset
|
177 | ret[j] = NULL; |
| 12246 | 178 | |
| 179 | return ret; | |
| 180 | } | |
| 181 | ||
| 182 | /* SM callback handlers */ | |
| 183 | ||
| 184 | static void session_save_yourself(SmcConn conn, SmPointer data, int save_type, | |
| 185 | Bool shutdown, int interact_style, Bool fast) { | |
| 186 | if (had_first_save == FALSE && save_type == SmSaveLocal && | |
| 187 | interact_style == SmInteractStyleNone && !shutdown && | |
| 188 | !fast) { | |
| 189 | /* this is just a dry run, spit it back */ | |
| 15884 | 190 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 191 | "Received first save_yourself\n"); |
| 192 | SmcSaveYourselfDone(conn, True); | |
| 193 | had_first_save = TRUE; | |
| 194 | return; | |
| 195 | } | |
| 196 | ||
| 197 | /* tum ti tum... don't add anything else here without * | |
| 198 | * reading SMlib.PS from an X.org ftp server near you */ | |
| 199 | ||
| 15884 | 200 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 201 | "Received save_yourself\n"); |
| 202 | ||
| 203 | if (save_type == SmSaveGlobal || save_type == SmSaveBoth) { | |
| 204 | /* may as well do something ... */ | |
| 205 | /* or not -- save_prefs(); */ | |
| 206 | } | |
| 207 | ||
| 208 | SmcSaveYourselfDone(conn, True); | |
| 209 | } | |
| 210 | ||
| 211 | static void session_die(SmcConn conn, SmPointer data) { | |
| 15884 | 212 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 213 | "Received die\n"); |
| 15884 | 214 | purple_core_quit(); |
| 12246 | 215 | } |
| 216 | ||
| 217 | static void session_save_complete(SmcConn conn, SmPointer data) { | |
| 15884 | 218 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 219 | "Received save_complete\n"); |
| 220 | } | |
| 221 | ||
| 222 | static void session_shutdown_cancelled(SmcConn conn, SmPointer data) { | |
| 15884 | 223 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 224 | "Received shutdown_cancelled\n"); |
| 225 | } | |
| 226 | ||
| 227 | /* utility functions stolen from Gnome-client */ | |
| 228 | ||
| 229 | static void session_set_value(SmcConn conn, gchar *name, char *type, | |
| 230 | int num_vals, SmPropValue *vals) { | |
| 231 | SmProp *proplist[1]; | |
| 232 | SmProp prop; | |
| 233 | ||
| 234 | g_return_if_fail(conn); | |
| 235 | ||
| 236 | prop.name = name; | |
| 237 | prop.type = type; | |
| 238 | prop.num_vals = num_vals; | |
| 239 | prop.vals = vals; | |
| 240 | ||
| 241 | proplist[0] = ∝ | |
| 242 | SmcSetProperties(conn, 1, proplist); | |
| 243 | } | |
| 244 | ||
| 245 | static void session_set_string(SmcConn conn, gchar *name, gchar *value) { | |
| 246 | SmPropValue val; | |
| 247 | ||
| 248 | g_return_if_fail(name); | |
| 249 | ||
| 250 | val.length = strlen (value)+1; | |
| 251 | val.value = value; | |
| 252 | ||
| 253 | session_set_value(conn, name, SmARRAY8, 1, &val); | |
| 254 | } | |
| 255 | ||
| 256 | static void session_set_gchar(SmcConn conn, gchar *name, gchar value) { | |
| 257 | SmPropValue val; | |
| 258 | ||
| 259 | g_return_if_fail(name); | |
| 260 | ||
| 261 | val.length = 1; | |
| 262 | val.value = &value; | |
| 263 | ||
| 264 | session_set_value(conn, name, SmCARD8, 1, &val); | |
| 265 | } | |
| 266 | ||
| 267 | static void session_set_array(SmcConn conn, gchar *name, gchar *array[]) { | |
| 268 | gint argc; | |
| 269 | gchar **ptr; | |
| 270 | gint i; | |
| 271 | ||
| 272 | SmPropValue *vals; | |
| 273 | ||
| 274 | g_return_if_fail (name); | |
| 275 | ||
| 276 | /* We count the number of elements in our array. */ | |
| 277 | for (ptr = array, argc = 0; *ptr ; ptr++, argc++) /* LOOP */; | |
| 278 | ||
| 279 | /* Now initialize the 'vals' array. */ | |
| 280 | vals = g_new (SmPropValue, argc); | |
| 281 | for (ptr = array, i = 0 ; i < argc ; ptr++, i++) { | |
| 282 | vals[i].length = strlen (*ptr); | |
| 283 | vals[i].value = *ptr; | |
| 284 | } | |
| 285 | ||
| 286 | session_set_value(conn, name, SmLISTofARRAY8, argc, vals); | |
| 287 | ||
| 288 | g_free (vals); | |
| 289 | } | |
| 290 | ||
| 291 | #endif /* USE_SM */ | |
| 292 | ||
| 293 | /* setup functions */ | |
| 294 | ||
| 295 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
296 | pidgin_session_init(gchar *argv0, gchar *previous_id, gchar *config_dir) |
| 12246 | 297 | { |
| 298 | #ifdef USE_SM | |
| 299 | SmcCallbacks callbacks; | |
| 300 | gchar *client_id = NULL; | |
| 301 | gchar error[ERROR_LENGTH] = ""; | |
| 302 | gchar *tmp = NULL; | |
| 303 | gchar **cmd = NULL; | |
| 304 | ||
| 305 | if (session != NULL) { | |
| 306 | /* session is already established, what the hell is going on? */ | |
| 15884 | 307 | purple_debug(PURPLE_DEBUG_WARNING, "Session Management", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
308 | "Duplicated call to pidgin_session_init!\n"); |
| 12246 | 309 | return; |
| 310 | } | |
| 311 | ||
| 312 | if (g_getenv("SESSION_MANAGER") == NULL) { | |
| 15884 | 313 | purple_debug(PURPLE_DEBUG_ERROR, "Session Management", |
| 12246 | 314 | "No SESSION_MANAGER found, aborting.\n"); |
| 315 | return; | |
| 316 | } | |
| 317 | ||
| 318 | ice_init(); | |
| 319 | ||
| 320 | callbacks.save_yourself.callback = session_save_yourself; | |
| 321 | callbacks.die.callback = session_die; | |
| 322 | callbacks.save_complete.callback = session_save_complete; | |
| 323 | callbacks.shutdown_cancelled.callback = session_shutdown_cancelled; | |
| 324 | ||
| 325 | callbacks.save_yourself.client_data = NULL; | |
| 326 | callbacks.die.client_data = NULL; | |
| 327 | callbacks.save_complete.client_data = NULL; | |
| 328 | callbacks.shutdown_cancelled.client_data = NULL; | |
| 329 | ||
| 330 | if (previous_id) { | |
| 15884 | 331 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 332 | "Connecting with previous ID %s\n", previous_id); |
| 333 | } else { | |
| 15884 | 334 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 335 | "Connecting with no previous ID\n"); |
| 336 | } | |
| 337 | ||
| 338 | session = SmcOpenConnection(NULL, "session", SmProtoMajor, SmProtoMinor, SmcSaveYourselfProcMask | | |
| 339 | SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, | |
| 340 | &callbacks, previous_id, &client_id, ERROR_LENGTH, error); | |
| 341 | ||
| 342 | if (session == NULL) { | |
| 343 | if (error[0] != '\0') { | |
| 15884 | 344 | purple_debug(PURPLE_DEBUG_ERROR, "Session Management", |
| 12246 | 345 | "Connection failed with error: %s\n", error); |
| 346 | } else { | |
| 15884 | 347 | purple_debug(PURPLE_DEBUG_ERROR, "Session Management", |
| 12246 | 348 | "Connetion failed with unknown error.\n"); |
| 349 | } | |
| 350 | return; | |
| 351 | } | |
| 352 | ||
| 353 | tmp = SmcVendor(session); | |
| 15884 | 354 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 355 | "Connected to manager (%s) with client ID %s\n", |
| 356 | tmp, client_id); | |
|
30269
d2943f2cf2fb
The returned value from SmcVendor() should be free'd with free() not
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29499
diff
changeset
|
357 | free(tmp); |
| 12246 | 358 | |
| 359 | session_managed = TRUE; | |
|
33133
9a31f084f259
Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
360 | gdk_x11_set_sm_client_id(client_id); |
| 12246 | 361 | |
| 362 | tmp = g_get_current_dir(); | |
| 363 | session_set_string(session, SmCurrentDirectory, tmp); | |
| 364 | g_free(tmp); | |
| 365 | ||
| 366 | tmp = g_strdup_printf("%d", (int) getpid()); | |
| 367 | session_set_string(session, SmProcessID, tmp); | |
| 368 | g_free(tmp); | |
| 369 | ||
| 370 | tmp = g_strdup(g_get_user_name()); | |
| 371 | session_set_string(session, SmUserID, tmp); | |
| 372 | g_free(tmp); | |
| 373 | ||
| 374 | session_set_gchar(session, SmRestartStyleHint, (gchar) SmRestartIfRunning); | |
|
35986
5dc98ddc6a9a
Backport more warning fixes for Pidgin and Finch from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
30702
diff
changeset
|
375 | session_set_string(session, SmProgram, (gchar *) g_get_prgname()); |
| 12246 | 376 | |
| 377 | myself = g_strdup(argv0); | |
| 15884 | 378 | purple_debug(PURPLE_DEBUG_MISC, "Session Management", |
| 12246 | 379 | "Using %s as command\n", myself); |
| 380 | ||
| 381 | cmd = session_make_command(NULL, config_dir); | |
| 382 | session_set_array(session, SmCloneCommand, cmd); | |
| 383 | g_strfreev(cmd); | |
| 384 | ||
| 385 | /* this is currently useless, but gnome-session warns 'the following applications will not | |
| 386 | save their current status' bla bla if we don't have it and the user checks 'Save Session' | |
| 387 | when they log out */ | |
| 388 | cmd = g_new(gchar *, 2); | |
| 389 | cmd[0] = g_strdup("/bin/true"); | |
| 390 | cmd[1] = NULL; | |
| 391 | session_set_array(session, SmDiscardCommand, cmd); | |
| 392 | g_strfreev(cmd); | |
| 393 | ||
| 394 | cmd = session_make_command(client_id, config_dir); | |
| 395 | session_set_array(session, SmRestartCommand, cmd); | |
| 396 | g_strfreev(cmd); | |
| 397 | ||
| 398 | g_free(client_id); | |
| 399 | #endif /* USE_SM */ | |
| 400 | } | |
| 401 | ||
| 402 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
403 | pidgin_session_end() |
| 12246 | 404 | { |
| 405 | #ifdef USE_SM | |
| 406 | if (session == NULL) /* no session to close */ | |
| 407 | return; | |
| 408 | ||
| 409 | SmcCloseConnection(session, 0, NULL); | |
| 410 | ||
| 15884 | 411 | purple_debug(PURPLE_DEBUG_INFO, "Session Management", |
| 12246 | 412 | "Connection closed.\n"); |
| 413 | #endif /* USE_SM */ | |
| 414 | } |