merge the dbus development branch, 77:541

git-svn-id: svn://svn.savannah.nongnu.org/lash/trunk@542 1de19dc7-4e3f-0410-a61d-eddf686bf0b7
This commit is contained in:
Nedko Arnaudov 2008-09-06 22:48:05 +00:00
parent c048ed46dc
commit 4d77bc329c
162 changed files with 17340 additions and 9227 deletions

View File

@ -7,3 +7,8 @@ Maintainer (as of Lash 0.5.0):
Server auto-start support:
Lars Luthman <larsl@users.sourceforge.net>
Developers:
Nedko Arnaudov <nedko@arnaudov.name>
Juuso Alasuutari <juuso.alasuutari@gmail.com>
LASH Icon created by Thorsten Wilms <t_w_@freenet.de>

View File

@ -1,4 +1,4 @@
SUBDIRS = m4 docs lash liblash lashd clients icons pylash
SUBDIRS = m4 docs lash common dbus liblash lashd clients icons pylash
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = lash-1.0.pc
@ -20,3 +20,24 @@ buildcheck:
cd $(top_srcdir)/buildcheck && make distclean
rm -rf $(top_srcdir)/buildcheck
cd $(top_srcdir) && ./autogen.sh
pacoinstall:
test `whoami` == root # test for root
-paco -rvB lash
-paco -lE `pwd` -p lash-`svnversion` "make install"
-paco -i lash
svnversion.h:: # SVNONLY
@if test -d $(top_srcdir)/.svn; then $(top_srcdir)/svnversion_regenerate.sh $@; fi # SVNONLY
DISTCLEANFILES = svnversion.h # SVNONLY
BUILT_SOURCES = svnversion.h # SVNONLY
EXTRA_DIST += svnversion.h svnversion.sh
dist-hook: # SVNONLY
sed -i 's/^.*SVNONLY.*//' $(distdir)/Makefile.am $(distdir)/Makefile.in # SVNONLY
# temporary hack for preview tarballs
# should be disabled before releasing official tarball
SVN_VERSION = $(shell $(top_srcdir)/svnversion.sh $(top_srcdir))
distdir = $(PACKAGE)-$(VERSION).$(SVN_VERSION)

View File

@ -82,3 +82,44 @@ $1],dnl
$2])
CPPFLAGS="$save_CPPFLAGS"
])
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl example
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc
dnl written by thomas vander stichele
AC_DEFUN([AS_AC_EXPAND],
[
EXP_VAR=[$1]
FROM_VAR=[$2]
dnl first expand prefix and exec_prefix if necessary
prefix_save=$prefix
if test "x$prefix" = "xNONE"; then
prefix=/usr/local
fi
exec_prefix_save=$exec_prefix
if test "x$exec_prefix" = "xNONE"; then
if test "x$prefix_save" = "xNONE"; then
exec_prefix=/usr/local
else
exec_prefix=$prefix
fi
fi
full_var="$FROM_VAR"
dnl loop until it doesn't change anymore
while true; do
new_full_var="`eval echo $full_var`"
if test "x$new_full_var" = "x$full_var"; then break; fi
full_var=$new_full_var
done
dnl clean up
full_var=$new_full_var
[$1]=$full_var
prefix=$prefix_save
exec_prefix=$exec_prefix_save
])

View File

@ -1,5 +1,14 @@
SUBDIRS = control save_button panel
include $(top_srcdir)/common.am
if WITH_ALSA
SUBDIRS += simple_client synth
if LASH_OLD_API
SUBDIRS = shell save_button panel
if HAVE_ALSA
SUBDIRS += simple_client synth
endif
else
if HAVE_ALSA
SUBDIRS = simple_client
endif
endif
dist_bin_SCRIPTS = lash_control

View File

@ -1,23 +0,0 @@
include $(top_srcdir)/common.am
EXTRA_PROGRAMS = lash_control
if HAVE_READLINE
bin_PROGRAMS = lash_control
lash_control_SOURCES = \
main.c \
lash_control.c \
lash_control.h \
client.c client.h \
project.c \
project.h
lash_control_CFLAGS = $(LASH_CFLAGS)
lash_control_LDADD = \
$(top_builddir)/liblash/liblash.la \
$(LASH_LIBS) @READLINE_LIBS@
endif

144
clients/lash_control Executable file
View File

@ -0,0 +1,144 @@
#!/usr/bin/env python
# LASH
#
# Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
control_interface_name = 'org.nongnu.LASH.Control'
service_name = 'org.nongnu.LASH'
import sys
import os
import time
from traceback import print_exc
import dbus
def bool_convert(str_value):
if str_value.lower() == "false":
return False
if str_value.lower() == "off":
return False
if str_value.lower() == "no":
return False
if str_value == "0":
return False
if str_value.lower() == "(null)":
return False
return bool(str_value)
def dbus_type_to_python_type(dbus_value):
if type(dbus_value) == dbus.Boolean:
return bool(dbus_value)
if type(dbus_value) == dbus.Int32 or type(dbus_value) == dbus.UInt32:
return int(dbus_value)
return dbus_value
def dbus_type_to_type_string(dbus_value):
if type(dbus_value) == dbus.Boolean:
return "bool"
if type(dbus_value) == dbus.Int32:
return "sint"
if type(dbus_value) == dbus.UInt32:
return "uint"
if type(dbus_value) == dbus.Byte:
return "char"
if type(dbus_value) == dbus.String:
return "str"
return None # throw exception here?
def dbus_typesig_to_type_string(type_char):
type_char = str(type_char)
if type_char == 'i':
return "sint"
if type_char == 'u':
return "uint"
if type_char == 'y':
return "char"
if type_char == 's':
return "str"
if type_char == 'b':
return "bool"
print 'shit'
return None # throw exception here?
def main():
if len(sys.argv) == 1:
print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0])
print "Commands:"
print " exit - exit lash dbus service"
print " list - list projects"
print " open <projectname> - open project"
print " save - save all open projects"
print " close - close all open projects"
sys.exit(0)
bus = dbus.SessionBus()
lash = None
# check arguments
index = 1
while index < len(sys.argv):
arg = sys.argv[index]
index += 1
try:
if not lash:
lash = bus.get_object(service_name, "/")
control_iface = dbus.Interface(lash, control_interface_name)
if arg == "exit":
print "--- exit"
control_iface.Exit()
time.sleep(1)
# we have deactivated the object and we need to get new connection if there are more commands
lash = None
control_iface = None
elif arg == 'list':
print "--- projects list"
projects = control_iface.ProjectsGetAvailable()
for project in projects:
print project
elif arg == 'open':
if index >= len(sys.argv):
print "project open command requires project name argument"
sys.exit()
arg = sys.argv[index]
index += 1
open_options = {}
#open_options["option1"] = "asd"
#open_options["option2"] = True
control_iface.ProjectOpen(arg, open_options)
elif arg == 'save':
control_iface.ProjectsSaveAll()
elif arg == 'close':
control_iface.ProjectsCloseAll()
else:
print "Unknown command '%s'" % arg
except dbus.DBusException, e:
print "DBus exception: %s" % str(e)
if __name__ == '__main__':
main()

View File

@ -8,7 +8,6 @@ lash_panel_SOURCES = \
project.h project.c
lash_panel_CFLAGS = \
$(LASH_CFLAGS) \
$(GTK2_CFLAGS)
lash_panel_LDADD = \

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <lash/lash.h>
#include "lash/lash.h"
#include <getopt.h>
#include <stdio.h>
@ -48,7 +48,6 @@ print_help()
int
main(int argc, char **argv)
{
lash_args_t *lash_args;
lash_client_t *lash_client;
panel_t *panel;
int opt;
@ -58,8 +57,6 @@ main(int argc, char **argv)
{0, 0, 0, 0}
};
lash_args = lash_extract_args(&argc, &argv);
gtk_set_locale();
gtk_init(&argc, &argv);
@ -78,8 +75,7 @@ main(int argc, char **argv)
}
}
lash_client = lash_init(lash_args, "LASH Control Panel",
LASH_Server_Interface, LASH_PROTOCOL(2, 0));
lash_client = lash_client_open_controller();
if (!lash_client) {
fprintf(stderr, "%s: could not initialise LASH\n", __FUNCTION__);
@ -88,6 +84,13 @@ main(int argc, char **argv)
panel = panel_create(lash_client);
if (!lash_set_control_callback(lash_client, deal_with_event,
(void *) panel)) {
// TODO: Is there really no destructor for panel_t?
fprintf(stderr, "%s: could not initialise LASH\n", __FUNCTION__);
exit(1);
}
gtk_main();
return 0;

View File

@ -16,11 +16,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include <lash/lash.h>
#include "lash/lash.h"
#include <gtk/gtk.h>
#include "panel.h"
@ -32,7 +34,8 @@
void quit_cb(GtkButton * button, void *data);
project_t *
get_project(panel_t * panel, const char *const name)
get_project(panel_t *panel,
const char *const name)
{
project_t *project = NULL;
GtkTreeModel *tree_model = GTK_TREE_MODEL(panel->projects);
@ -40,15 +43,16 @@ get_project(panel_t * panel, const char *const name)
if (gtk_tree_model_get_iter_first(tree_model, &iter))
do {
gtk_tree_model_get(tree_model, &iter, PROJECT_PROJECT_COLUMN,
&project, -1);
gtk_tree_model_get(tree_model, &iter,
PROJECT_PROJECT_COLUMN,
&project, -1);
if (!strcmp(name, project->name))
if (strcmp(name, project->name) == 0)
return project;
} while (gtk_tree_model_iter_next(tree_model, &iter));
fprintf(stderr, "Error: Unable to find project '%s'!", name);
fprintf(stderr, "Error: Unable to find project '%s'!\n", name);
return NULL;
}
@ -100,10 +104,11 @@ server_disconnect(panel_t * panel)
}
void
event_project_add(panel_t * panel, lash_event_t * event)
event_project_add(panel_t *panel,
const char *name,
const char *path)
{
project_t *project = NULL;
const char *name = lash_event_get_string(event);
GtkTreeIter iter;
printf("Add project: %s\n", name);
@ -116,19 +121,19 @@ event_project_add(panel_t * panel, lash_event_t * event)
project = project_create(panel->lash_client, name);
gtk_list_store_set(panel->projects, &iter,
PROJECT_PROJECT_COLUMN, project, -1);
PROJECT_PROJECT_COLUMN, project, -1);
project->page_number =
gtk_notebook_append_page(GTK_NOTEBOOK(panel->project_notebook),
project->box, project->tab_label);
gtk_notebook_append_page(GTK_NOTEBOOK(panel->project_notebook),
project->box, project->tab_label);
panel->num_projects++;
}
void
event_project_remove(panel_t * panel, lash_event_t * event)
event_project_remove(panel_t *panel,
const char *name)
{
const char *name = lash_event_get_string(event);
project_t *project = get_project(panel, name);
GtkTreeModel *tree_model = GTK_TREE_MODEL(panel->projects);
GtkTreeIter iter;
@ -137,19 +142,20 @@ event_project_remove(panel_t * panel, lash_event_t * event)
if (panel->num_projects == 1)
gtk_label_set_text(GTK_LABEL(panel->no_projects_label),
"(No projects open. Start a LASH client, or load a project from the File menu)");
"(No projects open. Start a LASH client, "
"or load a project from the File menu)");
if (project != NULL)
if (gtk_tree_model_get_iter_first(tree_model, &iter))
do {
gtk_tree_model_get(tree_model, &iter, PROJECT_PROJECT_COLUMN,
&project, -1);
gtk_tree_model_get(tree_model, &iter,
PROJECT_PROJECT_COLUMN,
&project, -1);
if (!strcmp(name, project->name)) {
gtk_list_store_remove(panel->projects, &iter);
gtk_notebook_remove_page(GTK_NOTEBOOK
(panel->project_notebook),
project->page_number);
gtk_notebook_remove_page(GTK_NOTEBOOK(panel->project_notebook),
project->page_number);
project_destroy(project);
break;
}
@ -159,55 +165,55 @@ event_project_remove(panel_t * panel, lash_event_t * event)
}
void
event_project_dir(panel_t * panel, lash_event_t * event)
event_project_path(panel_t *panel,
const char *name,
const char *path)
{
const char *name = lash_event_get_project(event);
const char *dir = lash_event_get_string(event);
project_t *project = get_project(panel, name);
printf("Change project dir: %s = %s\n", name, dir);
printf("Change project path: %s = %s\n", name, path);
if (project != NULL) {
project_set_dir(project, dir);
}
if (project)
project_set_dir(project, path);
}
void
event_project_name(panel_t * panel, lash_event_t * event)
event_project_name(panel_t *panel,
const char *old_name,
const char *new_name)
{
const char *old_name = lash_event_get_project(event);
const char *new_name = lash_event_get_string(event);
project_t *project = get_project(panel, old_name);
printf("Change project name: %s = %s\n", old_name, new_name);
if (project != NULL)
if (project)
project_set_name(project, new_name);
}
void
event_client_add(panel_t * panel, lash_event_t * event)
event_client_add(panel_t *panel,
uuid_t client_id,
const char *project_name)
{
const char *project_name = lash_event_get_project(event);
project_t *project = get_project(panel, project_name);
char *client_id_str = malloc(37);
char *search_id_str = NULL;
uuid_t client_id;
GtkTreeIter iter;
GtkTreeModel *tree_model;
int client_exists = FALSE;
lash_event_get_client_id(event, client_id);
uuid_unparse(client_id, client_id_str);
printf("Add client (%s): %s\n", project_name, client_id_str);
if (client_id != NULL && project != NULL) {
if (!uuid_is_null(client_id) && project) {
tree_model = GTK_TREE_MODEL(project->clients);
if (gtk_tree_model_get_iter_first(tree_model, &iter)) {
do {
gtk_tree_model_get(tree_model, &iter, CLIENT_ID_COLUMN, &search_id_str, -1);
gtk_tree_model_get(tree_model, &iter,
CLIENT_ID_COLUMN,
&search_id_str, -1);
if (!strcmp(search_id_str, client_id_str)) {
client_exists = TRUE;
@ -218,74 +224,94 @@ event_client_add(panel_t * panel, lash_event_t * event)
if (!client_exists) {
gtk_list_store_append(project->clients, &iter);
gtk_list_store_set(project->clients, &iter,
CLIENT_ID_COLUMN, client_id_str, -1);
CLIENT_ID_COLUMN, client_id_str, -1);
}
}
}
void
event_client_name(panel_t * panel, lash_event_t * event)
event_client_name(panel_t *panel,
uuid_t client_id,
const char *client_name)
{
const char *project_name = lash_event_get_project(event);
const char *client_name = lash_event_get_string(event);
project_t *project = get_project(panel, project_name);
GtkTreeModel *tree_model = NULL;
GtkTreeIter iter;
uuid_t client_id;
char *search_id_str = NULL;
char *client_id_str = malloc(37);
project_t *project;
const char *id_str;
uuid_t id;
GtkTreeModel *tree_model, *tree_model2;
GtkTreeIter iter, iter2;
lash_event_get_client_id(event, client_id);
uuid_unparse(client_id, client_id_str);
tree_model = GTK_TREE_MODEL(panel->projects);
printf("Change client name (%s): %s = %s\n", project_name, client_id_str,
client_name);
if (gtk_tree_model_get_iter_first(tree_model, &iter)) {
do {
gtk_tree_model_get(tree_model, &iter,
PROJECT_PROJECT_COLUMN,
&project, -1);
if (project != NULL) {
tree_model = GTK_TREE_MODEL(project->clients);
tree_model2 = GTK_TREE_MODEL(project->clients);
if (gtk_tree_model_get_iter_first(tree_model, &iter))
do {
gtk_tree_model_get(tree_model, &iter, CLIENT_ID_COLUMN,
&search_id_str, -1);
if (gtk_tree_model_get_iter_first(tree_model2, &iter2)) {
do {
gtk_tree_model_get(tree_model2, &iter2,
CLIENT_ID_COLUMN,
&id_str, -1);
if (!strcmp(search_id_str, client_id_str)) {
gtk_list_store_set(project->clients, &iter,
CLIENT_NAME_COLUMN, client_name, -1);
break;
}
} while (gtk_tree_model_iter_next(tree_model, &iter));
if (id_str && uuid_parse(id_str, id) == 0
&& uuid_compare(client_id, id) == 0) {
gtk_list_store_set(project->clients,
&iter2,
CLIENT_NAME_COLUMN,
client_name, -1);
printf("Change client name (%s): %s = %s\n",
project->name, id_str, client_name);
return;
}
} while (gtk_tree_model_iter_next(tree_model2, &iter2));
}
} while (gtk_tree_model_iter_next(tree_model, &iter));
}
}
void
deal_with_event(panel_t * panel, lash_event_t * event)
deal_with_event(enum LASH_Event_Type type,
const char *string1,
const char *string2,
uuid_t client_id,
void *user_data)
{
switch (lash_event_get_type(event)) {
panel_t *panel = user_data;
switch (type) {
case LASH_Project_Add:
event_project_add(panel, event);
event_project_add(panel, string1, string2);
break;
case LASH_Project_Remove:
event_project_remove(panel, event);
event_project_remove(panel, string1);
break;
case LASH_Project_Dir:
event_project_dir(panel, event);
event_project_path(panel, string1, string2);
break;
case LASH_Project_Name:
event_project_name(panel, event);
event_project_name(panel, string1, string2);
break;
case LASH_Client_Add:
event_client_add(panel, event);
event_client_add(panel, client_id, string1);
break;
case LASH_Client_Name:
event_client_name(panel, event);
event_client_name(panel, client_id, string1);
break;
/*
case LASH_Jack_Client_Name:
break;
case LASH_Alsa_Client_ID:
break;
case LASH_Percentage:
break;
*/
default:
break;
}
@ -295,15 +321,11 @@ gboolean
idle_cb(gpointer data)
{
panel_t *panel;
lash_event_t *event;
/*lash_config_t * config; */
panel = (panel_t *) data;
while ((event = lash_get_event(panel->lash_client))) {
deal_with_event(panel, event);
}
lash_dispatch(panel->lash_client);
/*while ((config = lash_get_config(panel->lash_client)) ) {
* add_config(panel, config);
@ -324,27 +346,24 @@ open_cb(GtkButton * button, void *data)
panel_t *panel = (panel_t *) data;
int response = GTK_RESPONSE_NONE;
char *filename = NULL;
lash_event_t *event = NULL;
GtkWidget *open_dialog =
gtk_file_chooser_dialog_new("Open Project", GTK_WINDOW(panel->window),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
gtk_file_chooser_dialog_new("Open Project", GTK_WINDOW(panel->window),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
char default_dir[256];
snprintf(default_dir, 256, "%s/%s", getenv("HOME"), DEFAULT_PROJECT_DIR);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(open_dialog),
default_dir);
default_dir);
response = gtk_dialog_run(GTK_DIALOG(open_dialog));
if (response == GTK_RESPONSE_OK) {
filename =
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(open_dialog));
event = lash_event_new_with_type(LASH_Project_Add);
lash_event_set_string(event, filename);
lash_send_event(panel->lash_client, event);
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(open_dialog));
lash_control_load_project_path(panel->lash_client, filename);
}
gtk_widget_destroy(open_dialog);

View File

@ -20,7 +20,7 @@
#define __PANEL_H__
#include <gtk/gtk.h>
#include <lash/lash.h>
#include "lash/lash.h"
typedef struct _panel panel_t;
@ -47,6 +47,11 @@ struct _panel
panel_t* panel_create (lash_client_t * client);
void
deal_with_event(enum LASH_Event_Type type,
const char *string1,
const char *string2,
uuid_t client_id,
void *user_data);
#endif /* __PANEL_H__ */

View File

@ -19,7 +19,7 @@
#include "project.h"
#include "config.h"
#include <stdlib.h>
#include <lash/lash.h>
#include "lash/lash.h"
#include <assert.h>
#include <unistd.h>
#include <string.h>
@ -27,58 +27,55 @@
/* Button callbacks */
void
save_cb(GtkButton * button, void *data)
save_cb(GtkButton *button,
void *data)
{
project_t *project = (project_t *) data;
lash_event_t *event = lash_event_new_with_type(LASH_Save);
lash_event_set_project(event, project->name);
lash_send_event(project->lash_client, event);
lash_control_save_project(project->lash_client, project->name);
printf("Told server to save project %s\n", project->name);
}
void
close_cb(GtkButton * button, void *data)
close_cb(GtkButton *button,
void *data)
{
project_t *project = (project_t *) data;
lash_event_t *event = lash_event_new_with_type(LASH_Project_Remove);
lash_event_set_project(event, project->name);
lash_send_event(project->lash_client, event);
lash_control_close_project(project->lash_client, project->name);
printf("Told server to close project %s\n", project->name);
}
void
set_dir_cb(GtkButton * button, void *data)
set_dir_cb(GtkButton *button,
void *data)
{
project_t *project = (project_t *) data;
int response = GTK_RESPONSE_NONE;
char *filename = NULL;
lash_event_t *event = NULL;
GtkWidget *save_dialog =
gtk_file_chooser_dialog_new("Set Project Directory", NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
gtk_file_chooser_dialog_new("Set Project Directory", NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
char default_dir[256];
snprintf(default_dir, 256, "%s/%s", getenv("HOME"), DEFAULT_PROJECT_DIR);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(save_dialog),
default_dir);
default_dir);
response = gtk_dialog_run(GTK_DIALOG(save_dialog));
if (response == GTK_RESPONSE_OK) {
filename =
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(save_dialog));
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(save_dialog));
project_set_dir(project, filename);
event = lash_event_new_with_type(LASH_Project_Dir);
lash_event_set_project(event, project->name);
lash_event_set_string(event, filename);
lash_send_event(project->lash_client, event);
lash_control_move_project(project->lash_client, project->name,
filename);
printf("Told server to set project directory %s\n", filename);
}
@ -87,18 +84,15 @@ set_dir_cb(GtkButton * button, void *data)
}
void
set_name_cb(GtkEntry * entry, void *data)
set_name_cb(GtkEntry *entry,
void *data)
{
project_t *project = (project_t *) data;
lash_event_t *event = NULL;
const char *new_name = gtk_entry_get_text(GTK_ENTRY(project->name_entry));
printf("Name changed: %s\n", new_name);
lash_control_name_project(project->lash_client, project->name, new_name);
event = lash_event_new_with_type(LASH_Project_Name);
lash_event_set_project(event, project->name);
lash_event_set_string(event, new_name);
lash_send_event(project->lash_client, event);
printf("Name changed: %s\n", new_name);
}
/* Project */

View File

@ -20,7 +20,7 @@
#define __PROJECT_H__
#include <gtk/gtk.h>
#include <lash/lash.h>
#include "lash/lash.h"
typedef struct _project project_t;

View File

@ -6,7 +6,6 @@ lash_save_button_SOURCES = \
save_button.c
lash_save_button_CFLAGS = \
$(LASH_CFLAGS) \
$(GTK2_CFLAGS)
lash_save_button_LDADD = \

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* 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
@ -21,8 +21,7 @@
#ifndef __HINTS_H__
#define __HINTS_H__
#include <lash/lash.h>
#include <lash/list.h>
#include "lash/lash.h"
extern void (*set_always_func)(GtkWidget *, gboolean);
extern void (*set_sticky_func)(GtkWidget *, gboolean);

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* 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
@ -23,7 +23,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <lash/lash.h>
#include "lash/lash.h"
#include <unistd.h>
#include <getopt.h>
@ -110,7 +110,7 @@ idle_cb(void *data)
gtk_main_quit();
exit(0);
default:
fprintf(stderr, "%s: recieved unknown LASH event of type %d\n",
fprintf(stderr, "%s: received unknown LASH event of type %d\n",
__FUNCTION__, lash_event_get_type(event));
lash_event_destroy(event);
break;

31
clients/shell/Makefile.am Normal file
View File

@ -0,0 +1,31 @@
include $(top_srcdir)/common.am
EXTRA_PROGRAMS = lash_shell
if HAVE_READLINE
bin_PROGRAMS = lash_shell
lash_shell_SOURCES = \
main.c \
lash_control.c \
lash_control.h \
client.c client.h \
project.c \
project.h
# Include safemem code
nodist_lash_shell_SOURCES = safety.c
BUILT_SOURCES = safety.c
CLEANFILES = safety.c
safety.c: Makefile
cp $(top_srcdir)/common/safety.c .
lash_shell_CFLAGS = \
-DDEBUG_OUTPUT_TERMINAL
lash_shell_LDADD = \
$(top_builddir)/liblash/liblash.la \
@READLINE_LIBS@
endif

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* Copyright (C) 2003 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
@ -18,39 +18,26 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <string.h>
#include <lash/lash.h>
#include <lash/internal_headers.h>
#include "client.h"
#include "common/safety.h"
client_t *
client_new()
client_new(void)
{
client_t *client;
client = lash_malloc0(sizeof(client_t));
uuid_clear(client->id);
return client;
return lash_calloc(1, sizeof(client_t));
}
void
client_destroy(client_t * client)
client_destroy(client_t *client)
{
client_set_name(client, NULL);
client_set_jack_client_name(client, NULL);
free(client);
}
void
client_set_name(client_t * client, const char *name)
{
set_string_property(client->name, name);
}
void
client_set_jack_client_name(client_t * client, const char *name)
{
set_string_property(client->jack_client_name, name);
if (client) {
lash_free(&client->name);
lash_free(&client->jack_client_name);
free(client);
}
}
const char *
@ -60,7 +47,7 @@ client_get_identity(client_t * client)
static size_t identity_size = sizeof(char[37]);
if (!identity)
identity = lash_malloc(identity_size);
identity = lash_malloc(1, identity_size);
if (client->name) {
size_t name_size;
@ -68,7 +55,7 @@ client_get_identity(client_t * client)
name_size = strlen(client->name) + 1;
if (name_size > identity_size) {
identity_size = name_size;
identity = lash_realloc(identity, identity_size);
identity = lash_realloc(identity, 1, identity_size);
}
strcpy(identity, client->name);

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* Copyright (C) 2003 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
@ -23,8 +23,8 @@
#include <uuid/uuid.h>
#include <lash/lash.h>
#include <lash/list.h>
#include "lash/lash.h"
#include "common/list.h"
typedef struct _client client_t;
@ -39,9 +39,6 @@ struct _client
client_t * client_new ();
void client_destroy (client_t * client);
void client_set_name (client_t * client, const char * name);
void client_set_jack_client_name (client_t * client, const char * name);
const char * client_get_identity (client_t * client);
#endif /* __CLIENT_H__ */

View File

@ -1,8 +1,9 @@
/*
* LASH
*
*
* Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
* 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
@ -28,6 +29,8 @@
#include <unistd.h>
#include <uuid/uuid.h>
#include "common/safety.h"
#undef HAVE_CONFIG_H
#ifdef HAVE_LIBREADLINE
@ -56,8 +59,8 @@ extern int read_history();
/* no history */
#endif /* HAVE_READLINE_HISTORY */
#include <lash/lash.h>
#include <lash/debug.h>
#include "lash/lash.h"
#include "common/debug.h"
#include "lash_control.h"
#include "client.h"
@ -452,13 +455,13 @@ deal_with_events(lash_control_t * control)
case LASH_Project_Dir:
printf("* Project '%s' changed to directory %s\n", project->name,
event_str);
project_set_dir(project, event_str);
lash_strset(&project->dir, event_str);
break;
case LASH_Project_Name:
printf("* Project '%s' changed name to '%s'\n", project->name,
event_str);
project_set_name(project, event_str);
lash_strset(&project->name, event_str);
break;
case LASH_Project_Add:
@ -526,13 +529,13 @@ deal_with_events(lash_control_t * control)
case LASH_Client_Name:
printf("* Client '%s' changed its name to '%s'\n",
client_get_identity(client), event_str);
client_set_name(client, event_str);
lash_strset(&client->name, event_str);
break;
case LASH_Jack_Client_Name:
printf("* Client '%s' set its JACK client name to '%s'\n",
client_get_identity(client), event_str);
client_set_jack_client_name(client, event_str);
lash_strset(&client->jack_client_name, event_str);
break;
case LASH_Alsa_Client_ID:
@ -576,7 +579,7 @@ lash_control_main(lash_control_t * control)
char *command;
int done = 0;
prompt = lash_malloc(prompt_size);
prompt = lash_malloc(1, prompt_size);
printf("\nLASH Control %s\n", PACKAGE_VERSION);
printf("\nConnected to server %s\n\n",
@ -592,7 +595,7 @@ lash_control_main(lash_control_t * control)
if (project_prompt_size > prompt_size) {
prompt_size = project_prompt_size;
prompt = lash_realloc(prompt, prompt_size);
prompt = lash_realloc(prompt, 1, prompt_size);
}
sprintf(prompt, "%s > ", control->cur_project->name);

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* 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
@ -21,8 +21,8 @@
#ifndef __LASH_CONTROL_H__
#define __LASH_CONTROL_H__
#include <lash/lash.h>
#include <lash/list.h>
#include "lash/lash.h"
#include "common/list.h"
#include "project.h"

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* 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
@ -20,7 +20,7 @@
#include "config.h"
#include <lash/lash.h>
#include "lash/lash.h"
#include <getopt.h>
#include <stdio.h>

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* Copyright (C) 2003 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
@ -19,19 +19,19 @@
*/
#include <lash/lash.h>
#include <lash/internal_headers.h>
#include "project.h"
#include "client.h"
#include "common/safety.h"
project_t *
project_new(const char *name)
{
project_t *project;
project = lash_malloc0(sizeof(project_t));
project = lash_calloc(1, sizeof(project_t));
project_set_name(project, name);
lash_strset(&project->name, name);
return project;
}
@ -41,8 +41,8 @@ project_destroy(project_t * project)
{
lash_list_t *node;
project_set_name(project, NULL);
project_set_dir(project, NULL);
lash_free(&project->name);
lash_free(&project->dir);
for (node = project->clients; node; node = lash_list_next(node))
client_destroy((client_t *) node->data);
@ -52,16 +52,4 @@ project_destroy(project_t * project)
free(project);
}
void
project_set_name(project_t * project, const char *name)
{
set_string_property(project->name, name);
}
void
project_set_dir(project_t * project, const char *dir)
{
set_string_property(project->dir, dir);
}
/* EOF */

View File

@ -1,8 +1,8 @@
/*
* LASH
*
*
* Copyright (C) 2003 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
@ -23,8 +23,8 @@
#include <uuid/uuid.h>
#include <lash/lash.h>
#include <lash/list.h>
#include "lash/lash.h"
#include "common/list.h"
typedef struct _project project_t;
@ -39,8 +39,4 @@ struct _project
project_t * project_new (const char * name);
void project_destroy (project_t * project);
void project_set_name (project_t * project, const char * name);
void project_set_dir (project_t * project, const char * dir);
#endif /* __PROJECT_H__ */

View File

@ -13,3 +13,18 @@ lash_simple_client_LDADD = \
$(top_builddir)/liblash/liblash.la \
$(JACK_LIBS) \
$(ALSA_LIBS)
bin_PROGRAMS = lash_simple_client_newapi
lash_simple_client_newapi_SOURCES = \
simple_client_newapi.c
lash_simple_client_newapi_CFLAGS = \
$(JACK_CFLAGS) \
$(ALSA_CFLAGS) \
-DDEBUG_OUTPUT_TERMINAL
lash_simple_client_newapi_LDADD = \
$(top_builddir)/liblash/liblash.la \
$(JACK_LIBS) \
$(ALSA_LIBS)

View File

@ -0,0 +1,170 @@
/*
* LASH
*
* Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <jack/jack.h>
#include <alsa/asoundlib.h>
#include <lash/lash.h>
#define info(fmt, args...) printf(fmt "\n", ## args)
#define error(fmt, args...) fprintf(stderr, "%s: " fmt "\n", __FUNCTION__, ## args)
/* Callback function prototypes */
static bool save_cb(lash_config_handle_t *handle, void *user_data);
static bool load_cb(lash_config_handle_t *handle, void *user_data);
static bool quit_cb(void *user_data);
int
main(int argc,
char **argv)
{
lash_client_t *client;
jack_client_t *jack_client;
snd_seq_t *aseq;
snd_seq_client_info_t *aseq_client_info;
char client_name[64];
bool done = false;
sprintf(client_name, "lsec_%d", getpid());
info("Client name: '%s'", client_name);
info("Attempting to initialise LASH");
client = lash_client_open("LASH Simple Client", LASH_Config_Data_Set,
argc, argv);
if (!client) {
error("Could not initialise LASH");
return EXIT_FAILURE;
}
info("Connected to LASH with client name '%s'\n"
"Associated with project '%s'",
lash_get_client_name(client),
lash_get_project_name(client));
/* JACK */
info("Connecting to JACK server");
jack_client = jack_client_open(client_name, JackNullOption, NULL);
if (!jack_client) {
error("Could not connect to JACK server");
return EXIT_FAILURE;
}