+static void session_state_free(ObSessionState *state)
+{
+ if (state) {
+ g_free(state->id);
+ g_free(state->command);
+ g_free(state->name);
+ g_free(state->class);
+ g_free(state->role);
+
+ g_free(state);
+ }
+}
+
+static gboolean session_state_cmp(ObSessionState *s, ObClient *c)
+{
+ ob_debug_type(OB_DEBUG_SM, "Comparing client against saved state: \n");
+ ob_debug_type(OB_DEBUG_SM, " client id: %s \n", c->sm_client_id);
+ ob_debug_type(OB_DEBUG_SM, " client name: %s \n", c->name);
+ ob_debug_type(OB_DEBUG_SM, " client class: %s \n", c->class);
+ ob_debug_type(OB_DEBUG_SM, " client role: %s \n", c->role);
+ ob_debug_type(OB_DEBUG_SM, " client command: %s \n",
+ c->wm_command ? c->wm_command : "(null)");
+ ob_debug_type(OB_DEBUG_SM, " state id: %s \n", s->id);
+ ob_debug_type(OB_DEBUG_SM, " state name: %s \n", s->name);
+ ob_debug_type(OB_DEBUG_SM, " state class: %s \n", s->class);
+ ob_debug_type(OB_DEBUG_SM, " state role: %s \n", s->role);
+ ob_debug_type(OB_DEBUG_SM, " state command: %s \n",
+ s->command ? s->command : "(null)");
+
+ if ((c->sm_client_id && s->id && !strcmp(c->sm_client_id, s->id)) ||
+ (c->wm_command && s->command && !strcmp(c->wm_command, s->command)))
+ {
+ return (!strcmp(s->name, c->name) &&
+ !strcmp(s->class, c->class) &&
+ !strcmp(s->role, c->role));
+ }
+ return FALSE;
+}
+
+GList* session_state_find(ObClient *c)
+{
+ GList *it;
+
+ for (it = session_saved_state; it; it = g_list_next(it)) {
+ ObSessionState *s = it->data;
+ if (!s->matched && session_state_cmp(s, c)) {
+ s->matched = TRUE;
+ break;
+ }
+ }
+ return it;
+}
+
+static void session_load_file(const gchar *path)