Timeline: Transition to C NSM API header instead of C++ version.
This commit is contained in:
parent
fa195cf817
commit
6ae771b297
|
@ -21,26 +21,22 @@
|
|||
#include "debug.h"
|
||||
#include "Timeline.H"
|
||||
#include "TLE.H"
|
||||
#include "NSM.H"
|
||||
#include "Project.H"
|
||||
#include "OSC/Endpoint.H"
|
||||
|
||||
#include <nsm.h>
|
||||
|
||||
#define OSC_INTERVAL 0.2f
|
||||
|
||||
extern char *instance_name;
|
||||
extern Timeline *timeline;
|
||||
|
||||
extern NSM_Client *nsm;
|
||||
// extern NSM_Client *nsm;
|
||||
|
||||
NSM_Client::NSM_Client ( )
|
||||
{
|
||||
}
|
||||
|
||||
int command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg );
|
||||
int command_save ( char **out_msg );
|
||||
|
||||
int
|
||||
NSM_Client::command_save ( char **out_msg )
|
||||
static int
|
||||
command_save ( char **out_msg, void *userdata )
|
||||
{
|
||||
if ( timeline->command_save() )
|
||||
return ERR_OK;
|
||||
|
@ -51,8 +47,8 @@ NSM_Client::command_save ( char **out_msg )
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
NSM_Client::command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg )
|
||||
static int
|
||||
command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg, void *userdata )
|
||||
{
|
||||
if ( instance_name )
|
||||
free( instance_name );
|
||||
|
@ -89,16 +85,16 @@ NSM_Client::command_open ( const char *name, const char *display_name, const cha
|
|||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
NSM_Client::command_session_is_loaded ( void )
|
||||
static void
|
||||
command_session_is_loaded ( void *userdata )
|
||||
{
|
||||
MESSAGE( "NSM says session is loaded." );
|
||||
|
||||
timeline->discover_peers();
|
||||
}
|
||||
|
||||
int
|
||||
NSM_Client::command_broadcast ( const char *path, lo_message msg )
|
||||
static int
|
||||
command_broadcast ( const char *path, lo_message msg, void *userdata )
|
||||
{
|
||||
int argc = lo_message_get_argc( msg );
|
||||
// lo_arg **argv = lo_message_get_argv( msg );
|
||||
|
@ -112,3 +108,12 @@ NSM_Client::command_broadcast ( const char *path, lo_message msg )
|
|||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
set_nsm_callbacks ( nsm_client_t *nsm )
|
||||
{
|
||||
nsm_set_open_callback( nsm, command_open, 0 );
|
||||
nsm_set_save_callback( nsm, command_save, 0 );
|
||||
nsm_set_broadcast_callback( nsm, command_broadcast, 0 );
|
||||
nsm_set_session_is_loaded_callback( nsm, command_session_is_loaded, 0 );
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
/*******************************************************************************/
|
||||
/* Copyright (C) 2012 Jonathan Moore Liles */
|
||||
/* */
|
||||
/* 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; see the file COPYING. If not,write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "NSM/Client.H"
|
||||
|
||||
class NSM_Client : public NSM::Client
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NSM_Client ( );
|
||||
~NSM_Client ( ) { };
|
||||
|
||||
protected:
|
||||
|
||||
int command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg );
|
||||
int command_save ( char **out_msg );
|
||||
void command_session_is_loaded ( void );
|
||||
|
||||
int command_broadcast ( const char *path, lo_message msg );
|
||||
};
|
|
@ -91,10 +91,10 @@ decl {\#include "FL/About_Dialog.H"} {private local
|
|||
decl {extern char project_display_name[256];} {private global
|
||||
}
|
||||
|
||||
decl {\#include "NSM.H"} {private local
|
||||
decl {\#include <nsm.h>} {private local
|
||||
}
|
||||
|
||||
decl {extern NSM_Client *nsm;} {private global
|
||||
decl {extern nsm_client_t *nsm;} {private global
|
||||
}
|
||||
|
||||
decl {extern char *user_config_dir;} {private global
|
||||
|
@ -905,7 +905,7 @@ else if ( 0 == p )
|
|||
|
||||
static char pat[10];
|
||||
|
||||
nsm->progress( p / 100.0f );
|
||||
nsm_send_progress( nsm, p / 100.0f );
|
||||
update_progress( progress, pat, p );
|
||||
|
||||
progress->redraw();
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#include "OSC_Thread.H"
|
||||
#include "OSC/Endpoint.H"
|
||||
|
||||
#include "NSM.H"
|
||||
extern NSM_Client *nsm;
|
||||
#include <nsm.h>
|
||||
extern nsm_client_t *nsm;
|
||||
|
||||
#ifdef USE_WIDGET_FOR_TIMELINE
|
||||
#define BASE Fl_Group
|
||||
|
@ -1556,7 +1556,7 @@ Timeline::command_new ( const char *name, const char *display_name )
|
|||
const char *
|
||||
Timeline::session_manager_name ( void )
|
||||
{
|
||||
return nsm->session_manager_name();
|
||||
return nsm_get_session_manager_name( nsm );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1673,14 +1673,14 @@ Timeline::connect_osc ( void )
|
|||
void
|
||||
Timeline::discover_peers ( void )
|
||||
{
|
||||
if ( nsm->is_active() )
|
||||
if ( nsm_is_active( nsm ) )
|
||||
{
|
||||
lo_message m = lo_message_new();
|
||||
|
||||
lo_message_add_string( m, "/non/finger" );
|
||||
lo_message_add_string( m, osc->url() );
|
||||
|
||||
nsm->broadcast( m );
|
||||
nsm_send_broadcast( nsm, m );
|
||||
|
||||
lo_message_free( m );
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@
|
|||
|
||||
#include "Thread.H"
|
||||
|
||||
#include "NSM.H"
|
||||
#include <nsm.h>
|
||||
|
||||
extern void set_nsm_callbacks ( nsm_client_t *nsm );
|
||||
|
||||
#ifdef HAVE_XPM
|
||||
#include "FL/Fl.H"
|
||||
|
@ -64,7 +66,7 @@ Engine *engine;
|
|||
Timeline *timeline;
|
||||
Transport *transport;
|
||||
TLE *tle;
|
||||
NSM_Client *nsm;
|
||||
nsm_client_t *nsm;
|
||||
|
||||
char *instance_name = NULL;
|
||||
|
||||
|
@ -118,7 +120,7 @@ extern Timeline *timeline;
|
|||
void
|
||||
check_nsm ( void * v )
|
||||
{
|
||||
nsm->check();
|
||||
nsm_check_nowait( nsm );
|
||||
Fl::repeat_timeout( NSM_CHECK_INTERVAL, check_nsm, v );
|
||||
}
|
||||
|
||||
|
@ -234,7 +236,8 @@ main ( int argc, char **argv )
|
|||
|
||||
tle = new TLE;
|
||||
|
||||
nsm = new NSM_Client;
|
||||
nsm = nsm_new();
|
||||
set_nsm_callbacks( nsm );
|
||||
|
||||
MESSAGE( "Starting GUI" );
|
||||
|
||||
|
@ -255,7 +258,7 @@ main ( int argc, char **argv )
|
|||
|
||||
if ( nsm_url )
|
||||
{
|
||||
if ( ! nsm->init( nsm_url ) )
|
||||
if ( ! nsm_init( nsm, nsm_url ) )
|
||||
{
|
||||
if ( instance_override )
|
||||
WARNING( "--instance option is not available when running under session management, ignoring." );
|
||||
|
@ -263,7 +266,7 @@ main ( int argc, char **argv )
|
|||
if ( optind < argc )
|
||||
WARNING( "Loading files from the command-line is incompatible with session management, ignoring." );
|
||||
|
||||
nsm->announce( APP_NAME, ":progress:switch:", argv[0] );
|
||||
nsm_send_announce( nsm, APP_NAME, ":progress:switch:", argv[0] );
|
||||
|
||||
/* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */
|
||||
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );
|
||||
|
@ -297,7 +300,7 @@ main ( int argc, char **argv )
|
|||
delete tle;
|
||||
tle = NULL;
|
||||
|
||||
delete nsm;
|
||||
nsm_free( nsm );
|
||||
nsm = NULL;
|
||||
|
||||
MESSAGE( "Your fun is over" );
|
||||
|
|
Loading…
Reference in New Issue