summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2011-01-06 17:27:52 +0000
committerfcolin2011-01-06 17:27:52 +0000
commit60920f8edff4a701e089e62b1f53c3040e58f309 (patch)
treeb6c9101cb9c6ac547b823f32acab85f47b3d6b37
parent090233152ffa7daad3c5c8268b8983298808d9c3 (diff)
downloadivy-cplusplus-60920f8edff4a701e089e62b1f53c3040e58f309.zip
ivy-cplusplus-60920f8edff4a701e089e62b1f53c3040e58f309.tar.gz
ivy-cplusplus-60920f8edff4a701e089e62b1f53c3040e58f309.tar.bz2
ivy-cplusplus-60920f8edff4a701e089e62b1f53c3040e58f309.tar.xz
correct bug in synchronous mode but no mainloop messages
remove synchronous mode from Ivy C Binding API
-rw-r--r--Ivy/IvyCbindings.cxx54
1 files changed, 41 insertions, 13 deletions
diff --git a/Ivy/IvyCbindings.cxx b/Ivy/IvyCbindings.cxx
index 722be71..abe94cf 100644
--- a/Ivy/IvyCbindings.cxx
+++ b/Ivy/IvyCbindings.cxx
@@ -7,19 +7,41 @@
#include "IvyCbindings.h"
static Ivy *bus = NULL;
+static bool synchronous = false;
// application callback wrappers
-IvyCApplicationCallback app_cb = NULL;
-void * app_user_data = NULL;
-void app_conn( IvyApplication *app )
-{
- (*app_cb)(app, app_user_data, IvyApplicationConnected );
-}
-void app_discon( IvyApplication *app )
-{
- (*app_cb)(app, app_user_data, IvyApplicationDisconnected );
-}
-
+static IvyCApplicationCallback app_cb = NULL;
+static void * app_user_data = NULL;
+static void app_conn( IvyApplication *app )
+{
+ if ( app_cb )
+ (*app_cb)(app, app_user_data, IvyApplicationConnected );
+}
+static void app_discon( IvyApplication *app )
+{
+ if ( app_cb )
+ (*app_cb)(app, app_user_data, IvyApplicationDisconnected );
+}
+#ifdef USE_MESSAGE_MAINLOOP
+static void MyMainLoop()
+{
+ MSG msg;
+ BOOL bRet;
+ while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
+ {
+ if (bRet == -1)
+ {
+ // handle the error and possibly exit
+ break;
+ }
+ else
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+}
+#endif
void IvyInit(
const char *AppName, /* nom de l'application */
const char *ready, /* ready Message peut etre NULL */
@@ -28,7 +50,7 @@ void IvyInit(
IvyCDieCallback die_callback, /* last change callback before die */
void *die_data ) /* user data */
{
- bus = new Ivy(AppName, ready, BUS_APPLICATION_CALLBACK(app_conn,app_discon) );
+ bus = new Ivy(AppName, ready, BUS_APPLICATION_CALLBACK(app_conn,app_discon) , synchronous );
}
/* filtrage des regexps */
void IvySetFilter( int argc, const char **argv)
@@ -123,7 +145,13 @@ void IvyBindDirectMsg( IvyCMsgDirectCallback callback, void *user_data)
void IvySendDirectMsg( IvyClientPtr app, int id, char *msg )
{
}
+
void IvyMainLoop()
{
- Sleep( INFINITE );
+#ifdef USE_MESSAGE_MAINLOOP
+ if ( synchronous )
+ MyMainLoop();
+ else
+#endif
+ Sleep( INFINITE );
}