1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 session.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
19 /* This session code is largely inspired by metacity code. */
25 GList
*session_saved_state
= NULL
;
26 gint session_desktop
= -1;
27 gint session_num_desktops
= 0;
28 gboolean session_desktop_layout_present
= FALSE
;
29 ObDesktopLayout session_desktop_layout
;
30 GSList
*session_desktop_names
= NULL
;
33 void session_startup(gint argc
, gchar
**argv
) {}
34 void session_shutdown(gboolean permanent
) {}
35 GList
* session_state_find(struct _ObClient
*c
) { return NULL
; }
43 #include "obt/parse.h"
44 #include "obt/paths.h"
51 # include <sys/types.h>
55 #include <X11/SM/SMlib.h>
57 #define SM_ERR_LEN 1024
59 static SmcConn sm_conn
;
61 static gchar
**sm_argv
;
63 /* Data saved from the first level save yourself */
65 ObClient
*focus_client
;
69 static gboolean
session_connect();
71 static void session_load_file(const gchar
*path
);
72 static gboolean
session_save_to_file(const ObSMSaveData
*savedata
);
74 static void session_setup_program();
75 static void session_setup_user();
76 static void session_setup_restart_style(gboolean restart
);
77 static void session_setup_pid();
78 static void session_setup_priority();
79 static void session_setup_clone_command();
80 static void session_setup_restart_command();
82 static void sm_save_yourself(SmcConn conn
, SmPointer data
, gint save_type
,
83 Bool shutdown
, gint interact_style
, Bool fast
);
84 static void sm_die(SmcConn conn
, SmPointer data
);
85 static void sm_save_complete(SmcConn conn
, SmPointer data
);
86 static void sm_shutdown_cancelled(SmcConn conn
, SmPointer data
);
88 static gboolean
session_state_cmp(ObSessionState
*s
, ObClient
*c
);
89 static void session_state_free(ObSessionState
*state
);
91 void session_startup(gint argc
, gchar
**argv
)
96 if (!ob_sm_use
) return;
102 dir
= g_build_filename(obt_paths_data_home(p
), "openbox", "sessions",NULL
);
103 obt_paths_unref(p
), p
= NULL
;
105 if (!obt_paths_mkdir_path(dir
, 0700)) {
106 g_message(_("Unable to make directory '%s': %s"),
107 dir
, g_strerror(errno
));
110 if (ob_sm_save_file
!= NULL
) {
112 ob_debug_type(OB_DEBUG_SM
, "Loading from session file %s\n",
114 session_load_file(ob_sm_save_file
);
119 /* this algo is from metacity */
120 filename
= g_strdup_printf("%u-%u-%u.obs",
124 ob_sm_save_file
= g_build_filename(dir
, filename
, NULL
);
128 if (session_connect()) {
129 session_setup_program();
130 session_setup_user();
131 session_setup_restart_style(TRUE
);
133 session_setup_priority();
134 session_setup_clone_command();
140 void session_shutdown(gboolean permanent
)
142 if (!ob_sm_use
) return;
145 /* if permanent is true then we will change our session state so that
146 the SM won't run us again */
148 session_setup_restart_style(FALSE
);
150 SmcCloseConnection(sm_conn
, 0, NULL
);
152 while (session_saved_state
) {
153 session_state_free(session_saved_state
->data
);
154 session_saved_state
= g_list_delete_link(session_saved_state
,
155 session_saved_state
);
160 /*! Connect to the session manager and set up our callback functions */
161 static gboolean
session_connect()
165 gchar sm_err
[SM_ERR_LEN
];
167 /* set up our callback functions */
168 cb
.save_yourself
.callback
= sm_save_yourself
;
169 cb
.save_yourself
.client_data
= NULL
;
170 cb
.die
.callback
= sm_die
;
171 cb
.die
.client_data
= NULL
;
172 cb
.save_complete
.callback
= sm_save_complete
;
173 cb
.save_complete
.client_data
= NULL
;
174 cb
.shutdown_cancelled
.callback
= sm_shutdown_cancelled
;
175 cb
.shutdown_cancelled
.client_data
= NULL
;
177 /* connect to the server */
179 ob_debug_type(OB_DEBUG_SM
, "Connecting to SM with id: %s\n",
180 oldid
? oldid
: "(null)");
181 sm_conn
= SmcOpenConnection(NULL
, NULL
, 1, 0,
182 SmcSaveYourselfProcMask
|
184 SmcSaveCompleteProcMask
|
185 SmcShutdownCancelledProcMask
,
186 &cb
, oldid
, &ob_sm_id
,
187 SM_ERR_LEN
-1, sm_err
);
189 ob_debug_type(OB_DEBUG_SM
, "Connected to SM with id: %s\n", ob_sm_id
);
191 ob_debug("Failed to connect to session manager: %s\n", sm_err
);
192 return sm_conn
!= NULL
;
195 static void session_setup_program()
199 .length
= strlen(sm_argv
[0]) + 1
202 .name
= g_strdup(SmProgram
),
203 .type
= g_strdup(SmARRAY8
),
207 SmProp
*list
= &prop
;
208 ob_debug_type(OB_DEBUG_SM
, "Setting program: %s\n", sm_argv
[0]);
209 SmcSetProperties(sm_conn
, 1, &list
);
214 static void session_setup_user()
216 char *user
= g_strdup(g_get_user_name());
220 .length
= strlen(user
) + 1
223 .name
= g_strdup(SmUserID
),
224 .type
= g_strdup(SmARRAY8
),
228 SmProp
*list
= &prop
;
229 ob_debug_type(OB_DEBUG_SM
, "Setting user: %s\n", user
);
230 SmcSetProperties(sm_conn
, 1, &list
);
236 static void session_setup_restart_style(gboolean restart
)
238 gchar restart_hint
= restart
? SmRestartImmediately
: SmRestartIfRunning
;
241 .value
= &restart_hint
,
245 .name
= g_strdup(SmRestartStyleHint
),
246 .type
= g_strdup(SmCARD8
),
250 SmProp
*list
= &prop
;
251 ob_debug_type(OB_DEBUG_SM
, "Setting restart: %d\n", restart
);
252 SmcSetProperties(sm_conn
, 1, &list
);
257 static void session_setup_pid()
259 gchar
*pid
= g_strdup_printf("%ld", (glong
) getpid());
263 .length
= strlen(pid
) + 1
266 .name
= g_strdup(SmProcessID
),
267 .type
= g_strdup(SmARRAY8
),
271 SmProp
*list
= &prop
;
272 ob_debug_type(OB_DEBUG_SM
, "Setting pid: %s\n", pid
);
273 SmcSetProperties(sm_conn
, 1, &list
);
279 /*! This is a gnome-session-manager extension */
280 static void session_setup_priority()
282 gchar priority
= 20; /* 20 is a lower prioity to run before other apps */
289 .name
= g_strdup("_GSM_Priority"),
290 .type
= g_strdup(SmCARD8
),
294 SmProp
*list
= &prop
;
295 ob_debug_type(OB_DEBUG_SM
, "Setting priority: %d\n", priority
);
296 SmcSetProperties(sm_conn
, 1, &list
);
301 static void session_setup_clone_command()
305 SmPropValue
*vals
= g_new(SmPropValue
, sm_argc
);
307 .name
= g_strdup(SmCloneCommand
),
308 .type
= g_strdup(SmLISTofARRAY8
),
312 SmProp
*list
= &prop
;
314 ob_debug_type(OB_DEBUG_SM
, "Setting clone command: (%d)\n", sm_argc
);
315 for (i
= 0; i
< sm_argc
; ++i
) {
316 vals
[i
].value
= sm_argv
[i
];
317 vals
[i
].length
= strlen(sm_argv
[i
]) + 1;
318 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
].value
);
321 SmcSetProperties(sm_conn
, 1, &list
);
327 static void session_setup_restart_command()
331 SmPropValue
*vals
= g_new(SmPropValue
, sm_argc
+ 4);
333 .name
= g_strdup(SmRestartCommand
),
334 .type
= g_strdup(SmLISTofARRAY8
),
335 .num_vals
= sm_argc
+ 4,
338 SmProp
*list
= &prop
;
340 ob_debug_type(OB_DEBUG_SM
, "Setting restart command: (%d)\n", sm_argc
+4);
341 for (i
= 0; i
< sm_argc
; ++i
) {
342 vals
[i
].value
= sm_argv
[i
];
343 vals
[i
].length
= strlen(sm_argv
[i
]) + 1;
344 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
].value
);
347 vals
[i
].value
= g_strdup("--sm-client-id");
348 vals
[i
].length
= strlen("--sm-client-id") + 1;
349 vals
[i
+1].value
= ob_sm_id
;
350 vals
[i
+1].length
= strlen(ob_sm_id
) + 1;
351 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
].value
);
352 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
+1].value
);
354 vals
[i
+2].value
= g_strdup("--sm-save-file");
355 vals
[i
+2].length
= strlen("--sm-save-file") + 1;
356 vals
[i
+3].value
= ob_sm_save_file
;
357 vals
[i
+3].length
= strlen(ob_sm_save_file
) + 1;
358 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
+2].value
);
359 ob_debug_type(OB_DEBUG_SM
, " %s\n", vals
[i
+3].value
);
361 SmcSetProperties(sm_conn
, 1, &list
);
364 g_free(vals
[i
].value
);
365 g_free(vals
[i
+2].value
);
369 static ObSMSaveData
*sm_save_get_data()
371 ObSMSaveData
*savedata
= g_new0(ObSMSaveData
, 1);
372 /* save the active desktop and client.
373 we don't bother to preemptively save the other desktop state like
374 number and names of desktops, cuz those shouldn't be changing during
376 savedata
->focus_client
= focus_client
;
377 savedata
->desktop
= screen_desktop
;
381 static void sm_save_yourself_2(SmcConn conn
, SmPointer data
)
384 ObSMSaveData
*savedata
= data
;
386 /* save the current state */
387 ob_debug_type(OB_DEBUG_SM
, "Session save phase 2 requested\n");
388 ob_debug_type(OB_DEBUG_SM
,
389 " Saving session to file '%s'\n", ob_sm_save_file
);
390 if (savedata
== NULL
)
391 savedata
= sm_save_get_data();
392 success
= session_save_to_file(savedata
);
395 /* tell the session manager how to restore this state */
396 if (success
) session_setup_restart_command();
398 ob_debug_type(OB_DEBUG_SM
, "Saving is done (success = %d)\n", success
);
399 SmcSaveYourselfDone(conn
, success
);
403 static void sm_save_yourself(SmcConn conn
, SmPointer data
, gint save_type
,
404 Bool shutdown
, gint interact_style
, Bool fast
)
406 ObSMSaveData
*savedata
= NULL
;
409 ob_debug_type(OB_DEBUG_SM
, "Session save requested\n");
411 vendor
= SmcVendor(sm_conn
);
412 ob_debug_type(OB_DEBUG_SM
, "Session manager's vendor: %s\n", vendor
);
414 if (!strcmp(vendor
, "KDE")) {
415 /* ksmserver guarantees that phase 1 will complete before allowing any
416 clients interaction, so we can save this sanely here before they
417 get messed up from interaction */
418 savedata
= sm_save_get_data();
422 if (!SmcRequestSaveYourselfPhase2(conn
, sm_save_yourself_2
, savedata
)) {
423 ob_debug_type(OB_DEBUG_SM
, "Requst for phase 2 failed\n");
425 SmcSaveYourselfDone(conn
, FALSE
);
429 static void sm_die(SmcConn conn
, SmPointer data
)
431 ob_debug_type(OB_DEBUG_SM
, "Die requested\n");
435 static void sm_save_complete(SmcConn conn
, SmPointer data
)
437 ob_debug_type(OB_DEBUG_SM
, "Save complete\n");
440 static void sm_shutdown_cancelled(SmcConn conn
, SmPointer data
)
442 ob_debug_type(OB_DEBUG_SM
, "Shutdown cancelled\n");
445 static gboolean
session_save_to_file(const ObSMSaveData
*savedata
)
449 gboolean success
= TRUE
;
451 f
= fopen(ob_sm_save_file
, "w");
454 g_message(_("Unable to save the session to '%s': %s"),
455 ob_sm_save_file
, g_strerror(errno
));
457 fprintf(f
, "<?xml version=\"1.0\"?>\n\n");
458 fprintf(f
, "<openbox_session>\n\n");
460 fprintf(f
, "<desktop>%d</desktop>\n", savedata
->desktop
);
462 fprintf(f
, "<numdesktops>%d</numdesktops>\n", screen_num_desktops
);
464 fprintf(f
, "<desktoplayout>\n");
465 fprintf(f
, " <orientation>%d</orientation>\n",
466 screen_desktop_layout
.orientation
);
467 fprintf(f
, " <startcorner>%d</startcorner>\n",
468 screen_desktop_layout
.start_corner
);
469 fprintf(f
, " <columns>%d</columns>\n",
470 screen_desktop_layout
.columns
);
471 fprintf(f
, " <rows>%d</rows>\n",
472 screen_desktop_layout
.rows
);
473 fprintf(f
, "</desktoplayout>\n");
475 if (screen_desktop_names
) {
478 fprintf(f
, "<desktopnames>\n");
479 for (i
= 0; screen_desktop_names
[i
]; ++i
)
480 fprintf(f
, " <name>%s</name>\n", screen_desktop_names
[i
]);
481 fprintf(f
, "</desktopnames>\n");
484 /* they are ordered top to bottom in stacking order */
485 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
486 gint prex
, prey
, prew
, preh
;
490 if (WINDOW_IS_CLIENT(it
->data
))
491 c
= WINDOW_AS_CLIENT(it
->data
);
495 if (!client_normal(c
))
498 if (!c
->sm_client_id
) {
499 ob_debug_type(OB_DEBUG_SM
, "Client %s does not have a "
502 if (!c
->wm_command
) {
503 ob_debug_type(OB_DEBUG_SM
, "Client %s does not have an "
504 "oldskool wm_command set either. We won't "
505 "be saving its data\n",
511 ob_debug_type(OB_DEBUG_SM
, "Saving state for client %s\n",
516 prew
= c
->area
.width
;
517 preh
= c
->area
.height
;
519 prex
= c
->pre_fullscreen_area
.x
;
520 prey
= c
->pre_fullscreen_area
.x
;
521 prew
= c
->pre_fullscreen_area
.width
;
522 preh
= c
->pre_fullscreen_area
.height
;
525 prex
= c
->pre_max_area
.x
;
526 prew
= c
->pre_max_area
.width
;
529 prey
= c
->pre_max_area
.y
;
530 preh
= c
->pre_max_area
.height
;
534 fprintf(f
, "<window id=\"%s\">\n", c
->sm_client_id
);
536 fprintf(f
, "<window command=\"%s\">\n", c
->wm_command
);
538 t
= g_markup_escape_text(c
->name
, -1);
539 fprintf(f
, "\t<name>%s</name>\n", t
);
542 t
= g_markup_escape_text(c
->class, -1);
543 fprintf(f
, "\t<class>%s</class>\n", t
);
546 t
= g_markup_escape_text(c
->role
, -1);
547 fprintf(f
, "\t<role>%s</role>\n", t
);
550 fprintf(f
, "\t<windowtype>%d</windowtype>\n", c
->type
);
552 fprintf(f
, "\t<desktop>%d</desktop>\n", c
->desktop
);
553 fprintf(f
, "\t<x>%d</x>\n", prex
);
554 fprintf(f
, "\t<y>%d</y>\n", prey
);
555 fprintf(f
, "\t<width>%d</width>\n", prew
);
556 fprintf(f
, "\t<height>%d</height>\n", preh
);
558 fprintf(f
, "\t<shaded />\n");
560 fprintf(f
, "\t<iconic />\n");
562 fprintf(f
, "\t<skip_pager />\n");
564 fprintf(f
, "\t<skip_taskbar />\n");
566 fprintf(f
, "\t<fullscreen />\n");
568 fprintf(f
, "\t<above />\n");
570 fprintf(f
, "\t<below />\n");
572 fprintf(f
, "\t<max_horz />\n");
574 fprintf(f
, "\t<max_vert />\n");
576 fprintf(f
, "\t<undecorated />\n");
577 if (savedata
->focus_client
== c
)
578 fprintf(f
, "\t<focused />\n");
579 fprintf(f
, "</window>\n\n");
582 fprintf(f
, "</openbox_session>\n");
586 g_message(_("Error while saving the session to '%s': %s"),
587 ob_sm_save_file
, g_strerror(errno
));
595 static void session_state_free(ObSessionState
*state
)
599 g_free(state
->command
);
601 g_free(state
->class);
608 static gboolean
session_state_cmp(ObSessionState
*s
, ObClient
*c
)
610 ob_debug_type(OB_DEBUG_SM
, "Comparing client against saved state: \n");
611 ob_debug_type(OB_DEBUG_SM
, " client id: %s \n", c
->sm_client_id
);
612 ob_debug_type(OB_DEBUG_SM
, " client name: %s \n", c
->name
);
613 ob_debug_type(OB_DEBUG_SM
, " client class: %s \n", c
->class);
614 ob_debug_type(OB_DEBUG_SM
, " client role: %s \n", c
->role
);
615 ob_debug_type(OB_DEBUG_SM
, " client type: %d \n", c
->type
);
616 ob_debug_type(OB_DEBUG_SM
, " client command: %s \n",
617 c
->wm_command
? c
->wm_command
: "(null)");
618 ob_debug_type(OB_DEBUG_SM
, " state id: %s \n", s
->id
);
619 ob_debug_type(OB_DEBUG_SM
, " state name: %s \n", s
->name
);
620 ob_debug_type(OB_DEBUG_SM
, " state class: %s \n", s
->class);
621 ob_debug_type(OB_DEBUG_SM
, " state role: %s \n", s
->role
);
622 ob_debug_type(OB_DEBUG_SM
, " state type: %d \n", s
->type
);
623 ob_debug_type(OB_DEBUG_SM
, " state command: %s \n",
624 s
->command
? s
->command
: "(null)");
626 if ((c
->sm_client_id
&& s
->id
&& !strcmp(c
->sm_client_id
, s
->id
)) ||
627 (c
->wm_command
&& s
->command
&& !strcmp(c
->wm_command
, s
->command
)))
629 return (!strcmp(s
->name
, c
->name
) &&
630 !strcmp(s
->class, c
->class) &&
631 !strcmp(s
->role
, c
->role
) &&
632 /* the check for type is to catch broken clients, like
633 firefox, which open a different window on startup
634 with the same info as the one we saved. only do this
635 check for old windows that dont use xsmp, others should
637 (!s
->command
|| c
->type
== s
->type
));
642 GList
* session_state_find(ObClient
*c
)
646 for (it
= session_saved_state
; it
; it
= g_list_next(it
)) {
647 ObSessionState
*s
= it
->data
;
648 if (!s
->matched
&& session_state_cmp(s
, c
)) {
656 static void session_load_file(const gchar
*path
)
659 xmlNodePtr node
, n
, m
;
662 i
= obt_parse_instance_new();
664 if (!obt_parse_load_file(i
, path
, "openbox_session")) {
665 obt_parse_instance_unref(i
);
668 node
= obt_parse_root(i
);
670 if ((n
= obt_parse_find_node(node
->children
, "desktop")))
671 session_desktop
= obt_parse_node_int(n
);
673 if ((n
= obt_parse_find_node(node
->children
, "numdesktops")))
674 session_num_desktops
= obt_parse_node_int(n
);
676 if ((n
= obt_parse_find_node(node
->children
, "desktoplayout"))) {
677 /* make sure they are all there for it to be valid */
678 if ((m
= obt_parse_find_node(n
->children
, "orientation")))
679 session_desktop_layout
.orientation
= obt_parse_node_int(m
);
680 if (m
&& (m
= obt_parse_find_node(n
->children
, "startcorner")))
681 session_desktop_layout
.start_corner
= obt_parse_node_int(m
);
682 if (m
&& (m
= obt_parse_find_node(n
->children
, "columns")))
683 session_desktop_layout
.columns
= obt_parse_node_int(m
);
684 if (m
&& (m
= obt_parse_find_node(n
->children
, "rows")))
685 session_desktop_layout
.rows
= obt_parse_node_int(m
);
686 session_desktop_layout_present
= m
!= NULL
;
689 if ((n
= obt_parse_find_node(node
->children
, "desktopnames"))) {
690 for (m
= obt_parse_find_node(n
->children
, "name"); m
;
691 m
= obt_parse_find_node(m
->next
, "name"))
693 session_desktop_names
= g_slist_append(session_desktop_names
,
694 obt_parse_node_string(m
));
698 for (node
= obt_parse_find_node(node
->children
, "window"); node
!= NULL
;
699 node
= obt_parse_find_node(node
->next
, "window"))
701 ObSessionState
*state
;
703 state
= g_new0(ObSessionState
, 1);
705 if (!obt_parse_attr_string(node
, "id", &state
->id
))
706 if (!obt_parse_attr_string(node
, "command", &state
->command
))
707 goto session_load_bail
;
708 if (!(n
= obt_parse_find_node(node
->children
, "name")))
709 goto session_load_bail
;
710 state
->name
= obt_parse_node_string(n
);
711 if (!(n
= obt_parse_find_node(node
->children
, "class")))
712 goto session_load_bail
;
713 state
->class = obt_parse_node_string(n
);
714 if (!(n
= obt_parse_find_node(node
->children
, "role")))
715 goto session_load_bail
;
716 state
->role
= obt_parse_node_string(n
);
717 if (!(n
= obt_parse_find_node(node
->children
, "windowtype")))
718 goto session_load_bail
;
719 state
->type
= obt_parse_node_int(n
);
720 if (!(n
= obt_parse_find_node(node
->children
, "desktop")))
721 goto session_load_bail
;
722 state
->desktop
= obt_parse_node_int(n
);
723 if (!(n
= obt_parse_find_node(node
->children
, "x")))
724 goto session_load_bail
;
725 state
->x
= obt_parse_node_int(n
);
726 if (!(n
= obt_parse_find_node(node
->children
, "y")))
727 goto session_load_bail
;
728 state
->y
= obt_parse_node_int(n
);
729 if (!(n
= obt_parse_find_node(node
->children
, "width")))
730 goto session_load_bail
;
731 state
->w
= obt_parse_node_int(n
);
732 if (!(n
= obt_parse_find_node(node
->children
, "height")))
733 goto session_load_bail
;
734 state
->h
= obt_parse_node_int(n
);
737 obt_parse_find_node(node
->children
, "shaded") != NULL
;
739 obt_parse_find_node(node
->children
, "iconic") != NULL
;
741 obt_parse_find_node(node
->children
, "skip_pager") != NULL
;
742 state
->skip_taskbar
=
743 obt_parse_find_node(node
->children
, "skip_taskbar") != NULL
;
745 obt_parse_find_node(node
->children
, "fullscreen") != NULL
;
747 obt_parse_find_node(node
->children
, "above") != NULL
;
749 obt_parse_find_node(node
->children
, "below") != NULL
;
751 obt_parse_find_node(node
->children
, "max_horz") != NULL
;
753 obt_parse_find_node(node
->children
, "max_vert") != NULL
;
755 obt_parse_find_node(node
->children
, "undecorated") != NULL
;
757 obt_parse_find_node(node
->children
, "focused") != NULL
;
759 /* save this. they are in the file in stacking order, so preserve
761 session_saved_state
= g_list_append(session_saved_state
, state
);
765 session_state_free(state
);
768 /* Remove any duplicates. This means that if two windows (or more) are
769 saved with the same session state, we won't restore a session for any
770 of them because we don't know what window to put what on. AHEM FIREFOX.
772 This is going to be an O(2^n) kind of operation unfortunately.
774 for (it
= session_saved_state
; it
; it
= inext
) {
776 gboolean founddup
= FALSE
;
777 ObSessionState
*s1
= it
->data
;
779 inext
= g_list_next(it
);
781 for (jt
= g_list_next(it
); jt
; jt
= jnext
) {
782 ObSessionState
*s2
= jt
->data
;
785 jnext
= g_list_next(jt
);
787 if (s1
->id
&& s2
->id
)
788 match
= strcmp(s1
->id
, s2
->id
) == 0;
789 else if (s1
->command
&& s2
->command
)
790 match
= strcmp(s1
->command
, s2
->command
) == 0;
795 !strcmp(s1
->name
, s2
->name
) &&
796 !strcmp(s1
->class, s2
->class) &&
797 !strcmp(s1
->role
, s2
->role
))
799 session_state_free(s2
);
800 session_saved_state
=
801 g_list_delete_link(session_saved_state
, jt
);
807 session_state_free(s1
);
808 session_saved_state
= g_list_delete_link(session_saved_state
, it
);
812 obt_parse_instance_unref(i
);