/*  This file is part of kzmws
    Copyright (C) 2009 mimas <mimasgpc@free.fr>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; version 2
    of the License.
 
    This library 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
    Library General Public License for more details.
 
    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/ 

#define WIN32_LEAN_AND_MEAN  /* speed up */
#include <windows.h>
#include <zmwslib.h>

#include "k-plugin.h"

long DoMessage(const char *to, const char *from, const char *subject, long data1, long data2);
kmeleonPlugin *GetKmeleonPlugin(void);

kmeleonPlugin kPlugin = {
   KMEL_PLUGIN_VER,
   "ZazouMiniwebServer plugin",
   DoMessage
};


BOOL APIENTRY DllMain (
	HANDLE hModule,
	DWORD ul_reason_for_call,
	LPVOID lpReserved) 
{ 
	return TRUE;
}

long DoMessage(
	const char *to, 
	const char *from, 
	const char *subject, 
	long data1, 
	long data2)
{
	if (to[0] == '*' || stricmp(to, kPlugin.dllname) == 0) {
 		if (stricmp(subject, "Init") == 0) {
			MessageBox(NULL, "Webserver is starting",  "Zwms", 0);
			zmws_easy_start ();
      		}
		else if (stricmp(subject, "Quit") == 0) {
			MessageBox(NULL, "Webserver is ending",  "Zwms", 0);
			zmws_stop ();
		}
		else return 0;

		return 1;
	}
	return 0;
}

KMELEON_PLUGIN kmeleonPlugin *GetKmeleonPlugin(void) {
	  return &kPlugin;
}

KMELEON_PLUGIN int DrawBitmap(DRAWITEMSTRUCT *dis) {
	  return 14; // 14 = icon width
}

