summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internet_time/InternetTime.cpp90
-rw-r--r--internet_time/InternetTime.dsp144
-rw-r--r--internet_time/InternetTime.dsw29
-rw-r--r--internet_time/InternetTime.h40
-rw-r--r--internet_time/InternetTime.plg97
-rw-r--r--internet_time/StdAfx.cpp8
-rw-r--r--internet_time/StdAfx.h26
-rw-r--r--internet_time/plugwin.cpp600
-rw-r--r--internet_time/plugwin.h77
-rw-r--r--internet_time/time_convert.cpp204
-rw-r--r--internet_time/time_convert.h30
-rw-r--r--internet_time/timezone.cpp92
-rw-r--r--internet_time/timezone.h47
13 files changed, 1484 insertions, 0 deletions
diff --git a/internet_time/InternetTime.cpp b/internet_time/InternetTime.cpp
new file mode 100644
index 0000000..4d8a558
--- /dev/null
+++ b/internet_time/InternetTime.cpp
@@ -0,0 +1,90 @@
+#include "stdafx.h"
+#include "InternetTime.h"
+
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+
+PLUGININFO pluginInfo={
+ sizeof(PLUGININFO),
+ "Internet Time",
+ PLUGIN_MAKE_VERSION(0, 0, 0, 9),
+ "Display Swatch Internet Time.",
+ "Scott Ellis",
+ "mail@scottellis.com.au",
+ "© 2004 Scott Ellis",
+ "http://scottellis.com.au/",
+ 0, //not transient
+ 0 //doesn't replace anything built-in
+};
+
+int winver = 0;
+
+#define VER_9X 1
+#define VER_NT40 2
+#define VER_2KXP 3
+
+void detect_win_version() {
+ OSVERSIONINFO version;
+
+ version.dwOSVersionInfoSize = sizeof(version);
+ GetVersionEx(&version);
+
+ winver = (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) ? VER_9X
+ : (version.dwMajorVersion == 4) ? VER_NT40 : VER_2KXP;
+}
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+extern "C" INTERNETTIME_API PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+void CreatePluginServices() {
+}
+
+static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+
+ HWND contact_list_hwnd = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
+ addmypluginwindow1(contact_list_hwnd);
+
+ return 0;
+}
+
+extern "C" INTERNETTIME_API int Load(PLUGINLINK *link)
+{
+ pluginLink=link;
+
+/*
+ detect_win_version();
+ if(winver < 2) {
+ MessageBox(0, "Sorry, this plugin does not work on Win9x (yet).\nPlugin disabled.", "World Time", MB_ICONERROR | MB_OK);
+ return 0;
+ }
+*/
+ if(build_timezone_list()) {
+ DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
+
+
+ CreatePluginServices();
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ } else {
+ MessageBox(0, "Unable to read timezone information.\nPlugin disabled.", "World Time", MB_ICONERROR | MB_OK);
+ }
+
+ return 0;
+}
+
+extern "C" INTERNETTIME_API int Unload(void)
+{
+ CloseHandle( mainThread );
+ plugwin_cleanup();
+ return 0;
+}
+
diff --git a/internet_time/InternetTime.dsp b/internet_time/InternetTime.dsp
new file mode 100644
index 0000000..1e204b4
--- /dev/null
+++ b/internet_time/InternetTime.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="InternetTime" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=InternetTime - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "InternetTime.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "InternetTime.mak" CFG="InternetTime - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "InternetTime - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "InternetTime - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "InternetTime - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0xc09 /d "NDEBUG"
+# ADD RSC /l 0xc09 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 user32.lib gdi32.lib shell32.lib advapi32.lib /nologo /base:"0x220a0000" /dll /machine:I386 /out:"../../bin/release/plugins/InternetTime.dll"
+
+!ELSEIF "$(CFG)" == "InternetTime - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0xc09 /d "_DEBUG"
+# ADD RSC /l 0xc09 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 user32.lib gdi32.lib shell32.lib advapi32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/debug/plugins/InternetTime.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "InternetTime - Win32 Release"
+# Name "InternetTime - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\InternetTime.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\plugwin.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\time_convert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\timezone.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\InternetTime.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\plugwin.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\time_convert.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\timezone.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/internet_time/InternetTime.dsw b/internet_time/InternetTime.dsw
new file mode 100644
index 0000000..ee0b744
--- /dev/null
+++ b/internet_time/InternetTime.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "InternetTime"=".\InternetTime.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/internet_time/InternetTime.h b/internet_time/InternetTime.h
new file mode 100644
index 0000000..052938e
--- /dev/null
+++ b/internet_time/InternetTime.h
@@ -0,0 +1,40 @@
+// © 2004 Scott Ellis
+#ifndef _WORLD_TIME_H
+#define _WORLD_TIME_H
+
+// The following ifdef block is the standard way of creating macros which make exporting
+// from a DLL simpler. All files within this DLL are compiled with the PINGPLUG_VC6_EXPORTS
+// symbol defined on the command line. this symbol should not be defined on any project
+// that uses this DLL. This way any other project whose source files include this file see
+// PINGPLUG_VC6_API functions as being imported from a DLL, wheras this DLL sees symbols
+// defined with this macro as being exported.
+#ifdef INTERNETTIME_EXPORTS
+#define INTERNETTIME_API __declspec(dllexport)
+#else
+#define INTERNETTIME_API __declspec(dllimport)
+#endif
+
+//#include "icmp.h"
+#include "plugwin.h"
+#include "timezone.h"
+
+//#include "../../include/newpluginapi.h"
+#include "../../include/m_clui.h"
+#include "../../include/m_system.h"
+#include "../../include/m_options.h"
+
+//#include "../../include/m_clist.h"
+//#include "../../include/m_skin.h"
+//#include "../../include/m_cluiframes.h"
+//#include "../../include/m_netlib.h"
+
+
+extern HINSTANCE hInst;
+extern PLUGINLINK *pluginLink;
+extern PLUGININFO pluginInfo;
+
+extern "C" INTERNETTIME_API PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion);
+extern "C" INTERNETTIME_API int Load(PLUGINLINK *link);
+extern "C" INTERNETTIME_API int Unload(void);
+
+#endif \ No newline at end of file
diff --git a/internet_time/InternetTime.plg b/internet_time/InternetTime.plg
new file mode 100644
index 0000000..acb71d9
--- /dev/null
+++ b/internet_time/InternetTime.plg
@@ -0,0 +1,97 @@
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: InternetTime - Win32 Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP34.tmp" with contents
+[
+/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Fp"Release/InternetTime.pch" /Yu"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\InternetTime.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\plugwin.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\time_convert.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\timezone.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP34.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP35.tmp" with contents
+[
+/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Fp"Release/InternetTime.pch" /Yc"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\StdAfx.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP35.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP36.tmp" with contents
+[
+user32.lib gdi32.lib shell32.lib advapi32.lib /nologo /dll /incremental:no /pdb:"Release/InternetTime.pdb" /machine:I386 /out:"../../bin/release/plugins/InternetTime.dll" /implib:"Release/InternetTime.lib"
+".\Release\InternetTime.obj"
+".\Release\plugwin.obj"
+".\Release\StdAfx.obj"
+".\Release\time_convert.obj"
+".\Release\timezone.obj"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP36.tmp"
+<h3>Output Window</h3>
+Compiling...
+StdAfx.cpp
+Compiling...
+InternetTime.cpp
+plugwin.cpp
+time_convert.cpp
+timezone.cpp
+Generating Code...
+Linking...
+ Creating library Release/InternetTime.lib and object Release/InternetTime.exp
+
+
+
+<h3>Results</h3>
+InternetTime.dll - 0 error(s), 0 warning(s)
+<h3>
+--------------------Configuration: InternetTime - Win32 Debug--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3A.tmp" with contents
+[
+/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Fp"Debug/InternetTime.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\InternetTime.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\plugwin.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\time_convert.cpp"
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\timezone.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3A.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3B.tmp" with contents
+[
+/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERNETTIME_EXPORTS" /D "_WINDLL" /D "_AFXDLL" /Fp"Debug/InternetTime.pch" /Yc"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\InternetTime\StdAfx.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3B.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3C.tmp" with contents
+[
+user32.lib gdi32.lib shell32.lib advapi32.lib /nologo /dll /incremental:yes /pdb:"Debug/InternetTime.pdb" /debug /machine:I386 /out:"../../bin/debug/plugins/InternetTime.dll" /implib:"Debug/InternetTime.lib" /pdbtype:sept
+".\Debug\InternetTime.obj"
+".\Debug\plugwin.obj"
+".\Debug\StdAfx.obj"
+".\Debug\time_convert.obj"
+".\Debug\timezone.obj"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSP3C.tmp"
+<h3>Output Window</h3>
+Compiling...
+StdAfx.cpp
+Compiling...
+InternetTime.cpp
+plugwin.cpp
+time_convert.cpp
+timezone.cpp
+Generating Code...
+Linking...
+ Creating library Debug/InternetTime.lib and object Debug/InternetTime.exp
+
+
+
+<h3>Results</h3>
+InternetTime.dll - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
diff --git a/internet_time/StdAfx.cpp b/internet_time/StdAfx.cpp
new file mode 100644
index 0000000..8248baf
--- /dev/null
+++ b/internet_time/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// WorldTime.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/internet_time/StdAfx.h b/internet_time/StdAfx.h
new file mode 100644
index 0000000..17ee329
--- /dev/null
+++ b/internet_time/StdAfx.h
@@ -0,0 +1,26 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__C0DB2B52_6239_4F4B_85C1_830836CC6209__INCLUDED_)
+#define AFX_STDAFX_H__C0DB2B52_6239_4F4B_85C1_830836CC6209__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+// Insert your headers here
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define _WIN32_WINNT 0x0500
+
+#include <windows.h>
+#include <winuser.h>
+#include <prsht.h>
+#include <shellapi.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__C0DB2B52_6239_4F4B_85C1_830836CC6209__INCLUDED_)
diff --git a/internet_time/plugwin.cpp b/internet_time/plugwin.cpp
new file mode 100644
index 0000000..6cea026
--- /dev/null
+++ b/internet_time/plugwin.cpp
@@ -0,0 +1,600 @@
+#include "stdafx.h"
+#include "plugwin.h"
+
+extern HINSTANCE hInst;
+HFONT TitleBarFont;
+
+HANDLE mainThread;
+
+HBRUSH tbrush = 0;
+
+HANDLE mainMenuItem, hIconsChangedEvent, hDBChange;
+
+HANDLE upIcon = 0, downIcon = 0;
+
+ITEMLIST listbox_items, temp_listbox_items;
+
+TCHAR format_string[512], date_format_string[512];
+
+int Frameid=-1;
+HWND label;
+
+HWND pluginwind = 0, hwnd_clist = 0;
+
+bool hook_window_behaviour_to_clist = true;
+
+static HMODULE hUserDll;
+BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
+BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags);
+
+#define TM_AUTOALPHA 1
+static int transparentFocus=1;
+
+REG_TZI ce_reg_tzi;
+
+static int CLUILoadTitleBarFont()
+{
+ char facename[]="MS Shell Dlg";
+ HFONT hfont;
+ LOGFONT logfont;
+ memset(&logfont,0,sizeof(logfont));
+ memcpy(logfont.lfFaceName,facename,sizeof(facename));
+ logfont.lfWeight=FW_NORMAL;
+ logfont.lfHeight=-10;
+ hfont=CreateFontIndirect(&logfont);
+ return((int)hfont);
+}
+
+void set_minmax(bool mm) {
+ hook_window_behaviour_to_clist = mm;
+ if(hook_window_behaviour_to_clist) {
+ BYTE state = DBGetContactSettingByte(NULL, "CList", "Setting", SETTING_STATE_NORMAL);
+
+ if(pluginwind) {
+ if(state == SETTING_STATE_NORMAL)
+ ShowWindow(pluginwind, SW_SHOW);
+ else
+ ShowWindow(pluginwind, SW_HIDE);
+ }
+ }
+}
+
+void CALLBACK plug1TimerProc2(
+ HWND hwnd, // handle to window
+ UINT uMsg, // WM_TIMER message
+ UINT idEvent, // timer identifier
+ DWORD dwTime // current system time
+)
+{
+ if(pluginwind) {
+ InvalidateRect(pluginwind, 0, FALSE);
+ //ValidateRect(pluginwind, 0);
+ }
+}
+
+void CALLBACK plug1TimerProc3(
+ HWND hwnd, // handle to window
+ UINT uMsg, // WM_TIMER message
+ UINT idEvent, // timer identifier
+ DWORD dwTime // current system time
+)
+{
+ if(pluginwind && hwnd_clist && hook_window_behaviour_to_clist) {
+ if(IsWindowVisible(pluginwind) != IsWindowVisible(hwnd_clist))
+ ShowWindow(pluginwind, IsWindowVisible(hwnd_clist) ? SW_SHOW : SW_HIDE);
+ }
+}
+
+LRESULT CALLBACK mypluginwindow1proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ RECT rect;
+ MEASUREITEMSTRUCT *mis;
+ LPDRAWITEMSTRUCT dis;
+ SIZE textSize;
+ RECT r;
+
+ switch(msg)
+ {
+
+ case WM_MEASUREITEM:
+ mis = (MEASUREITEMSTRUCT *)lParam;
+ mis->itemWidth = 100;
+ mis->itemHeight = 20;
+ return 0;
+ break;
+
+ case WM_DRAWITEM:
+ dis = (LPDRAWITEMSTRUCT)lParam;
+ //pItemData = (LISTITEM *)dis->itemData;
+ if(dis->hwndItem == label) {
+ if(dis->itemID != -1) {
+ COLORREF tcol;
+ HBRUSH ttbrush = 0;
+
+ if(dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS) {
+ tcol = DBGetContactSettingDword(NULL,"CLC","SelBkColour", CLCDEFAULT_SELBKCOLOUR);
+ SetBkColor(dis->hDC, tcol);
+
+ FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
+
+ //SendMessage(label, LB_GETITEMRECT, (WPARAM)dis->itemID, (LPARAM)&r);
+ //FillRect(dis->hDC, &r, (ttbrush = CreateSolidBrush(tcol)));
+
+ tcol = DBGetContactSettingDword(NULL,"CLC","SelTextColour", CLCDEFAULT_SELTEXTCOLOUR);
+ SetTextColor(dis->hDC, tcol);
+ } else {
+ tcol = DBGetContactSettingDword(NULL,"CLC","BkColour", CLCDEFAULT_BKCOLOUR);
+ SetBkColor(dis->hDC, tcol);
+
+ FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
+
+ //SendMessage(label, LB_GETITEMRECT, (WPARAM)dis->itemID, (LPARAM)&r);
+ //FillRect(dis->hDC, &r, (ttbrush = CreateSolidBrush(tcol)));
+
+ tcol = DBGetContactSettingDword(NULL,"CLC","Font0Col", CLCDEFAULT_TEXTCOLOUR);
+ SetTextColor(dis->hDC, tcol);
+ }
+
+ SetBkMode(dis->hDC, TRANSPARENT);
+ {
+ SYSTEMTIME st, other_st;
+ TCHAR buf[512] = "";
+ MyGetSystemTime(&st);
+
+
+ TIME_ZONE_INFORMATION tzi;
+ //get TZI for GMT + 1 (i.e. Central Europe Standard Time)
+ tzi.Bias = ce_reg_tzi.Bias;
+ tzi.DaylightBias = ce_reg_tzi.DaylightBias;
+ tzi.DaylightDate = ce_reg_tzi.DaylightDate;
+ tzi.StandardBias = ce_reg_tzi.StandardBias;
+ tzi.StandardDate = ce_reg_tzi.StandardDate;
+
+ // disable daylight savings
+ tzi.StandardDate.wMonth = 0;
+
+ MySystemTimeToTzSpecificLocalTime(&tzi, &st, &other_st);
+
+ double beats = (other_st.wHour + other_st.wMinute / 60.0 + other_st.wSecond / 60.0 / 60.0 + other_st.wMilliseconds / 1000.0 / 60.0 / 60.0) / 24.0 * 1000.0;
+
+ // doesn't print leading zeros!!
+ //sprintf(buf, "@%03.2f", beats);
+
+ buf[0] = '@';
+ int t = (int)(beats / 100);
+ beats -= t * 100;
+ buf[1] = '0' + t;
+ t = (int)(beats / 10);
+ beats -= t * 10;
+ buf[2] = '0' + t;
+ t = (int)beats;
+ beats -= t;
+ buf[3] = '0' + t;
+ buf[4] = '.';
+ t = (int)(beats / 0.1);
+ beats -= t * 0.1;
+ buf[5] = '0' + t;
+ t = (int)(beats / 0.01);
+ buf[6] = '0' + t;
+ buf[7] = '\0';
+
+ GetTextExtentPoint32(dis->hDC,"Internet Time",lstrlen("Internet Time"),&textSize);
+ TextOut(dis->hDC,dis->rcItem.left,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,"Internet Time",lstrlen("Internet Time"));
+
+ GetTextExtentPoint32(dis->hDC,buf,lstrlen(buf),&textSize);
+ TextOut(dis->hDC,dis->rcItem.right - textSize.cx - 2,(dis->rcItem.top+dis->rcItem.bottom-textSize.cy)>>1,buf,lstrlen(buf));
+
+ }
+
+ SetBkMode(dis->hDC, OPAQUE);
+
+ if(ttbrush) DeleteObject(ttbrush);
+ }
+ }
+ return 0;
+ break;
+ case WM_CTLCOLORLISTBOX:
+ {
+
+ if(tbrush) DeleteObject(tbrush);
+
+ return (BOOL)(tbrush = CreateSolidBrush((COLORREF)DBGetContactSettingDword(NULL,"CLC","BkColour", CLCDEFAULT_BKCOLOUR)));
+ }
+ break;
+ case WM_ERASEBKGND:
+// {
+// HDC hDC = (HDC)wParam;
+// HBRUSH tempBrush = CreateSolidBrush((COLORREF)DBGetContactSettingDword(NULL,"CLC","BkColour", CLCDEFAULT_BKCOLOUR));
+// GetClientRect(hwnd, &r);
+// FillRect(hDC, &r, tempBrush);
+// DeleteObject(tempBrush);
+// }
+ //return DefWindowProc(hwnd, msg, wParam, lParam);
+ return TRUE;
+
+
+ case WM_DELETEITEM:
+ // we don't need to delete stuff - it's handled already
+ return 0;
+ break;
+
+ case WM_SYSCOLORCHANGE:
+ SendMessage(label,msg,wParam,lParam);
+ break;
+
+ case WM_CREATE:
+ GetClientRect(hwnd,&r);
+ //label=CreateWindow("LISTBOX", "", (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY) & ~WS_BORDER, r.left, r.top, r.right - r.left, r.bottom - r.top, hwnd, NULL, hInst,0);
+ label=CreateWindow("LISTBOX", "", (WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWFIXED | LBS_NOTIFY) & ~WS_BORDER, r.left, r.top, r.right - r.left, r.bottom - r.top, hwnd, NULL, hInst,0);
+
+ SendMessage(label, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)"Internet Time");
+
+ if (DBGetContactSettingByte(NULL,"CList","Transparent",0))
+ {
+ if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+
+ } else {
+ SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
+ if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ }
+ //if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 255, LWA_ALPHA);
+ }
+
+ {
+ //CreateWindow("button","button1",WS_VISIBLE|WS_CHILD ,120,4,60,22,hwnd,NULL,hInst,0);
+ //label=CreateWindow("LISTBOX", "", (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY) & ~WS_BORDER, 2, 2, 120, 60, hwnd, NULL, hInst,0);
+
+ // 400 ms is about 1/2 of 1/100 of a beat (1/100 of a beat is our display resolution)
+ SetTimer(hwnd,TIMER_ID2, 432, plug1TimerProc2);
+ SetTimer(hwnd,TIMER_ID3, 1000, plug1TimerProc3);
+ return(0);
+
+ };
+
+
+ case WM_ACTIVATE:
+ if(wParam==WA_INACTIVE) {
+ if((HWND)wParam!=hwnd)
+ if(DBGetContactSettingByte(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT))
+ if(transparentFocus)
+ SetTimer(hwnd, TM_AUTOALPHA,250,NULL);
+ }
+ else {
+ if(DBGetContactSettingByte(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
+ KillTimer(hwnd,TM_AUTOALPHA);
+ if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ transparentFocus=1;
+ }
+ }
+ return DefWindowProc(hwnd,msg,wParam,lParam);
+
+ case WM_SETCURSOR:
+ if(DBGetContactSettingByte(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)) {
+ if (!transparentFocus && GetForegroundWindow()!=hwnd && MySetLayeredWindowAttributes) {
+ MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ transparentFocus=1;
+ SetTimer(hwnd, TM_AUTOALPHA,250,NULL);
+ }
+ }
+ return DefWindowProc(hwnd,msg,wParam,lParam);
+
+ case WM_TIMER:
+ if ((int)wParam==TM_AUTOALPHA)
+ { int inwnd;
+
+ if (GetForegroundWindow()==hwnd) {
+ KillTimer(hwnd,TM_AUTOALPHA);
+ inwnd=1;
+ }
+ else {
+ POINT pt;
+ HWND hwndPt;
+ pt.x=(short)LOWORD(GetMessagePos());
+ pt.y=(short)HIWORD(GetMessagePos());
+ hwndPt=WindowFromPoint(pt);
+ inwnd=(hwndPt==hwnd || GetParent(hwndPt)==hwnd);
+ }
+ if (inwnd!=transparentFocus && MySetLayeredWindowAttributes)
+ { //change
+ transparentFocus=inwnd;
+ if(transparentFocus) MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ else MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","AutoAlpha",SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
+ }
+ if(!transparentFocus) KillTimer(hwnd,TM_AUTOALPHA);
+ }
+ return TRUE;
+
+ case WM_SHOWWINDOW:
+ { static int noRecurse=0;
+ if(lParam) break;
+ if(noRecurse) break;
+ if(!DBGetContactSettingByte(NULL,"CLUI","FadeInOut",0) || !IsWinVer2000Plus()) break;
+ if(GetWindowLong(hwnd,GWL_EXSTYLE)&WS_EX_LAYERED) {
+ DWORD thisTick,startTick;
+ int sourceAlpha,destAlpha;
+ if(wParam) {
+ sourceAlpha=0;
+ destAlpha=(BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_AUTOALPHA_DEFAULT);
+ MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), 0, LWA_ALPHA);
+ noRecurse=1;
+ ShowWindow(hwnd,SW_SHOW);
+ noRecurse=0;
+ }
+ else {
+ sourceAlpha=(BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_AUTOALPHA_DEFAULT);
+ destAlpha=0;
+ }
+ for(startTick=GetTickCount();;) {
+ thisTick=GetTickCount();
+ if(thisTick>=startTick+200) break;
+ MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)(sourceAlpha+(destAlpha-sourceAlpha)*(int)(thisTick-startTick)/200), LWA_ALPHA);
+ }
+ MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)destAlpha, LWA_ALPHA);
+ }
+ else {
+// if(wParam) SetForegroundWindow(hwnd);
+ MyAnimateWindow(hwnd,200,AW_BLEND|(wParam?0:AW_HIDE));
+ //SetWindowPos(label,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
+ }
+ //int res = DefWindowProc(hwnd, msg, wParam, lParam);
+ //return res;
+ DBWriteContactSettingByte(NULL, "InternetTime", "WindowVisible", wParam ? 1 : 0);
+ break;
+ //return FALSE; //break;
+ }
+
+ case WM_SIZE:
+ //PostMessage(label, WM_SIZE, wParam, lParam);
+
+ GetClientRect(hwnd,&rect);
+ SetWindowPos(label, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
+ InvalidateRect(hwnd, &rect, FALSE);
+ return 0;
+
+
+ case WM_DESTROY:
+ if(tbrush) DeleteObject(tbrush);
+
+ if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ GetWindowRect(hwnd, &r);
+
+ DBWriteContactSettingDword(NULL, "InternetTime", "WindowX", r.left);
+ DBWriteContactSettingDword(NULL, "InternetTime", "WindowY", r.top);
+ DBWriteContactSettingDword(NULL, "InternetTime", "WindowWidth", r.right - r.left);
+ DBWriteContactSettingDword(NULL, "InternetTime", "WindowHeight", r.bottom - r.top);
+ }
+
+ KillTimer(hwnd,TIMER_ID2);
+ DestroyWindow(label);
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+
+ case WM_CLOSE:
+ if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if(!hook_window_behaviour_to_clist)
+ ShowWindow(hwnd, SW_HIDE);
+ return 0;
+ }
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+
+ };
+
+ return(TRUE);
+};
+
+static int PlugShowWindow(WPARAM wParam, LPARAM lParam) {
+ if(pluginwind && !hook_window_behaviour_to_clist) {
+ ShowWindow(pluginwind, IsWindowVisible(pluginwind) ? SW_HIDE : SW_SHOW);
+ DBWriteContactSettingByte(NULL, "InternetTime", "WindowVisible", IsWindowVisible(pluginwind) ? 1 : 0);
+ }
+ return 0;
+}
+
+static int DBSettingChange(WPARAM wParam, LPARAM lParam) {
+ if(pluginwind && (HANDLE)wParam == NULL) {
+ DBCONTACTWRITESETTING *db_write = (DBCONTACTWRITESETTING *)lParam;
+ if(hook_window_behaviour_to_clist) {
+ if(!strcmp("CList", db_write->szModule)) {
+ if(!strcmp("State", db_write->szSetting)) {
+ // contact list setting change
+ BYTE state = db_write->value.bVal;
+
+ if(state == SETTING_STATE_NORMAL)
+ ShowWindow(pluginwind, SW_SHOW);
+ else
+ ShowWindow(pluginwind, SW_HIDE);
+ } else if(!strcmp("Transparent", db_write->szSetting)) {
+ if(db_write->value.bVal) {
+ SetWindowLong(pluginwind, GWL_EXSTYLE, GetWindowLong(pluginwind, GWL_EXSTYLE) | WS_EX_LAYERED);
+ if (MySetLayeredWindowAttributes) MySetLayeredWindowAttributes(pluginwind, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
+ } else {
+ SetWindowLong(pluginwind, GWL_EXSTYLE, GetWindowLong(pluginwind, GWL_EXSTYLE) & ~WS_EX_LAYERED);
+ }
+ } else if(!strcmp("Alpha", db_write->szSetting)) {
+ ShowWindow(pluginwind, IsWindowVisible(pluginwind) ? SW_SHOW : SW_HIDE);
+ } else if(!strcmp("AutoAlpha", db_write->szSetting)) {
+ ShowWindow(pluginwind, IsWindowVisible(pluginwind) ? SW_SHOW : SW_HIDE);
+ }
+ }
+ }
+
+ if(db_write && !strcmp("CLC", db_write->szModule))
+ InvalidateRect(pluginwind, 0, FALSE);
+ }
+
+ return 0;
+}
+
+int addmypluginwindow1(HWND parent)
+{
+ if(!get_reg_tzi_for_central_european(ce_reg_tzi)) {
+ MessageBox(0, "Could not get Swiss time!", "Error", MB_OK);
+ return 0;
+ }
+
+ /*
+ std::ostringstream oss;
+ oss << "Bias for swiss time: " << ce_reg_tzi.Bias;
+ MessageBox(0, oss.str().c_str(), "blah", MB_OK);
+ */
+
+ hUserDll = LoadLibrary("user32.dll");
+ if (hUserDll) {
+ MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
+ MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow");
+ }
+
+ hwnd_clist = parent;
+
+ hook_window_behaviour_to_clist = (DBGetContactSettingByte(NULL, "InternetTime", "MinMax", DEFAULT_MINMAX ? 1 : 0) == 1);
+
+ WNDCLASS wndclass;
+ CLISTFrame Frame;
+ int font;
+
+ char pluginname[]="Internet Time";
+
+ hDBChange = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChange);
+
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = mypluginwindow1proc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = pluginname;
+ RegisterClass(&wndclass);
+
+
+ if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ pluginwind=CreateWindow(pluginname,Translate("Internet Time"),
+ WS_BORDER|WS_CHILD|WS_VISIBLE,
+ 0,0,0,0,parent,NULL,hInst,NULL);
+ } else {
+ CreateServiceFunction("InternetTime/ShowWindow", PlugShowWindow);
+
+ int x, y, width, height;
+ bool visible;
+
+ x = (int)DBGetContactSettingDword(NULL, "InternetTime", "WindowX", DEFAULT_WINDOW_X);
+ y = (int)DBGetContactSettingDword(NULL, "InternetTime", "WindowY", DEFAULT_WINDOW_Y);
+ width = (int)DBGetContactSettingDword(NULL, "InternetTime", "WindowWidth", DEFAULT_WINDOW_WIDTH);
+ height = (int)DBGetContactSettingDword(NULL, "InternetTime", "WindowHeight", DEFAULT_WINDOW_HEIGHT);
+
+
+ if(hook_window_behaviour_to_clist) {
+ visible = (DBGetContactSettingByte(NULL, "CList", "State", SETTING_STATE_NORMAL) == SETTING_STATE_NORMAL);
+ } else {
+ visible = ((int)DBGetContactSettingByte(NULL, "InternetTime", "WindowVisible", 1) == 1);
+ }
+
+ pluginwind=CreateWindowEx(WS_EX_TOOLWINDOW, pluginname,Translate("Internet Time"),
+ WS_POPUPWINDOW | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | (visible ? WS_VISIBLE : 0),
+ x,y,width,height,parent,NULL,hInst,NULL);
+
+ /*
+ CLISTMENUITEM mi;
+ memset( &mi, 0, sizeof( mi ));
+ mi.flags = 0;
+ mi.popupPosition = 0;
+ mi.pszPopupName = NULL;
+ mi.cbSize = sizeof( mi );
+ mi.position = 2000420000;
+ mi.hIcon = 0;//LoadIcon( hInst, 0);
+ mi.pszName = Translate( "Hide/Show &World Time Window" );
+ mi.pszService = "InternetTime/ShowWindow";
+ CallService( MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&mi );
+ */
+ }
+
+
+ font=SendMessage(parent,WM_GETFONT,0,0);
+ SendMessage(pluginwind,WM_SETFONT,font,0);
+
+ TitleBarFont = (HFONT)CLUILoadTitleBarFont();
+ SendMessage(label,WM_SETFONT,(WPARAM)TitleBarFont,0);
+
+ memset(&Frame,0,sizeof(Frame));
+ Frame.name=(char *)malloc(255);
+ memset(Frame.name,0,255);
+
+ memcpy(Frame.name,pluginname,sizeof(pluginname));
+
+ Frame.cbSize=sizeof(CLISTFrame);
+ Frame.hWnd=pluginwind;
+ Frame.align=alBottom;
+ Frame.Flags=F_VISIBLE|F_SHOWTB|F_SHOWTBTIP;
+ Frame.height=30;
+
+ if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ Frameid=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0);
+ }
+
+ return 0;
+
+};
+
+// popup support
+
+LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
+{
+ switch( message ) {
+ case WM_COMMAND: {
+ PUDeletePopUp( hWnd );
+ break;
+ }
+
+ case WM_CONTEXTMENU:
+ PUDeletePopUp( hWnd );
+ break;
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+void CALLBACK sttMainThreadCallback( ULONG dwParam )
+{
+ POPUPDATAEX* ppd = ( POPUPDATAEX* )dwParam;
+
+ if ( ServiceExists(MS_POPUP_ADDPOPUPEX) )
+ CallService( MS_POPUP_ADDPOPUPEX, ( WPARAM )ppd, 0 );
+ else
+ if ( ServiceExists(MS_POPUP_ADDPOPUP) )
+ CallService( MS_POPUP_ADDPOPUP, ( WPARAM )ppd, 0 );
+
+ free( ppd );
+}
+
+void __stdcall ShowPopup( const char* line1, const char* line2, int flags )
+{
+ if ( !ServiceExists( MS_POPUP_ADDPOPUP )) {
+ MessageBox( NULL, line2, Translate("World Time"), MB_OK | MB_ICONINFORMATION );
+ return;
+ }
+
+ POPUPDATAEX* ppd = ( POPUPDATAEX* )calloc( sizeof( POPUPDATAEX ), 1 );
+
+ ppd->lchContact = NULL;
+ ppd->lchIcon = 0;
+ strcpy( ppd->lpzContactName, line1 );
+ strcpy( ppd->lpzText, line2 );
+
+ ppd->colorBack = GetSysColor( COLOR_BTNFACE );
+ ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
+ ppd->iSeconds = 10;
+
+ ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
+ ppd->PluginData = NULL;
+
+ QueueUserAPC( sttMainThreadCallback , mainThread, ( ULONG )ppd );
+}
+
+void plugwin_cleanup() {
+ UnhookEvent(hDBChange);
+} \ No newline at end of file
diff --git a/internet_time/plugwin.h b/internet_time/plugwin.h
new file mode 100644
index 0000000..21eddea
--- /dev/null
+++ b/internet_time/plugwin.h
@@ -0,0 +1,77 @@
+#ifndef _PLUGWIN
+#define _PLUGWIN
+
+#define TIMER_ID2 1193
+#define TIMER_ID3 1194
+
+#include "../../include/newpluginapi.h"
+#include "../../include/m_langpack.h"
+#include "../../include/m_skin.h"
+#include "../../include/m_database.h"
+#include "../../include/m_options.h"
+#include "../../include/m_popup.h"
+#include "../../include/m_protosvc.h"
+#include "../mwclist/CLUIFrames/m_cluiframes.h"
+#include "../mwclist/m_clist.h"
+#include "../mwclist/m_clui.h"
+#include "../mwclist/m_clc.h"
+#include "../mwclist/m_genmenu.h"
+//#include "common.h"
+
+#include <sstream>
+
+#include "timezone.h"
+#include "time_convert.h"
+
+
+#define DEFAULT_MINMAX true
+
+#define DEFAULT_WINDOW_X 100
+#define DEFAULT_WINDOW_Y 100
+#define DEFAULT_WINDOW_WIDTH 200
+#define DEFAULT_WINDOW_HEIGHT 100
+
+#define MAX_NAME_LENGTH 256
+#define MAX_TIME_LENGTH 256
+
+typedef struct tagLISTITEM {
+ int cbSize;
+ char pszText[MAX_NAME_LENGTH];
+ int timezone_list_index;
+} LISTITEM;
+
+#include <vector>
+typedef std::vector<LISTITEM> ITEMLIST;
+
+extern HANDLE upIcon, downIcon;
+
+extern ITEMLIST listbox_items;
+
+extern HANDLE mainThread;
+
+extern char format_string[];
+
+int addmypluginwindow1(HWND parent);
+void plugwin_cleanup();
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int InternetTimeOptInit(WPARAM wParam,LPARAM lParam);
+void __stdcall ShowPopup( const char* line1, const char* line2, int flags );
+
+#ifdef __cplusplus
+};
+#endif
+
+#define WinVerMajor() LOBYTE(LOWORD(GetVersion()))
+#define WinVerMinor() HIBYTE(LOWORD(GetVersion()))
+#define IsWinVer2000Plus() (WinVerMajor()>=5)
+
+#define CLCDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
+#define CLCDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT)
+#define CLCDEFAULT_SELTEXTCOLOUR GetSysColor(COLOR_HIGHLIGHTTEXT)
+#define CLCDEFAULT_TEXTCOLOUR GetSysColor(COLOR_WINDOWTEXT)
+
+#endif
diff --git a/internet_time/time_convert.cpp b/internet_time/time_convert.cpp
new file mode 100644
index 0000000..9ed52c2
--- /dev/null
+++ b/internet_time/time_convert.cpp
@@ -0,0 +1,204 @@
+#include "stdafx.h"
+#include "time_convert.h"
+
+void ConvertToAbsolute (const SYSTEMTIME * pstLoc, const SYSTEMTIME * pstDst, SYSTEMTIME * pstDstAbs)
+{
+ static int iDays [12] = { 31, 28, 31, 30, 31, 30,
+ 31, 31, 30, 31, 30, 31 } ;
+ int iDay ;
+
+ // Set up the aboluste date structure except for wDay, which we must find
+
+ pstDstAbs->wYear = pstLoc->wYear ; // Notice from local date/time
+ pstDstAbs->wMonth = pstDst->wMonth ;
+ pstDstAbs->wDayOfWeek = pstDst->wDayOfWeek ;
+
+ pstDstAbs->wHour = pstDst->wHour ;
+ pstDstAbs->wMinute = pstDst->wMinute ;
+ pstDstAbs->wSecond = pstDst->wSecond ;
+ pstDstAbs->wMilliseconds = pstDst->wMilliseconds ;
+
+ // Fix the iDays array for leap years
+
+ if ((pstLoc->wYear % 4 == 0) && ((pstLoc->wYear % 100 != 0) ||
+ (pstLoc->wYear % 400 == 0)))
+ {
+ iDays[1] = 29 ;
+ }
+
+ // Find a day of the month that falls on the same
+ // day of the week as the transition.
+
+ // Suppose today is the 20th of the month (pstLoc->wDay = 20)
+ // Suppose today is a Wednesday (pstLoc->wDayOfWeek = 3)
+ // Suppose the transition occurs on a Friday (pstDst->wDayOfWeek = 5)
+ // Then iDay = 31, meaning that the 31st falls on a Friday
+ // (The 7 is this formula avoids negatives.)
+
+ iDay = pstLoc->wDay + pstDst->wDayOfWeek + 7 - pstLoc->wDayOfWeek ;
+
+ // Now shrink iDay to a value between 1 and 7.
+
+ iDay = (iDay - 1) % 7 + 1 ;
+
+ // Now iDay is a day of the month ranging from 1 to 7.
+ // Recall that the wDay field of the structure can range
+ // from 1 to 5, 1 meaning "first", 2 meaning "second",
+ // and 5 meaning "last".
+ // So, increase iDay so it's the proper day of the month.
+
+ iDay += 7 * (pstDst->wDay - 1) ;
+
+ // Could be that iDay overshot the end of the month, so
+ // fix it up using the number of days in each month
+
+ if (iDay > iDays[pstDst->wMonth - 1])
+ iDay -= 7 ;
+
+ // Assign that day to the structure.
+
+ pstDstAbs->wDay = iDay ;
+}
+
+BOOL LocalGreaterThanTransition (const SYSTEMTIME * pstLoc, const SYSTEMTIME * pstTran)
+{
+ FILETIME ftLoc, ftTran ;
+ LARGE_INTEGER liLoc, liTran ;
+ SYSTEMTIME stTranAbs ;
+
+ // Easy case: Just compare the two months
+
+ if (pstLoc->wMonth != pstTran->wMonth)
+ return (pstLoc->wMonth > pstTran->wMonth) ;
+
+ // Well, we're in a transition month. That requires a bit more work.
+
+ // Check if pstDst is in absolute or day-in-month format.
+ // (See documentation of TIME_ZONE_INFORMATION, StandardDate field.)
+
+ if (pstTran->wYear) // absolute format (haven't seen one yet!)
+ {
+ stTranAbs = * pstTran ;
+ }
+ else // day-in-month format
+ {
+ ConvertToAbsolute (pstLoc, pstTran, &stTranAbs) ;
+ }
+
+ // Now convert both date/time structures to large integers & compare
+
+ SystemTimeToFileTime (pstLoc, &ftLoc) ;
+ liLoc = * (LARGE_INTEGER *) (void *) &ftLoc ;
+
+ SystemTimeToFileTime (&stTranAbs, &ftTran) ;
+ liTran = * (LARGE_INTEGER *) (void *) &ftTran ;
+
+ return (liLoc.QuadPart > liTran.QuadPart) ;
+}
+
+BOOL MySystemTimeToTzSpecificLocalTime(const TIME_ZONE_INFORMATION *ptzi, const SYSTEMTIME *pstUtc, SYSTEMTIME *pstLoc) {
+ // st is UTC
+
+ FILETIME ft ;
+ LARGE_INTEGER li ;
+ SYSTEMTIME stDst ;
+
+ // If we're running under NT, just call the real function
+
+ if (!(0x80000000 & GetVersion()))
+ return SystemTimeToTzSpecificLocalTime ((TIME_ZONE_INFORMATION *) ptzi, (SYSTEMTIME *) pstUtc, pstLoc) ;
+
+ // Convert time to a LARGE_INTEGER and subtract the bias
+
+ SystemTimeToFileTime (pstUtc, &ft) ;
+ li = * (LARGE_INTEGER *) (void *) &ft;
+ li.QuadPart -= (LONGLONG) 600000000 * ptzi->Bias ;
+
+ // Convert to a local date/time before application of daylight saving time.
+ // The local date/time must be used to determine when the conversion occurs.
+
+ ft = * (FILETIME *) (void *) &li ;
+ FileTimeToSystemTime (&ft, pstLoc) ;
+
+ // Find the time assuming Daylight Saving Time
+
+ li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
+ ft = * (FILETIME *) (void *) &li ;
+ FileTimeToSystemTime (&ft, &stDst) ;
+
+ // Now put li back the way it was
+
+ li.QuadPart += (LONGLONG) 600000000 * ptzi->DaylightBias ;
+
+ if (ptzi->StandardDate.wMonth) // ie, daylight savings time
+ {
+ // Northern hemisphere
+
+ if ((ptzi->DaylightDate.wMonth < ptzi->StandardDate.wMonth) &&
+
+ (stDst.wMonth >= pstLoc->wMonth) && // avoid the end of year problem
+
+ LocalGreaterThanTransition (pstLoc, &ptzi->DaylightDate) &&
+ !LocalGreaterThanTransition (&stDst, &ptzi->StandardDate))
+ {
+ li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
+ }
+ // Southern hemisphere
+
+ else if ((ptzi->StandardDate.wMonth < ptzi->DaylightDate.wMonth) &&
+ (!LocalGreaterThanTransition (&stDst, &ptzi->StandardDate) ||
+ LocalGreaterThanTransition (pstLoc, &ptzi->DaylightDate)))
+ {
+ li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
+ }
+ else
+ {
+ li.QuadPart -= (LONGLONG) 600000000 * ptzi->StandardBias ;
+ }
+ }
+
+ ft = * (FILETIME *) (void *) &li ;
+ FileTimeToSystemTime (&ft, pstLoc) ;
+ return TRUE ;
+}
+
+VOID MyGetSystemTime(LPSYSTEMTIME lpSystemTime) {
+ TIME_ZONE_INFORMATION tzi;
+ FILETIME ft;
+ LARGE_INTEGER li;
+
+ GetSystemTime(lpSystemTime);
+ GetTimeZoneInformation(&tzi);
+
+
+ // this condition occurs when 'automaticall adjust for daylight savings' is off!
+ if(tzi.StandardDate.wMonth != 0 && tzi.DaylightBias == 0 && tzi.StandardBias == 0) {
+ if ((tzi.DaylightDate.wMonth < tzi.StandardDate.wMonth) &&
+
+ LocalGreaterThanTransition (lpSystemTime, &tzi.DaylightDate) &&
+ !LocalGreaterThanTransition (lpSystemTime, &tzi.StandardDate))
+ {
+ // add one hour to the system time
+ SystemTimeToFileTime(lpSystemTime, &ft);
+ li = * (LARGE_INTEGER *) (void *) &ft;
+ li.QuadPart += (LONGLONG) 600000000 * 60;
+ ft = * (FILETIME *) (void *) &li ;
+ FileTimeToSystemTime(&ft, lpSystemTime);
+ }
+ // Southern hemisphere
+
+ else if ((tzi.StandardDate.wMonth < tzi.DaylightDate.wMonth) &&
+ (!LocalGreaterThanTransition (lpSystemTime, &tzi.StandardDate) ||
+ LocalGreaterThanTransition (lpSystemTime, &tzi.DaylightDate)))
+ {
+ // add one hour to the system time
+ SystemTimeToFileTime(lpSystemTime, &ft);
+ li = * (LARGE_INTEGER *) (void *) &ft;
+ li.QuadPart += (LONGLONG) 600000000 * 60;
+ ft = * (FILETIME *) (void *) &li ;
+ FileTimeToSystemTime(&ft, lpSystemTime);
+ }
+
+ }
+}
+
diff --git a/internet_time/time_convert.h b/internet_time/time_convert.h
new file mode 100644
index 0000000..d1322bd
--- /dev/null
+++ b/internet_time/time_convert.h
@@ -0,0 +1,30 @@
+#ifndef _TIME_CONVERT_H
+#define _TIME_CONVERT_H
+
+/*
+
+ from http://cvs.sourceforge.net/viewcvs.py/tortoisecvs/TortoiseCVS/src/Utils/Attic/ClockRackCon.c?view=markup
+ (GPL)
+
+----------------------------------------------------------------
+ ClockRackCon.c -- Time-zone time conversion for ClockRack 1.1
+ (c) Ziff Davis Media, Inc.
+ All rights reserved.
+
+ First published in PC Magazine, US edition, September 1, 2000.
+
+ Programmed by Charles Petzold.
+
+ The entire function of this module is to implement the
+ MySystemTimeToTzSpecificLocalTime all because Windows 95 & 98
+ do not implement the NT function SystemTimeToTzSpecificLocalTime.
+ ---------------------------------------------------------------------
+
+
+*/
+
+BOOL MySystemTimeToTzSpecificLocalTime(const TIME_ZONE_INFORMATION *pTZI, const SYSTEMTIME *st, SYSTEMTIME *other_st);
+
+VOID MyGetSystemTime(LPSYSTEMTIME lpSystemTime);
+
+#endif \ No newline at end of file
diff --git a/internet_time/timezone.cpp b/internet_time/timezone.cpp
new file mode 100644
index 0000000..ca6519b
--- /dev/null
+++ b/internet_time/timezone.cpp
@@ -0,0 +1,92 @@
+#include "stdafx.h"
+#include "timezone.h"
+
+TimeList timezone_list, geo_timezone_list;
+
+bool LS_TZREG::operator<(const LS_TZREG &other) {
+ //return Index < other.Index;
+ return TZI.Bias < other.TZI.Bias;
+}
+
+bool build_timezone_list() {
+ HKEY HKlmtz;
+ HKEY KKtz;
+ DWORD dwIndex = 0;
+ CHAR tcName[MAX_SIZE];
+ DWORD dwcbName = MAX_SIZE;
+ DWORD dwcbValue;
+ DWORD dwcbSTD;
+ DWORD dwcbDLT;
+ LS_TZREG Temp;
+ FILETIME ftLastWrite;
+ unsigned int list_index = 0;
+ bool win9x = false;
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TZREG, 0, KEY_ENUMERATE_SUB_KEYS, &HKlmtz) != ERROR_SUCCESS) {
+ win9x = true;
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TZREG_9X, 0, KEY_ENUMERATE_SUB_KEYS, &HKlmtz) != ERROR_SUCCESS)
+ return false;
+ }
+
+ while(RegEnumKeyEx(HKlmtz, dwIndex++, tcName, &dwcbName, NULL, NULL, NULL, &ftLastWrite) != ERROR_NO_MORE_ITEMS) {
+
+ if(RegOpenKeyEx(HKlmtz, tcName, 0,KEY_QUERY_VALUE, &KKtz) != ERROR_SUCCESS) {
+ RegCloseKey(HKlmtz);
+ return false;
+ }
+
+ strncpy(Temp.tcName, tcName, MAX_SIZE);
+ dwcbValue = MAX_SIZE;
+ RegQueryValueEx(KKtz,"Display",NULL,NULL,(BYTE*)Temp.tcDisp,&dwcbValue);
+ dwcbDLT = MAX_SIZE;
+ RegQueryValueEx(KKtz,"Dlt",NULL,NULL,(BYTE*)Temp.tcDLT,&dwcbDLT);
+ dwcbSTD = MAX_SIZE;
+ RegQueryValueEx(KKtz,"Std",NULL,NULL,(BYTE*)Temp.tcSTD,&dwcbSTD);
+ dwcbValue = MAX_SIZE;
+ RegQueryValueEx(KKtz,"MapID",NULL,NULL,(BYTE*)Temp.MapID,&dwcbValue);
+ if(!win9x) {
+ dwcbValue = sizeof(DWORD);
+ RegQueryValueEx(KKtz,"Index",NULL,NULL,(BYTE*)&Temp.Index,&dwcbValue);
+ }
+ dwcbValue = sizeof(Temp.TZI);
+ RegQueryValueEx(KKtz,"TZI",NULL,NULL,(BYTE*)&Temp.TZI,&dwcbValue);
+
+ RegCloseKey(KKtz);
+
+ Temp.list_index = list_index;
+ timezone_list.push_back(Temp);
+
+ dwcbName = MAX_SIZE;
+ list_index++;
+ }
+
+ RegCloseKey(HKlmtz);
+
+ geo_timezone_list = timezone_list;
+ std::sort(geo_timezone_list.begin(), geo_timezone_list.end());
+
+ return true;
+}
+
+bool get_reg_tzi_for_gmt(REG_TZI &reg_tzi) {
+ for(TimeList::iterator i = timezone_list.begin(); i != timezone_list.end(); i++) {
+ if(!strcmp(i->tcName, "GMT Standard Time")) {
+ reg_tzi = i->TZI;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool get_reg_tzi_for_central_european(REG_TZI &reg_tzi) {
+ // for language independece, look for a timezone with Bias == -60 - daylight savings is ignored anyway
+ for(TimeList::iterator i = timezone_list.begin(); i != timezone_list.end(); i++) {
+ if(i->TZI.Bias == -60) {
+ reg_tzi = i->TZI;
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/internet_time/timezone.h b/internet_time/timezone.h
new file mode 100644
index 0000000..d1997c5
--- /dev/null
+++ b/internet_time/timezone.h
@@ -0,0 +1,47 @@
+#ifndef _TIMEZONE_H
+#define _TIMEZONE_H
+
+#define TZREG "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
+#define TZREG_9X "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones"
+//#define TZREG2 "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation"
+#define MAX_SIZE 512
+
+#include <vector>
+#include <algorithm>
+
+#include <wchar.h>
+
+struct REG_TZI {
+ long Bias;
+ long StandardBias;
+ long DaylightBias;
+ SYSTEMTIME StandardDate;
+ SYSTEMTIME DaylightDate;
+};
+
+
+struct LS_TZREG {
+ TCHAR tcName[MAX_SIZE];
+ TCHAR tcDisp[MAX_SIZE];
+ TCHAR tcDLT[MAX_SIZE];
+ TCHAR tcSTD[MAX_SIZE];
+ TCHAR MapID[MAX_SIZE];
+ DWORD Index;
+ DWORD ActiveTimeBias;
+ //TIME_ZONE_INFORMATION TZI;
+ REG_TZI TZI;
+
+ unsigned int list_index;
+
+ bool operator<(const LS_TZREG &other);
+};
+
+typedef std::vector< LS_TZREG > TimeList;
+
+extern TimeList timezone_list, geo_timezone_list;
+bool build_timezone_list();
+
+bool get_reg_tzi_for_gmt(REG_TZI &reg_tzi);
+bool get_reg_tzi_for_central_european(REG_TZI &reg_tzi);
+
+#endif