Re: uwog - r21730 - abiword-plugins/trunk/tools/abicollab/backends/tcp/xp

From: Ryan Pavlik <abiryan_at_ryand.net>
Date: Thu Aug 16 2007 - 15:23:35 CEST

Bad uwog, you told me it did! :)

Sorry about that!

cvs@abisource.com wrote:
> Author: uwog
> Date: 2007-08-16 14:46:09 +0200 (Thu, 16 Aug 2007)
> New Revision: 21730
>
> Modified:
> abiword-plugins/trunk/tools/abicollab/backends/tcp/xp/Synchronizer.h
> Log:
> Fix the tcp backend on unix; bad rp! the UNIX define doesn't exist :)
>
>
>
> Modified: abiword-plugins/trunk/tools/abicollab/backends/tcp/xp/Synchronizer.h
> ===================================================================
> --- abiword-plugins/trunk/tools/abicollab/backends/tcp/xp/Synchronizer.h 2007-08-16 12:32:04 UTC (rev 21729)
> +++ abiword-plugins/trunk/tools/abicollab/backends/tcp/xp/Synchronizer.h 2007-08-16 12:46:09 UTC (rev 21730)
> @@ -28,18 +28,14 @@
>
> class Synchronizer;
>
> -#ifdef UNIX
> -
> -#include <glib.h>
> -static gboolean s_glib_mainloop_callback(GIOChannel *channel, GIOCondition condition, Synchronizer* synchronizer);
> -
> -#endif
> #ifdef WIN32
> #define WM_ABI_TCP_BACKEND WM_USER+15
>
> #include <windows.h>
> #include <xp/AbiCollabSessionManager.h>
> -
> +#else
> +#include <glib.h>
> +static gboolean s_glib_mainloop_callback(GIOChannel *channel, GIOCondition condition, Synchronizer* synchronizer);
> #endif
>
> class Synchronizer
> @@ -115,30 +111,6 @@
> : f_(f),
> data_(data)
> {
> -
> -#ifdef UNIX
> - // on unix, we use the self-pipe trick to signal the glib main loop
> - fdr = -1;
> - fdw = -1;
> -
> - int pfd[2];
> - if (pipe(pfd) == -1)
> - {
> - UT_DEBUGMSG(("pipe error!\n"));
> - // FIXME: throw an exception here, don't just bail out!
> - exit(EXIT_FAILURE);
> - }
> - else
> - {
> - fdr = pfd[0];
> - fdw = pfd[1];
> -
> - // setup the glib main loop integration
> - io_channel = g_io_channel_unix_new(fdr);
> - io_channel_watch_id = g_io_add_watch(io_channel, G_IO_IN, (GIOFunc)s_glib_mainloop_callback, this);
> - }
> -
> -#endif
> #ifdef WIN32
>
> // register a message handler
> @@ -206,8 +178,27 @@
> };
>
> }
> +#else
> + // on unix, we use the self-pipe trick to signal the glib main loop
> + fdr = -1;
> + fdw = -1;
>
> + int pfd[2];
> + if (pipe(pfd) == -1)
> + {
> + UT_DEBUGMSG(("pipe error!\n"));
> + // FIXME: throw an exception here, don't just bail out!
> + exit(EXIT_FAILURE);
> + }
> + else
> + {
> + fdr = pfd[0];
> + fdw = pfd[1];
>
> + // setup the glib main loop integration
> + io_channel = g_io_channel_unix_new(fdr);
> + io_channel_watch_id = g_io_add_watch(io_channel, G_IO_IN, (GIOFunc)s_glib_mainloop_callback, this);
> + }
> #endif
> }
> // end constructor
> @@ -220,17 +211,6 @@
> {
> UT_DEBUGMSG(("~Synchronizer()\n"));
>
> -#ifdef UNIX
> - if (fdr != -1)
> - close(fdr);
> - if (fdw != -1)
> - close(fdw);
> -
> - g_source_remove(io_channel_watch_id);
> - //g_io_channel_shutdown(io_channel, TRUE, NULL);
> - g_io_channel_unref(io_channel);
> - io_channel_watch_id = 0;
> -#endif
> #ifdef WIN32
>
> // destroy our window
> @@ -243,6 +223,16 @@
> {
> UT_DEBUGMSG(("TCP Backend Synchronizer Window already destroyed!\n"));
> }
> +#else
> + if (fdr != -1)
> + close(fdr);
> + if (fdw != -1)
> + close(fdw);
> +
> + g_source_remove(io_channel_watch_id);
> + //g_io_channel_shutdown(io_channel, TRUE, NULL);
> + g_io_channel_unref(io_channel);
> + io_channel_watch_id = 0;
> #endif
>
> }
> @@ -254,19 +244,18 @@
> //////////////////
> void signal()
> {
> -#ifdef UNIX
> -
> - char signal = 0xff;
> - if (write(fdw, &signal, 1) != 1)
> - printf("Error signaling main loop!\n");
> -
> -#endif
> + UT_DEBUGMSG(("Synchronizer::signal()\n"));
> #ifdef WIN32
>
> // send a message to the main loop
> int result=SendMessage(m_hWnd, WM_ABI_TCP_BACKEND, 0, 0);
> UT_DEBUGMSG(("Synchronizer::signal() - SendMessage returned %d\n", result));
>
> +#else
> + UT_DEBUGMSG(("Signalling the main loop\n"));
> + char signal = 0xff;
> + if (write(fdw, &signal, 1) != 1)
> + printf("Error signaling main loop!\n");
> #endif
> }
>
> @@ -276,17 +265,13 @@
> //////////////////
> void consume()
> {
> -#ifdef UNIX
> -
> +#ifdef WIN32
> + // void on win32
> +#else
> char signal = 0;
> if (read(fdr, &signal, 1) != 1)
> printf("Error signaling main loop!\n");
> -
> #endif
> -#ifdef WIN32
> - // void on win32
> -
> -#endif
> }
>
>
> @@ -306,19 +291,15 @@
> //////////////////
> // PRIVATE DATA
> //////////////////
> -#ifdef UNIX
> -
> +#ifdef WIN32
> + HWND m_hWnd;
> +#else
> int fdr;
> int fdw;
> GIOChannel* io_channel;
> guint io_channel_watch_id;
> -
> #endif
> -#ifdef WIN32
> - HWND m_hWnd;
>
> -#endif
> -
> void (*f_)(void*);
> void* data_;
> };
> @@ -326,13 +307,12 @@
> //////////////////
> // GLOBAL FUNCTIONS
> //////////////////
> -#ifdef UNIX
> +#ifndef WIN32
> static gboolean s_glib_mainloop_callback(GIOChannel *channel, GIOCondition condition, Synchronizer* synchronizer)
> {
> synchronizer->fromMainloopCallback();
> return TRUE;
> }
> -
> #endif
>
> #endif /* __SYNCHRONIZER__ */
>
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the word
> unsubscribe in the message body.
>
>

-- 
Ryan Pavlik
AbiWord Win32 Platform Maintainer, Art Lead: www.abisource.com
AbiWord Community Outreach Project: www.cleardefinition.com/oss/abi/blog/
"Optimism is the father that leads to achievement."
 -- Helen Keller
"The folder structure in a modern Linux distribution such as Ubuntu
was largely inspired by the original UNIX foundations that were
created by men with large beards and sensible jumpers."
 -- Jono Bacon, The Ubuntu Guide
Received on Thu Aug 16 15:26:30 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 16 2007 - 15:26:30 CEST