Logo Search packages:      
Sourcecode: ladcca version File versions  Download package

jack_mgr_client.c

/*
 *   LADCCA
 *    
 *   Copyright (C) 2002 Robert Ham <rah@bash.sh>
 *    
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#define _GNU_SOURCE

#include <ladcca/ladcca.h>
#include <ladcca/internal_headers.h>

#include "jack_mgr_client.h"

static void
jack_mgr_client_free_patch_list (cca_list_t ** list_ptr)
{
  cca_list_t * list;
  jack_patch_t * patch;

  for (list = *list_ptr; list; list = cca_list_next (list))
    {
      patch = (jack_patch_t *) list->data;
      if (!patch)
        {
          CCA_DEBUG ("NULL patch!")
        }
      else
        jack_patch_destroy (patch);
    }
    
  cca_list_free (*list_ptr);
  
  *list_ptr = NULL;
}

void
jack_mgr_client_free_patches (jack_mgr_client_t * client)
{
  if (!client->patches)
    return;
  
  jack_mgr_client_free_patch_list (&client->patches);
}

void
jack_mgr_client_free_backup_patches (jack_mgr_client_t * client)
{
  if (!client->backup_patches)
    return;
  
  jack_mgr_client_free_patch_list (&client->backup_patches);
}

static void
jack_mgr_client_free_old_patches (jack_mgr_client_t * client)
{
  jack_mgr_client_free_patch_list (&client->old_patches);
}

void
jack_mgr_client_free (jack_mgr_client_t * client)
{
  jack_mgr_client_set_name (client, NULL);
  jack_mgr_client_free_patches (client);
  jack_mgr_client_free_old_patches (client);
}

jack_mgr_client_t *
jack_mgr_client_new ()
{
  jack_mgr_client_t * client;
  client = cca_malloc0 (sizeof (jack_mgr_client_t));
  uuid_clear (client->id);
  return client;
}

void
jack_mgr_client_destroy (jack_mgr_client_t * client)
{
  jack_mgr_client_free (client);
  free (client);
}

void
jack_mgr_client_set_id          (jack_mgr_client_t * client, uuid_t id)
{
  uuid_copy (client->id, id);
}

void
jack_mgr_client_set_name        (jack_mgr_client_t * client, const char * name)
{
  set_string_property (client->name, name);
}

cca_list_t *
jack_mgr_client_dup_patches   (const jack_mgr_client_t * client)
{
  cca_list_t * list = NULL, * exlist;
  jack_patch_t * patch, * expatch;
  
  for (exlist = client->patches; exlist; exlist = cca_list_next (exlist))
    {
      expatch = (jack_patch_t *) exlist->data;
      
      patch = jack_patch_dup (expatch);
      list = cca_list_append (list, patch);

      CCA_DEBUGARGS ("duplicated jack patch '%s': '%s'",
                      jack_patch_get_desc (expatch),
                      jack_patch_get_desc (patch));
    }
  
  return list;
}

cca_list_t *
jack_mgr_client_get_patches   (jack_mgr_client_t * client)
{
  return client->patches;
}

const char *
jack_mgr_client_get_name        (const jack_mgr_client_t * client)
{
  return client->name;
}

void
jack_mgr_client_get_id          (const jack_mgr_client_t * client, uuid_t id)
{
  uuid_copy (id, ((jack_mgr_client_t *)client)->id);
}

/* EOF */


Generated by  Doxygen 1.6.0   Back to index