summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ivy/Ivy.cxx29
1 files changed, 25 insertions, 4 deletions
diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx
index e5b11ea..8b26e77 100644
--- a/Ivy/Ivy.cxx
+++ b/Ivy/Ivy.cxx
@@ -27,6 +27,7 @@ Ivy::~Ivy()
// remove all app and stop watcher
stop();
regexp_out.clear();
+
if ( synchronous )
{
@@ -55,7 +56,7 @@ Ivy::~Ivy()
Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, bool Synchronous)
{
InitializeCriticalSection( &m_application_cs );
-
+ regexp_id = 0;
synchronous = Synchronous;
if ( synchronous )
IvySynchronousCallback::m_synchro = new IvySynchroWnd();
@@ -129,7 +130,6 @@ void Ivy::stop()
}
int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb)
{
- static int id = 0;
regexp_out.push_back( regexp );
callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb );
@@ -138,11 +138,32 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb)
for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
IvyApplication *app = *iter;
- app->SendMsg(IvyApplication::AddRegexp, id, regexp );
+ app->SendMsg(IvyApplication::AddRegexp, regexp_id, regexp );
}
- return id++;
+ return regexp_id++;
}
+int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... )
+{
+ char buffer[4096];
+ va_list args;
+
+ va_start( args, regexp ); /* Initialize variable arguments. */
+ vsprintf( buffer, regexp, args );
+ va_end( args);
+
+ regexp_out.push_back( regexp );
+ callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb );
+ /* send to already connected */
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
+ {
+ IvyApplication *app = *iter;
+ app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer );
+ }
+ return regexp_id++;
+}
+
void Ivy::UnbindMsg(int id)
{
regexp_out[ id ] = "";