Mercurial > pidgin.yaz
changeset 14224:ab8a105eff62
[gaim-migrate @ 16905]
First step of getting wingaim working again.
libgaim and gtk are compiling.
The protocols aren't compiling yet.
There are a number of things that are compiling, but should be cleaned up.
committer: Tailor Script <tailor@pidgin.im>
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,229 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of Gaim +# + +# +# PATHS +# + +GTK_TOP := ../../win32-dev/gtk_2_0 +GAIM_TOP := .. +GTKGAIM_TOP := . +LIBGAIM_TOP := ../libgaim +ASPELL_TOP := ../../win32-dev/aspell-dev-0-50-3-3 +GTKSPELL_TOP := ../../win32-dev/gtkspell-2.0.6 +IDLETRACK_TOP := $(GTKGAIM_TOP)/win32/IdleTracker +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +#LIBXML2_DIR := ../../win32-dev/libxml2 + +## +## VARIABLE DEFINITIONS +## + +EXE_TARGET = gaim + +GTKGAIM_TARGET = gtkgaim + +# Compiler and Linker Options + +CFLAGS = + +DEFINES = + +ifeq ($(MAKECMDGOALS), $(EXE_TARGET)-portable.exe) +DEFINES := $(DEFINES) -DPORTABLE +endif + +WINAPP := -mwindows +# The Debug version of gaim is a console app, always having a console +CONSOLEAPP := -mconsole + +LDFLAGS := $(WINAPP) + +WINDRES := windres + +## +## INCLUDE MAKEFILES +## + +include $(LIBGAIM_TOP)/win32/global.mak + +## +## INCLUDE PATHS +## + +LIBGAIM_INCLUDE_PATHS = \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GAIM_TOP) \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include + +# -I$(LIBXML2_DIR)/include + +INCLUDE_PATHS = \ + $(LIBGAIM_INCLUDE_PATHS) \ + -I$(IDLETRACK_TOP) \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(GTKSPELL_TOP) \ + -I$(ASPELL_TOP)/include + + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) \ + -L$(IDLETRACK_TOP) \ + -L$(ASPELL_TOP)/lib + +# -L$(LIBXML2_DIR)/lib + +## +## SOURCES, OBJECTS +## + +GTKGAIM_C_SRC = \ + gaimstock.c \ + gtkaccount.c \ + gtkblist.c \ + gtkconn.c \ + gtkconv.c \ + gtkcellrendererprogress.c \ + gtkdebug.c \ + gtkdialogs.c \ + gtkdnd-hints.c \ + gtkeventloop.c \ + gtkexpander.c \ + gtkft.c \ + gtkidle.c \ + gtkimhtml.c \ + gtkimhtmltoolbar.c \ + gtklog.c \ + gtkmain.c \ + gtkmenutray.c \ + gtknotify.c \ + gtkplugin.c \ + gtkpluginpref.c \ + gtkpounce.c \ + gtkprefs.c \ + gtkprivacy.c \ + gtkrequest.c \ + gtkroomlist.c \ + gtksavedstatuses.c \ + gtksound.c \ + gtksourceiter.c \ + gtkstatusbox.c \ + gtkthemes.c \ + gtkutils.c \ + gtkwhiteboard.c \ + win32/gtkwin32dep.c \ + win32/untar.c \ + win32/wspell.c + +RC_SRC = win32/gaimrc.rc + +EXE_C_SRC = win32/win_gaim.c + +GTKGAIM_OBJECTS = $(GTKGAIM_C_SRC:%.c=%.o) + +EXE_OBJECTS = $(EXE_C_SRC:%.c=%.o) $(RC_SRC:%.rc=%.o) + +## +## LIBRARIES +## + +LIBGAIM_LIBS = \ + -lgaim \ + -lglib-2.0 \ + -lgthread-2.0 \ + -lgobject-2.0 \ + -lgmodule-2.0 \ + -lintl \ + -lws2_32 \ + -lwinmm \ + -lz \ + -liberty \ + -lidletrack + +# -lxml2 + +GTKGAIM_LIBS = \ + $(LIBGAIM_LIBS) \ + -lgtk-win32-2.0 \ + -latk-1.0 \ + -lpango-1.0 \ + -lgdk-win32-2.0 \ + -lgdk_pixbuf-2.0 + +EXE_LIBS = + +## +## RULES +## + +# How to make a C file +%.o: %.c + $(CC) $(CFLAGS) $(INCLUDE_PATHS) $(DEFINES) -c $< -o $@ + +# How to make an RC file +%.o: %.rc + $(WINDRES) -i $< -o $@ + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean libgaim_include_path gtkgaim_include_path + +all: $(EXE_TARGET).exe $(GTKGAIM_TARGET).dll + +install: all + cp $(GTKGAIM_TOP)/$(EXE_TARGET).exe $(GTKGAIM_TOP)/$(GTKGAIM_TARGET).dll $(GAIM_INSTALL_DIR) + +$(LIBGAIM_TOP)/libgaim.dll.a: + S(MAKE) -C $(LIBGAIM_TOP) -f Makefile.mingw libgaim.dll.a + +$(IDLETRACK_TOP)/idletrack.dll: + $(MAKE) -C $(IDLETRACK_TOP) -f Makefile.mingw + +# +# BUILD DLL +# +#$(GTKGAIM_TARGET).dll.a $(GTKGAIM_TARGET).dll: INCLUDE_PATHS = $(GTKGAIM_INCLUDE_PATHS) +#Once the UI split has finished for server.c, this will be the correct line +#$(GTKGAIM_TARGET).dll.a $(GTKGAIM_TARGET).dll: $(LIBGAIM_TARGET).dll.a $(GTKGAIM_OBJECTS) +$(GTKGAIM_TARGET).dll.a $(GTKGAIM_TARGET).dll: $(LIBGAIM_TOP)/libgaim.dll.a $(GTKGAIM_OBJECTS) $(IDLETRACK_TOP)/idletrack.dll + $(CC) -shared $(LIBGAIM_OBJECTS) $(GTKGAIM_OBJECTS) $(LIB_PATHS) $(GTKGAIM_LIBS) $(DLL_LD_FLAGS) -Wl,--out-implib,$(GTKGAIM_TARGET).dll.a -o $(GTKGAIM_TARGET).dll + +# +# BUILD EXE +# + +$(EXE_TARGET).exe: $(GTKGAIM_TARGET).dll $(EXE_OBJECTS) + $(CC) $(LDFLAGS) $(EXE_OBJECTS) $(LIB_PATHS) $(EXE_LIBS) -o $(EXE_TARGET).exe + +$(EXE_TARGET)-portable.exe: clean_exe $(EXE_OBJECTS) + $(CC) $(LDFLAGS) $(EXE_OBJECTS) $(LIB_PATHS) $(EXE_LIBS) -o $(EXE_TARGET)-portable.exe + rm win_gaim.o + +## +## CLEAN RULES +## + +clean: + $(MAKE) -C $(IDLETRACK_TOP) -f Makefile.mingw clean + rm -rf *.o ./win32/*.o + rm -rf $(GTKGAIM_TARGET).dll + rm -rf $(GTKGAIM_TARGET).dll.a + rm -rf $(EXE_TARGET).exe + +clean_exe: + rm -rf win_gaim.o
--- a/gtk/gtkmain.c Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/gtkmain.c Sun Aug 20 16:49:37 2006 +0000 @@ -78,7 +78,7 @@ #endif #ifdef _WIN32 -# include "wspell.h" +# include "gtkwin32dep.h" #endif @@ -635,9 +635,6 @@ gaim_debug_set_enabled(debug_enabled); -#ifdef _WIN32 - wgaim_init(hint); -#endif search_path = g_build_filename(gaim_user_dir(), "gtkrc-2.0", NULL); gtk_rc_add_default_file(search_path); @@ -668,11 +665,7 @@ } #ifdef _WIN32 - /** TODO: Move this to a wgaim_gtk_init() if we need such a thing */ - wgaim_gtkspell_init(); - gaim_debug_info("wgaim", "GTK+ :%u.%u.%u\n", - gtk_major_version, gtk_minor_version, gtk_micro_version); - + gtkwgaim_init(hint); #endif gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops()); @@ -784,7 +777,7 @@ #endif #ifdef _WIN32 - wgaim_cleanup(); + gtkwgaim_cleanup(); #endif return 0;
--- a/gtk/gtknotify.c Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/gtknotify.c Sun Aug 20 16:49:37 2006 +0000 @@ -38,6 +38,10 @@ #include "gtknotify.h" #include "gtkutils.h" +#ifdef _WIN32 +# include "gtkwin32dep.h" +#endif + typedef struct { GaimConnection *gc; @@ -116,7 +120,7 @@ if (id == GTK_RESPONSE_YES) { GtkTreeSelection *selection; - + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); if (gtk_tree_selection_get_selected(selection, NULL, &iter)) @@ -762,7 +766,7 @@ gaim_notify_searchresults_column_get_title(results, i-1), renderer, "text", i, NULL); } - + /* Setup the button area */ button_area = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(vbox), button_area, FALSE, FALSE, 0); @@ -1072,7 +1076,7 @@ g_free(command); #else /* !_WIN32 */ - wgaim_notify_uri(uri); + gtkwgaim_notify_uri(uri); #endif /* !_WIN32 */ return NULL;
--- a/gtk/gtkprefs.c Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/gtkprefs.c Sun Aug 20 16:49:37 2006 +0000 @@ -50,6 +50,10 @@ #include "gtkutils.h" #include "gaimstock.h" +#ifdef _WIN32 +# include "gtkwin32dep.h" +#endif + #define PROXYHOST 0 #define PROXYPORT 1 #define PROXYUSER 2 @@ -494,7 +498,7 @@ g_free(path_escaped); g_free(destdir_escaped); #else - if(!wgaim_gz_untar(path, destdir)) { + if(!gtkwgaim_gz_untar(path, destdir)) { g_free(destdir); return; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,136 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of Gaim Plugins +# + +# +# PATHS +# + +GAIM_PLUGINS := . +GAIM_TOP := ../.. +GTKGAIM_TOP := .. +LIBGAIM_TOP := $(GAIM_TOP)/libgaim +GTK_TOP := ../../../win32-dev/gtk_2_0 +#OSCAR_ROOT := ../src/protocols/oscar +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +TICKER := ./ticker +TRANSPARENCY := ./win32/transparency +WINPREFS := ./win32/winprefs +#PERL_PLUGIN_LOADER := ./perl +DOCKLET := ./docklet + +## +## VARIABLE DEFINITIONS +## + +# Compiler Options + +CFLAGS = + +DEFINES = + +.SUFFIXES: +.SUFFIXES: .c .dll + +## +## INCLUDE MAKEFILES +## + +include $(LIBGAIM_TOP)/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(GAIM_TOP) \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) + + +## +## LIBRARIES +## + +LIBS = -lgtk-win32-2.0 \ + -lglib-2.0 \ + -lgdk-win32-2.0 \ + -lgobject-2.0 \ + -lgmodule-2.0 \ + -lgdk_pixbuf-2.0 \ + -lpango-1.0 \ + -lintl \ + -lws2_32 \ + -lgaim \ + -lgtkgaim + +## +## RULES +## + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: plugins + $(MAKE) -C $(TICKER) -f Makefile.mingw + $(MAKE) -C $(WINPREFS) -f Makefile.mingw + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw + $(MAKE) -C $(DOCKLET) -f Makefile.mingw + +install: + cp $(GAIM_PLUGINS)/*.dll $(GAIM_INSTALL_DIR)/plugins + $(MAKE) -C $(TICKER) -f Makefile.mingw install + $(MAKE) -C $(WINPREFS) -f Makefile.mingw install + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw install + $(MAKE) -C $(DOCKLET) -f Makefile.mingw install + +# +# BUILD Plugin +# + +.c.dll: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@.o -c $< + $(CC) -shared $@.o $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $@ + +plugins: \ + extplacement.dll \ + gaimrc.dll \ + history.dll \ + iconaway.dll \ + notify.dll \ + relnot.dll \ + spellchk.dll \ + timestamp_format.dll \ + timestamp.dll + + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf *.dll + $(MAKE) -C $(TICKER) -f Makefile.mingw clean + $(MAKE) -C $(TRANSPARENCY) -f Makefile.mingw clean + $(MAKE) -C $(WINPREFS) -f Makefile.mingw clean + $(MAKE) -C $(DOCKLET) -f Makefile.mingw clean
--- a/gtk/plugins/docklet/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/plugins/docklet/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -8,8 +8,10 @@ # PATHS # -GTK_TOP := ../../../win32-dev/gtk_2_0 -GAIM_TOP := ../.. +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +LIBGAIM_TOP := $(GAIM_TOP)/libgaim +GTKGAIM_TOP := $(GAIM_TOP)/gtk GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins @@ -29,7 +31,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak ## ## INCLUDE PATHS @@ -43,13 +45,16 @@ -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ -I$(GTK_TOP)/lib/gtk-2.0/include \ - -I$(GAIM_TOP)/src \ - -I$(GAIM_TOP)/src/win32 \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 \ -I$(GAIM_TOP) LIB_PATHS = -L$(GTK_TOP)/lib \ - -L$(GAIM_TOP)/src + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) ## @@ -71,11 +76,10 @@ LIBS = -lgtk-win32-2.0 \ -lglib-2.0 \ -lgdk-win32-2.0 \ - -lgmodule-2.0 \ -lgobject-2.0 \ - -lws2_32 \ -lintl \ - -lgaim + -lgaim \ + -lgtkgaim ## @@ -103,14 +107,15 @@ ## BUILD Dependencies ## -$(GAIM_TOP)/src/gaim.lib: - $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib +$(GTKGAIM_TOP)/gtkgaim.dll.a: + $(MAKE) -C $(GTKGAIM_TOP) -f Makefile.mingw gtkgaim.dll.a + ## ## BUILD DLL ## -$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib +$(TARGET).dll: $(OBJECTS) $(GTKGAIM_TOP)/gtkgaim.dll.a $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll ##
--- a/gtk/plugins/docklet/docklet-win32.c Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/plugins/docklet/docklet-win32.c Sun Aug 20 16:49:37 2006 +0000 @@ -36,6 +36,7 @@ #include "resource.h" #include "MinimizeToTray.h" +#include "gtkwin32dep.h" #include "docklet.h" /* @@ -115,7 +116,7 @@ wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; - wcex.hInstance = wgaim_hinstance(); + wcex.hInstance = gtkwgaim_hinstance(); wcex.hIcon = NULL; wcex.hCursor = NULL, wcex.hbrBackground = NULL; @@ -126,7 +127,7 @@ RegisterClassEx(&wcex); /* Create the window */ - return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, wgaim_hinstance(), 0)); + return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, gtkwgaim_hinstance(), 0)); } static void systray_init_icon(HWND hWnd, HICON icon) { @@ -212,19 +213,19 @@ * but will scale it back to 4-bits for display. * That is why we use custom 4-bit icons for pre XP Windowses */ if (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) { - sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); } else { - sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); } - sysicon_blank = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_blank = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0); /* Create icon in systray */ systray_init_icon(systray_hwnd, sysicon_disconn);
--- a/gtk/plugins/ticker/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/plugins/ticker/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -8,10 +8,10 @@ # PATHS # -INCLUDE_DIR := . - -GTK_TOP := ../../../win32-dev/gtk_2_0 -GAIM_TOP := ../.. +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +GTKGAIM_TOP := $(GAIM_TOP)/gtk +LIBGAIM_TOP := $(GAIM_TOP)/libgaim TICKER_ROOT := . GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins @@ -33,7 +33,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak ## ## INCLUDE PATHS @@ -47,13 +47,16 @@ -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ -I$(GTK_TOP)/lib/gtk-2.0/include \ - -I$(GAIM_TOP)/src \ - -I$(GAIM_TOP)/src/win32 \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 \ -I$(GAIM_TOP) LIB_PATHS = -L$(GTK_TOP)/lib \ - -L$(GAIM_TOP)/src + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) ## @@ -76,9 +79,9 @@ -lgdk-win32-2.0 \ -lgmodule-2.0 \ -lgobject-2.0 \ - -lws2_32 \ -lintl \ - -lgaim + -lgaim \ + -lgtkgaim ## ## RULES @@ -105,14 +108,14 @@ ## BUILD Dependencies ## -$(GAIM_TOP)/src/gaim.lib: - $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib +$(GTKGAIM_TOP)/gtkgaim.dll.a: + $(MAKE) -C $(GTKGAIM_TOP) -f Makefile.mingw gtkgaim.dll.a ## ## BUILD DLL ## -$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib +$(TARGET).dll: $(OBJECTS) $(GTKGAIM_TOP)/gtkgaim.dll.a $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll ##
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/transparency/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,126 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32trans plugin. +# + +# +# PATHS +# + +GTK_TOP := ../../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../../.. +LIBGAIM_TOP := ../../../../libgaim +GTKGAIM_TOP := ../../../../gtk +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins + +## +## VARIABLE DEFINITIONS +## + +TARGET = win2ktrans + +# Compiler Options + +CFLAGS = + +# This plugin requires W2K+ API +DEFINES = -D_WIN32_WINNT=0x0500 + +## +## INCLUDE MAKEFILES +## + +include $(LIBGAIM_TOP)/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += -I. \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 \ + -I$(GAIM_TOP) + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) + + +## +## SOURCES, OBJECTS +## + +C_SRC = win2ktrans.c + + +OBJECTS = $(C_SRC:%.c=%.o) + + +## +## LIBRARIES +## + +LIBS = -lgtk-win32-2.0 \ + -lglib-2.0 \ + -lgdk-win32-2.0 \ + -lgmodule-2.0 \ + -lgobject-2.0 \ + -lintl \ + -lgtkgaim \ + -lgaim + + +## +## RULES +## + +# How to make a C file + +%.o: %.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@ -c $< + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: $(TARGET).dll + +install: all + cp $(TARGET).dll $(DLL_INSTALL_DIR) + + +## +## BUILD Dependencies +## + +$(GTKGAIM_TOP)/gtkgaim.dll.a: + $(MAKE) -C $(GTKGAIM_TOP) -f Makefile.mingw gtkgaim.dll.a + +## +## BUILD DLL +## + +$(TARGET).dll: $(OBJECTS) $(GTKGAIM_TOP)/gtkgaim.dll.a + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf $(TARGET).dll
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/transparency/win2ktrans.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,692 @@ +/* + * gaim - Transparency plugin + * + * copyright (c) 1998-2002, rob flynn <rob@marko.net> + * copyright (c) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * copyright (c) 2005, Daniel Atallah <daniel_atallah@yahoo.com> + * + * 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., 59 temple place, suite 330, boston, ma 02111-1307 usa + * + */ +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#endif +#include <gdk/gdkwin32.h> +#include "internal.h" + +#include "core.h" +#include "prefs.h" +#include "debug.h" + +#include "gtkconv.h" +#include "gtkplugin.h" +#include "gtkprefs.h" +#include "gtkblist.h" +#include "gtkutils.h" +#include "signals.h" +#include "version.h" + +/* + * MACROS & DEFINES + */ +#define WINTRANS_PLUGIN_ID "gtk-win-trans" + +#define blist (gaim_get_blist() \ + ? (GAIM_GTK_BLIST(gaim_get_blist()) \ + ? ((GAIM_GTK_BLIST(gaim_get_blist()))->window) \ + : NULL) \ + : NULL) + +/* + * DATA STRUCTS + */ +typedef struct { + GtkWidget *win; + GtkWidget *slider; +} slider_win; + +/* + * LOCALS + */ +static const char *OPT_WINTRANS_IM_ENABLED= "/plugins/gtk/win32/wintrans/im_enabled"; +static const char *OPT_WINTRANS_IM_ALPHA = "/plugins/gtk/win32/wintrans/im_alpha"; +static const char *OPT_WINTRANS_IM_SLIDER = "/plugins/gtk/win32/wintrans/im_slider"; +static const char *OPT_WINTRANS_IM_ONFOCUS= "/plugins/gtk/win32/wintrans/im_solid_onfocus"; +static const char *OPT_WINTRANS_IM_ONTOP = "/plugins/gtk/win32/wintrans/im_always_on_top"; +static const char *OPT_WINTRANS_BL_ENABLED= "/plugins/gtk/win32/wintrans/bl_enabled"; +static const char *OPT_WINTRANS_BL_ALPHA = "/plugins/gtk/win32/wintrans/bl_alpha"; +static const char *OPT_WINTRANS_BL_ONFOCUS= "/plugins/gtk/win32/wintrans/bl_solid_onfocus"; +static const char *OPT_WINTRANS_BL_ONTOP = "/plugins/gtk/win32/wintrans/bl_always_on_top"; +static GSList *window_list = NULL; + +static BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) = NULL; + +/* + * CODE + */ +static GtkWidget *wgaim_button(const char *text, const char *pref, GtkWidget *page) { + GtkWidget *button; + button = gtk_check_button_new_with_mnemonic(text); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), + gaim_prefs_get_bool(pref)); + gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); + gtk_widget_show(button); + return button; +} + +/* Set window transparency level */ +static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, + gboolean always_on_top) { + if (MySetLayeredWindowAttributes) { + HWND hWnd = GDK_WINDOW_HWND(window->window); + LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); + if (enabled) { + style |= WS_EX_LAYERED; + } else { + style &= ~WS_EX_LAYERED; + } + SetWindowLong(hWnd, GWL_EXSTYLE, style); + + + if (enabled) { + SetWindowPos(hWnd, + always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, + 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + MySetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); + } else { + /* Ask the window and its children to repaint */ + SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + + RedrawWindow(hWnd, NULL, NULL, + RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); + } + } +} + +/* When a conv window is focused, if we're only transparent when unfocused, + * deal with transparency */ +static gboolean focus_conv_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) { + if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED) + && gaim_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS)) { + GtkWidget *window = (GtkWidget *) d; + if (e->in) { /* Focused */ + set_wintrans(window, 0, FALSE, + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + } else { + set_wintrans(window, + gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA), + TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + } + } + return FALSE; +} + +/* When buddy list window is focused, + * if we're only transparent when unfocused, deal with transparency */ +static gboolean focus_blist_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) { + if (gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED) + && gaim_prefs_get_bool(OPT_WINTRANS_BL_ONFOCUS)) { + GtkWidget *window = (GtkWidget *) d; + if (e->in) { /* Focused */ + set_wintrans(window, 0, FALSE, + gaim_prefs_get_bool(OPT_WINTRANS_BL_ONTOP)); + } else { + set_wintrans(window, + gaim_prefs_get_int(OPT_WINTRANS_BL_ALPHA), + TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_BL_ONTOP)); + } + } + return FALSE; +} + +static void change_alpha(GtkWidget *w, gpointer data) { + int alpha = gtk_range_get_value(GTK_RANGE(w)); + gaim_prefs_set_int(OPT_WINTRANS_IM_ALPHA, alpha); + + /* If we're in no-transparency on focus mode, + * don't take effect immediately */ + if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS)) + set_wintrans(GTK_WIDGET(data), alpha, TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); +} + + +static GtkWidget *wintrans_slider(GtkWidget *win) { + GtkWidget *hbox; + GtkWidget *label, *slider; + GtkWidget *frame; + + int imalpha = gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA); + + frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); + gtk_widget_show(frame); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(frame), hbox); + + label = gtk_label_new(_("Opacity:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + slider = gtk_hscale_new_with_range(50, 255, 1); + gtk_range_set_value(GTK_RANGE(slider), imalpha); + gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); + + /* On slider val change, update window's transparency level */ + g_signal_connect(GTK_OBJECT(slider), "value-changed", + GTK_SIGNAL_FUNC(change_alpha), win); + + gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); + + /* Set the initial transparency level */ + set_wintrans(win, imalpha, TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + + gtk_widget_show_all(hbox); + + return frame; +} + +static slider_win* find_slidwin(GtkWidget *win) { + GSList *tmp = window_list; + + while (tmp) { + if (((slider_win*) (tmp->data))->win == win) + return (slider_win*) tmp->data; + tmp = tmp->next; + } + return NULL; +} + +/* Clean up transparency stuff for the conv window */ +static void cleanup_conv_window(GaimGtkWindow *win) { + GtkWidget *window = win->window; + slider_win *slidwin = NULL; + + /* Remove window from the window list */ + gaim_debug_info(WINTRANS_PLUGIN_ID, + "Conv window destroyed... removing from list\n"); + + if ((slidwin = find_slidwin(window))) { + window_list = g_slist_remove(window_list, slidwin); + g_free(slidwin); + } + + /* Remove the focus cbs */ + g_signal_handlers_disconnect_by_func(G_OBJECT(window), + G_CALLBACK(focus_conv_win_cb), window); +} + +static void gaim_conversation_delete(GaimConversation *conv) { + GaimGtkWindow *win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); + /* If it is the last conversation in the window, cleanup */ + if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) + cleanup_conv_window(win); +} + +static void set_blist_trans(GtkWidget *w, const char *pref) { + gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); + gaim_prefs_set_bool(pref, enabled); + if (blist) { + set_wintrans(blist, gaim_prefs_get_int(OPT_WINTRANS_BL_ALPHA), + gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED), + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + } +} + +static void add_slider(GtkWidget *win) { + GList *wl, *wl1; + GtkWidget *vbox = NULL; + + /* Look up this window to see if it already has a slider */ + if (!find_slidwin(win)) { + GtkWidget *slider_box = NULL; + slider_win *slidwin = NULL; + GtkRequisition slidereq; + gint width, height; + + /* Get top vbox */ + for (wl1 = wl = gtk_container_get_children( + GTK_CONTAINER(win)); + wl != NULL; + wl = wl->next) { + if (GTK_IS_VBOX(GTK_OBJECT(wl->data))) + vbox = GTK_WIDGET(wl->data); + else { + gaim_debug_error(WINTRANS_PLUGIN_ID, + "no vbox found\n"); + return; + } + } + g_list_free(wl1); + + slider_box = wintrans_slider(win); + /* Figure out how tall the slider wants to be */ + gtk_widget_size_request(slider_box, &slidereq); + gtk_window_get_size(GTK_WINDOW(win), &width, &height); + gtk_box_pack_start(GTK_BOX(vbox), + slider_box, FALSE, FALSE, 0); + /* Make window taller so we don't slowly collapse its message area */ + gtk_window_resize(GTK_WINDOW(win), width, + (height + slidereq.height)); + /* Add window to list, to track that it has a slider */ + slidwin = g_new0(slider_win, 1); + slidwin->win = win; + slidwin->slider = slider_box; + window_list = g_slist_append(window_list, slidwin); + } +} + +static void remove_sliders() { + if (window_list) { + GSList *tmp = window_list; + while (tmp) { + slider_win *slidwin = (slider_win*) tmp->data; + if (slidwin != NULL && + GTK_IS_WINDOW(slidwin->win)) { + GtkRequisition slidereq; + gint width, height; + /* Figure out how tall the slider was */ + gtk_widget_size_request( + slidwin->slider, &slidereq); + gtk_window_get_size( + GTK_WINDOW(slidwin->win), + &width, &height); + + gtk_widget_destroy(slidwin->slider); + + gtk_window_resize( + GTK_WINDOW(slidwin->win), + width, (height - slidereq.height)); + } + g_free(slidwin); + tmp = tmp->next; + } + g_slist_free(window_list); + window_list = NULL; + } +} + +/* Remove all transparency related aspects from conversation windows */ +static void remove_convs_wintrans(gboolean remove_signal) { + GList *wins; + + for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { + GaimGtkWindow *win = wins->data; + GtkWidget *window = win->window; + + if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) + set_wintrans(window, 0, FALSE, FALSE); + + /* Remove the focus cbs */ + if (remove_signal) + g_signal_handlers_disconnect_by_func(G_OBJECT(window), + G_CALLBACK(focus_conv_win_cb), window); + } + + remove_sliders(); +} + +static void set_conv_window_trans(GaimGtkWindow *oldwin, GaimGtkWindow *newwin) { + GtkWidget *win = newwin->window; + + /* check prefs to see if we want trans */ + if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) { + set_wintrans(win, gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA), + TRUE, gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + + if (gaim_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) { + add_slider(win); + } + } + + /* If we're moving from one window to another, + * add the focus listeners to the new window if not already there */ + if (oldwin != NULL && oldwin != newwin) { + if (gaim_gtk_conv_window_get_gtkconv_count(newwin) == 0) { + g_signal_connect(G_OBJECT(win), "focus_in_event", + G_CALLBACK(focus_conv_win_cb), win); + g_signal_connect(G_OBJECT(win), "focus_out_event", + G_CALLBACK(focus_conv_win_cb), win); + } + + /* If we've moved the last conversation, cleanup the window */ + if (gaim_gtk_conv_window_get_gtkconv_count(oldwin) == 1) + cleanup_conv_window(oldwin); + } +} + +static void update_convs_wintrans(GtkWidget *toggle_btn, const char *pref) { + gaim_prefs_set_bool(pref, gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(toggle_btn))); + + if (gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) { + GList *wins; + + for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { + GaimGtkWindow *win = wins->data; + set_conv_window_trans(NULL, win); + } + + if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) + remove_sliders(); + } + else + remove_convs_wintrans(FALSE); +} + +static void gaim_new_conversation(GaimConversation *conv) { + GaimGtkWindow *win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); + + /* If it is the first conversation in the window, + * add the sliders, and set transparency */ + if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { + GtkWidget *window = win->window; + + set_conv_window_trans(NULL, win); + + g_signal_connect(G_OBJECT(window), "focus_in_event", + G_CALLBACK(focus_conv_win_cb), window); + g_signal_connect(G_OBJECT(window), "focus_out_event", + G_CALLBACK(focus_conv_win_cb), window); + } +} + +static void blist_created_cb(GaimBuddyList *gaim_blist, gpointer data) { + if (blist) { + if (gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) { + set_wintrans(blist, + gaim_prefs_get_int(OPT_WINTRANS_BL_ALPHA), + TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_BL_ONTOP)); + } + + g_signal_connect(G_OBJECT(blist), "focus_in_event", + G_CALLBACK(focus_blist_win_cb), blist); + g_signal_connect(G_OBJECT(blist), "focus_out_event", + G_CALLBACK(focus_blist_win_cb), blist); + } +} + +static void alpha_change(GtkWidget *w, gpointer data) { + GList *wins; + int imalpha = gtk_range_get_value(GTK_RANGE(w)); + + for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { + GaimGtkWindow *win = wins->data; + set_wintrans(win->window, imalpha, TRUE, + gaim_prefs_get_bool(OPT_WINTRANS_IM_ONTOP)); + } +} + +static void alpha_pref_set_int (GtkWidget *w, GdkEventFocus *e, const char *pref) +{ + int alpha = gtk_range_get_value(GTK_RANGE(w)); + gaim_prefs_set_int(pref, alpha); +} + +static void bl_alpha_change(GtkWidget *w, gpointer data) { + if (blist) + change_alpha(w, blist); +} + +static void update_existing_convs() { + GList *wins; + + for (wins = gaim_gtk_conv_windows_get_list(); wins; wins = wins->next) { + GaimGtkWindow *win = wins->data; + GtkWidget *window = win->window; + + set_conv_window_trans(NULL, win); + + g_signal_connect(G_OBJECT(window), "focus_in_event", + G_CALLBACK(focus_conv_win_cb), window); + g_signal_connect(G_OBJECT(window), "focus_out_event", + G_CALLBACK(focus_conv_win_cb), window); + } +} + +/* + * EXPORTED FUNCTIONS + */ +static gboolean plugin_load(GaimPlugin *plugin) { + MySetLayeredWindowAttributes = (void*) wgaim_find_and_loadproc( + "user32.dll", "SetLayeredWindowAttributes"); + + if (!MySetLayeredWindowAttributes) { + gaim_debug_error(WINTRANS_PLUGIN_ID, + "SetLayeredWindowAttributes API not found (Required W2K+)\n"); + return FALSE; + } + + gaim_signal_connect(gaim_conversations_get_handle(), + "conversation-created", plugin, + GAIM_CALLBACK(gaim_new_conversation), NULL); + + /* Set callback to remove window from the list, if the window is destroyed */ + gaim_signal_connect(gaim_conversations_get_handle(), + "deleting-conversation", plugin, + GAIM_CALLBACK(gaim_conversation_delete), NULL); + + gaim_signal_connect(gaim_gtk_conversations_get_handle(), + "conversation-dragging", plugin, + GAIM_CALLBACK(set_conv_window_trans), NULL); + + update_existing_convs(); + + if (blist) + blist_created_cb(NULL, NULL); + else + gaim_signal_connect(gaim_gtk_blist_get_handle(), + "gtkblist-created", plugin, + GAIM_CALLBACK(blist_created_cb), NULL); + + + return TRUE; +} + +static gboolean plugin_unload(GaimPlugin *plugin) { + gaim_debug_info(WINTRANS_PLUGIN_ID, "Unloading win2ktrans plugin\n"); + + remove_convs_wintrans(TRUE); + + if (blist) { + if (gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) + set_wintrans(blist, 0, FALSE, FALSE); + + /* Remove the focus cbs */ + g_signal_handlers_disconnect_by_func(G_OBJECT(blist), + G_CALLBACK(focus_blist_win_cb), blist); + } + + return TRUE; +} + +static GtkWidget *get_config_frame(GaimPlugin *plugin) { + GtkWidget *ret; + GtkWidget *imtransbox, *bltransbox; + GtkWidget *hbox; + GtkWidget *label, *slider; + GtkWidget *button; + GtkWidget *trans_box; + + ret = gtk_vbox_new(FALSE, 18); + gtk_container_set_border_width(GTK_CONTAINER (ret), 12); + + /* IM Convo trans options */ + imtransbox = gaim_gtk_make_frame(ret, _("IM Conversation Windows")); + button = wgaim_button(_("_IM window transparency"), + OPT_WINTRANS_IM_ENABLED, imtransbox); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(update_convs_wintrans), + (gpointer) OPT_WINTRANS_IM_ENABLED); + + trans_box = gtk_vbox_new(FALSE, 18); + if (!gaim_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) + gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); + gtk_widget_show(trans_box); + + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box); + + button = wgaim_button(_("_Show slider bar in IM window"), + OPT_WINTRANS_IM_SLIDER, trans_box); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(update_convs_wintrans), + (gpointer) OPT_WINTRANS_IM_SLIDER); + + button = gaim_gtk_prefs_checkbox( + _("Remove IM window transparency on focus"), + OPT_WINTRANS_IM_ONFOCUS, trans_box); + + button = wgaim_button(_("Always on top"), OPT_WINTRANS_IM_ONTOP, + trans_box); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(update_convs_wintrans), + (gpointer) OPT_WINTRANS_IM_ONTOP); + + gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5); + + /* IM transparency slider */ + hbox = gtk_hbox_new(FALSE, 5); + + label = gtk_label_new(_("Opacity:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + + slider = gtk_hscale_new_with_range(50, 255, 1); + gtk_range_set_value(GTK_RANGE(slider), + gaim_prefs_get_int(OPT_WINTRANS_IM_ALPHA)); + gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); + + g_signal_connect(GTK_OBJECT(slider), "value-changed", + GTK_SIGNAL_FUNC(alpha_change), NULL); + g_signal_connect(GTK_OBJECT(slider), "focus-out-event", + GTK_SIGNAL_FUNC(alpha_pref_set_int), + (gpointer) OPT_WINTRANS_IM_ALPHA); + + gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); + + gtk_widget_show_all(hbox); + + gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); + + /* Buddy List trans options */ + bltransbox = gaim_gtk_make_frame (ret, _("Buddy List Window")); + button = wgaim_button(_("_Buddy List window transparency"), + OPT_WINTRANS_BL_ENABLED, bltransbox); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(set_blist_trans), + (gpointer) OPT_WINTRANS_BL_ENABLED); + + trans_box = gtk_vbox_new(FALSE, 18); + if (!gaim_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) + gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); + gtk_widget_show(trans_box); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(gaim_gtk_toggle_sensitive), trans_box); + button = gaim_gtk_prefs_checkbox( + _("Remove Buddy List window transparency on focus"), + OPT_WINTRANS_BL_ONFOCUS, trans_box); + button = wgaim_button(_("Always on top"), OPT_WINTRANS_BL_ONTOP, + trans_box); + g_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(set_blist_trans), + (gpointer) OPT_WINTRANS_BL_ONTOP); + gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); + + /* IM transparency slider */ + hbox = gtk_hbox_new(FALSE, 5); + + label = gtk_label_new(_("Opacity:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + + slider = gtk_hscale_new_with_range(50, 255, 1); + gtk_range_set_value(GTK_RANGE(slider), + gaim_prefs_get_int(OPT_WINTRANS_BL_ALPHA)); + + gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); + + g_signal_connect(GTK_OBJECT(slider), "value-changed", + GTK_SIGNAL_FUNC(bl_alpha_change), NULL); + g_signal_connect(GTK_OBJECT(slider), "focus-out-event", + GTK_SIGNAL_FUNC(alpha_pref_set_int), + (gpointer) OPT_WINTRANS_BL_ALPHA); + + gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); + + gtk_widget_show_all(hbox); + + gtk_box_pack_start(GTK_BOX(trans_box), hbox, FALSE, FALSE, 5); + + gtk_widget_show_all(ret); + return ret; +} + +static GaimGtkPluginUiInfo ui_info = +{ + get_config_frame, + 0 /* page_num (Reserved) */ +}; + +static GaimPluginInfo info = +{ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, + GAIM_PLUGIN_STANDARD, /**< type */ + GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ + 0, /**< flags */ + NULL, /**< dependencies */ + GAIM_PRIORITY_DEFAULT, /**< priority */ + WINTRANS_PLUGIN_ID, /**< id */ + N_("Transparency"), /**< name */ + VERSION, /**< version */ + /** summary */ + N_("Variable Transparency for the buddy list and conversations."), + /** description */ + N_("This plugin enables variable alpha transparency on conversation windows and the buddy list.\n\n" + "* Note: This plugin requires Win2000 or greater."), + "Herman Bloggs <hermanator12002@yahoo.com>", /**< author */ + GAIM_WEBSITE, /**< homepage */ + plugin_load, /**< load */ + plugin_unload, /**< unload */ + NULL, /**< destroy */ + &ui_info, /**< ui_info */ + NULL, /**< extra_info */ + NULL, /**< prefs_info */ + NULL /**< actions */ +}; + +static void +init_plugin(GaimPlugin *plugin) +{ + gaim_prefs_add_none("/plugins/gtk/win32"); + gaim_prefs_add_none("/plugins/gtk/win32/wintrans"); + gaim_prefs_add_bool(OPT_WINTRANS_IM_ENABLED, FALSE); + gaim_prefs_add_int(OPT_WINTRANS_IM_ALPHA, 255); + gaim_prefs_add_bool(OPT_WINTRANS_IM_SLIDER, FALSE); + gaim_prefs_add_bool(OPT_WINTRANS_IM_ONFOCUS, FALSE); + gaim_prefs_add_bool(OPT_WINTRANS_IM_ONTOP, FALSE); + gaim_prefs_add_bool(OPT_WINTRANS_BL_ENABLED, FALSE); + gaim_prefs_add_int(OPT_WINTRANS_BL_ALPHA, 255); + gaim_prefs_add_bool(OPT_WINTRANS_BL_ONFOCUS, FALSE); + gaim_prefs_add_bool(OPT_WINTRANS_BL_ONTOP, FALSE); +} + +GAIM_INIT_PLUGIN(wintrans, init_plugin, info)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/winprefs/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,127 @@ +# +# Makefile.mingw +# +# Description: Makefile for winprefs plugin. +# + +# +# PATHS +# + +GTK_TOP := ../../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../../.. +LIBGAIM_TOP := $(GAIM_TOP)/libgaim +GTKGAIM_TOP := $(GAIM_TOP)/gtk +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins + +## +## VARIABLE DEFINITIONS +## + +TARGET = winprefs + +# Compiler Options + +CFLAGS = + +DEFINES = -DWINVER=0x500 + +## +## INCLUDE MAKEFILES +## + +include $(LIBGAIM_TOP)/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += -I. \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/gtk-2.0 \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/include/pango-1.0 \ + -I$(GTK_TOP)/include/atk-1.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GTK_TOP)/lib/gtk-2.0/include \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ + -I$(GTKGAIM_TOP) \ + -I$(GTKGAIM_TOP)/win32 \ + -I$(GAIM_TOP) + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(LIBGAIM_TOP) \ + -L$(GTKGAIM_TOP) + + +## +## SOURCES, OBJECTS +## + +C_SRC = winprefs.c \ + gtkappbar.c + + +OBJECTS = $(C_SRC:%.c=%.o) + + +## +## LIBRARIES +## + +LIBS = -lgtk-win32-2.0 \ + -lglib-2.0 \ + -lgdk-win32-2.0 \ + -lgmodule-2.0 \ + -lgobject-2.0 \ + -lws2_32 \ + -lintl \ + -lgaim \ + -lgtkgaim + + +## +## RULES +## + +# How to make a C file + +%.o: %.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@ -c $< + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: $(TARGET).dll + +install: $(TARGET).dll + cp $(TARGET).dll $(DLL_INSTALL_DIR) + + +## +## BUILD Dependencies +## + +$(GTKGAIM_TOP)/gtkgaim.dll.a: + $(MAKE) -C $(GTKGAIM_TOP) -f Makefile.mingw gtkgaim.dll.a + +## +## BUILD DLL +## + +$(TARGET).dll: $(OBJECTS) $(GTKGAIM_TOP)/gtkgaim.dll.a + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf $(TARGET).dll
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/winprefs/gtkappbar.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,646 @@ +/* + * gaim - WinGaim Options Plugin + * + * File: gtkappbar.c + * Date: August 2, 2003 + * Description: Appbar functionality for Windows GTK+ applications + * + * Copyright (C) 2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/* + * TODO: + * - Move 'App on top' feature from Trans plugin to here + * - Bug: Multiple Show/Hide Desktop calls causes client area to disappear + */ +#include <windows.h> +#include <winver.h> +#include <stdio.h> +#include <gtk/gtk.h> +#include <gdk/gdkwin32.h> +#include "gtkappbar.h" +#include "debug.h" + +#define APPBAR_CALLBACK WM_USER + 1010 + +typedef HMONITOR WINAPI gaim_MonitorFromPoint(POINT, DWORD); +typedef HMONITOR WINAPI gaim_MonitorFromWindow(HWND, DWORD); +typedef BOOL WINAPI gaim_GetMonitorInfo(HMONITOR, LPMONITORINFO); + +/* Retrieve the rectangular display area from the specified monitor + * Return TRUE if successful, otherwise FALSE + */ +static gboolean +get_rect_from_monitor(HMODULE hmod, HMONITOR monitor, RECT *rect) { + gaim_GetMonitorInfo *the_GetMonitorInfo; + MONITORINFO info; + + if (!(the_GetMonitorInfo = (gaim_GetMonitorInfo*) + GetProcAddress(hmod, "GetMonitorInfoA"))) { + return FALSE; + } + + info.cbSize = sizeof(info); + if (!the_GetMonitorInfo(monitor, &info)) { + return FALSE; + } + + CopyRect(rect, &(info.rcMonitor)); + + return TRUE; +} + +/** + * This will only work on Win98+ and Win2K+ + * Return TRUE if successful, otherwise FALSE + */ +static gboolean +get_rect_at_point_multimonitor(POINT pt, RECT *rect) { + HMODULE hmod; + gaim_MonitorFromPoint *the_MonitorFromPoint; + HMONITOR monitor; + + if (!(hmod = GetModuleHandle("user32"))) { + return FALSE; + } + + if (!(the_MonitorFromPoint = (gaim_MonitorFromPoint*) + GetProcAddress(hmod, "MonitorFromPoint"))) { + return FALSE; + } + + monitor = + the_MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); + + return get_rect_from_monitor(hmod, monitor, rect); +} + +/** + * This will only work on Win98+ and Win2K+ + * Return TRUE if successful, otherwise FALSE + */ +static gboolean +get_rect_of_window_multimonitor(HWND window, RECT *rect) { + HMODULE hmod; + gaim_MonitorFromWindow *the_MonitorFromWindow; + HMONITOR monitor; + + if (!(hmod = GetModuleHandle("user32"))) { + return FALSE; + } + + if (!(the_MonitorFromWindow = (gaim_MonitorFromWindow*) + GetProcAddress(hmod, "MonitorFromWindow"))) { + return FALSE; + } + + monitor = + the_MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); + + return get_rect_from_monitor(hmod, monitor, rect); +} + +/* + * Fallback if cannot get the RECT from the monitor directly + */ +static void get_default_workarea(RECT *rect) { + if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, FALSE)) { + /* I don't think this will ever happen */ + rect->left = 0; + rect->top = 0; + rect->bottom = GetSystemMetrics(SM_CYSCREEN); + rect->right = GetSystemMetrics(SM_CXSCREEN); + } +} + +/* Retrieve the rectangle of the active work area at a point */ +static RECT get_rect_at_point(POINT pt) { + RECT rc; + if (!get_rect_at_point_multimonitor(pt, &rc)) { + get_default_workarea(&rc); + } + return rc; +} + +/* Retrieve the rectangle of the active work area of a window*/ +static RECT get_rect_of_window(HWND window) { + RECT rc; + if (!get_rect_of_window_multimonitor(window, &rc)) { + get_default_workarea(&rc); + } + return rc; +} + +static void get_window_normal_rc(HWND hwnd, RECT *rc) { + WINDOWPLACEMENT wplc; + GetWindowPlacement(hwnd, &wplc); + CopyRect(rc, &wplc.rcNormalPosition); +} +#if 0 +static void print_rect(RECT *rc) { + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "RECT: L:%ld R:%ld T:%ld B:%ld\n", + rc->left, rc->right, rc->top, rc->bottom); +} +#endif +/** Set the window style to be the "Tool Window" style - small header, no min/max buttons */ +static void set_toolbar(HWND hwnd, gboolean val) { + LONG style=0; + + style = GetWindowLong(hwnd, GWL_EXSTYLE); + if(val && !(style & WS_EX_TOOLWINDOW)) + style |= WS_EX_TOOLWINDOW; + else if(!val && style & WS_EX_TOOLWINDOW) + style &= ~WS_EX_TOOLWINDOW; + else + return; + SetWindowLong(hwnd, GWL_EXSTYLE, style); + SetWindowPos(hwnd, 0, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + +/* This really should be the following, but SWP_FRAMECHANGED strangely causes initermittent problems "Show Desktop" done more than once. + * Not having SWP_FRAMECHANGED *should* cause the Style not to be applied, but i haven't noticed any problems + * SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + */ +} +/** Register the window as an appbar */ +static gboolean gtk_appbar_register(GtkAppBar *ab, HWND hwnd) { + APPBARDATA abd; + + abd.cbSize = sizeof(APPBARDATA); + abd.hWnd = hwnd; + abd.uCallbackMessage = APPBAR_CALLBACK; + + ab->registered = SHAppBarMessage(ABM_NEW, &abd); + + return ab->registered; +} +/** Unregister the window as an appbar */ +static gboolean gtk_appbar_unregister(GtkAppBar *ab, HWND hwnd) { + APPBARDATA abd; + + if(!ab->registered) + return TRUE; + + abd.cbSize = sizeof(APPBARDATA); + abd.hWnd = hwnd; + + SHAppBarMessage(ABM_REMOVE, &abd); /** This always returns TRUE */ + + ab->registered = FALSE; + + ab->docked = FALSE; + ab->docking = FALSE; + + return TRUE; +} + +static void gtk_appbar_querypos(GtkAppBar *ab, HWND hwnd, RECT rcWorkspace) { + APPBARDATA abd; + guint iWidth = 0; + + if(!ab->registered) + gtk_appbar_register(ab, hwnd); + + abd.hWnd = hwnd; + abd.cbSize = sizeof(APPBARDATA); + abd.uEdge = ab->side; + + iWidth = ab->docked_rect.right - ab->docked_rect.left; + + abd.rc.top = rcWorkspace.top; + abd.rc.bottom = rcWorkspace.bottom; + switch (abd.uEdge) + { + case ABE_LEFT: + abd.rc.left = rcWorkspace.left; + abd.rc.right = rcWorkspace.left + iWidth; + break; + + case ABE_RIGHT: + abd.rc.right = rcWorkspace.right; + abd.rc.left = rcWorkspace.right - iWidth; + break; + } + + /* Ask the system for the screen space */ + SHAppBarMessage(ABM_QUERYPOS, &abd); + + switch (abd.uEdge) + { + case ABE_LEFT: + abd.rc.right = abd.rc.left + iWidth; + break; + + case ABE_RIGHT: + abd.rc.left = abd.rc.right - iWidth; + break; + } + + CopyRect(&(ab->docked_rect), &abd.rc); +} +/* Actually set the size and screen location of the appbar */ +static void gtk_appbar_setpos(GtkAppBar *ab, HWND hwnd) { + APPBARDATA abd; + + if(!ab->registered) + gtk_appbar_register(ab, hwnd); + + abd.hWnd = hwnd; + abd.cbSize = sizeof(APPBARDATA); + CopyRect(&abd.rc, &(ab->docked_rect)); + abd.uEdge = ab->side; + + SHAppBarMessage(ABM_SETPOS, &abd); +} +/** Let any callbacks know that we have docked or undocked */ +static void gtk_appbar_dispatch_dock_cbs(GtkAppBar *ab, gboolean val) { + GList *lst = ab->dock_cbs; + + while(lst) { + GtkAppBarDockCB dock_cb = lst->data; + dock_cb(val); + lst = lst->next; + } +} + +static GdkFilterReturn wnd_moving(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + POINT cp; + RECT *rc = (RECT*)msg->lParam; + RECT monRect; + int side = -1; + long dockAreaWidth = 0; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_moving\n"); + + GetCursorPos(&cp); + monRect = get_rect_at_point(cp); + + dockAreaWidth = (monRect.right - monRect.left) / 10; + /* Which part of the screen are we in ? */ + if (cp.x > (monRect.right - dockAreaWidth)) { + side = ABE_RIGHT; + } else if (cp.x < (monRect.left + dockAreaWidth)) { + side = ABE_LEFT; + } + + if(!ab->docked) { + if( (side == ABE_RIGHT || side == ABE_LEFT) ) { + if( !ab->docking ) { + ab->side = side; + GetWindowRect(msg->hwnd, &(ab->docked_rect)); + gtk_appbar_querypos(ab, msg->hwnd, monRect); + + /* save pre-docking height */ + ab->undocked_height = rc->bottom - rc->top; + ab->docking = TRUE; + } + } + else + ab->docking = FALSE; + } + else if(side < 0) { + gtk_appbar_unregister(ab, msg->hwnd); + rc->bottom = rc->top + ab->undocked_height; + } + + /* Switch to toolbar/regular caption*/ + if(ab->docking) + set_toolbar(msg->hwnd, TRUE); + else if(!ab->docked) + set_toolbar(msg->hwnd, FALSE); + + return GDK_FILTER_CONTINUE; +} + +static GdkFilterReturn wnd_sizing(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_sizing\n"); + if(ab->docked) { + RECT *rc = (RECT*)msg->lParam; + if(ab->side == ABE_LEFT && msg->wParam == WMSZ_RIGHT) { + ab->docked_rect.right = rc->right; + gtk_appbar_setpos(ab, msg->hwnd); + } + else if(ab->side == ABE_RIGHT && msg->wParam == WMSZ_LEFT) { + ab->docked_rect.left = rc->left; + gtk_appbar_setpos(ab, msg->hwnd); + } + return GDK_FILTER_REMOVE; + } + return GDK_FILTER_CONTINUE; +} +/** Notify the system that the appbar has been activated */ +static GdkFilterReturn wnd_activate(GtkAppBar *ab, GdkXEvent *xevent) { + if (ab->registered) { + APPBARDATA abd; + MSG *msg = (MSG*)xevent; + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_activate\n"); + + abd.hWnd = msg->hwnd; + abd.cbSize = sizeof(APPBARDATA); + + SHAppBarMessage(ABM_ACTIVATE, &abd); + } + return GDK_FILTER_CONTINUE; +} +/** Notify the system that the appbar's position has changed */ +static GdkFilterReturn wnd_poschanged(GtkAppBar *ab, GdkXEvent *xevent) { + if (ab->registered) { + APPBARDATA abd; + MSG *msg = (MSG*)xevent; + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_poschanged\n"); + + abd.hWnd = msg->hwnd; + abd.cbSize = sizeof(APPBARDATA); + + SHAppBarMessage(ABM_WINDOWPOSCHANGED, &abd); + } + return GDK_FILTER_CONTINUE; +} +/** The window is about to change */ +static GdkFilterReturn wnd_poschanging(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + WINDOWPOS *wpos = (WINDOWPOS*)msg->lParam; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_poschanging\n"); + + if(ab->docked || ab->docking) { + wpos->x = ab->docked_rect.left; + wpos->y = ab->docked_rect.top; + wpos->cx = ab->docked_rect.right - ab->docked_rect.left; + wpos->cy = ab->docked_rect.bottom - ab->docked_rect.top; + if(IsIconic(msg->hwnd)) + set_toolbar(msg->hwnd, FALSE); + /*return GDK_FILTER_REMOVE;*/ + } + return GDK_FILTER_CONTINUE; +} + +static GdkFilterReturn wnd_exitsizemove(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_exitsizemove\n"); + if(ab->docking) { + gtk_appbar_setpos(ab, msg->hwnd); + ab->docking = FALSE; + ab->docked = TRUE; + gtk_appbar_dispatch_dock_cbs(ab, TRUE); + } + else if(!ab->docked) { + gtk_appbar_unregister(ab, msg->hwnd); + gtk_appbar_dispatch_dock_cbs(ab, FALSE); + } + + return GDK_FILTER_CONTINUE; +} + +static GdkFilterReturn wnd_showwindow(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_showwindow\n"); + if(msg->wParam && ab->docked) { + ab->iconized = FALSE; + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "shown\n"); + ab->docked = FALSE; + gtk_appbar_dock(ab, ab->side); + } + else if(!msg->wParam && ab->docked) { + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "hidden\n"); + gtk_appbar_unregister(ab, GDK_WINDOW_HWND(ab->win->window)); + set_toolbar(GDK_WINDOW_HWND(ab->win->window), FALSE); + ab->docked = TRUE; + ab->iconized = TRUE; + } + return GDK_FILTER_CONTINUE; +} +/** The window's size has changed */ +static GdkFilterReturn wnd_size(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_size\n"); + + if(msg->wParam == SIZE_MINIMIZED) { + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "Minimize\n"); + if(ab->docked) { + gtk_appbar_unregister(ab, GDK_WINDOW_HWND(ab->win->window)); + ab->docked = TRUE; + } + } + else if(msg->wParam == SIZE_RESTORED) { + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "Restore\n"); + if (!ab->iconized && ab->docked) { + gtk_appbar_dock(ab, ab->side); + } + } + return GDK_FILTER_CONTINUE; +} + +static GdkFilterReturn wnd_nchittest(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + if(ab->docked) { + UINT ret = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam); + + switch(ret) { + case HTBOTTOM: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + case HTTOP: + case HTTOPLEFT: + case HTTOPRIGHT: + return GDK_FILTER_REMOVE; + case HTLEFT: + if(ab->side == ABE_LEFT) + return GDK_FILTER_REMOVE; + break; + case HTRIGHT: + if(ab->side == ABE_RIGHT) + return GDK_FILTER_REMOVE; + break; + } + } + return GDK_FILTER_CONTINUE; +} + +#if 0 +static GdkFilterReturn wnd_initmenupopup(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + + if(ab->docked && HIWORD(msg->lParam)) { + HMENU sysmenu = GetSystemMenu(msg->hwnd, FALSE); + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "wnd_initpopupmenu: docked: %d ismenu: %d\n", ab->docked, IsMenu(sysmenu)); + if(EnableMenuItem(sysmenu, SC_MAXIMIZE, MF_BYCOMMAND|MF_GRAYED)<0) + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "SC_MAXIMIZE Menu item does not exist\n"); + if(EnableMenuItem(sysmenu, SC_MOVE, MF_BYCOMMAND|MF_GRAYED)<0) + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "SC_MOVE Menu item does not exist\n"); + return GDK_FILTER_CONTINUE; + } + else + GetSystemMenu(msg->hwnd, TRUE); + return GDK_FILTER_CONTINUE; +} +#endif + +static GdkFilterReturn gtk_appbar_callback(GtkAppBar *ab, GdkXEvent *xevent) { + MSG *msg = (MSG*)xevent; + RECT orig; + + switch (msg->wParam) { + case ABN_STATECHANGE: + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_STATECHANGE\n"); + break; + + case ABN_FULLSCREENAPP: + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_FULLSCREENAPP: %d\n", (BOOL)msg->lParam); + if (!ab->iconized && ab->docked) { + if ((BOOL)msg->lParam) { + SetWindowPos(msg->hwnd, HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + } else { + SetWindowPos(msg->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED); + } + } + + break; + + case ABN_POSCHANGED: + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: ABN_POSCHANGED\n"); + CopyRect(&orig, &(ab->docked_rect)); + gtk_appbar_querypos(ab, msg->hwnd, get_rect_of_window(msg->hwnd)); + if (EqualRect(&orig, &(ab->docked_rect)) == 0) { + MoveWindow(msg->hwnd, ab->docked_rect.left, ab->docked_rect.top, + ab->docked_rect.right - ab->docked_rect.left, + ab->docked_rect.bottom - ab->docked_rect.top, TRUE); + } + gtk_appbar_setpos(ab, msg->hwnd); + break; +#if 0 + default: + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_callback: %d\n", msg->wParam); +#endif + } + return GDK_FILTER_CONTINUE; +} + +static GdkFilterReturn gtk_appbar_event_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) { + MSG *msg = (MSG*)xevent; + + /*printf("MSG: %s\n", message_to_string (msg->message));*/ + switch(msg->message) { + case WM_EXITSIZEMOVE: + return wnd_exitsizemove(data, xevent); + case WM_WINDOWPOSCHANGING: + return wnd_poschanging(data, xevent); + case WM_WINDOWPOSCHANGED: + return wnd_poschanged(data, xevent); + case WM_ACTIVATE: + return wnd_activate(data, xevent); + case WM_SIZING: + return wnd_sizing(data, xevent); + case WM_MOVING: + return wnd_moving(data, xevent); + case WM_SHOWWINDOW: + return wnd_showwindow(data, xevent); + case WM_NCHITTEST: + return wnd_nchittest(data, xevent); +#if 0 + case WM_INITMENUPOPUP: + return wnd_initmenupopup(data, xevent); +#endif + case WM_SIZE: + return wnd_size(data, xevent); + case APPBAR_CALLBACK: + return gtk_appbar_callback(data, xevent); +#if 0 + default: + gaim_debug_info("gtkappbar", "gtk_appbar_event_filter %d\n", msg->message); +#endif + } + return GDK_FILTER_CONTINUE; +} + +void gtk_appbar_dock(GtkAppBar *ab, UINT side) { + RECT orig; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_dock\n"); + + if(!ab || !IsWindow(GDK_WINDOW_HWND(ab->win->window))) + return; + + ab->side = side; + get_window_normal_rc(GDK_WINDOW_HWND(ab->win->window), &(ab->docked_rect)); + CopyRect(&orig, &(ab->docked_rect)); + gtk_appbar_querypos(ab, GDK_WINDOW_HWND(ab->win->window), + get_rect_of_window(GDK_WINDOW_HWND(ab->win->window))); + if(EqualRect(&orig, &(ab->docked_rect)) == 0) + MoveWindow(GDK_WINDOW_HWND(ab->win->window), + ab->docked_rect.left, + ab->docked_rect.top, + ab->docked_rect.right - ab->docked_rect.left, + ab->docked_rect.bottom - ab->docked_rect.top, TRUE); + gtk_appbar_setpos(ab, GDK_WINDOW_HWND(ab->win->window)); + set_toolbar(GDK_WINDOW_HWND(ab->win->window), TRUE); + ab->docked = TRUE; +} + +void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb) { + if(!ab) + return; + ab->dock_cbs = g_list_append(ab->dock_cbs, dock_cb); +} + +GtkAppBar *gtk_appbar_add(GtkWidget *win) { + GtkAppBar *ab; + + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_add\n"); + + if(!win) + return NULL; + ab = g_new0(GtkAppBar, 1); + ab->win = win; + + /* init docking coords */ + get_window_normal_rc(GDK_WINDOW_HWND(win->window), &(ab->docked_rect)); + + /* Add main window filter */ + gdk_window_add_filter(win->window, + gtk_appbar_event_filter, + ab); + return ab; +} + +void gtk_appbar_remove(GtkAppBar *ab) { + gaim_debug(GAIM_DEBUG_INFO, "gtkappbar", "gtk_appbar_remove\n"); + + if(!ab) + return; + gdk_window_remove_filter(ab->win->window, + gtk_appbar_event_filter, + ab); + if(ab->docked) { + gtk_window_resize(GTK_WINDOW(ab->win), + ab->docked_rect.right - ab->docked_rect.left, + ab->undocked_height); + set_toolbar(GDK_WINDOW_HWND(ab->win->window), FALSE); + } + gtk_appbar_unregister(ab, GDK_WINDOW_HWND(ab->win->window)); + + g_free(ab); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/winprefs/gtkappbar.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,55 @@ +/* + * gaim - WinGaim Options Plugin + * + * File: gtkappbar.h + * Date: August 2, 2003 + * Description: Appbar functionality for Windows GTK+ applications + * + * Copyright (C) 2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _GTKAPPBAR_H_ +#define _GTKAPPBAR_H_ + +typedef struct { + GtkWidget *win; + /** The rectangle of the screen area used for docking */ + RECT docked_rect; + /** The height of the window prior to docking */ + UINT undocked_height; + /** The side of the screen to which the window is docked*/ + UINT side; + /** Is the window currently docked? */ + gboolean docked; + /** Is the window currently in the process of docking? */ + gboolean docking; + /** Is the window currently registered as an appbar */ + gboolean registered; + /** Callback functions to notify of dock state change */ + GList *dock_cbs; + /** Is the window currently iconized? */ + gboolean iconized; +} GtkAppBar; + +typedef void (*GtkAppBarDockCB)(gboolean); + +GtkAppBar *gtk_appbar_add(GtkWidget *win); +void gtk_appbar_remove(GtkAppBar *ab); +void gtk_appbar_dock(GtkAppBar *ab, UINT side); +void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb); + +#endif /* _GTKAPPBAR_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/plugins/win32/winprefs/winprefs.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,563 @@ +/* + * gaim - WinGaim Options Plugin + * + * Gaim is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include <gtk/gtk.h> +#include <gdk/gdkwin32.h> + +#include "internal.h" + +#include "gtkwin32dep.h" + +#include "core.h" +#include "debug.h" +#include "prefs.h" +#include "signals.h" +#include "version.h" + +#include "gtkappbar.h" +#include "gtkblist.h" +#include "gtkconv.h" +#include "gtkplugin.h" +#include "gtkprefs.h" +#include "gtkutils.h" + +/* + * MACROS & DEFINES + */ +#define WINPREFS_PLUGIN_ID "gtk-win-prefs" + +/* + * LOCALS + */ +static const char *PREF_DBLIST_DOCKABLE = "/plugins/gtk/win32/winprefs/dblist_dockable"; +static const char *PREF_DBLIST_DOCKED = "/plugins/gtk/win32/winprefs/dblist_docked"; +static const char *PREF_DBLIST_HEIGHT = "/plugins/gtk/win32/winprefs/dblist_height"; +static const char *PREF_DBLIST_SIDE = "/plugins/gtk/win32/winprefs/dblist_side"; +static const char *PREF_BLIST_ON_TOP = "/plugins/gtk/win32/winprefs/blist_on_top"; +static const char *PREF_IM_BLINK = "/plugins/gtk/win32/winprefs/im_blink"; +static const char *PREF_CHAT_BLINK = "/plugins/gtk/win32/winprefs/chat_blink"; + +/* Deprecated */ +static const char *PREF_DBLIST_ON_TOP = "/plugins/gtk/win32/winprefs/dblist_on_top"; + +static GaimPlugin *handle = NULL; +static GtkAppBar *blist_ab = NULL; +static GtkWidget *blist = NULL; +static guint blist_visible_cb_id = 0; + +/* flash info */ + +struct _WGAIM_FLASH_INFO { + guint t_handle; + guint sig_handler; +}; + +enum { + BLIST_TOP_NEVER = 0, + BLIST_TOP_ALWAYS, + BLIST_TOP_DOCKED, +}; + +typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; + +typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); + +static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; + +/* + * CODE + */ + +/* BLIST DOCKING */ + +static void blist_save_state() { + if(blist_ab) { + if(gaim_prefs_get_bool(PREF_DBLIST_DOCKABLE) && blist_ab->docked) { + gaim_prefs_set_int(PREF_DBLIST_HEIGHT, blist_ab->undocked_height); + gaim_prefs_set_int(PREF_DBLIST_SIDE, blist_ab->side); + gaim_prefs_set_bool(PREF_DBLIST_DOCKED, blist_ab->docked); + } else + gaim_prefs_set_bool(PREF_DBLIST_DOCKED, FALSE); + } +} + +static void blist_set_ontop(gboolean val) { + if(!blist) + return; + + if(val) + SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + else + SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + +} + +static void blist_dock_cb(gboolean val) { + if(val) { + gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking...\n"); + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) != BLIST_TOP_NEVER) + blist_set_ontop(TRUE); + } else { + gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking...\n"); + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) + blist_set_ontop(TRUE); + else + blist_set_ontop(FALSE); + } +} + +static void blist_set_dockable(gboolean val) { + if(val) { + if(blist_ab == NULL && blist != NULL) { + blist_ab = gtk_appbar_add(blist); + gtk_appbar_add_dock_cb(blist_ab, blist_dock_cb); + } + } else { + if(blist_ab != NULL) { + gtk_appbar_remove(blist_ab); + blist_ab = NULL; + } + + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) + blist_set_ontop(TRUE); + else + blist_set_ontop(FALSE); + } +} + +/* PLUGIN CALLBACKS */ + +/* We need this because the blist destroy cb won't be called before the + plugin is unloaded, when quitting */ +static void gaim_quit_cb() { + gaim_debug_info(WINPREFS_PLUGIN_ID, "gaim_quit_cb: removing appbar\n"); + blist_save_state(); + blist_set_dockable(FALSE); +} + +/* Listen for the first time the window stops being withdrawn */ +static void blist_visible_cb(const char *pref, GaimPrefType type, + gconstpointer value, gpointer user_data) { + if(gaim_prefs_get_bool(pref)) { + gtk_appbar_dock(blist_ab, + gaim_prefs_get_int(PREF_DBLIST_SIDE)); + + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) + == BLIST_TOP_DOCKED) + blist_set_ontop(TRUE); + + /* We only need to be notified about this once */ + gaim_prefs_disconnect_callback(blist_visible_cb_id); + } +} + +/* This needs to be delayed otherwise, when the blist is originally created and + * hidden, it'll trigger the blist_visible_cb */ +static gboolean listen_for_blist_visible_cb(gpointer data) { + if (handle != NULL) + blist_visible_cb_id = + gaim_prefs_connect_callback(handle, + "/gaim/gtk/blist/list_visible", + blist_visible_cb, NULL); + + return FALSE; +} + +static void blist_create_cb(GaimBuddyList *gaim_blist, void *data) { + gaim_debug_info(WINPREFS_PLUGIN_ID, "buddy list created\n"); + + blist = GAIM_GTK_BLIST(gaim_blist)->window; + + if(gaim_prefs_get_bool(PREF_DBLIST_DOCKABLE)) { + blist_set_dockable(TRUE); + if(gaim_prefs_get_bool(PREF_DBLIST_DOCKED)) { + blist_ab->undocked_height = gaim_prefs_get_int(PREF_DBLIST_HEIGHT); + if(!(gdk_window_get_state(blist->window) + & GDK_WINDOW_STATE_WITHDRAWN)) { + gtk_appbar_dock(blist_ab, + gaim_prefs_get_int(PREF_DBLIST_SIDE)); + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) + == BLIST_TOP_DOCKED) + blist_set_ontop(TRUE); + } else { + g_idle_add(listen_for_blist_visible_cb, NULL); + } + } + } + + if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) + blist_set_ontop(TRUE); + +} + +/* AUTOSTART */ + +static gboolean open_run_key(PHKEY phKey, REGSAM samDesired) { + /* First try current user key (for WinNT & Win2k +), fall back to local machine */ + if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + 0, samDesired, phKey)); + else if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + 0, samDesired, phKey)); + else { + gaim_debug_error(WINPREFS_PLUGIN_ID, "open_run_key: Could not open key for writing value\n"); + return FALSE; + } + return TRUE; +} + +/* WIN PREFS GENERAL */ + +static void +winprefs_set_autostart(GtkWidget *w) +{ + HKEY hKey; + + if(!open_run_key(&hKey, KEY_SET_VALUE)) + return; + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { + char buffer[1024]; + DWORD size; + + if((size = GetModuleFileName(gtkwgaim_hinstance(), + (LPBYTE) buffer , sizeof(buffer))) == 0) { + gaim_debug_error(WINPREFS_PLUGIN_ID, "GetModuleFileName Error. Could not set Gaim autostart.\n"); + RegCloseKey(hKey); + return; + } + + /* Now set value of new key */ + if(ERROR_SUCCESS != RegSetValueEx(hKey, "Gaim", 0, REG_SZ, buffer, size)) + gaim_debug_error(WINPREFS_PLUGIN_ID, "Could not set registry key value\n"); + } else { + if(ERROR_SUCCESS != RegDeleteValue(hKey, "Gaim")) + gaim_debug_error(WINPREFS_PLUGIN_ID, "Could not delete registry key value\n"); + } + RegCloseKey(hKey); +} + +static void +winprefs_set_blist_dockable(const char *pref, GaimPrefType type, + gconstpointer value, gpointer user_data) +{ + blist_set_dockable(GPOINTER_TO_INT(value)); +} + +static void +winprefs_set_blist_ontop(const char *pref, GaimPrefType type, + gconstpointer value, gpointer user_data) +{ + gint setting = gaim_prefs_get_int(PREF_BLIST_ON_TOP); + if((setting == BLIST_TOP_DOCKED && blist_ab && blist_ab->docked) + || setting == BLIST_TOP_ALWAYS) + blist_set_ontop(TRUE); + else + blist_set_ontop(FALSE); +} + +static void load_winver_specific_procs(void) { + /* Used for Win98+ and WinNT5+ */ + MyFlashWindowEx = (LPFNFLASHWINDOWEX) wgaim_find_and_loadproc("user32.dll", "FlashWindowEx"); +} + +/* Window flasher */ +static gboolean flash_window_cb(gpointer data) { + FlashWindow((HWND) data, TRUE); + return TRUE; +} + +static int +halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + if(MyFlashWindowEx) { + HWND hWnd = data; + FLASHWINFO info; + + if(!IsWindow(hWnd)) + return 0; + + memset(&info, 0, sizeof(FLASHWINFO)); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = hWnd; + info.dwFlags = FLASHW_STOP; + info.dwTimeout = 0; + MyFlashWindowEx(&info); + + } else { + WGAIM_FLASH_INFO *finfo = data; + /* Stop flashing and remove filter */ + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n"); + gaim_timeout_remove(finfo->t_handle); + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n"); + g_signal_handler_disconnect(G_OBJECT(widget), + finfo->sig_handler); + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n"); + g_free(finfo); + } + return 0; +} + +/* FlashWindowEx is only supported by Win98+ and WinNT5+. If it's + not supported we do it our own way */ +static gboolean +wgaim_conv_blink(GaimConversation *conv, int flags) +{ + GaimGtkWindow *win; + GtkWidget *window; + + /* Don't flash for our own messages or system messages */ + if(flags & GAIM_MESSAGE_SEND || flags & GAIM_MESSAGE_SYSTEM) + return FALSE; + + if(conv == NULL) { + gaim_debug_info("winprefs", "gar!\n"); + return FALSE; + } + win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); + if(win == NULL) { + gaim_debug_info("winprefs", "gar2!\n"); + return FALSE; + } + window = win->window; + + if(MyFlashWindowEx) { + FLASHWINFO info; + if(GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) + return FALSE; + + memset(&info, 0, sizeof(FLASHWINFO)); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = GDK_WINDOW_HWND(window->window); + info.dwFlags = FLASHW_ALL | FLASHW_TIMER; + info.dwTimeout = 0; + MyFlashWindowEx(&info); + /* Stop flashing when window receives focus */ + g_signal_connect(G_OBJECT(window), "focus-in-event", + G_CALLBACK(halt_flash_filter), info.hwnd); + } else { + WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); + + /* Start Flashing window */ + finfo->t_handle = gaim_timeout_add(1000, flash_window_cb, + GDK_WINDOW_HWND(window->window)); + finfo->sig_handler = g_signal_connect(G_OBJECT(window), + "focus-in-event", G_CALLBACK(halt_flash_filter), finfo); + } + + return FALSE; +} + +static gboolean +wgaim_conv_im_blink(GaimAccount *account, const char *who, char **message, + GaimConversation *conv, int flags, void *data) +{ + if(!gaim_prefs_get_bool(PREF_IM_BLINK)) + return FALSE; + + return wgaim_conv_blink(conv, flags); + +} + +static gboolean +wgaim_conv_chat_blink(GaimAccount *account, const char *who, char **message, + GaimConversation *conv, int flags, void *data) +{ + if(!gaim_prefs_get_bool(PREF_CHAT_BLINK)) + return FALSE; + + return wgaim_conv_blink(conv, flags); +} + + +/* + * EXPORTED FUNCTIONS + */ + +static gboolean plugin_load(GaimPlugin *plugin) { + /* Find out how to go blinky */ + load_winver_specific_procs(); + + handle = plugin; + + /* blist docking init */ + if(gaim_get_blist() && GAIM_GTK_BLIST(gaim_get_blist()) + && GAIM_GTK_BLIST(gaim_get_blist())->window) { + blist_create_cb(gaim_get_blist(), NULL); + } + + /* This really shouldn't happen anymore generally, but if for some strange + reason, the blist is recreated, we need to set it up again. */ + gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-created", + plugin, GAIM_CALLBACK(blist_create_cb), NULL); + + gaim_signal_connect(gaim_gtk_conversations_get_handle(), + "displaying-im-msg", plugin, GAIM_CALLBACK(wgaim_conv_im_blink), + NULL); + + gaim_signal_connect(gaim_gtk_conversations_get_handle(), + "displaying-chat-msg", plugin, GAIM_CALLBACK(wgaim_conv_chat_blink), + NULL); + + gaim_signal_connect((void*)gaim_get_core(), "quitting", plugin, + GAIM_CALLBACK(gaim_quit_cb), NULL); + + gaim_prefs_connect_callback(handle, PREF_BLIST_ON_TOP, + winprefs_set_blist_ontop, NULL); + gaim_prefs_connect_callback(handle, PREF_DBLIST_DOCKABLE, + winprefs_set_blist_dockable, NULL); + + return TRUE; +} + +static gboolean plugin_unload(GaimPlugin *plugin) { + blist_set_dockable(FALSE); + blist_set_ontop(FALSE); + + handle = NULL; + + return TRUE; +} + +static GtkWidget* get_config_frame(GaimPlugin *plugin) { + GtkWidget *ret; + GtkWidget *vbox; + GtkWidget *button; + char* gtk_version = NULL; + HKEY hKey; + + ret = gtk_vbox_new(FALSE, 18); + gtk_container_set_border_width(GTK_CONTAINER(ret), 12); + + gtk_version = g_strdup_printf("GTK+\t%u.%u.%u\nGlib\t%u.%u.%u", + gtk_major_version, gtk_minor_version, gtk_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + + /* Display Installed GTK+ Runtime Version */ + if(gtk_version) { + GtkWidget *label; + vbox = gaim_gtk_make_frame(ret, _("GTK+ Runtime Version")); + label = gtk_label_new(gtk_version); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + g_free(gtk_version); + } + + /* Autostart */ + vbox = gaim_gtk_make_frame(ret, _("Startup")); + button = gtk_check_button_new_with_mnemonic(_("_Start Gaim on Windows startup")); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + if(open_run_key(&hKey, KEY_QUERY_VALUE)) { + if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Gaim", 0, NULL, NULL, NULL)) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + } + RegCloseKey(hKey); + } + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(winprefs_set_autostart), NULL); + gtk_widget_show(button); + + /* Buddy List */ + vbox = gaim_gtk_make_frame(ret, _("Buddy List")); + gaim_gtk_prefs_checkbox(_("_Dockable Buddy List"), + PREF_DBLIST_DOCKABLE, vbox); + + /* Blist On Top */ + gaim_gtk_prefs_dropdown(vbox, _("_Keep Buddy List window on top:"), + GAIM_PREF_INT, PREF_BLIST_ON_TOP, + _("Never"), BLIST_TOP_NEVER, + _("Always"), BLIST_TOP_ALWAYS, + /* XXX: Did this ever work? */ + _("Only when docked"), BLIST_TOP_DOCKED, + NULL); + + /* Conversations */ + vbox = gaim_gtk_make_frame(ret, _("Conversations")); + gaim_gtk_prefs_checkbox(_("_Flash window when IMs are received"), + PREF_IM_BLINK, vbox); + gaim_gtk_prefs_checkbox(_("_Flash window when chat messages are received"), + PREF_CHAT_BLINK, vbox); + + gtk_widget_show_all(ret); + return ret; +} + +static GaimGtkPluginUiInfo ui_info = +{ + get_config_frame, + 0 +}; + +static GaimPluginInfo info = +{ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, + GAIM_PLUGIN_STANDARD, + GAIM_GTK_PLUGIN_TYPE, + 0, + NULL, + GAIM_PRIORITY_DEFAULT, + WINPREFS_PLUGIN_ID, + N_("WinGaim Options"), + VERSION, + N_("Options specific to Windows Gaim."), + N_("Provides options specific to Windows Gaim, such as buddy list docking and conversation flashing."), + "Herman Bloggs <hermanator12002@yahoo.com>", + GAIM_WEBSITE, + plugin_load, + plugin_unload, + NULL, + &ui_info, + NULL, + NULL, + NULL +}; + +static void +init_plugin(GaimPlugin *plugin) +{ + gaim_prefs_add_none("/plugins/gtk"); + gaim_prefs_add_none("/plugins/gtk/win32"); + gaim_prefs_add_none("/plugins/gtk/win32/winprefs"); + gaim_prefs_add_bool(PREF_DBLIST_DOCKABLE, FALSE); + gaim_prefs_add_bool(PREF_DBLIST_DOCKED, FALSE); + gaim_prefs_add_int(PREF_DBLIST_HEIGHT, 0); + gaim_prefs_add_int(PREF_DBLIST_SIDE, 0); + gaim_prefs_add_bool(PREF_IM_BLINK, TRUE); + gaim_prefs_add_bool(PREF_CHAT_BLINK, FALSE); + + /* Convert old preferences */ + if(gaim_prefs_exists(PREF_DBLIST_ON_TOP)) { + gint blist_top = BLIST_TOP_NEVER; + if(gaim_prefs_get_bool(PREF_BLIST_ON_TOP)) + blist_top = BLIST_TOP_ALWAYS; + else if(gaim_prefs_get_bool(PREF_DBLIST_ON_TOP)) + blist_top = BLIST_TOP_DOCKED; + gaim_prefs_remove(PREF_BLIST_ON_TOP); + gaim_prefs_remove(PREF_DBLIST_ON_TOP); + gaim_prefs_add_int(PREF_BLIST_ON_TOP, blist_top); + } else + gaim_prefs_add_int(PREF_BLIST_ON_TOP, BLIST_TOP_NEVER); +} + +GAIM_INIT_PLUGIN(winprefs, init_plugin, info) +
--- a/gtk/win32/IdleTracker/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/win32/IdleTracker/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -9,6 +9,7 @@ # GAIM_TOP := ../../.. +LIBGAIM_TOP := $(GAIM_TOP)/libgaim GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir ## @@ -27,7 +28,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak ## ## INCLUDE PATHS @@ -77,7 +78,7 @@ ## $(TARGET).dll: $(OBJECTS) - $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--out-implib,$(TARGET).lib -o $(TARGET).dll + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--out-implib,$(TARGET).dll.a -o $(TARGET).dll ## ## CLEAN RULES @@ -86,5 +87,4 @@ clean: rm -rf *.o rm -rf $(TARGET).dll - rm -rf $(TARGET).lib - rm -rf $(TARGET).def + rm -rf $(TARGET).dll.a
--- a/gtk/win32/gaimrc.rc Sun Aug 20 16:45:57 2006 +0000 +++ b/gtk/win32/gaimrc.rc Sun Aug 20 16:49:37 2006 +0000 @@ -1,14 +1,16 @@ #include "resource.h" -GAIM_ICON ICON "../pixmaps/gaim.ico" -GAIM_TRAY_ICON ICON "../pixmaps/gaim_16.ico" -GAIM_OFFLINE_TRAY_ICON ICON "../pixmaps/gaim_offline_16.ico" -GAIM_AWAY_TRAY_ICON ICON "../pixmaps/gaim_away_16.ico" -GAIM_PEND_TRAY_ICON ICON "../pixmaps/gaim_msgunread_16.ico" -GAIM_AWAYPEND_TRAY_ICON ICON "../pixmaps/gaim_msgpend_16.ico" -GAIM_BLANK_TRAY_ICON ICON "../pixmaps/gaim_blank_4bit_16.ico" -GAIM_TRAY_ICON_4BIT ICON "../pixmaps/gaim_4bit_16.ico" -GAIM_OFFLINE_TRAY_ICON_4BIT ICON "../pixmaps/gaim_offline_4bit_16.ico" -GAIM_AWAY_TRAY_ICON_4BIT ICON "../pixmaps/gaim_away_4bit_16.ico" -GAIM_PEND_TRAY_ICON_4BIT ICON "../pixmaps/gaim_msgunread_4bit_16.ico" -GAIM_AWAYPEND_TRAY_ICON_4BIT ICON "../pixmaps/gaim_msgpend_4bit_16.ico" +#define PIXMAPDIR "pixmaps/" + +GAIM_ICON ICON PIXMAPDIR "gaim.ico" +GAIM_TRAY_ICON ICON PIXMAPDIR "gaim_16.ico" +GAIM_OFFLINE_TRAY_ICON ICON PIXMAPDIR "gaim_offline_16.ico" +GAIM_AWAY_TRAY_ICON ICON PIXMAPDIR "gaim_away_16.ico" +GAIM_PEND_TRAY_ICON ICON PIXMAPDIR "gaim_msgunread_16.ico" +GAIM_AWAYPEND_TRAY_ICON ICON PIXMAPDIR "gaim_msgpend_16.ico" +GAIM_BLANK_TRAY_ICON ICON PIXMAPDIR "gaim_blank_4bit_16.ico" +GAIM_TRAY_ICON_4BIT ICON PIXMAPDIR "gaim_4bit_16.ico" +GAIM_OFFLINE_TRAY_ICON_4BIT ICON PIXMAPDIR "gaim_offline_4bit_16.ico" +GAIM_AWAY_TRAY_ICON_4BIT ICON PIXMAPDIR "gaim_away_4bit_16.ico" +GAIM_PEND_TRAY_ICON_4BIT ICON PIXMAPDIR "gaim_msgunread_4bit_16.ico" +GAIM_AWAYPEND_TRAY_ICON_4BIT ICON PIXMAPDIR "gaim_msgpend_4bit_16.ico"
--- a/gtk/win32/global.mak Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# -# global.mak -# -# This file should be included by all Makefile.mingw files for project -# wide definitions. -# - -CC = gcc.exe - -# Use -g flag when building debug version of Gaim (including plugins). -# Use -fnative-struct instead of -mms-bitfields when using mingw 1.1 -# (gcc 2.95) -CFLAGS += -O2 -Wall -pipe -mno-cygwin -mms-bitfields - -# If not specified, dlls are built with the default base address of 0x10000000. -# When loaded into a process address space a dll will be rebased if its base -# address colides with the base address of an existing dll. To avoid rebasing -# we do the following. Rebasing can slow down the load time of dlls and it -# also renders debug info useless. -DLL_LD_FLAGS += -Wl,--enable-auto-image-base - -VERSION := $(shell cat $(GAIM_TOP)/VERSION) - -DEFINES += -DVERSION=\"$(VERSION)\" \ - -DHAVE_CONFIG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/win32/gtkwin32dep.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,202 @@ +/* + * gaim + * + * File: gtkwin32dep.c + * Date: June, 2002 + * Description: Windows dependant code for Gaim + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#define _WIN32_IE 0x500 +#include <windows.h> +#include <io.h> +#include <stdlib.h> +#include <stdio.h> +#include <winuser.h> + +#include <glib.h> +#include <glib/gstdio.h> +#include <gtk/gtk.h> + +#include "gaim.h" +#include "debug.h" +#include "notify.h" + +#include "resource.h" +#include "idletrack.h" +#include "zlib.h" +#include "untar.h" + +#include <libintl.h> + +#include "gtkwin32dep.h" + +#include "wspell.h" + +/* + * GLOBALS + */ +HINSTANCE gaimexe_hInstance = 0; +HINSTANCE gtkgaimdll_hInstance = 0; + +/* + * PUBLIC CODE + */ + +HINSTANCE gtkwgaim_hinstance(void) { + return gaimexe_hInstance; +} + +int gtkwgaim_gz_decompress(const char* in, const char* out) { + gzFile fin; + FILE *fout; + char buf[1024]; + int ret; + + if((fin = gzopen(in, "rb"))) { + if(!(fout = g_fopen(out, "wb"))) { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out); + gzclose(fin); + return 0; + } + } + else { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in); + return 0; + } + + while((ret = gzread(fin, buf, 1024))) { + if(fwrite(buf, 1, ret, fout) < ret) { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret); + gzclose(fin); + fclose(fout); + return 0; + } + } + fclose(fout); + gzclose(fin); + + if(ret < 0) { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in); + return 0; + } + + return 1; +} + +int gtkwgaim_gz_untar(const char* filename, const char* destdir) { + char tmpfile[_MAX_PATH]; + char template[]="wgaimXXXXXX"; + + sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template)); + if(gtkwgaim_gz_decompress(filename, tmpfile)) { + int ret; + if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) + ret = 1; + else { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile); + ret = 0; + } + g_unlink(tmpfile); + return ret; + } + else { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename); + return 0; + } +} + +void gtkwgaim_notify_uri(const char *uri) { + + /* We'll allow whatever URI schemes are supported by the + * default http browser. + */ + + if (G_WIN32_HAVE_WIDECHAR_API()) { + SHELLEXECUTEINFOW wsinfo; + wchar_t *w_uri; + + w_uri = g_utf8_to_utf16(uri, -1, NULL, NULL, NULL); + + memset(&wsinfo, 0, sizeof(wsinfo)); + wsinfo.cbSize = sizeof(wsinfo); + wsinfo.fMask = SEE_MASK_CLASSNAME; + wsinfo.lpVerb = L"open"; + wsinfo.lpFile = w_uri; + wsinfo.nShow = SW_SHOWNORMAL; + wsinfo.lpClass = L"http"; + + gaim_debug(GAIM_DEBUG_INFO, "wgaim_notify_uri", "The wide uri is %s\n", uri); + if(!ShellExecuteExW(&wsinfo)) + gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", + uri, (int) wsinfo.hInstApp); + + g_free(w_uri); + } else { + SHELLEXECUTEINFOA sinfo; + gchar *locale_uri; + + locale_uri = g_locale_from_utf8(uri, -1, NULL, NULL, NULL); + + memset(&sinfo, 0, sizeof(sinfo)); + sinfo.cbSize = sizeof(sinfo); + sinfo.fMask = SEE_MASK_CLASSNAME; + sinfo.lpVerb = "open"; + sinfo.lpFile = locale_uri; + sinfo.nShow = SW_SHOWNORMAL; + sinfo.lpClass = "http"; + + if(!ShellExecuteExA(&sinfo)) + gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", + uri, (int) sinfo.hInstApp); + + g_free(locale_uri); + } +} + +void gtkwgaim_init(HINSTANCE hint) { + gaim_debug_info("gtkwgaim", "gtkwgaim_init start\n"); + + gaimexe_hInstance = hint; + + /* IdleTracker Initialization */ + if(!wgaim_set_idlehooks()) + gaim_debug(GAIM_DEBUG_ERROR, "gtkwgaim", "Failed to initialize idle tracker\n"); + + wgaim_gtkspell_init(); + gaim_debug_info("gtkwgaim", "GTK+ :%u.%u.%u\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + + gaim_debug(GAIM_DEBUG_INFO, "gtkwgaim", "gtkwgaim_init end\n"); +} + +/* Windows Cleanup */ + +void gtkwgaim_cleanup(void) { + gaim_debug(GAIM_DEBUG_INFO, "gtkwgaim", "gtkwgaim_cleanup\n"); + + /* Idle tracker cleanup */ + wgaim_remove_idlehooks(); + +} + +/* DLL initializer */ +BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { + gtkgaimdll_hInstance = hinstDLL; + return TRUE; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/win32/gtkwin32dep.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,40 @@ +/* + * gaim + * + * File: win32dep.h + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _GTKWIN32DEP_H_ +#define _GTKWIN32DEP_H_ + +HINSTANCE gtkwgaim_hinstance(void); + +/* Utility */ +int gtkwgaim_gz_decompress(const char* in, const char* out); +int gtkwgaim_gz_untar(const char* filename, const char* destdir); + +/* Misc */ +void gtkwgaim_notify_uri(const char *uri); + +/* init / cleanup */ +void gtkwgaim_init(HINSTANCE); +void gtkwgaim_cleanup(void); + +#endif /* _WIN32DEP_H_ */ +
--- a/gtk/win32/libc_interface.c Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,990 +0,0 @@ -/* - * gaim - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#include <winsock2.h> -#include <ws2tcpip.h> -#include <io.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <sys/timeb.h> -#include <sys/stat.h> -#include <time.h> -#include <glib.h> -#include "debug.h" -#include "libc_internal.h" -#if GLIB_CHECK_VERSION(2,6,0) -# include <glib/gstdio.h> -#else -#define g_remove remove -#define g_rename rename -#define g_stat stat -#endif - -static char errbuf[1024]; - -/* helpers */ -static int wgaim_is_socket( int fd ) { - int optval; - unsigned int optlen = sizeof(int); - - if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) { - int error = WSAGetLastError(); - if( error == WSAENOTSOCK ) - return FALSE; - else { - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_is_socket: getsockopt returned error: %d\n", error); - return FALSE; - } - } - return TRUE; -} - -/* socket.h */ -int wgaim_socket (int namespace, int style, int protocol) { - int ret; - - ret = socket( namespace, style, protocol ); - - if( ret == INVALID_SOCKET ) { - errno = WSAGetLastError(); - return -1; - } - return ret; -} - -int wgaim_connect(int socket, struct sockaddr *addr, u_long length) { - int ret; - - ret = connect( socket, addr, length ); - - if( ret == SOCKET_ERROR ) { - errno = WSAGetLastError(); - if( errno == WSAEWOULDBLOCK ) - errno = WSAEINPROGRESS; - return -1; - } - return 0; -} - -int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { - if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) { - if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { - if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { - if(bind(socket, addr, length) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -int wgaim_listen(int socket, unsigned int n) { - if(listen(socket, n) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) { - int ret; - if ((ret = sendto(socket, buf, len, flags, to, tolen) - ) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return ret; -} - -/* fcntl.h */ -/* This is not a full implementation of fcntl. Update as needed.. */ -int wgaim_fcntl(int socket, int command, int val) { - switch( command ) { - case F_SETFL: - { - int ret=0; - - switch( val ) { - case O_NONBLOCK: - { - u_long imode=1; - ret = ioctlsocket(socket, FIONBIO, &imode); - break; - } - case 0: - { - u_long imode=0; - ret = ioctlsocket(socket, FIONBIO, &imode); - break; - } - default: - errno = EINVAL; - return -1; - }/*end switch*/ - if( ret == SOCKET_ERROR ) { - errno = WSAGetLastError(); - return -1; - } - return 0; - } - default: - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_fcntl: Unsupported command\n"); - return -1; - }/*end switch*/ -} - -/* sys/ioctl.h */ -int wgaim_ioctl(int fd, int command, void* val) { - switch( command ) { - case FIONBIO: - { - if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return 0; - } - case SIOCGIFCONF: - { - INTERFACE_INFO InterfaceList[20]; - unsigned long nBytesReturned; - if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST, - 0, 0, &InterfaceList, - sizeof(InterfaceList), &nBytesReturned, - 0, 0) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } else { - int i; - struct ifconf *ifc = val; - char *tmp = ifc->ifc_buf; - int nNumInterfaces = - nBytesReturned / sizeof(INTERFACE_INFO); - for (i = 0; i < nNumInterfaces; i++) { - INTERFACE_INFO ii = InterfaceList[i]; - struct ifreq *ifr = (struct ifreq *) tmp; - struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr; - - sa->sin_family = ii.iiAddress.AddressIn.sin_family; - sa->sin_port = ii.iiAddress.AddressIn.sin_port; - sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr; - tmp += sizeof(struct ifreq); - - /* Make sure that we can fit in the original buffer */ - if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) { - break; - } - } - /* Replace the length with the actually used length */ - ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp); - return 0; - } - } - default: - errno = EINVAL; - return -1; - }/*end switch*/ -} - -/* arpa/inet.h */ -int wgaim_inet_aton(const char *name, struct in_addr *addr) { - if((addr->s_addr = inet_addr(name)) == INADDR_NONE) - return 0; - else - return 1; -} - -/* netdb.h */ -struct hostent* wgaim_gethostbyname(const char *name) { - struct hostent *hp; - - if((hp = gethostbyname(name)) == NULL) { - errno = WSAGetLastError(); - return NULL; - } - return hp; -} - -/* string.h */ -char* wgaim_strerror( int errornum ) { - if( errornum > WSABASEERR ) { - sprintf( errbuf, "Windows socket error #%d", errornum ); - return errbuf; - } - else - return strerror( errornum ); -} - -/* unistd.h */ - -/* - * We need to figure out whether fd is a file or socket handle. - */ -int wgaim_read(int fd, void *buf, unsigned int size) { - int ret; - - if(wgaim_is_socket(fd)) { - if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) { - errno = WSAGetLastError(); - if(errno == WSAEWOULDBLOCK) - errno = EAGAIN; - return -1; - } -#if 0 - else if( ret == 0 ) { - /* connection has been gracefully closed */ - errno = WSAENOTCONN; - return -1; - } -#endif - else { - /* success reading socket */ - return ret; - } - } else { - /* fd is not a socket handle.. pass it off to read */ - return read(fd, buf, size); - } -} - -int wgaim_send(int fd, const void *buf, unsigned int size, int flags) { - int ret; - - ret = send(fd, buf, size, flags); - - if (ret == SOCKET_ERROR) { - errno = WSAGetLastError(); - if(errno == WSAEWOULDBLOCK) - errno = EAGAIN; - return -1; - } - return ret; -} - -int wgaim_write(int fd, const void *buf, unsigned int size) { - - if(wgaim_is_socket(fd)) - return wgaim_send(fd, buf, size, 0); - else - return write(fd, buf, size); -} - -int wgaim_recv(int fd, void *buf, size_t len, int flags) { - int ret; - - if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) { - errno = WSAGetLastError(); - if(errno == WSAEWOULDBLOCK) - errno = EAGAIN; - return -1; - } else { - return ret; - } -} - -int wgaim_close(int fd) { - int ret; - - if( wgaim_is_socket(fd) ) { - if( (ret = closesocket(fd)) == SOCKET_ERROR ) { - errno = WSAGetLastError(); - return -1; - } - else - return 0; - } - else - return close(fd); -} - -int wgaim_gethostname(char *name, size_t size) { - if(gethostname(name, size) == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; - } - return 0; -} - -/* sys/time.h */ - -int wgaim_gettimeofday(struct timeval *p, struct timezone *z) { - int res = 0; - struct _timeb timebuffer; - - if (z != 0) { - _tzset(); - z->tz_minuteswest = _timezone/60; - z->tz_dsttime = _daylight; - } - - if (p != 0) { - _ftime(&timebuffer); - p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */ - p->tv_usec = timebuffer.millitm*1000; /* microseconds */ - } - - return res; -} - -/* stdio.h */ - -int wgaim_rename (const char *oldname, const char *newname) { - struct stat oldstat, newstat; - - if(g_stat(oldname, &oldstat) == 0) { - /* newname exists */ - if(g_stat(newname, &newstat) == 0) { - /* oldname is a dir */ - if(_S_ISDIR(oldstat.st_mode)) { - if(!_S_ISDIR(newstat.st_mode)) { - return g_rename(oldname, newname); - } - /* newname is a dir */ - else { - /* This is not quite right.. If newname is empty and - is not a sub dir of oldname, newname should be - deleted and oldname should be renamed. - */ - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_rename does not behave here as it should\n"); - return g_rename(oldname, newname); - } - } - /* oldname is not a dir */ - else { - /* newname is a dir */ - if(_S_ISDIR(newstat.st_mode)) { - errno = EISDIR; - return -1; - } - /* newname is not a dir */ - else { - g_remove(newname); - return g_rename(oldname, newname); - } - } - } - /* newname doesn't exist */ - else - return g_rename(oldname, newname); - } - else { - /* oldname doesn't exist */ - errno = ENOENT; - return -1; - } - -} - -/* time.h */ - -struct tm * wgaim_localtime_r (const time_t *time, struct tm *resultp) { - struct tm* tmptm; - - if(!time) - return NULL; - tmptm = localtime(time); - if(resultp && tmptm) - return memcpy(resultp, tmptm, sizeof(struct tm)); - else - return NULL; -} - -/* - * Used by gaim_utf8_strftime() by way of gaim_internal_strftime() - * in src/util.c - * - * Code derived from PostgreSQL src/timezone/pgtz.c: - * http://developer.postgresql.org/cvsweb.cgi/pgsql/src/timezone/pgtz.c - */ - -/* -PostgreSQL Database Management System -(formerly known as Postgres, then as Postgres95) - -Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group - -Portions Copyright (c) 1994, The Regents of the University of California - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose, without fee, and without a written agreement -is hereby granted, provided that the above copyright notice and this -paragraph and the following two paragraphs appear in all copies. - -IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING -LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS -DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO -PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - -*/ -static struct -{ - char *wstd; /* Windows name of standard timezone */ - char *wdst; /* Windows name of daylight timezone */ - char *ustd; /* Unix name of standard timezone */ - char *udst; /* Unix name of daylight timezone */ -} win32_tzmap[] = -{ - { - "", "", - "", "", - }, - /* - * This list was built from the contents of the registry at - * "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" - * on Windows XP Professional SP1 - */ - { - "Afghanistan Standard Time", "Afghanistan Daylight Time", - "AFT", "AFT" - }, - { - "Alaskan Standard Time", "Alaskan Daylight Time", - "AKST", "AKDT" - }, - { - "Arab Standard Time", "Arab Daylight Time", - "AST", "AST" - }, - { - "Arabian Standard Time", "Arabian Daylight Time", - "GST", "GST" - }, - { - "Arabic Standard Time", "Arabic Daylight Time", - "AST", "ADT" - }, - { - "Atlantic Standard Time", "Atlantic Daylight Time", - "AST", "ADT" - }, - { - "AUS Central Standard Time", "AUS Central Daylight Time", - "CST", "CST" - }, - { - "AUS Eastern Standard Time", "AUS Eastern Daylight Time", - "EST", "EST" - }, - { - "Azores Standard Time", "Azores Daylight Time", - "AZOT", "AZOST" - }, - { - "Canada Central Standard Time", "Canada Central Daylight Time", - "CST", "MDT" - }, - { - "Cape Verde Standard Time", "Cape Verde Daylight Time", - "CVT", "CVST" - }, - { - "Caucasus Standard Time", "Caucasus Daylight Time", - "AZT", "AZST" - }, - { - "Cen. Australia Standard Time", "Cen. Australia Daylight Time", - "CST", "CST" - }, - { - "Central America Standard Time", "Central America Daylight Time", - "CST", "CDT" - }, - { - "Central Asia Standard Time", "Central Asia Daylight Time", - "BDT", "BDT" - }, - { - "Central Europe Standard Time", "Central Europe Daylight Time", - "CET", "CEST" - }, - { - "Central European Standard Time", "Central European Daylight Time", - "CET", "CEST" - }, - { - "Central Pacific Standard Time", "Central Pacific Daylight Time", - "NCT", "NCST" - }, - { - "Central Standard Time", "Central Daylight Time", - "CST", "CDT" - }, - { - "China Standard Time", "China Daylight Time", - "HKT", "HKST" - }, - { - "Dateline Standard Time", "Dateline Daylight Time", - "GMT+12", "GMT+12" - }, - { - "E. Africa Standard Time", "E. Africa Daylight Time", - "EAT", "EAT" - }, - { - "E. Australia Standard Time", "E. Australia Daylight Time", - "EST", "EST" - }, - { - "E. Europe Standard Time", "E. Europe Daylight Time", - "EET", "EEST" - }, - { - "E. South America Standard Time", "E. South America Daylight Time", - "BRT", "BRST" - }, - { - "Eastern Standard Time", "Eastern Daylight Time", - "EST", "EDT" - }, - { - "Egypt Standard Time", "Egypt Daylight Time", - "EET", "EEST" - }, - { - "Ekaterinburg Standard Time", "Ekaterinburg Daylight Time", - "YEKT", "YEKST" - }, - { - "Fiji Standard Time", "Fiji Daylight Time", - "FJT", "FJST" - }, - { - "FLE Standard Time", "FLE Daylight Time", - "EET", "EEST" - }, - { - "GMT Standard Time", "GMT Daylight Time", - "GMT", "IST" - }, - { - "Greenland Standard Time", "Greenland Daylight Time", - "WGT", "WGST" - }, - { - "Greenwich Standard Time", "Greenwich Daylight Time", - "WET", "WEST" - }, - { - "GTB Standard Time", "GTB Daylight Time", - "EET", "EEST" - }, - { - "Hawaiian Standard Time", "Hawaiian Daylight Time", - "HST", "HPT" - }, - { - "India Standard Time", "India Daylight Time", - "IST", "IST" - }, - { - "Iran Standard Time", "Iran Daylight Time", - "IRST", "IRDT" - }, - { - "Jerusalem Standard Time", "Jerusalem Daylight Time", - "IST", "IDT" - }, - { - "Korea Standard Time", "Korea Daylight Time", - "KST", "KDT" - }, - { - "Mexico Standard Time", "Mexico Daylight Time", - "CST", "CDT" - }, - { - "Mexico Standard Time", "Mexico Daylight Time", - "BOT", "BOST" - }, - { - "Mid-Atlantic Standard Time", "Mid-Atlantic Daylight Time", - "GST", "GST" - }, - { - "Mountain Standard Time", "Mountain Daylight Time", - "MST", "MDT" - }, - { - "Myanmar Standard Time", "Myanmar Daylight Time", - "MMT", "MMT" - }, - { - "N. Central Asia Standard Time", "N. Central Asia Daylight Time", - "ALMT", "ALMST" - }, - { - "Nepal Standard Time", "Nepal Daylight Time", - "NPT", "NPT" - }, - { - "New Zealand Standard Time", "New Zealand Daylight Time", - "NZST", "NZDT" - }, - { - "Newfoundland Standard Time", "Newfoundland Daylight Time", - "NST", "NDT" - }, - { - "North Asia East Standard Time", "North Asia East Daylight Time", - "IRKT", "IRKST" - }, - { - "North Asia Standard Time", "North Asia Daylight Time", - "KRAT", "KRAST" - }, - { - "Pacific SA Standard Time", "Pacific SA Daylight Time", - "CLT", "CLST" - }, - { - "Pacific Standard Time", "Pacific Daylight Time", - "PST", "PDT" - }, - { - "Romance Standard Time", "Romance Daylight Time", - "CET", "CEST" - }, - { - "Russian Standard Time", "Russian Daylight Time", - "MSK", "MSD" - }, - { - "SA Eastern Standard Time", "SA Eastern Daylight Time", - "ART", "ARST" - }, - { - "SA Pacific Standard Time", "SA Pacific Daylight Time", - "COT", "COST" - }, - { - "SA Western Standard Time", "SA Western Daylight Time", - "VET", "VET" - }, - { - "Samoa Standard Time", "Samoa Daylight Time", - "SST", "NDT" - }, - { - "SE Asia Standard Time", "SE Asia Daylight Time", - "ICT", "ICT" - }, - { - "Malay Peninsula Standard Time", "Malay Peninsula Daylight Time", - "MYT", "MALST" - }, - { - "South Africa Standard Time", "South Africa Daylight Time", - "CAT", "CAT" - }, - { - "Sri Lanka Standard Time", "Sri Lanka Daylight Time", - "LKT", "IST" - }, - { - "Taipei Standard Time", "Taipei Daylight Time", - "CST", "CDT" - }, - { - "Tasmania Standard Time", "Tasmania Daylight Time", - "EST", "EST" - }, - { - "Tokyo Standard Time", "Tokyo Daylight Time", - "JST", "JDT" - }, - { - "Tonga Standard Time", "Tonga Daylight Time", - "TOT", "TOST" - }, - { - "US Eastern Standard Time", "US Eastern Daylight Time", - "EST", "EDT" - }, - { - "US Mountain Standard Time", "US Mountain Daylight Time", - "MST", "MDT" - }, - { - "Vladivostok Standard Time", "Vladivostok Daylight Time", - "VLAT", "VLAST" - }, - { - "W. Australia Standard Time", "W. Australia Daylight Time", - "WST", "WST" - }, - - /* Not mapped in PostgreSQL. - * - * I mapped this based on the following information... -- rlaager - * $ cd /usr/share/zoneinfo/Africa - * $ for i in * ; do echo `TZ=Africa/$i date +"%z %Z"` $i ; done | grep +0100 - * +0100 CET Algiers - * +0100 WAT Bangui - * +0100 WAT Brazzaville - * +0100 CET Ceuta - * +0100 WAT Douala - * +0100 WAT Kinshasa - * +0100 WAT Lagos - * +0100 WAT Libreville - * +0100 WAT Luanda - * +0100 WAT Malabo - * +0100 WAT Ndjamena - * +0100 WAT Niamey - * +0100 WAT Porto-Novo - * +0100 CET Tunis - **/ - { - "W. Central Africa Standard Time", "W. Central Africa Daylight Time", - "WAT", "WAT" - }, - - { - "W. Europe Standard Time", "W. Europe Daylight Time", - "CET", "CEST" - }, - { - "West Asia Standard Time", "West Asia Daylight Time", - "PKT", "PKST" - }, - { - "West Pacific Standard Time", "West Pacific Daylight Time", - "ChST", "ChST" - }, - { - "Yakutsk Standard Time", "Yakutsk Daylight Time", - "YAKT", "YAKST" - }, - { - NULL, NULL, - NULL, NULL - } -}; - -const char * -wgaim_get_timezone_abbreviation(const struct tm *tm) -{ - int i; - char tzname[128]; - char localtzname[256]; - HKEY rootKey; - int idx; - - if (!tm) - { - gaim_debug_warning("wgaim", "could not determine current date/time: localtime failed\n"); - return ""; - } - - if (strftime(tzname, sizeof(tzname) - 1, "%Z", tm) == 0) - { - gaim_debug_error("wgaim", "timezone name is too long for the buffer\n"); - return ""; - } - - for (i = 0; win32_tzmap[i].wstd != NULL; i++) - { - if (strcmp(tzname, win32_tzmap[i].wstd) == 0) - { -#if 0 - gaim_debug_info("wgaim", "TZ \"%s\" matches Windows timezone \"%s\"\n", - win32_tzmap[i].ustd, tzname); -#endif - /* Cache the Result */ - if (i > 0) { - if (win32_tzmap[0].wstd[0] != '\0') - g_free(win32_tzmap[0].wstd); - win32_tzmap[0].wstd = g_strdup(tzname); - win32_tzmap[0].ustd = win32_tzmap[i].ustd; - } - - return win32_tzmap[i].ustd; - } - if (strcmp(tzname, win32_tzmap[i].wdst) == 0) - { -#if 0 - gaim_debug_info("wgaim", "TZ \"%s\" matches Windows timezone \"%s\"\n", - win32_tzmap[i].udst, tzname); -#endif - /* Cache the Result */ - if (i > 0) { - if (win32_tzmap[0].wdst[0] != '\0') - g_free(win32_tzmap[0].wdst); - win32_tzmap[0].wdst = g_strdup(tzname); - win32_tzmap[0].udst = win32_tzmap[i].udst; - } - - return win32_tzmap[i].udst; - } - } - - /* - * Localized Windows versions return localized names for the timezone. - * Scan the registry to find the English name, and then try matching - * against our table again. - */ - memset(localtzname, 0, sizeof(localtzname)); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", - 0, - KEY_READ, - &rootKey) != ERROR_SUCCESS) - { - gaim_debug_warning("wgaim", "could not open registry key to identify Windows timezone: %i\n", (int) GetLastError()); - return ""; - } - - for (idx = 0;; idx++) - { - char keyname[256]; - char zonename[256]; - DWORD namesize; - FILETIME lastwrite; - HKEY key; - LONG r; - - memset(keyname, 0, sizeof(keyname)); - namesize = sizeof(keyname); - if ((r = RegEnumKeyEx(rootKey, - idx, - keyname, - &namesize, - NULL, - NULL, - NULL, - &lastwrite)) != ERROR_SUCCESS) - { - if (r == ERROR_NO_MORE_ITEMS) - break; - gaim_debug_warning("wgaim", "could not enumerate registry subkeys to identify Windows timezone: %i\n", (int) r); - break; - } - - if ((r = RegOpenKeyEx(rootKey, keyname, 0, KEY_READ, &key)) != ERROR_SUCCESS) - { - gaim_debug_warning("wgaim", "could not open registry subkey to identify Windows timezone: %i\n", (int) r); - break; - } - - memset(zonename, 0, sizeof(zonename)); - namesize = sizeof(zonename); - if ((r = RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) - { - gaim_debug_warning("wgaim", "could not query value for 'std' to identify Windows timezone: %i\n", (int) r); - RegCloseKey(key); - break; - } - if (strcmp(tzname, zonename) == 0) - { - /* Matched zone */ - strcpy(localtzname, keyname); - RegCloseKey(key); - break; - } - memset(zonename, 0, sizeof(zonename)); - namesize = sizeof(zonename); - if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) - { - gaim_debug_warning("wgaim", "could not query value for 'dlt' to identify Windows timezone: %i\n", (int) r); - RegCloseKey(key); - break; - } - if (strcmp(tzname, zonename) == 0) - { - /* Matched DST zone */ - strcpy(localtzname, keyname); - RegCloseKey(key); - break; - } - - RegCloseKey(key); - } - - RegCloseKey(rootKey); - - if (localtzname[0]) - { - /* Found a localized name, so scan for that one too */ - for (i = 0; win32_tzmap[i].wstd != NULL; i++) - { - if (strcmp(localtzname, win32_tzmap[i].wstd) == 0) - { -#if 0 - gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")\n", - win32_tzmap[i].ustd, tzname, localtzname); -#endif - /* Cache the Result */ - if (win32_tzmap[0].wstd[0] != '\0') - g_free(win32_tzmap[0].wstd); - win32_tzmap[0].wstd = g_strdup(tzname); - win32_tzmap[0].ustd = win32_tzmap[i].ustd; - - return win32_tzmap[i].ustd; - } - if (strcmp(localtzname, win32_tzmap[i].wdst) == 0) - { -#if 0 - gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")\n", - win32_tzmap[i].udst, tzname, localtzname); -#endif - /* Cache the Result */ - if (win32_tzmap[0].wdst[0] != '\0') - g_free(win32_tzmap[0].wdst); - - win32_tzmap[0].wdst = g_strdup(tzname); - win32_tzmap[0].udst = win32_tzmap[i].udst; - - return win32_tzmap[i].udst; - } - } - } - - gaim_debug_warning("wgaim", "could not find a match for Windows timezone \"%s\"\n", tzname); - return ""; -} -
--- a/gtk/win32/libc_interface.h Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* - * gaim - * - * File: libc_interface.h - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _LIBC_INTERFACE_H_ -#define _LIBC_INTERFACE_H_ -#include <winsock2.h> -#include <ws2tcpip.h> -#include <io.h> -#include <errno.h> -#include "libc_internal.h" -#include <glib.h> - -/* sys/socket.h */ -int wgaim_socket(int namespace, int style, int protocol); -#define socket( namespace, style, protocol ) \ -wgaim_socket( namespace, style, protocol ) - -int wgaim_connect(int socket, struct sockaddr *addr, u_long length); -#define connect( socket, addr, length ) \ -wgaim_connect( socket, addr, length ) - -int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr); -#define getsockopt( args... ) \ -wgaim_getsockopt( args ) - -int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen); -#define setsockopt( args... ) \ -wgaim_setsockopt( args ) - -int wgaim_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr); -#define getsockname( socket, addr, lenptr ) \ -wgaim_getsockname( socket, addr, lenptr ) - -int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length); -#define bind( socket, addr, length ) \ -wgaim_bind( socket, addr, length ) - -int wgaim_listen(int socket, unsigned int n); -#define listen( socket, n ) \ -wgaim_listen( socket, n ) - -int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); -#define sendto(socket, buf, len, flags, to, tolen) \ -wgaim_sendto(socket, buf, len, flags, to, tolen) - -/* sys/ioctl.h */ -int wgaim_ioctl(int fd, int command, void* opt); -#define ioctl( fd, command, val ) \ -wgaim_ioctl( fd, command, val ) - -/* fcntl.h */ -int wgaim_fcntl(int socket, int command, int val); -#define fcntl( fd, command, val ) \ -wgaim_fcntl( fd, command, val ) - -#if !GLIB_CHECK_VERSION(2,6,0) -# define open( args... ) _open( args ) -#endif - -/* arpa/inet.h */ -int wgaim_inet_aton(const char *name, struct in_addr *addr); -#define inet_aton( name, addr ) \ -wgaim_inet_aton( name, addr ) - -/* netdb.h */ -struct hostent* wgaim_gethostbyname(const char *name); -#define gethostbyname( name ) \ -wgaim_gethostbyname( name ) - -/* netinet/in.h */ -#define ntohl( netlong ) \ -(unsigned int)ntohl( netlong ) - -/* string.h */ -char* wgaim_strerror( int errornum ); -#define hstrerror( herror ) \ -wgaim_strerror( errno ) -#define strerror( errornum ) \ -wgaim_strerror( errornum ) - -#define bzero( dest, size ) memset( dest, 0, size ) - -/* unistd.h */ -int wgaim_read(int fd, void *buf, unsigned int size); -#define read( fd, buf, buflen ) \ -wgaim_read( fd, buf, buflen ) - -int wgaim_write(int fd, const void *buf, unsigned int size); -#define write( socket, buf, buflen ) \ -wgaim_write( socket, buf, buflen ) - -int wgaim_recv(int fd, void *buf, size_t len, int flags); -#define recv(fd, buf, len, flags) \ -wgaim_recv(fd, buf, len, flags) - -int wgaim_send(int fd, const void *buf, unsigned int size, int flags); -#define send(socket, buf, buflen, flags) \ -wgaim_send(socket, buf, buflen, flags) - -int wgaim_close(int fd); -#define close( fd ) \ -wgaim_close( fd ) - -#ifndef sleep -#define sleep(x) Sleep((x)*1000) -#endif - -int wgaim_gethostname(char *name, size_t size); -#define gethostname( name, size ) \ -wgaim_gethostname( name, size ) - -/* sys/time.h */ -int wgaim_gettimeofday(struct timeval *p, struct timezone *z); -#define gettimeofday( timeval, timezone ) \ -wgaim_gettimeofday( timeval, timezone ) - -/* stdio.h */ -#define snprintf _snprintf -#define vsnprintf _vsnprintf - -int wgaim_rename(const char *oldname, const char *newname); -#define rename( oldname, newname ) \ -wgaim_rename( oldname, newname ) - -#if GLIB_CHECK_VERSION(2,6,0) -#ifdef g_rename -# undef g_rename -#endif -/* This is necessary because we want rename on win32 to be able to overwrite an existing file, it is done in internal.h if GLib < 2.6*/ -#define g_rename(oldname, newname) \ -wgaim_rename(oldname, newname) -#endif - - -/* sys/stat.h */ - -#if !GLIB_CHECK_VERSION(2,6,0) -#define mkdir(a,b) _mkdir((a)) -#endif -#define fchmod(a,b) - -/* time.h */ -struct tm *wgaim_localtime_r(const time_t *time, struct tm *resultp); -#define localtime_r( time, resultp ) \ -wgaim_localtime_r( time, resultp ) - -/* helper for gaim_utf8_strftime() by way of gaim_internal_strftime() in src/util.c */ -const char *wgaim_get_timezone_abbreviation(const struct tm *tm); - -#endif /* _LIBC_INTERFACE_H_ */
--- a/gtk/win32/libc_internal.h Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * gaim - * - * File: libc_internal.h - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _LIBC_INTERNAL_ -#define _LIBC_INTERNAL_ - -/* fcntl.h */ -#define F_SETFL 1 -#define O_NONBLOCK 1 - -/* ioctl.h */ -#define SIOCGIFCONF 0x8912 /* get iface list */ - -/* net/if.h */ -struct ifreq -{ - union - { - char ifrn_name[6]; /* Interface name, e.g. "en0". */ - } ifr_ifrn; - - union - { - struct sockaddr ifru_addr; -#if 0 - struct sockaddr ifru_dstaddr; - struct sockaddr ifru_broadaddr; - struct sockaddr ifru_netmask; - struct sockaddr ifru_hwaddr; - short int ifru_flags; - int ifru_ivalue; - int ifru_mtu; -#endif - char *ifru_data; - } ifr_ifru; -}; -# define ifr_name ifr_ifrn.ifrn_name /* interface name */ -# define ifr_addr ifr_ifru.ifru_addr /* address */ -#if 0 -# define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ -# define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ -# define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ -# define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ -# define ifr_flags ifr_ifru.ifru_flags /* flags */ -# define ifr_metric ifr_ifru.ifru_ivalue /* metric */ -# define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ -#endif -# define ifr_data ifr_ifru.ifru_data /* for use by interface */ -#if 0 -# define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ -# define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ -# define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ -#endif - - -struct ifconf -{ - int ifc_len; /* Size of buffer. */ - union - { - char *ifcu_buf; - struct ifreq *ifcu_req; - } ifc_ifcu; -}; -# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */ -# define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */ - -/* sys/time.h */ -struct timezone { - int tz_minuteswest; - int tz_dsttime; -}; - - -#endif /* _LIBC_INTERNAL_ */
--- a/gtk/win32/wgaimerror.h Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * gaim - * - * File: wgaimerror.h - * Date: October 14, 2002 - * Description: Convert Winsock errors to Unix errors - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _WGAIMERROR_H -#define _WGAIMERROR_H - -/* Here we define unix socket errors as windows socket errors */ - -#define ENETDOWN WSAENETDOWN -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define EINPROGRESS WSAEINPROGRESS -#define ENOBUFS WSAENOBUFS -#define EPROTONOSUPPORT WSAEPROTONOSUPPORT -#define EPROTOTYPE WSAEPROTOTYPE -#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT - -#define EADDRINUSE WSAEADDRINUSE -#define EINPROGRESS WSAEINPROGRESS -#define EALREADY WSAEALREADY -#define EADDRNOTAVAIL WSAEADDRNOTAVAIL -#define ECONNREFUSED WSAECONNREFUSED -#define EISCONN WSAEISCONN -#define ENETUNREACH WSAENETUNREACH -#define ENOTSOCK WSAENOTSOCK -#define ETIMEDOUT WSAETIMEDOUT -#define EWOULDBLOCK WSAEWOULDBLOCK - -#define ENOTCONN WSAENOTCONN -#define ENETRESET WSAENETRESET -#define EOPNOTSUPP WSAEOPNOTSUPP -#define ESHUTDOWN WSAESHUTDOWN -#define EMSGSIZE WSAEMSGSIZE -#define ECONNABORTED WSAECONNABORTED -#define ECONNRESET WSAECONNRESET -#define EHOSTUNREACH WSAEHOSTUNREACH - -#endif /* end _WGAIMERROR_H */
--- a/gtk/win32/win32dep.c Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,478 +0,0 @@ -/* - * gaim - * - * File: win32dep.c - * Date: June, 2002 - * Description: Windows dependant code for Gaim - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#define _WIN32_IE 0x500 -#include <windows.h> -#include <io.h> -#include <stdlib.h> -#include <stdio.h> -#include <winuser.h> - -#include <glib.h> -#include <glib/gstdio.h> - -#include "gaim.h" -#include "debug.h" -#include "notify.h" - -#include "resource.h" -#include "idletrack.h" -#include "zlib.h" -#include "untar.h" - -#include <libintl.h> - -#include "win32dep.h" - -/* - * DEFINES & MACROS - */ -#define _(x) gettext(x) - -/* - * DATA STRUCTS - */ - -/* For shfolder.dll */ -typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); -typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); - -/* - * LOCALS - */ -static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; - -/* - * GLOBALS - */ -HINSTANCE gaimexe_hInstance = 0; -HINSTANCE gaimdll_hInstance = 0; - -/* - * PROTOS - */ - -FARPROC wgaim_find_and_loadproc(char*, char*); -char* wgaim_data_dir(void); - -/* - * STATIC CODE - */ - -static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) { - char *str = NULL; - if (args != NULL) { - str = g_strdup_vprintf(format, args); - } else { - str = g_strdup(format); - } - printf("%s%s%s", category ? category : "", category ? ": " : "", str); - g_free(str); -} - -static GaimDebugUiOps ops = { - wgaim_debug_print -}; - -/* - * PUBLIC CODE - */ - -HINSTANCE wgaim_hinstance(void) { - return gaimexe_hInstance; -} - -/* Escape windows dir separators. This is needed when paths are saved, - and on being read back have their '\' chars used as an escape char. - Returns an allocated string which needs to be freed. -*/ -char* wgaim_escape_dirsep(char* filename) { - int sepcount = 0; - char* ret = NULL; - int cnt = 0; - - ret = filename; - while(*ret) { - if(*ret == '\\') - sepcount++; - ret++; - } - ret = g_malloc0(strlen(filename) + sepcount + 1); - while(*filename) { - ret[cnt] = *filename; - if(*filename == '\\') - ret[++cnt] = '\\'; - filename++; - cnt++; - } - ret[cnt] = '\0'; - return ret; -} - -/* Determine whether the specified dll contains the specified procedure. - If so, load it (if not already loaded). */ -FARPROC wgaim_find_and_loadproc(char* dllname, char* procedure) { - HMODULE hmod; - BOOL did_load = FALSE; - FARPROC proc = 0; - - if(!(hmod = GetModuleHandle(dllname))) { - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not already loaded; loading it...\n", dllname); - if(!(hmod = LoadLibrary(dllname))) { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); - return NULL; - } - else - did_load = TRUE; - } - - if((proc = GetProcAddress(hmod, procedure))) { - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", - dllname, procedure); - return proc; - } - else { - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", - procedure, dllname); - if(did_load) { - /* unload dll */ - FreeLibrary(hmod); - } - return NULL; - } -} - -/* Determine Gaim Paths during Runtime */ - -/* Get paths to special Windows folders. */ -char *wgaim_get_special_folder(int folder_type) { - static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; - static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; - char *retval = NULL; - - if (!MySHGetFolderPathW) { - MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) - wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); - } - - if (MySHGetFolderPathW) { - wchar_t utf_16_dir[MAX_PATH + 1]; - - if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL, - SHGFP_TYPE_CURRENT, utf_16_dir))) { - retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); - } - } - - if (!retval) { - if (!MySHGetFolderPathA) { - MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) - wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); - } - if (MySHGetFolderPathA) { - char locale_dir[MAX_PATH + 1]; - - if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, - SHGFP_TYPE_CURRENT, locale_dir))) { - retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); - } - } - } - - return retval; -} - -char* wgaim_install_dir(void) { - static gboolean initialized = FALSE; - - if (!initialized) { - char *tmp = NULL; - if (G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t winstall_dir[MAXPATHLEN]; - if (GetModuleFileNameW(NULL, winstall_dir, - MAXPATHLEN) > 0) { - tmp = g_utf16_to_utf8(winstall_dir, -1, - NULL, NULL, NULL); - } - } else { - gchar cpinstall_dir[MAXPATHLEN]; - if (GetModuleFileNameA(NULL, cpinstall_dir, - MAXPATHLEN) > 0) { - tmp = g_locale_to_utf8(cpinstall_dir, - -1, NULL, NULL, NULL); - } - } - - if (tmp == NULL) { - tmp = g_win32_error_message(GetLastError()); - gaim_debug(GAIM_DEBUG_ERROR, "wgaim", - "GetModuleFileName error: %s\n", tmp); - g_free(tmp); - return NULL; - } else { - install_dir = g_path_get_dirname(tmp); - g_free(tmp); - initialized = TRUE; - } - } - - return install_dir; -} - -char* wgaim_lib_dir(void) { - static gboolean initialized = FALSE; - - if (!initialized) { - char *inst_dir = wgaim_install_dir(); - if (inst_dir != NULL) { - lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); - initialized = TRUE; - } else { - return NULL; - } - } - - return lib_dir; -} - -char* wgaim_locale_dir(void) { - static gboolean initialized = FALSE; - - if (!initialized) { - char *inst_dir = wgaim_install_dir(); - if (inst_dir != NULL) { - locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); - initialized = TRUE; - } else { - return NULL; - } - } - - return locale_dir; -} - -char* wgaim_data_dir(void) { - return app_data_dir; -} - -/* Miscellaneous */ - -gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { - HKEY hkey; - gboolean ret = FALSE; - - if(ERROR_SUCCESS == RegOpenKeyEx(key, sub_key, 0, KEY_QUERY_VALUE, - &hkey)) { - if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, - data, data_len)) - ret = TRUE; - RegCloseKey(key); - } - return ret; -} - -int wgaim_gz_decompress(const char* in, const char* out) { - gzFile fin; - FILE *fout; - char buf[1024]; - int ret; - - if((fin = gzopen(in, "rb"))) { - if(!(fout = g_fopen(out, "wb"))) { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out); - gzclose(fin); - return 0; - } - } - else { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in); - return 0; - } - - while((ret = gzread(fin, buf, 1024))) { - if(fwrite(buf, 1, ret, fout) < ret) { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret); - gzclose(fin); - fclose(fout); - return 0; - } - } - fclose(fout); - gzclose(fin); - - if(ret < 0) { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in); - return 0; - } - - return 1; -} - -int wgaim_gz_untar(const char* filename, const char* destdir) { - char tmpfile[_MAX_PATH]; - char template[]="wgaimXXXXXX"; - - sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template)); - if(wgaim_gz_decompress(filename, tmpfile)) { - int ret; - if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) - ret = 1; - else { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile); - ret = 0; - } - g_unlink(tmpfile); - return ret; - } - else { - gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename); - return 0; - } -} - -void wgaim_notify_uri(const char *uri) { - - /* We'll allow whatever URI schemes are supported by the - * default http browser. - */ - - if (G_WIN32_HAVE_WIDECHAR_API()) { - SHELLEXECUTEINFOW wsinfo; - wchar_t *w_uri; - - w_uri = g_utf8_to_utf16(uri, -1, NULL, NULL, NULL); - - memset(&wsinfo, 0, sizeof(wsinfo)); - wsinfo.cbSize = sizeof(wsinfo); - wsinfo.fMask = SEE_MASK_CLASSNAME; - wsinfo.lpVerb = L"open"; - wsinfo.lpFile = w_uri; - wsinfo.nShow = SW_SHOWNORMAL; - wsinfo.lpClass = L"http"; - - gaim_debug(GAIM_DEBUG_INFO, "wgaim_notify_uri", "The wide uri is %s\n", uri); - if(!ShellExecuteExW(&wsinfo)) - gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", - uri, (int) wsinfo.hInstApp); - - g_free(w_uri); - } else { - SHELLEXECUTEINFOA sinfo; - gchar *locale_uri; - - locale_uri = g_locale_from_utf8(uri, -1, NULL, NULL, NULL); - - memset(&sinfo, 0, sizeof(sinfo)); - sinfo.cbSize = sizeof(sinfo); - sinfo.fMask = SEE_MASK_CLASSNAME; - sinfo.lpVerb = "open"; - sinfo.lpFile = locale_uri; - sinfo.nShow = SW_SHOWNORMAL; - sinfo.lpClass = "http"; - - if(!ShellExecuteExA(&sinfo)) - gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", - uri, (int) sinfo.hInstApp); - - g_free(locale_uri); - } -} - -void wgaim_init(HINSTANCE hint) { - WORD wVersionRequested; - WSADATA wsaData; - const char *perlenv; - char *newenv; - - gaim_debug_set_ui_ops(&ops); - gaim_debug_info("wgaim", "wgaim_init start\n"); - - gaim_debug_info("wgaim", "Glib:%u.%u.%u\n", - glib_major_version, glib_minor_version, glib_micro_version); - - gaimexe_hInstance = hint; - - /* Winsock init */ - wVersionRequested = MAKEWORD(2, 2); - WSAStartup(wVersionRequested, &wsaData); - - /* Confirm that the winsock DLL supports 2.2 */ - /* Note that if the DLL supports versions greater than - 2.2 in addition to 2.2, it will still return 2.2 in - wVersion since that is the version we requested. */ - if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); - WSACleanup(); - } - - /* Set Environmental Variables */ - /* Tell perl where to find Gaim's perl modules */ - perlenv = g_getenv("PERL5LIB"); - newenv = g_strdup_printf("PERL5LIB=%s%s%s" G_DIR_SEPARATOR_S "perlmod;", - perlenv ? perlenv : "", - perlenv ? ";" : "", - wgaim_install_dir()); - if (putenv(newenv) < 0) - gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); - g_free(newenv); - - /* Set app data dir, used by gaim_home_dir */ - newenv = (char*) g_getenv("GAIMHOME"); - if (newenv) { - app_data_dir = g_strdup(newenv); - } else { - app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); - if (!app_data_dir) { - app_data_dir = g_strdup("C:"); - } - } - - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); - - /* IdleTracker Initialization */ - if(!wgaim_set_idlehooks()) - gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n"); - - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); -} - -/* Windows Cleanup */ - -void wgaim_cleanup(void) { - gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n"); - - /* winsock cleanup */ - WSACleanup(); - - /* Idle tracker cleanup */ - wgaim_remove_idlehooks(); - - g_free(app_data_dir); -} - -/* DLL initializer */ -BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { - gaimdll_hInstance = hinstDLL; - return TRUE; -}
--- a/gtk/win32/win32dep.h Sun Aug 20 16:45:57 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * gaim - * - * File: win32dep.h - * - * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _WIN32DEP_H_ -#define _WIN32DEP_H_ -#include <shlobj.h> -#include <winsock2.h> -#include <process.h> -#include "wgaimerror.h" -#include "libc_interface.h" - -/* - * PROTOS - */ - -/** - ** win32dep.c - **/ -/* Windows helper functions */ -HINSTANCE wgaim_hinstance(void); -FARPROC wgaim_find_and_loadproc(char*, char*); -gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len); -char* wgaim_escape_dirsep(char*); - -/* Determine Gaim paths */ -char* wgaim_get_special_folder(int folder_type); /* needs to be g_free'd */ -char* wgaim_install_dir(void); -char* wgaim_lib_dir(void); -char* wgaim_locale_dir(void); -char* wgaim_data_dir(void); - -/* Utility */ -int wgaim_gz_decompress(const char* in, const char* out); -int wgaim_gz_untar(const char* filename, const char* destdir); - -/* Misc */ -void wgaim_notify_uri(const char *uri); - -/* init / cleanup */ -void wgaim_init(HINSTANCE); -void wgaim_cleanup(void); - - -/* - * MACROS - */ - -/* - * Gaim specific - */ -#define DATADIR wgaim_install_dir() -#define LIBDIR wgaim_lib_dir() -#define LOCALEDIR wgaim_locale_dir() - -#endif /* _WIN32DEP_H_ */ -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/win32/win_gaim.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,544 @@ +/* + * win_gaim.c + * + * Date: June, 2002 + * Description: Entry point for win32 gaim, and various win32 dependant + * routines. + * + * Gaim is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* This is for ATTACH_PARENT_PROCESS */ +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x501 +#endif +#include <windows.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#define WIN32_PROXY_REGKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" + +typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); +typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); +typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); + +/* + * PROTOTYPES + */ +static LPFNGAIMMAIN gaim_main = NULL; +static LPFNSETDLLDIRECTORY MySetDllDirectory = NULL; + + +static BOOL read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { + HKEY hkey; + BOOL ret = FALSE; + LONG retv; + + if (ERROR_SUCCESS == (retv = RegOpenKeyEx(key, sub_key, 0, + KEY_QUERY_VALUE, &hkey))) { + if (ERROR_SUCCESS == (retv = RegQueryValueEx(hkey, val_name, + NULL, NULL, data, data_len))) + ret = TRUE; + else { + TCHAR szBuf[80]; + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + NULL, retv, 0, + (LPTSTR) &szBuf, sizeof(szBuf), NULL); + + printf("Could not read reg key '%s' subkey '%s' value: '%s'\nError: (%ld) %s\n", + ((key == HKEY_LOCAL_MACHINE) ? "HKLM" : + (key == HKEY_CURRENT_USER) ? "HKCU" : + "???"), + sub_key, val_name, retv, szBuf); + } + RegCloseKey(hkey); + } + else { + TCHAR szBuf[80]; + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0, + (LPTSTR) &szBuf, sizeof(szBuf), NULL); + printf("Could not open reg subkey: %s\nError: (%ld) %s\n", + sub_key, retv, szBuf); + } + + return ret; +} + +static void dll_prep() { + char path[MAX_PATH + 1]; + HMODULE hmod; + HKEY hkey; +#ifdef PORTABLE + /* We assume that GTK+ is installed under \\path\to\Gaim\..\GTK + * First we find \\path\to + */ + if (GetModuleFileName(NULL, path, MAX_PATH) != 0) { + char *tmp = path; + char *prev = NULL; + char *prev2 = NULL; + + while ((tmp = strchr(tmp, '\\'))) { + prev2 = prev; + prev = tmp; + tmp++; + } + + if (prev2) { + prev2[0] = '\0'; + } + } else { + printf("Unable to determine current executable path. \n" + "This will prevent the settings dir from being set.\n" + "Assuming GTK+ is in the PATH.\n"); + } + + if (path) { + /* Set up the settings dir base to be \\path\to + * The actual settings dir will be \\path\to\.gaim */ + char settingsdir[strlen(path) + strlen("GAIMHOME=") + 1]; + char aspelldir[strlen(path) + strlen("GAIM_ASPELL_DIR=\\Aspell\\bin") + 1]; + + snprintf(settingsdir, sizeof(settingsdir), "GAIMHOME=%s", path); + printf("Setting settings dir: %s\n", settingsdir); + putenv(settingsdir); + + snprintf(aspelldir, sizeof(aspelldir), "GAIM_ASPELL_DIR=%s\\Aspell\\bin", path); + printf(aspelldir); + putenv(aspelldir); + + /* set the GTK+ path to be \\path\to\GTK\bin */ + strcat(path, "\\GTK\\bin"); + } else + return; +#else /* PORTABLE */ + char gtkpath[MAX_PATH + 1]; + DWORD plen; + + plen = sizeof(gtkpath); + hkey = HKEY_CURRENT_USER; + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", + (LPBYTE) >kpath, &plen)) { + hkey = HKEY_LOCAL_MACHINE; + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", + (LPBYTE) >kpath, &plen)) { + printf("GTK+ Path Registry Key not found. " + "Assuming GTK+ is in the PATH.\n"); + return; + } + } + + /* this value is replaced during a successful RegQueryValueEx() */ + plen = sizeof(path); + /* Determine GTK+ dll path .. */ + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", + (LPBYTE) &path, &plen)) { + strcpy(path, gtkpath); + strcat(path, "\\bin"); + } +#endif + printf("GTK+ path found: %s\n", path); + + if ((hmod = GetModuleHandle("kernel32.dll"))) { + MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( + hmod, "SetDllDirectoryA"); + if (!MySetDllDirectory) + printf("SetDllDirectory not supported\n"); + } else + printf("Error getting kernel32.dll module handle\n"); + + /* For Windows XP SP1+ / Server 2003 we use SetDllDirectory to avoid dll hell */ + if (MySetDllDirectory) { + printf("Using SetDllDirectory\n"); + MySetDllDirectory(path); + } + + /* For the rest, we set the current directory and make sure + * SafeDllSearch is set to 0 where needed. */ + else { + OSVERSIONINFO osinfo; + + printf("Setting current directory to GTK+ dll directory\n"); + SetCurrentDirectory(path); + /* For Windows 2000 (SP3+) / WinXP (No SP): + * If SafeDllSearchMode is set to 1, Windows system directories are + * searched for dlls before the current directory. Therefore we set it + * to 0. + */ + osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osinfo); + if ((osinfo.dwMajorVersion == 5 && + osinfo.dwMinorVersion == 0 && + strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) || + (osinfo.dwMajorVersion == 5 && + osinfo.dwMinorVersion == 1 && + strcmp(osinfo.szCSDVersion, "") >= 0) + ) { + DWORD regval = 1; + DWORD reglen = sizeof(DWORD); + + printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n"); + read_reg_string(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Control\\Session Manager", + "SafeDllSearchMode", + (LPBYTE) ®val, + ®len); + + if (regval != 0) { + printf("Trying to set SafeDllSearchMode to 0\n"); + regval = 0; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Control\\Session Manager", + 0, KEY_SET_VALUE, &hkey + ) == ERROR_SUCCESS) { + if (RegSetValueEx(hkey, + "SafeDllSearchMode", 0, + REG_DWORD, (LPBYTE) ®val, + sizeof(DWORD) + ) != ERROR_SUCCESS) + printf("Error writing SafeDllSearchMode. Error: %u\n", + (UINT) GetLastError()); + RegCloseKey(hkey); + } else + printf("Error opening Session Manager key for writing. Error: %u\n", + (UINT) GetLastError()); + } else + printf("SafeDllSearchMode is set to 0\n"); + }/*end else*/ + } +} + +static char* wgaim_lcid_to_posix(LCID lcid) { + char *posix = NULL; + int lang_id = PRIMARYLANGID(lcid); + int sub_id = SUBLANGID(lcid); + + switch (lang_id) { + case LANG_ARABIC: break; + case LANG_BULGARIAN: posix = "bg"; break; + case LANG_CATALAN: posix = "ca"; break; + case LANG_CHINESE: + switch (sub_id) { + case SUBLANG_CHINESE_SIMPLIFIED: + posix = "zh_CN"; break; + case SUBLANG_CHINESE_TRADITIONAL: + posix = "zh_TW"; break; + default: + posix = "zh"; break; + } + break; + case LANG_CZECH: posix = "cs"; break; + case LANG_DANISH: posix = "da"; break; + case LANG_GERMAN: posix = "de"; break; + case LANG_GREEK: posix = "el"; break; + case LANG_ENGLISH: + switch (sub_id) { + case SUBLANG_ENGLISH_UK: + posix = "en_GB"; break; + case SUBLANG_ENGLISH_AUS: + posix = "en_AU"; break; + case SUBLANG_ENGLISH_CAN: + posix = "en_CA"; break; + default: + posix = "en"; break; + } + break; + case LANG_SPANISH: posix = "es"; break; + case LANG_FINNISH: posix = "fi"; break; + case LANG_FRENCH: posix = "fr"; break; + case LANG_HEBREW: posix = "he"; break; + case LANG_HUNGARIAN: posix = "hu"; break; + case LANG_ICELANDIC: break; + case LANG_ITALIAN: posix = "it"; break; + case LANG_JAPANESE: posix = "ja"; break; + case LANG_KOREAN: posix = "ko"; break; + case LANG_DUTCH: posix = "nl"; break; + case LANG_NORWEGIAN: + switch (sub_id) { + case SUBLANG_NORWEGIAN_BOKMAL: + posix = "nb"; break; + case SUBLANG_NORWEGIAN_NYNORSK: + posix = "nn"; break; + } + break; + case LANG_POLISH: posix = "pl"; break; + case LANG_PORTUGUESE: + switch (sub_id) { + case SUBLANG_PORTUGUESE_BRAZILIAN: + posix = "pt_BR"; break; + default: + posix = "pt"; break; + } + break; + case LANG_ROMANIAN: posix = "ro"; break; + case LANG_RUSSIAN: posix = "ru"; break; + /* LANG_CROATIAN == LANG_SERBIAN for some reason + * We'll need to do something here if we ever get a croatian translation */ + /* case LANG_CROATIAN: posix = "hr"; break;*/ + case LANG_SERBIAN: + switch (sub_id) { + case SUBLANG_SERBIAN_LATIN: + posix = "sr@Latn"; break; + case SUBLANG_SERBIAN_CYRILLIC: + posix = "sr"; break; + } + break; + case LANG_SLOVAK: posix = "sk"; break; + case LANG_ALBANIAN: posix = "sq"; break; + case LANG_SWEDISH: posix = "sv"; break; + case LANG_THAI: posix = "th"; break; + case LANG_TURKISH: posix = "tr"; break; + case LANG_URDU: break; + case LANG_INDONESIAN: break; + case LANG_UKRAINIAN: posix = "uk"; break; + case LANG_BELARUSIAN: break; + case LANG_SLOVENIAN: posix = "sl"; break; + case LANG_ESTONIAN: posix = "et"; break; + case LANG_LATVIAN: break; + case LANG_LITHUANIAN: posix = "lt"; break; + case LANG_FARSI: break; + case LANG_VIETNAMESE: posix = "vi"; break; + case LANG_ARMENIAN: break; + case LANG_AZERI: posix = "az"; break; + case LANG_BASQUE: break; + case LANG_MACEDONIAN: posix = "mk"; break; + case LANG_AFRIKAANS: break; + case LANG_GEORGIAN: posix = "ka"; break; + case LANG_FAEROESE: break; + case LANG_HINDI: posix = "hi"; break; + case LANG_MALAY: break; + case LANG_KAZAK: break; + case LANG_KYRGYZ: break; + case LANG_SWAHILI: break; + case LANG_UZBEK: break; + case LANG_TATAR: break; + case LANG_BENGALI: break; + case LANG_PUNJABI: posix = "pa"; break; + case LANG_GUJARATI: posix = "gu"; break; + case LANG_ORIYA: break; + case LANG_TAMIL: posix = "ta"; break; + case LANG_TELUGU: break; + case LANG_KANNADA: break; + case LANG_MALAYALAM: break; + case LANG_ASSAMESE: break; + case LANG_MARATHI: break; + case LANG_SANSKRIT: break; + case LANG_MONGOLIAN: break; + case LANG_GALICIAN: posix = "gl"; break; + case LANG_KONKANI: break; + case LANG_MANIPURI: break; + case LANG_SINDHI: break; + case LANG_SYRIAC: break; + case LANG_KASHMIRI: break; + case LANG_NEPALI: break; + case LANG_DIVEHI: break; + } + + /* Deal with exceptions */ + if (posix == NULL) { + switch (lcid) { + case 2125: posix = "my_MM"; break; /* Myanmar (Burmese) */ + case 1076: posix = "xh"; break; /* Xhosa */ + case 9999: posix = "ku"; break; /* Kurdish (from NSIS) */ + } + } + + return posix; +} + +/* Determine and set Gaim locale as follows (in order of priority): + - Check GAIMLANG env var + - Check NSIS Installer Language reg value + - Use default user locale +*/ +static const char *wgaim_get_locale() { + const char *locale = NULL; + LCID lcid; +#ifndef PORTABLE + char data[10]; + DWORD datalen = 10; +#endif + + /* Check if user set GAIMLANG env var */ + if ((locale = getenv("GAIMLANG"))) + return locale; + +#ifndef PORTABLE + if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", + "Installer Language", (LPBYTE) &data, &datalen)) { + if ((locale = wgaim_lcid_to_posix(atoi(data)))) + return locale; + } +#endif + + lcid = GetUserDefaultLCID(); + if ((locale = wgaim_lcid_to_posix(lcid))) + return locale; + + return "en"; +} + +static void wgaim_set_locale() { + const char *locale = NULL; + char envstr[25]; + + locale = wgaim_get_locale(); + + snprintf(envstr, 25, "LANG=%s", locale); + printf("Setting locale: %s\n", envstr); + putenv(envstr); +} + +static BOOL wgaim_set_running() { + HANDLE h; + + if ((h = CreateMutex(NULL, FALSE, "gaim_is_running"))) { + if (GetLastError() == ERROR_ALREADY_EXISTS) { + MessageBox(NULL, + "An instance of Gaim is already running", + NULL, MB_OK | MB_TOPMOST); + return FALSE; + } + } + return TRUE; +} + +static void wgaim_set_proxy() { + DWORD regval = 1; + DWORD reglen = sizeof(DWORD); + + /* If the proxy server environment variables are already set, + * we shouldn't override them */ + if (getenv("HTTP_PROXY") || getenv("http_proxy") || getenv("HTTPPROXY")) + return; + + if (read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, + "ProxyEnable", + (LPBYTE) ®val, ®len) && (regval & 1)) { + char proxy_server[2048]; + char *c = NULL; + reglen = sizeof(proxy_server); + + if (!read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, + "ProxyServer", (LPBYTE) &proxy_server, ®len)) + return; + + if ((reglen > strlen("http=")) + && (c = strstr(proxy_server, "http="))) { + char *d; + c += strlen("http="); + d = strchr(c, ';'); + if (d) { + *d = '\0'; + } + /* c now points the proxy server (and port) */ + } + + if (c) { + const char envstr_prefix[] = "HTTP_PROXY=http://"; + char envstr[sizeof(envstr_prefix) + strlen(c) + 1]; + snprintf(envstr, sizeof(envstr), "%s%s", + envstr_prefix, c); + printf("Setting HTTP Proxy: %s\n", envstr); + putenv(envstr); + } + } + +} + +#ifdef __GNUC__ +# ifndef _stdcall +# define _stdcall __attribute__((stdcall)) +# endif +#endif + +int _stdcall +WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, + char *lpszCmdLine, int nCmdShow) { + char errbuf[512]; + char gaimdir[MAX_PATH]; + HMODULE hmod; + + /* If debug or help or version flag used, create console for output */ + if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { + LPFNATTACHCONSOLE MyAttachConsole = NULL; + if ((hmod = GetModuleHandle("kernel32.dll"))) { + MyAttachConsole = + (LPFNATTACHCONSOLE) + GetProcAddress(hmod, "AttachConsole"); + } + if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) + || AllocConsole()) + freopen("CONOUT$", "w", stdout); + } + + /* Load exception handler if we have it */ + if (GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { + char *tmp = gaimdir; + char *prev = NULL; + + while ((tmp = strchr(tmp, '\\'))) { + prev = tmp; + tmp++; + } + + if (prev) { + prev[0] = '\0'; + strcat(gaimdir, "\\exchndl.dll"); + if (LoadLibrary(gaimdir)) + printf("Loaded exchndl.dll\n"); + } + } else { + snprintf(errbuf, 512, + "Error getting module filename. Error: %u", + (UINT) GetLastError()); + MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); + } + +#ifndef PORTABLE + if (!getenv("GAIM_NO_DLL_CHECK")) +#endif + dll_prep(); + + wgaim_set_locale(); + /* If help or version flag used, do not check Mutex */ + if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) + if (!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) + return 0; + + wgaim_set_proxy(); + + /* Now we are ready for Gaim .. */ + if ((hmod = LoadLibrary("gtkgaim.dll"))) { + gaim_main = (LPFNGAIMMAIN) GetProcAddress(hmod, "gaim_main"); + } + + if (!gaim_main) { + snprintf(errbuf, 512, "Error loading gaim.dll. Error: %u", + (UINT) GetLastError()); + MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); + return 0; + } + + return gaim_main (hInstance, __argc, __argv); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,155 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of Gaim +# + +# +# PATHS +# + +INCLUDE_DIR := . +GTK_TOP := ../../win32-dev/gtk_2_0 +GAIM_TOP := .. +GAIM_SRC := . +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +LIBXML2_DIR := ../../win32-dev/libxml2 + +## +## VARIABLE DEFINITIONS +## + +TARGET = libgaim + +# Compiler and Linker Options + +CFLAGS = + +DEFINES = + +## +## INCLUDE MAKEFILES +## + +include $(GAIM_TOP)/libgaim/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS = \ + -I$(INCLUDE_DIR) \ + -I$(INCLUDE_DIR)/win32 \ + -I$(GAIM_TOP) \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(LIBXML2_DIR)/include + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(GAIM_SRC) \ + -L$(LIBXML2_DIR)/lib + +## +## SOURCES, OBJECTS +## + +C_SRC = \ + account.c \ + accountopt.c \ + blist.c \ + buddyicon.c \ + cipher.c \ + cmds.c \ + connection.c \ + conversation.c \ + core.c \ + debug.c \ + dnsquery.c \ + dnssrv.c \ + eventloop.c \ + ft.c \ + circbuffer.c \ + idle.c \ + imgstore.c \ + log.c \ + mime.c \ + network.c \ + notify.c \ + ntlm.c \ + plugin.c \ + pluginpref.c \ + pounce.c \ + prefs.c \ + privacy.c \ + proxy.c \ + prpl.c \ + request.c \ + roomlist.c \ + savedstatuses.c \ + server.c \ + signals.c \ + sound.c \ + sslconn.c \ + status.c \ + stringref.c \ + stun.c \ + upnp.c \ + util.c \ + value.c \ + xmlnode.c \ + whiteboard.c \ + win32/libc_interface.c \ + win32/win32dep.c + + +OBJECTS = $(C_SRC:%.c=%.o) + +## +## LIBRARIES +## + +LIBS = \ + -lglib-2.0 \ + -lgthread-2.0 \ + -lgobject-2.0 \ + -lgmodule-2.0 \ + -lintl \ + -lws2_32 \ + -liberty \ + -lxml2 + +## +## RULES +## + +# How to make a C file +%.o: %.c + $(CC) $(CFLAGS) $(INCLUDE_PATHS) $(DEFINES) -c $< -o $@ + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean include_path + +all: $(TARGET).dll + +install: all + cp $(GAIM_SRC)/$(TARGET).dll $(GAIM_INSTALL_DIR) + +# +# BUILD DLL +# +$(TARGET).dll.a $(TARGET).dll: +$(TARGET).dll.a $(TARGET).dll: $(OBJECTS) + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--out-implib,$(TARGET).dll.a -o $(TARGET).dll + +## +## CLEAN RULES +## + +clean: + rm -rf *.o ./win32/*.o + rm -rf $(TARGET).dll + rm -rf $(TARGET).dll.a
--- a/libgaim/core.c Sun Aug 20 16:45:57 2006 +0000 +++ b/libgaim/core.c Sun Aug 20 16:49:37 2006 +0000 @@ -69,6 +69,10 @@ g_return_val_if_fail(ui != NULL, FALSE); g_return_val_if_fail(gaim_get_core() == NULL, FALSE); +#ifdef _WIN32 + wgaim_init(); +#endif + _core = core = g_new0(GaimCore, 1); core->ui = g_strdup(ui); core->reserved = NULL; @@ -199,6 +203,10 @@ g_free(core->ui); g_free(core); +#ifdef _WIN32 + wgaim_cleanup(); +#endif + _core = NULL; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/plugins/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,112 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of Gaim Plugins +# + +# +# PATHS +# + +GAIM_PLUGINS := . +GAIM_TOP := ../.. +LIBGAIM_TOP := .. +GTK_TOP := ../../../win32-dev/gtk_2_0 +GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir +PERL_PLUGIN_LOADER := ./perl +TCL_PLUGIN_LOADER := ./tcl +SSL := ./ssl + +## +## VARIABLE DEFINITIONS +## + +# Compiler Options + +CFLAGS = + +DEFINES = + +.SUFFIXES: +.SUFFIXES: .c .dll + +## +## INCLUDE MAKEFILES +## + +include $(LIBGAIM_TOP)/win32/global.mak + +## +## INCLUDE PATHS +## + +INCLUDE_PATHS += \ + -I$(GTK_TOP)/include \ + -I$(GTK_TOP)/include/glib-2.0 \ + -I$(GTK_TOP)/lib/glib-2.0/include \ + -I$(GAIM_TOP) \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 + + +LIB_PATHS = -L$(GTK_TOP)/lib \ + -L$(LIBGAIM_TOP) + + +## +## LIBRARIES +## + +LIBS = \ + -lglib-2.0 \ + -lgobject-2.0 \ + -lgmodule-2.0 \ + -lintl \ + -lws2_32 \ + -lgaim + +## +## RULES +## + +## +## TARGET DEFINITIONS +## + +.PHONY: all clean + +all: plugins +# $(MAKE) -C $(PERL_PLUGIN_LOADER) -f Makefile.mingw + $(MAKE) -C $(TCL_PLUGIN_LOADER) -f Makefile.mingw + $(MAKE) -C $(SSL) -f Makefile.mingw + +install: + cp $(GAIM_PLUGINS)/*.dll $(GAIM_INSTALL_DIR)/plugins +# $(MAKE) -C $(PERL_PLUGIN_LOADER) -f Makefile.mingw install + $(MAKE) -C $(TCL_PLUGIN_LOADER) -f Makefile.mingw install + $(MAKE) -C $(SSL) -f Makefile.mingw install + +# +# BUILD Plugin +# + +.c.dll: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@.o -c $< + $(CC) -shared $@.o $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $@ + +plugins: \ + idle.dll \ + psychic.dll \ + statenotify.dll + + +## +## CLEAN RULES +## + +clean: + rm -rf *.o + rm -rf *.dll + $(MAKE) -C $(PERL_PLUGIN_LOADER) -f Makefile.mingw clean + $(MAKE) -C $(TCL_PLUGIN_LOADER) -f Makefile.mingw clean + $(MAKE) -C $(SSL) -f Makefile.mingw clean
--- a/libgaim/plugins/perl/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/libgaim/plugins/perl/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -8,10 +8,11 @@ # PATHS # -GTK_TOP := ../../../win32-dev/gtk_2_0 -GAIM_TOP := ../.. -PERL_LIB_DIR := ../../../win32-dev/perl58 -PERL_INCLUDE := $(PERL_LIB_DIR)/CORE +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +LIBGAIM_TOP := ../.. +PERL_LIB_DIR := ../../../../win32-dev/perl58 +PERL_INCLUDE := $(PERL_LIB_DIR)/CORE GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins @@ -33,7 +34,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak # Perl headers with /* /* */ type comments.. Turn off warnings. CFLAGS += -Wno-comment @@ -44,15 +45,11 @@ INCLUDE_PATHS += -I. \ -I$(GAIM_TOP) \ - -I$(GAIM_TOP)/src \ - -I$(GAIM_TOP)/src/win32 \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ -I$(GTK_TOP)/include \ - -I$(GTK_TOP)/include/gtk-2.0 \ -I$(GTK_TOP)/include/glib-2.0 \ - -I$(GTK_TOP)/include/pango-1.0 \ - -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ - -I$(GTK_TOP)/lib/gtk-2.0/include \ -I$(PERL_INCLUDE) @@ -79,9 +76,8 @@ ## LIBRARIES ## -LIBS = -lgtk-win32-2.0 \ +LIBS = \ -lglib-2.0 \ - -lgdk-win32-2.0 \ -lgmodule-2.0 \ -lgobject-2.0 \ -lws2_32 \ @@ -116,15 +112,15 @@ ## BUILD Dependencies ## -$(GAIM_TOP)/src/gaim.lib: - $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib +$(GAIM_TOP)/src/libgaim.dll.a: + $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw libgaim.dll.a ## ## BUILD DLL ## -$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib - $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--export-all-symbols -Wl,--out-implib,$(TARGET).lib -o $(TARGET).dll +$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/libgaim.dll.a + $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--export-all-symbols -o $(TARGET).dll ##
--- a/libgaim/plugins/ssl/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/libgaim/plugins/ssl/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -8,12 +8,13 @@ # PATHS # -GTK_TOP := ../../../win32-dev/gtk_2_0 -GAIM_TOP := ../.. +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +LIBGAIM_TOP := ../.. GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins -NSS_DIR := ../../../win32-dev/nss-3.9 -NSPR_DIR := ../../../win32-dev/nspr-4.4.1 +NSS_DIR := ../../../../win32-dev/nss-3.9 +NSPR_DIR := ../../../../win32-dev/nspr-4.4.1 ## ## VARIABLE DEFINITIONS @@ -40,7 +41,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak ## ## INCLUDE PATHS @@ -48,22 +49,18 @@ INCLUDE_PATHS += -I. \ -I$(GTK_TOP)/include \ - -I$(GTK_TOP)/include/gtk-2.0 \ -I$(GTK_TOP)/include/glib-2.0 \ - -I$(GTK_TOP)/include/pango-1.0 \ - -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ - -I$(GTK_TOP)/lib/gtk-2.0/include \ - -I$(GAIM_TOP)/src \ - -I$(GAIM_TOP)/src/win32 \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ -I$(GAIM_TOP) \ - -I$(NSS_DIR)/include \ - -I$(NSPR_DIR)/include + -I$(NSS_DIR)/include \ + -I$(NSPR_DIR)/include LIB_PATHS = -L$(GTK_TOP)/lib \ - -L$(GAIM_TOP)/src \ - -L$(NSS_DIR)/lib \ - -L$(NSPR_DIR)/lib + -L$(LIBGAIM_TOP) \ + -L$(NSS_DIR)/lib \ + -L$(NSPR_DIR)/lib ## ## SOURCES, OBJECTS @@ -83,11 +80,8 @@ ## LIBRARIES ## -LIBS = -lgtk-win32-2.0 \ +LIBS = \ -lglib-2.0 \ - -lgdk-win32-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ -lws2_32 \ -lintl \ -lgaim \ @@ -122,17 +116,17 @@ ## BUILD Dependencies ## -$(GAIM_TOP)/src/gaim.lib: - $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib +$(LIBGAIM_TOP)/libgaim.dll.a: + $(MAKE) -C $(LIBGAIM_TOP) -f Makefile.mingw libgaim.dll.a ## ## BUILD DLL ## -$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib +$(TARGET).dll: $(OBJECTS) $(LIBGAIM_TOP)/libgaim.dll.a $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll -$(TARGET_NSS).dll: $(OBJECTS_NSS) $(GAIM_TOP)/src/gaim.lib +$(TARGET_NSS).dll: $(OBJECTS_NSS) $(LIBGAIM_TOP)/libgaim.dll.a $(CC) -shared $(OBJECTS_NSS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET_NSS).dll ##
--- a/libgaim/plugins/tcl/Makefile.mingw Sun Aug 20 16:45:57 2006 +0000 +++ b/libgaim/plugins/tcl/Makefile.mingw Sun Aug 20 16:49:37 2006 +0000 @@ -8,9 +8,10 @@ # PATHS # -GTK_TOP := ../../../win32-dev/gtk_2_0 -GAIM_TOP := ../.. -TCL_LIB_DIR := ../../../win32-dev/tcl-8.4.5 +GTK_TOP := ../../../../win32-dev/gtk_2_0 +GAIM_TOP := ../../.. +LIBGAIM_TOP := ../.. +TCL_LIB_DIR := ../../../../win32-dev/tcl-8.4.5 TCL_INC_DIR := $(TCL_LIB_DIR)/include GAIM_INSTALL_DIR := $(GAIM_TOP)/win32-install-dir DLL_INSTALL_DIR := $(GAIM_INSTALL_DIR)/plugins @@ -31,7 +32,7 @@ ## INCLUDE MAKEFILES ## -include $(GAIM_TOP)/src/win32/global.mak +include $(LIBGAIM_TOP)/win32/global.mak ## ## INCLUDE PATHS @@ -39,20 +40,16 @@ INCLUDE_PATHS += -I. \ -I$(GAIM_TOP) \ - -I$(GAIM_TOP)/src \ - -I$(GAIM_TOP)/src/win32 \ + -I$(LIBGAIM_TOP) \ + -I$(LIBGAIM_TOP)/win32 \ -I$(GTK_TOP)/include \ - -I$(GTK_TOP)/include/gtk-2.0 \ -I$(GTK_TOP)/include/glib-2.0 \ - -I$(GTK_TOP)/include/pango-1.0 \ - -I$(GTK_TOP)/include/atk-1.0 \ -I$(GTK_TOP)/lib/glib-2.0/include \ - -I$(GTK_TOP)/lib/gtk-2.0/include \ -I$(TCL_INC_DIR) LIB_PATHS = -L$(GTK_TOP)/lib \ - -L$(GAIM_TOP)/src \ + -L$(LIBGAIM_TOP) \ -L$(TCL_LIB_DIR) @@ -75,11 +72,8 @@ ## LIBRARIES ## -LIBS = -lgtk-win32-2.0 \ +LIBS = \ -lglib-2.0 \ - -lgdk-win32-2.0 \ - -lgmodule-2.0 \ - -lgobject-2.0 \ -lws2_32 \ -lintl \ -lgaim \ @@ -111,14 +105,14 @@ ## BUILD Dependencies ## -$(GAIM_TOP)/src/gaim.lib: - $(MAKE) -C $(GAIM_TOP)/src -f Makefile.mingw gaim.lib +$(LIBGAIM_TOP)/libgaim.dll.a: + $(MAKE) -C $(LIBGAIM_TOP) -f Makefile.mingw libgaim.dll.a ## ## BUILD DLL ## -$(TARGET).dll: $(OBJECTS) $(GAIM_TOP)/src/gaim.lib +$(TARGET).dll: $(OBJECTS) $(LIBGAIM_TOP)/libgaim.dll.a $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/global.mak Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,28 @@ +# +# global.mak +# +# This file should be included by all Makefile.mingw files for project +# wide definitions. +# + +CC = gcc.exe + +GCCWARNINGS := -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef + +# Use -g flag when building debug version of Gaim (including plugins). +# Use -fnative-struct instead of -mms-bitfields when using mingw 1.1 +# (gcc 2.95) +CFLAGS += -O2 -Wall $(GCCWARNINGS) -pipe -mno-cygwin -mms-bitfields -g + + +# If not specified, dlls are built with the default base address of 0x10000000. +# When loaded into a process address space a dll will be rebased if its base +# address colides with the base address of an existing dll. To avoid rebasing +# we do the following. Rebasing can slow down the load time of dlls and it +# also renders debug info useless. +DLL_LD_FLAGS += -Wl,--enable-auto-image-base + +VERSION := $(shell cat $(GAIM_TOP)/VERSION) + +DEFINES += -DVERSION=\"$(VERSION)\" \ + -DHAVE_CONFIG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/libc_interface.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,990 @@ +/* + * gaim + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include <winsock2.h> +#include <ws2tcpip.h> +#include <io.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <sys/timeb.h> +#include <sys/stat.h> +#include <time.h> +#include <glib.h> +#include "debug.h" +#include "libc_internal.h" +#if GLIB_CHECK_VERSION(2,6,0) +# include <glib/gstdio.h> +#else +#define g_remove remove +#define g_rename rename +#define g_stat stat +#endif + +static char errbuf[1024]; + +/* helpers */ +static int wgaim_is_socket( int fd ) { + int optval; + unsigned int optlen = sizeof(int); + + if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) { + int error = WSAGetLastError(); + if( error == WSAENOTSOCK ) + return FALSE; + else { + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_is_socket: getsockopt returned error: %d\n", error); + return FALSE; + } + } + return TRUE; +} + +/* socket.h */ +int wgaim_socket (int namespace, int style, int protocol) { + int ret; + + ret = socket( namespace, style, protocol ); + + if( ret == INVALID_SOCKET ) { + errno = WSAGetLastError(); + return -1; + } + return ret; +} + +int wgaim_connect(int socket, struct sockaddr *addr, u_long length) { + int ret; + + ret = connect( socket, addr, length ); + + if( ret == SOCKET_ERROR ) { + errno = WSAGetLastError(); + if( errno == WSAEWOULDBLOCK ) + errno = WSAEINPROGRESS; + return -1; + } + return 0; +} + +int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { + if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) { + if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { + if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { + if(bind(socket, addr, length) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_listen(int socket, unsigned int n) { + if(listen(socket, n) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) { + int ret; + if ((ret = sendto(socket, buf, len, flags, to, tolen) + ) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return ret; +} + +/* fcntl.h */ +/* This is not a full implementation of fcntl. Update as needed.. */ +int wgaim_fcntl(int socket, int command, int val) { + switch( command ) { + case F_SETFL: + { + int ret=0; + + switch( val ) { + case O_NONBLOCK: + { + u_long imode=1; + ret = ioctlsocket(socket, FIONBIO, &imode); + break; + } + case 0: + { + u_long imode=0; + ret = ioctlsocket(socket, FIONBIO, &imode); + break; + } + default: + errno = EINVAL; + return -1; + }/*end switch*/ + if( ret == SOCKET_ERROR ) { + errno = WSAGetLastError(); + return -1; + } + return 0; + } + default: + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_fcntl: Unsupported command\n"); + return -1; + }/*end switch*/ +} + +/* sys/ioctl.h */ +int wgaim_ioctl(int fd, int command, void* val) { + switch( command ) { + case FIONBIO: + { + if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; + } + case SIOCGIFCONF: + { + INTERFACE_INFO InterfaceList[20]; + unsigned long nBytesReturned; + if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST, + 0, 0, &InterfaceList, + sizeof(InterfaceList), &nBytesReturned, + 0, 0) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } else { + int i; + struct ifconf *ifc = val; + char *tmp = ifc->ifc_buf; + int nNumInterfaces = + nBytesReturned / sizeof(INTERFACE_INFO); + for (i = 0; i < nNumInterfaces; i++) { + INTERFACE_INFO ii = InterfaceList[i]; + struct ifreq *ifr = (struct ifreq *) tmp; + struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr; + + sa->sin_family = ii.iiAddress.AddressIn.sin_family; + sa->sin_port = ii.iiAddress.AddressIn.sin_port; + sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr; + tmp += sizeof(struct ifreq); + + /* Make sure that we can fit in the original buffer */ + if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) { + break; + } + } + /* Replace the length with the actually used length */ + ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp); + return 0; + } + } + default: + errno = EINVAL; + return -1; + }/*end switch*/ +} + +/* arpa/inet.h */ +int wgaim_inet_aton(const char *name, struct in_addr *addr) { + if((addr->s_addr = inet_addr(name)) == INADDR_NONE) + return 0; + else + return 1; +} + +/* netdb.h */ +struct hostent* wgaim_gethostbyname(const char *name) { + struct hostent *hp; + + if((hp = gethostbyname(name)) == NULL) { + errno = WSAGetLastError(); + return NULL; + } + return hp; +} + +/* string.h */ +char* wgaim_strerror( int errornum ) { + if( errornum > WSABASEERR ) { + sprintf( errbuf, "Windows socket error #%d", errornum ); + return errbuf; + } + else + return strerror( errornum ); +} + +/* unistd.h */ + +/* + * We need to figure out whether fd is a file or socket handle. + */ +int wgaim_read(int fd, void *buf, unsigned int size) { + int ret; + + if(wgaim_is_socket(fd)) { + if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) { + errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; + return -1; + } +#if 0 + else if( ret == 0 ) { + /* connection has been gracefully closed */ + errno = WSAENOTCONN; + return -1; + } +#endif + else { + /* success reading socket */ + return ret; + } + } else { + /* fd is not a socket handle.. pass it off to read */ + return read(fd, buf, size); + } +} + +int wgaim_send(int fd, const void *buf, unsigned int size, int flags) { + int ret; + + ret = send(fd, buf, size, flags); + + if (ret == SOCKET_ERROR) { + errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; + return -1; + } + return ret; +} + +int wgaim_write(int fd, const void *buf, unsigned int size) { + + if(wgaim_is_socket(fd)) + return wgaim_send(fd, buf, size, 0); + else + return write(fd, buf, size); +} + +int wgaim_recv(int fd, void *buf, size_t len, int flags) { + int ret; + + if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) { + errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; + return -1; + } else { + return ret; + } +} + +int wgaim_close(int fd) { + int ret; + + if( wgaim_is_socket(fd) ) { + if( (ret = closesocket(fd)) == SOCKET_ERROR ) { + errno = WSAGetLastError(); + return -1; + } + else + return 0; + } + else + return close(fd); +} + +int wgaim_gethostname(char *name, size_t size) { + if(gethostname(name, size) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +/* sys/time.h */ + +int wgaim_gettimeofday(struct timeval *p, struct timezone *z) { + int res = 0; + struct _timeb timebuffer; + + if (z != 0) { + _tzset(); + z->tz_minuteswest = _timezone/60; + z->tz_dsttime = _daylight; + } + + if (p != 0) { + _ftime(&timebuffer); + p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */ + p->tv_usec = timebuffer.millitm*1000; /* microseconds */ + } + + return res; +} + +/* stdio.h */ + +int wgaim_rename (const char *oldname, const char *newname) { + struct stat oldstat, newstat; + + if(g_stat(oldname, &oldstat) == 0) { + /* newname exists */ + if(g_stat(newname, &newstat) == 0) { + /* oldname is a dir */ + if(_S_ISDIR(oldstat.st_mode)) { + if(!_S_ISDIR(newstat.st_mode)) { + return g_rename(oldname, newname); + } + /* newname is a dir */ + else { + /* This is not quite right.. If newname is empty and + is not a sub dir of oldname, newname should be + deleted and oldname should be renamed. + */ + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_rename does not behave here as it should\n"); + return g_rename(oldname, newname); + } + } + /* oldname is not a dir */ + else { + /* newname is a dir */ + if(_S_ISDIR(newstat.st_mode)) { + errno = EISDIR; + return -1; + } + /* newname is not a dir */ + else { + g_remove(newname); + return g_rename(oldname, newname); + } + } + } + /* newname doesn't exist */ + else + return g_rename(oldname, newname); + } + else { + /* oldname doesn't exist */ + errno = ENOENT; + return -1; + } + +} + +/* time.h */ + +struct tm * wgaim_localtime_r (const time_t *time, struct tm *resultp) { + struct tm* tmptm; + + if(!time) + return NULL; + tmptm = localtime(time); + if(resultp && tmptm) + return memcpy(resultp, tmptm, sizeof(struct tm)); + else + return NULL; +} + +/* + * Used by gaim_utf8_strftime() by way of gaim_internal_strftime() + * in src/util.c + * + * Code derived from PostgreSQL src/timezone/pgtz.c: + * http://developer.postgresql.org/cvsweb.cgi/pgsql/src/timezone/pgtz.c + */ + +/* +PostgreSQL Database Management System +(formerly known as Postgres, then as Postgres95) + +Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + +Portions Copyright (c) 1994, The Regents of the University of California + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this +paragraph and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS +DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO +PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*/ +static struct +{ + char *wstd; /* Windows name of standard timezone */ + char *wdst; /* Windows name of daylight timezone */ + char *ustd; /* Unix name of standard timezone */ + char *udst; /* Unix name of daylight timezone */ +} win32_tzmap[] = +{ + { + "", "", + "", "", + }, + /* + * This list was built from the contents of the registry at + * "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" + * on Windows XP Professional SP1 + */ + { + "Afghanistan Standard Time", "Afghanistan Daylight Time", + "AFT", "AFT" + }, + { + "Alaskan Standard Time", "Alaskan Daylight Time", + "AKST", "AKDT" + }, + { + "Arab Standard Time", "Arab Daylight Time", + "AST", "AST" + }, + { + "Arabian Standard Time", "Arabian Daylight Time", + "GST", "GST" + }, + { + "Arabic Standard Time", "Arabic Daylight Time", + "AST", "ADT" + }, + { + "Atlantic Standard Time", "Atlantic Daylight Time", + "AST", "ADT" + }, + { + "AUS Central Standard Time", "AUS Central Daylight Time", + "CST", "CST" + }, + { + "AUS Eastern Standard Time", "AUS Eastern Daylight Time", + "EST", "EST" + }, + { + "Azores Standard Time", "Azores Daylight Time", + "AZOT", "AZOST" + }, + { + "Canada Central Standard Time", "Canada Central Daylight Time", + "CST", "MDT" + }, + { + "Cape Verde Standard Time", "Cape Verde Daylight Time", + "CVT", "CVST" + }, + { + "Caucasus Standard Time", "Caucasus Daylight Time", + "AZT", "AZST" + }, + { + "Cen. Australia Standard Time", "Cen. Australia Daylight Time", + "CST", "CST" + }, + { + "Central America Standard Time", "Central America Daylight Time", + "CST", "CDT" + }, + { + "Central Asia Standard Time", "Central Asia Daylight Time", + "BDT", "BDT" + }, + { + "Central Europe Standard Time", "Central Europe Daylight Time", + "CET", "CEST" + }, + { + "Central European Standard Time", "Central European Daylight Time", + "CET", "CEST" + }, + { + "Central Pacific Standard Time", "Central Pacific Daylight Time", + "NCT", "NCST" + }, + { + "Central Standard Time", "Central Daylight Time", + "CST", "CDT" + }, + { + "China Standard Time", "China Daylight Time", + "HKT", "HKST" + }, + { + "Dateline Standard Time", "Dateline Daylight Time", + "GMT+12", "GMT+12" + }, + { + "E. Africa Standard Time", "E. Africa Daylight Time", + "EAT", "EAT" + }, + { + "E. Australia Standard Time", "E. Australia Daylight Time", + "EST", "EST" + }, + { + "E. Europe Standard Time", "E. Europe Daylight Time", + "EET", "EEST" + }, + { + "E. South America Standard Time", "E. South America Daylight Time", + "BRT", "BRST" + }, + { + "Eastern Standard Time", "Eastern Daylight Time", + "EST", "EDT" + }, + { + "Egypt Standard Time", "Egypt Daylight Time", + "EET", "EEST" + }, + { + "Ekaterinburg Standard Time", "Ekaterinburg Daylight Time", + "YEKT", "YEKST" + }, + { + "Fiji Standard Time", "Fiji Daylight Time", + "FJT", "FJST" + }, + { + "FLE Standard Time", "FLE Daylight Time", + "EET", "EEST" + }, + { + "GMT Standard Time", "GMT Daylight Time", + "GMT", "IST" + }, + { + "Greenland Standard Time", "Greenland Daylight Time", + "WGT", "WGST" + }, + { + "Greenwich Standard Time", "Greenwich Daylight Time", + "WET", "WEST" + }, + { + "GTB Standard Time", "GTB Daylight Time", + "EET", "EEST" + }, + { + "Hawaiian Standard Time", "Hawaiian Daylight Time", + "HST", "HPT" + }, + { + "India Standard Time", "India Daylight Time", + "IST", "IST" + }, + { + "Iran Standard Time", "Iran Daylight Time", + "IRST", "IRDT" + }, + { + "Jerusalem Standard Time", "Jerusalem Daylight Time", + "IST", "IDT" + }, + { + "Korea Standard Time", "Korea Daylight Time", + "KST", "KDT" + }, + { + "Mexico Standard Time", "Mexico Daylight Time", + "CST", "CDT" + }, + { + "Mexico Standard Time", "Mexico Daylight Time", + "BOT", "BOST" + }, + { + "Mid-Atlantic Standard Time", "Mid-Atlantic Daylight Time", + "GST", "GST" + }, + { + "Mountain Standard Time", "Mountain Daylight Time", + "MST", "MDT" + }, + { + "Myanmar Standard Time", "Myanmar Daylight Time", + "MMT", "MMT" + }, + { + "N. Central Asia Standard Time", "N. Central Asia Daylight Time", + "ALMT", "ALMST" + }, + { + "Nepal Standard Time", "Nepal Daylight Time", + "NPT", "NPT" + }, + { + "New Zealand Standard Time", "New Zealand Daylight Time", + "NZST", "NZDT" + }, + { + "Newfoundland Standard Time", "Newfoundland Daylight Time", + "NST", "NDT" + }, + { + "North Asia East Standard Time", "North Asia East Daylight Time", + "IRKT", "IRKST" + }, + { + "North Asia Standard Time", "North Asia Daylight Time", + "KRAT", "KRAST" + }, + { + "Pacific SA Standard Time", "Pacific SA Daylight Time", + "CLT", "CLST" + }, + { + "Pacific Standard Time", "Pacific Daylight Time", + "PST", "PDT" + }, + { + "Romance Standard Time", "Romance Daylight Time", + "CET", "CEST" + }, + { + "Russian Standard Time", "Russian Daylight Time", + "MSK", "MSD" + }, + { + "SA Eastern Standard Time", "SA Eastern Daylight Time", + "ART", "ARST" + }, + { + "SA Pacific Standard Time", "SA Pacific Daylight Time", + "COT", "COST" + }, + { + "SA Western Standard Time", "SA Western Daylight Time", + "VET", "VET" + }, + { + "Samoa Standard Time", "Samoa Daylight Time", + "SST", "NDT" + }, + { + "SE Asia Standard Time", "SE Asia Daylight Time", + "ICT", "ICT" + }, + { + "Malay Peninsula Standard Time", "Malay Peninsula Daylight Time", + "MYT", "MALST" + }, + { + "South Africa Standard Time", "South Africa Daylight Time", + "CAT", "CAT" + }, + { + "Sri Lanka Standard Time", "Sri Lanka Daylight Time", + "LKT", "IST" + }, + { + "Taipei Standard Time", "Taipei Daylight Time", + "CST", "CDT" + }, + { + "Tasmania Standard Time", "Tasmania Daylight Time", + "EST", "EST" + }, + { + "Tokyo Standard Time", "Tokyo Daylight Time", + "JST", "JDT" + }, + { + "Tonga Standard Time", "Tonga Daylight Time", + "TOT", "TOST" + }, + { + "US Eastern Standard Time", "US Eastern Daylight Time", + "EST", "EDT" + }, + { + "US Mountain Standard Time", "US Mountain Daylight Time", + "MST", "MDT" + }, + { + "Vladivostok Standard Time", "Vladivostok Daylight Time", + "VLAT", "VLAST" + }, + { + "W. Australia Standard Time", "W. Australia Daylight Time", + "WST", "WST" + }, + + /* Not mapped in PostgreSQL. + * + * I mapped this based on the following information... -- rlaager + * $ cd /usr/share/zoneinfo/Africa + * $ for i in * ; do echo `TZ=Africa/$i date +"%z %Z"` $i ; done | grep +0100 + * +0100 CET Algiers + * +0100 WAT Bangui + * +0100 WAT Brazzaville + * +0100 CET Ceuta + * +0100 WAT Douala + * +0100 WAT Kinshasa + * +0100 WAT Lagos + * +0100 WAT Libreville + * +0100 WAT Luanda + * +0100 WAT Malabo + * +0100 WAT Ndjamena + * +0100 WAT Niamey + * +0100 WAT Porto-Novo + * +0100 CET Tunis + **/ + { + "W. Central Africa Standard Time", "W. Central Africa Daylight Time", + "WAT", "WAT" + }, + + { + "W. Europe Standard Time", "W. Europe Daylight Time", + "CET", "CEST" + }, + { + "West Asia Standard Time", "West Asia Daylight Time", + "PKT", "PKST" + }, + { + "West Pacific Standard Time", "West Pacific Daylight Time", + "ChST", "ChST" + }, + { + "Yakutsk Standard Time", "Yakutsk Daylight Time", + "YAKT", "YAKST" + }, + { + NULL, NULL, + NULL, NULL + } +}; + +const char * +wgaim_get_timezone_abbreviation(const struct tm *tm) +{ + int i; + char tzname[128]; + char localtzname[256]; + HKEY rootKey; + int idx; + + if (!tm) + { + gaim_debug_warning("wgaim", "could not determine current date/time: localtime failed\n"); + return ""; + } + + if (strftime(tzname, sizeof(tzname) - 1, "%Z", tm) == 0) + { + gaim_debug_error("wgaim", "timezone name is too long for the buffer\n"); + return ""; + } + + for (i = 0; win32_tzmap[i].wstd != NULL; i++) + { + if (strcmp(tzname, win32_tzmap[i].wstd) == 0) + { +#if 0 + gaim_debug_info("wgaim", "TZ \"%s\" matches Windows timezone \"%s\"\n", + win32_tzmap[i].ustd, tzname); +#endif + /* Cache the Result */ + if (i > 0) { + if (win32_tzmap[0].wstd[0] != '\0') + g_free(win32_tzmap[0].wstd); + win32_tzmap[0].wstd = g_strdup(tzname); + win32_tzmap[0].ustd = win32_tzmap[i].ustd; + } + + return win32_tzmap[i].ustd; + } + if (strcmp(tzname, win32_tzmap[i].wdst) == 0) + { +#if 0 + gaim_debug_info("wgaim", "TZ \"%s\" matches Windows timezone \"%s\"\n", + win32_tzmap[i].udst, tzname); +#endif + /* Cache the Result */ + if (i > 0) { + if (win32_tzmap[0].wdst[0] != '\0') + g_free(win32_tzmap[0].wdst); + win32_tzmap[0].wdst = g_strdup(tzname); + win32_tzmap[0].udst = win32_tzmap[i].udst; + } + + return win32_tzmap[i].udst; + } + } + + /* + * Localized Windows versions return localized names for the timezone. + * Scan the registry to find the English name, and then try matching + * against our table again. + */ + memset(localtzname, 0, sizeof(localtzname)); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + 0, + KEY_READ, + &rootKey) != ERROR_SUCCESS) + { + gaim_debug_warning("wgaim", "could not open registry key to identify Windows timezone: %i\n", (int) GetLastError()); + return ""; + } + + for (idx = 0;; idx++) + { + char keyname[256]; + char zonename[256]; + DWORD namesize; + FILETIME lastwrite; + HKEY key; + LONG r; + + memset(keyname, 0, sizeof(keyname)); + namesize = sizeof(keyname); + if ((r = RegEnumKeyEx(rootKey, + idx, + keyname, + &namesize, + NULL, + NULL, + NULL, + &lastwrite)) != ERROR_SUCCESS) + { + if (r == ERROR_NO_MORE_ITEMS) + break; + gaim_debug_warning("wgaim", "could not enumerate registry subkeys to identify Windows timezone: %i\n", (int) r); + break; + } + + if ((r = RegOpenKeyEx(rootKey, keyname, 0, KEY_READ, &key)) != ERROR_SUCCESS) + { + gaim_debug_warning("wgaim", "could not open registry subkey to identify Windows timezone: %i\n", (int) r); + break; + } + + memset(zonename, 0, sizeof(zonename)); + namesize = sizeof(zonename); + if ((r = RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + { + gaim_debug_warning("wgaim", "could not query value for 'std' to identify Windows timezone: %i\n", (int) r); + RegCloseKey(key); + break; + } + if (strcmp(tzname, zonename) == 0) + { + /* Matched zone */ + strcpy(localtzname, keyname); + RegCloseKey(key); + break; + } + memset(zonename, 0, sizeof(zonename)); + namesize = sizeof(zonename); + if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + { + gaim_debug_warning("wgaim", "could not query value for 'dlt' to identify Windows timezone: %i\n", (int) r); + RegCloseKey(key); + break; + } + if (strcmp(tzname, zonename) == 0) + { + /* Matched DST zone */ + strcpy(localtzname, keyname); + RegCloseKey(key); + break; + } + + RegCloseKey(key); + } + + RegCloseKey(rootKey); + + if (localtzname[0]) + { + /* Found a localized name, so scan for that one too */ + for (i = 0; win32_tzmap[i].wstd != NULL; i++) + { + if (strcmp(localtzname, win32_tzmap[i].wstd) == 0) + { +#if 0 + gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")\n", + win32_tzmap[i].ustd, tzname, localtzname); +#endif + /* Cache the Result */ + if (win32_tzmap[0].wstd[0] != '\0') + g_free(win32_tzmap[0].wstd); + win32_tzmap[0].wstd = g_strdup(tzname); + win32_tzmap[0].ustd = win32_tzmap[i].ustd; + + return win32_tzmap[i].ustd; + } + if (strcmp(localtzname, win32_tzmap[i].wdst) == 0) + { +#if 0 + gaim_debug_info("wgaim", "TZ \"%s\" matches localized Windows timezone \"%s\" (\"%s\")\n", + win32_tzmap[i].udst, tzname, localtzname); +#endif + /* Cache the Result */ + if (win32_tzmap[0].wdst[0] != '\0') + g_free(win32_tzmap[0].wdst); + + win32_tzmap[0].wdst = g_strdup(tzname); + win32_tzmap[0].udst = win32_tzmap[i].udst; + + return win32_tzmap[i].udst; + } + } + } + + gaim_debug_warning("wgaim", "could not find a match for Windows timezone \"%s\"\n", tzname); + return ""; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/libc_interface.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,169 @@ +/* + * gaim + * + * File: libc_interface.h + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _LIBC_INTERFACE_H_ +#define _LIBC_INTERFACE_H_ +#include <winsock2.h> +#include <ws2tcpip.h> +#include <io.h> +#include <errno.h> +#include "libc_internal.h" +#include <glib.h> + +/* sys/socket.h */ +int wgaim_socket(int namespace, int style, int protocol); +#define socket( namespace, style, protocol ) \ +wgaim_socket( namespace, style, protocol ) + +int wgaim_connect(int socket, struct sockaddr *addr, u_long length); +#define connect( socket, addr, length ) \ +wgaim_connect( socket, addr, length ) + +int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr); +#define getsockopt( args... ) \ +wgaim_getsockopt( args ) + +int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen); +#define setsockopt( args... ) \ +wgaim_setsockopt( args ) + +int wgaim_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr); +#define getsockname( socket, addr, lenptr ) \ +wgaim_getsockname( socket, addr, lenptr ) + +int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length); +#define bind( socket, addr, length ) \ +wgaim_bind( socket, addr, length ) + +int wgaim_listen(int socket, unsigned int n); +#define listen( socket, n ) \ +wgaim_listen( socket, n ) + +int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); +#define sendto(socket, buf, len, flags, to, tolen) \ +wgaim_sendto(socket, buf, len, flags, to, tolen) + +/* sys/ioctl.h */ +int wgaim_ioctl(int fd, int command, void* opt); +#define ioctl( fd, command, val ) \ +wgaim_ioctl( fd, command, val ) + +/* fcntl.h */ +int wgaim_fcntl(int socket, int command, int val); +#define fcntl( fd, command, val ) \ +wgaim_fcntl( fd, command, val ) + +#if !GLIB_CHECK_VERSION(2,6,0) +# define open( args... ) _open( args ) +#endif + +/* arpa/inet.h */ +int wgaim_inet_aton(const char *name, struct in_addr *addr); +#define inet_aton( name, addr ) \ +wgaim_inet_aton( name, addr ) + +/* netdb.h */ +struct hostent* wgaim_gethostbyname(const char *name); +#define gethostbyname( name ) \ +wgaim_gethostbyname( name ) + +/* netinet/in.h */ +#define ntohl( netlong ) \ +(unsigned int)ntohl( netlong ) + +/* string.h */ +char* wgaim_strerror( int errornum ); +#define hstrerror( herror ) \ +wgaim_strerror( errno ) +#define strerror( errornum ) \ +wgaim_strerror( errornum ) + +#define bzero( dest, size ) memset( dest, 0, size ) + +/* unistd.h */ +int wgaim_read(int fd, void *buf, unsigned int size); +#define read( fd, buf, buflen ) \ +wgaim_read( fd, buf, buflen ) + +int wgaim_write(int fd, const void *buf, unsigned int size); +#define write( socket, buf, buflen ) \ +wgaim_write( socket, buf, buflen ) + +int wgaim_recv(int fd, void *buf, size_t len, int flags); +#define recv(fd, buf, len, flags) \ +wgaim_recv(fd, buf, len, flags) + +int wgaim_send(int fd, const void *buf, unsigned int size, int flags); +#define send(socket, buf, buflen, flags) \ +wgaim_send(socket, buf, buflen, flags) + +int wgaim_close(int fd); +#define close( fd ) \ +wgaim_close( fd ) + +#ifndef sleep +#define sleep(x) Sleep((x)*1000) +#endif + +int wgaim_gethostname(char *name, size_t size); +#define gethostname( name, size ) \ +wgaim_gethostname( name, size ) + +/* sys/time.h */ +int wgaim_gettimeofday(struct timeval *p, struct timezone *z); +#define gettimeofday( timeval, timezone ) \ +wgaim_gettimeofday( timeval, timezone ) + +/* stdio.h */ +#define snprintf _snprintf +#define vsnprintf _vsnprintf + +int wgaim_rename(const char *oldname, const char *newname); +#define rename( oldname, newname ) \ +wgaim_rename( oldname, newname ) + +#if GLIB_CHECK_VERSION(2,6,0) +#ifdef g_rename +# undef g_rename +#endif +/* This is necessary because we want rename on win32 to be able to overwrite an existing file, it is done in internal.h if GLib < 2.6*/ +#define g_rename(oldname, newname) \ +wgaim_rename(oldname, newname) +#endif + + +/* sys/stat.h */ + +#if !GLIB_CHECK_VERSION(2,6,0) +#define mkdir(a,b) _mkdir((a)) +#endif +#define fchmod(a,b) + +/* time.h */ +struct tm *wgaim_localtime_r(const time_t *time, struct tm *resultp); +#define localtime_r( time, resultp ) \ +wgaim_localtime_r( time, resultp ) + +/* helper for gaim_utf8_strftime() by way of gaim_internal_strftime() in src/util.c */ +const char *wgaim_get_timezone_abbreviation(const struct tm *tm); + +#endif /* _LIBC_INTERFACE_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/libc_internal.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,94 @@ +/* + * gaim + * + * File: libc_internal.h + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _LIBC_INTERNAL_ +#define _LIBC_INTERNAL_ + +/* fcntl.h */ +#define F_SETFL 1 +#define O_NONBLOCK 1 + +/* ioctl.h */ +#define SIOCGIFCONF 0x8912 /* get iface list */ + +/* net/if.h */ +struct ifreq +{ + union + { + char ifrn_name[6]; /* Interface name, e.g. "en0". */ + } ifr_ifrn; + + union + { + struct sockaddr ifru_addr; +#if 0 + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short int ifru_flags; + int ifru_ivalue; + int ifru_mtu; +#endif + char *ifru_data; + } ifr_ifru; +}; +# define ifr_name ifr_ifrn.ifrn_name /* interface name */ +# define ifr_addr ifr_ifru.ifru_addr /* address */ +#if 0 +# define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +# define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ +# define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +# define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +# define ifr_flags ifr_ifru.ifru_flags /* flags */ +# define ifr_metric ifr_ifru.ifru_ivalue /* metric */ +# define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#endif +# define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#if 0 +# define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ +# define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ +# define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ +#endif + + +struct ifconf +{ + int ifc_len; /* Size of buffer. */ + union + { + char *ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; +# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */ +# define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */ + +/* sys/time.h */ +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; + + +#endif /* _LIBC_INTERNAL_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/wgaimerror.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,58 @@ +/* + * gaim + * + * File: wgaimerror.h + * Date: October 14, 2002 + * Description: Convert Winsock errors to Unix errors + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _WGAIMERROR_H +#define _WGAIMERROR_H + +/* Here we define unix socket errors as windows socket errors */ + +#define ENETDOWN WSAENETDOWN +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EINPROGRESS WSAEINPROGRESS +#define ENOBUFS WSAENOBUFS +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define EPROTOTYPE WSAEPROTOTYPE +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT + +#define EADDRINUSE WSAEADDRINUSE +#define EINPROGRESS WSAEINPROGRESS +#define EALREADY WSAEALREADY +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#define ECONNREFUSED WSAECONNREFUSED +#define EISCONN WSAEISCONN +#define ENETUNREACH WSAENETUNREACH +#define ENOTSOCK WSAENOTSOCK +#define ETIMEDOUT WSAETIMEDOUT +#define EWOULDBLOCK WSAEWOULDBLOCK + +#define ENOTCONN WSAENOTCONN +#define ENETRESET WSAENETRESET +#define EOPNOTSUPP WSAEOPNOTSUPP +#define ESHUTDOWN WSAESHUTDOWN +#define EMSGSIZE WSAEMSGSIZE +#define ECONNABORTED WSAECONNABORTED +#define ECONNRESET WSAECONNRESET +#define EHOSTUNREACH WSAEHOSTUNREACH + +#endif /* end _WGAIMERROR_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/win32dep.c Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,352 @@ +/* + * gaim + * + * File: win32dep.c + * Date: June, 2002 + * Description: Windows dependant code for Gaim + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#define _WIN32_IE 0x500 +#include <windows.h> +#include <io.h> +#include <stdlib.h> +#include <stdio.h> +#include <winuser.h> + +#include <glib.h> +#include <glib/gstdio.h> + +#include "gaim.h" +#include "debug.h" +#include "notify.h" + +#include <libintl.h> + +#include "win32dep.h" + +/* + * DEFINES & MACROS + */ +#define _(x) gettext(x) + +/* + * DATA STRUCTS + */ + +/* For shfolder.dll */ +typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); +typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); + +/* + * LOCALS + */ +static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; + +/* + * GLOBALS + */ +HINSTANCE libgaimdll_hInstance = 0; + +/* + * PROTOS + */ + +FARPROC wgaim_find_and_loadproc(char*, char*); +char* wgaim_data_dir(void); + +/* + * STATIC CODE + */ + +static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) { + char *str = NULL; + if (args != NULL) { + str = g_strdup_vprintf(format, args); + } else { + str = g_strdup(format); + } + printf("%s%s%s", category ? category : "", category ? ": " : "", str); + g_free(str); +} + +static GaimDebugUiOps ops = { + wgaim_debug_print +}; + +/* + * PUBLIC CODE + */ + +/* Escape windows dir separators. This is needed when paths are saved, + and on being read back have their '\' chars used as an escape char. + Returns an allocated string which needs to be freed. +*/ +char* wgaim_escape_dirsep(char* filename) { + int sepcount = 0; + char* ret = NULL; + int cnt = 0; + + ret = filename; + while(*ret) { + if(*ret == '\\') + sepcount++; + ret++; + } + ret = g_malloc0(strlen(filename) + sepcount + 1); + while(*filename) { + ret[cnt] = *filename; + if(*filename == '\\') + ret[++cnt] = '\\'; + filename++; + cnt++; + } + ret[cnt] = '\0'; + return ret; +} + +/* Determine whether the specified dll contains the specified procedure. + If so, load it (if not already loaded). */ +FARPROC wgaim_find_and_loadproc(char* dllname, char* procedure) { + HMODULE hmod; + BOOL did_load = FALSE; + FARPROC proc = 0; + + if(!(hmod = GetModuleHandle(dllname))) { + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not already loaded; loading it...\n", dllname); + if(!(hmod = LoadLibrary(dllname))) { + gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); + return NULL; + } + else + did_load = TRUE; + } + + if((proc = GetProcAddress(hmod, procedure))) { + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", + dllname, procedure); + return proc; + } + else { + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", + procedure, dllname); + if(did_load) { + /* unload dll */ + FreeLibrary(hmod); + } + return NULL; + } +} + +/* Determine Gaim Paths during Runtime */ + +/* Get paths to special Windows folders. */ +char *wgaim_get_special_folder(int folder_type) { + static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; + static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; + char *retval = NULL; + + if (!MySHGetFolderPathW) { + MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) + wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); + } + + if (MySHGetFolderPathW) { + wchar_t utf_16_dir[MAX_PATH + 1]; + + if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL, + SHGFP_TYPE_CURRENT, utf_16_dir))) { + retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); + } + } + + if (!retval) { + if (!MySHGetFolderPathA) { + MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) + wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); + } + if (MySHGetFolderPathA) { + char locale_dir[MAX_PATH + 1]; + + if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, + SHGFP_TYPE_CURRENT, locale_dir))) { + retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); + } + } + } + + return retval; +} + +char* wgaim_install_dir(void) { + static gboolean initialized = FALSE; + + if (!initialized) { + char *tmp = NULL; + if (G_WIN32_HAVE_WIDECHAR_API()) { + wchar_t winstall_dir[MAXPATHLEN]; + if (GetModuleFileNameW(NULL, winstall_dir, + MAXPATHLEN) > 0) { + tmp = g_utf16_to_utf8(winstall_dir, -1, + NULL, NULL, NULL); + } + } else { + gchar cpinstall_dir[MAXPATHLEN]; + if (GetModuleFileNameA(NULL, cpinstall_dir, + MAXPATHLEN) > 0) { + tmp = g_locale_to_utf8(cpinstall_dir, + -1, NULL, NULL, NULL); + } + } + + if (tmp == NULL) { + tmp = g_win32_error_message(GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim", + "GetModuleFileName error: %s\n", tmp); + g_free(tmp); + return NULL; + } else { + install_dir = g_path_get_dirname(tmp); + g_free(tmp); + initialized = TRUE; + } + } + + return install_dir; +} + +char* wgaim_lib_dir(void) { + static gboolean initialized = FALSE; + + if (!initialized) { + char *inst_dir = wgaim_install_dir(); + if (inst_dir != NULL) { + lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); + initialized = TRUE; + } else { + return NULL; + } + } + + return lib_dir; +} + +char* wgaim_locale_dir(void) { + static gboolean initialized = FALSE; + + if (!initialized) { + char *inst_dir = wgaim_install_dir(); + if (inst_dir != NULL) { + locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); + initialized = TRUE; + } else { + return NULL; + } + } + + return locale_dir; +} + +char* wgaim_data_dir(void) { + return app_data_dir; +} + +/* Miscellaneous */ + +gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { + HKEY hkey; + gboolean ret = FALSE; + + if(ERROR_SUCCESS == RegOpenKeyEx(key, sub_key, 0, KEY_QUERY_VALUE, + &hkey)) { + if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, + data, data_len)) + ret = TRUE; + RegCloseKey(key); + } + return ret; +} + +void wgaim_init(void) { + WORD wVersionRequested; + WSADATA wsaData; + const char *perlenv; + char *newenv; + + gaim_debug_set_ui_ops(&ops); + gaim_debug_info("wgaim", "wgaim_init start\n"); + + gaim_debug_info("wgaim", "Glib:%u.%u.%u\n", + glib_major_version, glib_minor_version, glib_micro_version); + + /* Winsock init */ + wVersionRequested = MAKEWORD(2, 2); + WSAStartup(wVersionRequested, &wsaData); + + /* Confirm that the winsock DLL supports 2.2 */ + /* Note that if the DLL supports versions greater than + 2.2 in addition to 2.2, it will still return 2.2 in + wVersion since that is the version we requested. */ + if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); + WSACleanup(); + } + + /* Set Environmental Variables */ + /* Tell perl where to find Gaim's perl modules */ + perlenv = g_getenv("PERL5LIB"); + newenv = g_strdup_printf("PERL5LIB=%s%s%s" G_DIR_SEPARATOR_S "perlmod;", + perlenv ? perlenv : "", + perlenv ? ";" : "", + wgaim_install_dir()); + if (putenv(newenv) < 0) + gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); + g_free(newenv); + + /* Set app data dir, used by gaim_home_dir */ + newenv = (char*) g_getenv("GAIMHOME"); + if (newenv) { + app_data_dir = g_strdup(newenv); + } else { + app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); + if (!app_data_dir) { + app_data_dir = g_strdup("C:"); + } + } + + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); + + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); +} + +/* Windows Cleanup */ + +void wgaim_cleanup(void) { + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n"); + + /* winsock cleanup */ + WSACleanup(); + + g_free(app_data_dir); +} + +/* DLL initializer */ +BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { + libgaimdll_hInstance = hinstDLL; + return TRUE; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgaim/win32/win32dep.h Sun Aug 20 16:49:37 2006 +0000 @@ -0,0 +1,67 @@ +/* + * gaim + * + * File: win32dep.h + * + * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef _WIN32DEP_H_ +#define _WIN32DEP_H_ +#include <shlobj.h> +#include <winsock2.h> +#include <process.h> +#include "wgaimerror.h" +#include "libc_interface.h" + +/* + * PROTOS + */ + +/** + ** win32dep.c + **/ +/* Windows helper functions */ +FARPROC wgaim_find_and_loadproc(char*, char*); +gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len); +char* wgaim_escape_dirsep(char*); + +/* Determine Gaim paths */ +char* wgaim_get_special_folder(int folder_type); /* needs to be g_free'd */ +char* wgaim_install_dir(void); +char* wgaim_lib_dir(void); +char* wgaim_locale_dir(void); +char* wgaim_data_dir(void); + +/* init / cleanup */ +void wgaim_init(void); +void wgaim_cleanup(void); + + +/* + * MACROS + */ + +/* + * Gaim specific + */ +#define DATADIR wgaim_install_dir() +#define LIBDIR wgaim_lib_dir() +#define LOCALEDIR wgaim_locale_dir() + +#endif /* _WIN32DEP_H_ */ +