Initial community commit

This commit is contained in:
Jef
2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit 20d28e80a5
16810 changed files with 4640254 additions and 2 deletions

View File

@ -0,0 +1,518 @@
#include "main.h"
#include "./addressEncoder.h"
#include <wininet.h>
#include <strsafe.h>
typedef struct __ENCODEBUFFER
{
LPWSTR buffer;
size_t bufferMax;
LPWSTR cursor;
size_t remaining;
} ENCODEBUFFER;
HRESULT AddressEncoder_ReAllocBuffer(ENCODEBUFFER *decoder, size_t cchBufferSize)
{
if (NULL == decoder)
return E_INVALIDARG;
if (cchBufferSize == decoder->bufferMax)
return S_FALSE;
if (cchBufferSize < decoder->bufferMax)
return E_FAIL;
LPWSTR test = Plugin_ReAllocString(decoder->buffer, cchBufferSize);
if (NULL == test)
return E_OUTOFMEMORY;
decoder->cursor = test + (decoder->cursor - decoder->buffer);
decoder->remaining += (cchBufferSize - decoder->bufferMax);
decoder->buffer = test;
decoder->bufferMax = cchBufferSize;
return S_OK;
}
HRESULT AddressEncoder_AppendAnsiString(ENCODEBUFFER *decoder, LPCSTR pszString, size_t cchString)
{
if (NULL == decoder)
return E_INVALIDARG;
INT cchConverted;
while(0 ==(cchConverted = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, pszString, (int)cchString, decoder->cursor, (int)decoder->remaining)))
{
DWORD errorCode = GetLastError();
if (ERROR_INSUFFICIENT_BUFFER == errorCode)
{
INT cchNeed = MultiByteToWideChar(CP_UTF8, 0, pszString, (int)cchString, NULL, 0) - (INT)decoder->remaining;
if (cchNeed < 32) cchNeed = 32;
HRESULT hr = AddressEncoder_ReAllocBuffer(decoder, decoder->bufferMax + cchNeed);
if (FAILED(hr))
return hr;
}
else
{
return HRESULT_FROM_WIN32(errorCode);
}
}
if (0 != cchConverted)
{
decoder->cursor += cchConverted;
decoder->remaining -= cchConverted;
}
return S_OK;
}
HRESULT AddressEncoder_AppendString(ENCODEBUFFER *decoder, LPCWSTR pszString, size_t cchString)
{
if (NULL == decoder)
return E_INVALIDARG;
LPWSTR cursor;
size_t remaining;
HRESULT hr;
if (cchString >= decoder->remaining)
{
hr = AddressEncoder_ReAllocBuffer(decoder, decoder->bufferMax + (cchString - decoder->remaining) + 1);
if (FAILED(hr)) return hr;
}
hr = StringCchCopyNEx(decoder->cursor, decoder->remaining, pszString, cchString, &cursor, &remaining, 0);
if (SUCCEEDED(hr))
{
decoder->cursor = cursor;
decoder->remaining = remaining;
}
return hr;
}
HRESULT AddressEncoder_GetEscapeBlock(LPCWSTR pszEscape, LPCWSTR *ppszEnd, size_t *pcchEscapeLen, LPSTR pszBuffer, UINT *pcbBufferMax)
{
if (NULL == pszEscape || (NULL != pszBuffer && NULL == pcbBufferMax))
return E_INVALIDARG;
UINT cbBinary = 0;
WORD charInfo;
WCHAR szDigit[3] = {0};
HRESULT hr = S_OK;
LPCWSTR cursor = pszEscape;
while (L'%' == *cursor)
{
LPCWSTR testChar = CharNext(cursor);
if (L'\0' == *testChar ||
FALSE == GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, testChar, 1, &charInfo) ||
0 == (C1_XDIGIT & charInfo))
{
break;
}
szDigit[0] = *testChar;
testChar = CharNext(testChar);
if (L'\0' == *testChar ||
FALSE == GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, testChar, 1, &charInfo) ||
0 == (C1_XDIGIT & charInfo))
{
break;
}
szDigit[1] = *testChar;
CharUpperBuff(szDigit, 2);
BYTE binaryData = ((szDigit[0] - ((szDigit[0] <= L'9' ? L'0' : L'A' - 10))) << 4) & 0xf0;
binaryData += (szDigit[1] - ((szDigit[1] <= L'9' ? L'0' : L'A' - 10))) & 0x0f;
if (NULL != pszBuffer)
{
if (cbBinary < *pcbBufferMax)
pszBuffer[cbBinary] = binaryData;
else
hr = E_OUTOFMEMORY;
}
cbBinary++;
cursor = CharNext(testChar);
}
if (cursor == pszEscape)
hr = HRESULT_FROM_WIN32(ERROR_INVALID_BLOCK_LENGTH);
if (NULL != ppszEnd)
*ppszEnd = cursor;
if (NULL != pcchEscapeLen)
*pcchEscapeLen = (size_t)(cursor - pszEscape);
if (NULL != pcbBufferMax)
*pcbBufferMax = cbBinary;
return hr;
}
HRESULT AddressEncoder_DecodeString(LPCWSTR pszUrl, LPWSTR *ppResult)
{
if (NULL == pszUrl)
{
*ppResult = NULL;
return S_FALSE;
}
UINT cchUrl = 0;
UINT escapeSize = 0;
UINT escapeBlockSize,escapeBlockMaxSize = 0;
LPCWSTR escapeBlockEnd;
for (LPCWSTR cursor = pszUrl; L'\0' != *cursor;)
{
if (L'%' == *cursor && SUCCEEDED(AddressEncoder_GetEscapeBlock(cursor, &escapeBlockEnd, NULL, NULL, &escapeBlockSize)))
{
escapeSize += escapeBlockSize;
if (escapeBlockSize > escapeBlockMaxSize)
escapeBlockMaxSize = escapeBlockSize;
cursor = escapeBlockEnd;
}
else
{
cchUrl++;
cursor = CharNext(cursor);
}
}
if (0 == escapeSize)
{
*ppResult = Plugin_CopyString(pszUrl);
if (NULL == *ppResult) return E_OUTOFMEMORY;
return S_FALSE;
}
HRESULT hr = S_OK;
ENCODEBUFFER decoder;
ZeroMemory(&decoder, sizeof(decoder));
LPSTR escapeBuffer = Plugin_MallocAnsiString(escapeBlockMaxSize);
if (NULL == escapeBuffer)
{
hr = E_OUTOFMEMORY;
}
else
{
hr = AddressEncoder_ReAllocBuffer(&decoder, cchUrl + (escapeSize + 1)* sizeof(WCHAR));
if (SUCCEEDED(hr))
{
LPCWSTR cursor = pszUrl;
LPCWSTR copyBlock = cursor;
for (;;)
{
escapeBlockSize = escapeBlockMaxSize;
if (L'%' == *cursor && SUCCEEDED(AddressEncoder_GetEscapeBlock(cursor, &escapeBlockEnd, NULL, escapeBuffer, &escapeBlockSize)))
{
if (copyBlock != cursor)
{
hr = AddressEncoder_AppendString(&decoder, copyBlock, cursor - copyBlock);
if (FAILED(hr))
break;
copyBlock = cursor;
}
HRESULT convertResult = AddressEncoder_AppendAnsiString(&decoder, escapeBuffer, escapeBlockSize);
if (L'\0' == *cursor)
break;
cursor = escapeBlockEnd;
if (SUCCEEDED(convertResult))
{
copyBlock = cursor;
}
continue;
}
if (L'\0' == *cursor)
{
if (copyBlock != cursor)
hr = AddressEncoder_AppendString(&decoder, copyBlock, cursor - copyBlock);
break;
}
else
cursor = CharNext(cursor);
}
}
}
if (NULL != escapeBuffer)
Plugin_FreeAnsiString(escapeBuffer);
if (FAILED(hr))
{
Plugin_FreeString(decoder.buffer);
decoder.buffer = NULL;
}
else
{
*decoder.cursor = L'\0';
}
*ppResult = decoder.buffer;
return hr;
}
HRESULT AddressEncoder_GetWideBlock(LPCWSTR pszWide, LPCWSTR *pszEnd, LPWSTR pszBuffer, size_t *pcchBufferMax)
{
LPCWSTR cursor = pszWide;
if (NULL == pszWide)
return E_INVALIDARG;
if (NULL != pszBuffer && NULL == pcchBufferMax)
return E_INVALIDARG;
while (L'\0' == *cursor || *cursor > 0xFF)
{
if (L'\0' == *cursor)
break;
cursor = CharNext(cursor);
}
if (NULL != pszEnd)
*pszEnd = cursor;
HRESULT hr = S_OK;
size_t cchBuffer = 0;
if (cursor == pszWide)
{
hr = S_FALSE;
}
else
{
size_t bytesCount = WideCharToMultiByte(CP_UTF8, 0, pszWide, (int)(cursor - pszWide), NULL, 0, NULL, NULL);
if (0 == bytesCount)
{
DWORD errorCode = GetLastError();
if (ERROR_SUCCESS != errorCode)
hr = HRESULT_FROM_WIN32(errorCode);
}
else
{
cchBuffer = 3 * bytesCount;
if (NULL != pszBuffer)
{
if (*pcchBufferMax >= cchBuffer)
{
LPWSTR p = pszBuffer;
BYTE *bytes = ((BYTE*)(pszBuffer + *pcchBufferMax)) - bytesCount;
WideCharToMultiByte(CP_UTF8, 0, pszWide, (int)(cursor - pszWide), (LPSTR)bytes, (int)bytesCount, NULL, NULL);
for (size_t i = 0; i < bytesCount; i++)
{
BYTE b = bytes[i];
*p++ = L'%';
BYTE c = (b >> 4) & 0x0F;
*p++ = (c < 10) ? (L'0' + c) : (L'A' + (c -10));
c = b & 0x0F;
*p++ = (c < 10) ? (L'0' + c) : (L'A' + (c -10));
}
}
else
{
hr = E_OUTOFMEMORY;
}
}
}
}
if (NULL != pcchBufferMax)
{
*pcchBufferMax = cchBuffer;
}
return hr;
}
HRESULT AddressEncoder_EncodeWideChars(LPCWSTR pszAddress, size_t cchAddress, LPWSTR *ppResult)
{
if (NULL == ppResult)
return E_POINTER;
if (NULL == pszAddress)
{
*ppResult = NULL;
return S_FALSE;
}
LPCWSTR blockEnd;
size_t blockSize;
size_t cchResultMax = 0;
BOOL needEncode = FALSE;
for (LPCWSTR cursor = pszAddress; L'\0' != *cursor;)
{
if (*cursor > 0xFF && SUCCEEDED(AddressEncoder_GetWideBlock(cursor, &blockEnd, NULL, &blockSize)))
{
cursor = blockEnd;
cchResultMax += blockSize;
needEncode = TRUE;
}
else
{
cursor = CharNext(cursor);
cchResultMax++;
}
}
if (FALSE == needEncode)
{
*ppResult = NULL;
return S_FALSE;
}
HRESULT hr;
cchResultMax++;
LPWSTR result = Plugin_MallocString(cchResultMax);
if (NULL == result)
hr = E_OUTOFMEMORY;
else
{
LPWSTR cursor = result;
size_t remaining = cchResultMax;
LPCWSTR address = pszAddress;
LPCWSTR addressBlock = address;
for (;;)
{
if (*address > 0xFF)
{
if (addressBlock != address)
{
hr = StringCchCopyNEx(cursor, remaining, addressBlock, (size_t)(address - addressBlock), &cursor, &remaining, 0);
if (FAILED(hr)) break;
}
blockSize = remaining;
hr = AddressEncoder_GetWideBlock(address, &address, cursor, &blockSize);
if (FAILED(hr)) break;
cursor += blockSize;
remaining -= blockSize;
addressBlock = address;
continue;
}
if (L'\0' == *address)
{
if (addressBlock != address)
{
hr = StringCchCopyNEx(cursor, remaining, addressBlock, (size_t)(address - addressBlock), &cursor, &remaining, 0);
}
break;
}
else
address = CharNext(address);
}
*cursor = L'\0';
}
if (FAILED(hr))
{
Plugin_FreeString(result);
result = NULL;
}
*ppResult = result;
return hr;
}
HRESULT AddressEncoder_EncodeString(LPCWSTR pszAddress, LPWSTR pszBuffer, size_t *pcchBufferMax, UINT flags)
{
if (NULL == pszBuffer || NULL == pcchBufferMax)
return E_INVALIDARG;
if (NULL == pszAddress || L'\0' == *pszAddress)
{
*pszBuffer = L'\0';
*pcchBufferMax = 0;
return S_OK;
}
INT cchAddress = lstrlen(pszAddress);
LPCWSTR begin, end;
begin = pszAddress;
end = pszAddress + cchAddress;
WORD charType;
while (L'\0' != *begin &&
FALSE != GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, begin, 1, &charType) && 0 != (C1_SPACE & charType))
{
begin = CharNext(begin);
}
while (begin != end &&
FALSE != GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, begin, 1, &charType) && 0 != (C1_SPACE & charType))
{
end = CharPrev(begin, end);
}
if (end <= begin)
{
*pszBuffer = L'\0';
*pcchBufferMax = 0;
return S_OK;
}
LPWSTR encoded;
HRESULT hr = AddressEncoder_EncodeWideChars(begin, (end - begin), &encoded);
if (FAILED(hr)) return hr;
if (S_OK == hr)
{
begin = encoded;
end = begin + lstrlen(begin);
}
DWORD bufferLen = (DWORD)(*pcchBufferMax);
if (FALSE == InternetCanonicalizeUrl(begin, pszBuffer, &bufferLen, flags))
{
DWORD errorCode = GetLastError();
if (ERROR_INSUFFICIENT_BUFFER == errorCode)
{
*pcchBufferMax = bufferLen;
hr = ENC_E_INSUFFICIENT_BUFFER;
}
else
{
size_t cchNeeded = (end - begin);
if (cchNeeded < *pcchBufferMax)
{
hr = StringCchCopyN(pszBuffer, *pcchBufferMax, begin, cchNeeded);
if (STRSAFE_E_INSUFFICIENT_BUFFER == hr)
{
hr = ENC_E_INSUFFICIENT_BUFFER;
}
}
else
{
hr = ENC_E_INSUFFICIENT_BUFFER;
}
*pcchBufferMax = cchNeeded + 1;
}
}
else
hr = S_OK;
Plugin_FreeString(encoded);
return hr;
}

View File

@ -0,0 +1,15 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_ADDRESS_DECODER_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_ADDRESS_DECODER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#define ENC_E_INSUFFICIENT_BUFFER (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER))
HRESULT AddressEncoder_DecodeString(LPCWSTR pszAddress, LPWSTR *ppResult);
HRESULT AddressEncoder_EncodeString(LPCWSTR pszAddress, LPWSTR pszBuffer, size_t *pcchBufferMax, UINT flags);
#endif //NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_ADDRESS_DECODER_HEADER

1579
Src/omBrowser/browser.cpp Normal file

File diff suppressed because it is too large Load Diff

226
Src/omBrowser/browser.h Normal file
View File

@ -0,0 +1,226 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "../nu/HTMLContainer2.h"
#include "./browserInternal.h"
class obj_ombrowser;
class Browser;
class ifc_omdebugconfig;
class ifc_omservice;
class ifc_travelloghelper;
typedef void (CALLBACK *BHCALLBACK)(Browser* /*browser*/);
typedef void (CALLBACK *BHNAVCOMPLETECALLBACK)(Browser* /*browser*/, IDispatch* /*pDispatch*/, VARIANT* /*URL*/);
typedef void (CALLBACK *BHCMDSTATECALLBACK)(Browser* /*browser*/, INT /*commandId*/, BOOL /*fEnabled*/);
typedef void (CALLBACK *BHTEXTCALLBACK)(Browser* /*browser*/, LPCWSTR /*pszText*/);
typedef HRESULT (CALLBACK *BHSERVICECALLBACK)(Browser* /*browser*/, ifc_omservice** /*ppService*/);
typedef LRESULT (CALLBACK *BHMSGCALLBACK)(Browser* /*browser*/, MSG* /*pMsg*/);
typedef void (CALLBACK *BHCREATEPOPUPCALLBACK)(Browser* /*browser*/, IDispatch** /*ppDisp*/, VARIANT_BOOL* /*Cancel*/);
typedef void (CALLBACK *BHBOOLCALLBACK)(Browser* /*browser*/, VARIANT_BOOL /*Visible*/);
typedef void (CALLBACK *BHCLOSECALLBACK)(Browser* /*browser*/, VARIANT_BOOL /*IsChild*/, VARIANT_BOOL* /*Cancel*/);
typedef void (CALLBACK *BHSHOWUICALLBACK)(Browser* /*browser*/, UINT /*elementId*/, VARIANT_BOOL /*fShow*/);
typedef void (CALLBACK *BHCLIENTTOHOSTCALLBACK)(Browser* /*browser*/, LONG* /*CX*/, LONG* /*CY*/);
typedef void (CALLBACK *BHFOCUSCHANGECALLBACK)(Browser* /*browser*/, VARIANT_BOOL* /*fAllow*/);
typedef void (CALLBACK *BHWINDOWPOSCALLBACK)(Browser* /*browser*/, UINT /*Flags*/, LONG /*X*/, LONG /*Y*/, LONG /*Width*/, LONG /*Height*/);
class Browser : public HTMLContainer2,
public IDropTarget,
public IProtectFocus,
public IHTMLOMWindowServices,
public INewWindowManager
{
public:
typedef enum
{
commandNone = 0,
commandBack = 1,
commandForward = 2,
commandStop = 3,
commandRefresh = 4,
commandRefreshCompletely = 5,
} Commands;
typedef enum
{
commandStateSupported = 1,
commandStateEnabled = 2,
commandStateLatched = 4,
} CommandStates;
typedef enum
{
flagUiDisableScroll = 0x00000001,
flagUiDisableContextMenu = 0x00000002,
flagUiDialogMode = 0x00000004,
flagUiDisableHostCss = 0x00000008,
} UiFlags;
protected:
Browser(obj_ombrowser *browserMngr, HWND winampWindow, HWND hParent);
~Browser();
public:
static Browser *CreateInstance(obj_ombrowser *browserManager, HWND winampWindow, HWND hParent);
public:
/*** IUnknown ***/
STDMETHOD_(ULONG, AddRef)(void);
STDMETHOD_(ULONG, Release)(void);
STDMETHOD (QueryInterface)(REFIID, LPVOID*);
/*** IDropTarget ***/
STDMETHOD (DragEnter)(IDataObject *, DWORD, POINTL, DWORD*);
STDMETHOD (DragOver)(DWORD, POINTL, DWORD*);
STDMETHOD (DragLeave)(void);
STDMETHOD (Drop)(IDataObject*, DWORD, POINTL, DWORD*);
STDMETHOD (GetDropTarget)(IDropTarget*, IDropTarget **);
STDMETHOD (GetExternal)(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
STDMETHOD (ShowContextMenu)(DWORD dwID, POINT __RPC_FAR *ppt, IUnknown __RPC_FAR *pcmdtReserved, IDispatch __RPC_FAR *pdispReserved);
STDMETHOD (ShowMessage)(HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult);
// *** IDocHostUIHandler ***
STDMETHOD (TranslateAccelerator)(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID);
/*** IDocHostUIHandler2 ***/
STDMETHOD (GetOverrideKeyPath)(LPOLESTR __RPC_FAR *pchKey, DWORD dw);
/*** IOleCommandTarget ***/
STDMETHOD (Exec)(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
/*** IServiceProvider ***/
STDMETHOD (QueryService)(REFGUID guidService, REFIID riid, void **ppv);
/*** IProtectFocus ***/
STDMETHOD (AllowFocusChange)(BOOL *pfAllow);
/*** IHTMLOMWindowServices ***/
STDMETHOD (moveTo)(LONG x, LONG y);
STDMETHOD (moveBy)(LONG x, LONG y);
STDMETHOD (resizeTo)(LONG x, LONG y);
STDMETHOD (resizeBy)(LONG x, LONG y);
/*** INewWindowManager ***/
STDMETHOD (EvaluateNewWindow)(LPCWSTR pszUrl, LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags, DWORD dwUserActionTime);
STDMETHOD (Initialize)(BOOL fRegisterAsBrowser);
STDMETHOD (Finish)(void);
HRESULT SetExternal(IDispatch *pDispatch);
HRESULT SendCommand(INT commandId);
HRESULT QueryCommandState(INT commandId, INT *commandState);
UINT GetSecueLockIcon() { return secureLockIcon; }
BOOL TranslateKey(LPMSG pMsg);
/*Events*/
BHNAVCOMPLETECALLBACK EventDocumentReady;
BHNAVCOMPLETECALLBACK EventNavigateComplete;
BHCALLBACK EventDownloadBegin;
BHCALLBACK EventDownloadComplete;
BHCALLBACK EventContainerDestroyed;
BHCMDSTATECALLBACK EventCommandStateChange;
BHTEXTCALLBACK EventStatusChange;
BHTEXTCALLBACK EventTitleChange;
BHCALLBACK EventSecureLockIconChange;
BHCREATEPOPUPCALLBACK EventCreatePopup;
BHBOOLCALLBACK EventVisible;
BHBOOLCALLBACK EventSetResizable;
BHCLOSECALLBACK EventWindowClosing;
BHSHOWUICALLBACK EventShowUiElement;
BHCLIENTTOHOSTCALLBACK EventClientToHost;
BHWINDOWPOSCALLBACK EventSetWindowPos;
BHFOCUSCHANGECALLBACK EventFocusChange;
BHBOOLCALLBACK EventSetFullscreen;
BHCALLBACK EventClosePopup;
BHSERVICECALLBACK CallbackGetOmService;
BHMSGCALLBACK CallbackRedirectKey;
HRESULT GetExternalName(LPWSTR pszBuffer, INT cchBufferMax);
void SetUiFlags(UINT flags, UINT mask);
UINT GetUiFlags(UINT mask);
HRESULT ToggleFullscreen();
HRESULT GetTravelLog(ifc_travelloghelper **travelLog);
protected:
void OnBeforeNavigate(IDispatch *pDispatch, VARIANT *URL, VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers, VARIANT_BOOL *Cancel);
void OnDownloadBegin(void);
void OnDownloadComplete(void);
void OnNavigateComplete(IDispatch *pDispatch, VARIANT *URL);
void OnDocumentReady(IDispatch *pDispatch, VARIANT *URL);
void OnNavigateError(IDispatch *pDispatch, VARIANT *URL, VARIANT *TargetFrameName, VARIANT *StatusCode, VARIANT_BOOL *Cancel);
void OnCommandStateChange(LONG commandId, VARIANT_BOOL Enable);
void OnStatusTextChange(LPCWSTR pszText);
void OnSetSecureLockIcon(UINT secureLockIcon);
void OnNavigateCancelled(LPCWSTR pszUrl, VARIANT_BOOL *Cancel);
void OnNewWindow2(IDispatch **ppDisp, VARIANT_BOOL *Cancel);
void OnNewWindow3(IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl);
void OnTitleChange(BSTR pszText);
void OnVisibleChange(VARIANT_BOOL fVisible);
void OnWindowClosing(VARIANT_BOOL IsChildWindow, VARIANT_BOOL *Cancel);
void OnShowUiElement(UINT elementId, VARIANT_BOOL fShow);
void OnWindowSetResizable(VARIANT_BOOL Enable);
void OnEnableFullscreen(VARIANT_BOOL Enable);
void OnClientToHostWindow(LONG *CX, LONG *CY);
void OnSetWindowPos(UINT Flags, LONG X, LONG Y, LONG CX, LONG CY);
virtual COLORREF OnGetHostBkColor(void);
virtual DWORD OnGetHostInfoFlags(void);
virtual OLECHAR* OnGetHostCSS(void);
virtual DWORD OnGetDownlodFlags(void);
virtual LPCWSTR OnGetUserAgent(void);
HRESULT FormatErrorParam(LPWSTR pszBuffer, INT cchBufferMax, UINT errorCode, LPCWSTR pszUrl);
HANDLE InitializePopupHook(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void DeletePopupHook(HANDLE hHook);
void InitializeMenuPopup(HWND hwnd, HMENU hMenu, INT iPos, BOOL fWindowMenu);
BOOL InputLangChangeRequest(HWND hwnd, UINT flags, HKL hkl);
void InputLangChange(UINT charset, HKL hkl);
void OnClosePopupInternal();
HRESULT GetDebugConfig(ifc_omdebugconfig **debugConfig);
HRESULT GetErrorPageName(LPWSTR pszBuffer, HRESULT cchBufferMax, UINT errorCode, BOOL fCancel);
private:
typedef enum
{
navigationForwardEnabled = 0x0001,
navigationBackEnabled = 0x0002,
navigationActive = 0x0004,
} navigationState;
private:
obj_ombrowser *browserManager;
IDispatch *externalDisp;
IDropTargetHelper *pDropTargetHerlper;
UINT navigationState;
UINT secureLockIcon;
WCHAR szDone[64];
LPWSTR pszUserAgent;
UINT uiFlags;
};
#ifdef _DEBUG
void BrowserDebug_PrintRefs(Browser *browser);
#else
#define BrowserDebug_PrintRefs(x)
#endif //_DEBUG
#endif //NULLSOFT_WINAMP_OMBROWSER_HEADER

View File

@ -0,0 +1,191 @@
#include "main.h"
#include "./browserClass.h"
#include "./browserRegistry.h"
#include "./configIni.h"
#include <strsafe.h>
OmBrowserClass::OmBrowserClass(LPCWSTR pszName)
: ref(1), name(NULL), config(NULL), registry(NULL)
{
InitializeCriticalSection(&lock);
name = Plugin_CopyString(pszName);
}
OmBrowserClass::~OmBrowserClass()
{
if (NULL != config)
config->Release();
if (NULL != registry)
{
registry->Delete();
registry->Release();
}
Plugin_FreeString(name);
DeleteCriticalSection(&lock);
}
HRESULT OmBrowserClass::CreateInstance(LPCWSTR pszName, OmBrowserClass **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
*instance = new OmBrowserClass(pszName);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t OmBrowserClass::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t OmBrowserClass::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
{
if (NULL != name && L'\0' != *name)
Plugin_UnregisterBrowserClass(name);
delete(this);
}
return r;
}
int OmBrowserClass::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmBrowserClass))
*object = static_cast<ifc_ombrowserclass*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT OmBrowserClass::GetName(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
return StringCchCopyEx(pszBuffer, cchBufferMax, name, NULL, NULL, STRSAFE_IGNORE_NULLS);
}
HRESULT OmBrowserClass::IsEqual(LPCWSTR pszName)
{
if (NULL == pszName || L'\0' == *pszName)
return E_INVALIDARG;
if (NULL == name)
return E_UNEXPECTED;
INT result = CompareString(CSTR_INVARIANT, NORM_IGNORECASE, pszName, -1, name, -1);
if (0 == result)
{
DWORD errorCode = GetLastError();
return HRESULT_FROM_WIN32(errorCode);
}
return (CSTR_EQUAL == result) ? S_OK : S_FALSE;
}
HRESULT OmBrowserClass::GetConfig(ifc_omconfig **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
if (NULL == config)
{
hr = OmConfigIni::CreateInstance(name, &config);
if (FAILED(hr))
{
config = NULL;
}
}
if (SUCCEEDED(hr))
{
*instance = config;
config->AddRef();
}
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT OmBrowserClass::GetRegistry(ifc_ombrowserregistry **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
if (NULL == registry)
{
hr = OmBrowserRegistry::CreateInstance(name, &registry);
if (FAILED(hr))
{
registry = NULL;
}
else
{
registry->Write();
}
}
if (SUCCEEDED(hr))
{
*instance = registry;
registry->AddRef();
}
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT OmBrowserClass::UpdateRegColors()
{
HRESULT hr = S_FALSE;
EnterCriticalSection(&lock);
if (NULL != registry)
hr = registry->UpdateColors();
LeaveCriticalSection(&lock);
return hr;
}
#define CBCLASS OmBrowserClass
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETNAME, GetName)
CB(API_ISEQUAL, IsEqual)
CB(API_GETCONFIG, GetConfig)
CB(API_GETREGISTRY, GetRegistry)
CB(API_UPDATEREGCOLORS, UpdateRegColors)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,46 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_CLASS_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_CLASS_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_ombrowserclass.h"
class OmConfigIni;
class OmBrowserRegistry;
class OmBrowserClass : public ifc_ombrowserclass
{
protected:
OmBrowserClass(LPCWSTR pszName);
~OmBrowserClass();
public:
static HRESULT CreateInstance(LPCWSTR pszName, OmBrowserClass **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/*ifc_ombrowserclass */
HRESULT GetName(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT IsEqual(LPCWSTR pszName);
HRESULT GetConfig(ifc_omconfig **instance);
HRESULT GetRegistry(ifc_ombrowserregistry **instance);
HRESULT UpdateRegColors();
protected:
RECVS_DISPATCH;
protected:
ULONG ref;
CRITICAL_SECTION lock;
LPWSTR name;
OmConfigIni *config;
OmBrowserRegistry *registry;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_CLASS_HEADER

View File

@ -0,0 +1,90 @@
#include "./browserFactory.h"
#include "./browserObject.h"
FOURCC OmBrowserFactory::GetServiceType()
{
return WaSvc::UNIQUE;
}
const char *OmBrowserFactory::GetServiceName()
{
return "OmBrowser Object";
}
const char *OmBrowserFactory::GetTestString()
{
return NULL;
}
GUID OmBrowserFactory::GetGUID()
{
return OBJ_OmBrowser;
}
void *OmBrowserFactory::GetInterface( int global_lock )
{
OmBrowserObject *browserObject = NULL;
HRESULT hr = OmBrowserObject::CreateInstance( &browserObject );
if ( FAILED( hr ) )
browserObject = NULL;
return browserObject;
}
int OmBrowserFactory::ReleaseInterface( void *ifc )
{
obj_ombrowser *object = (obj_ombrowser *)ifc;
if ( object != NULL )
object->Release();
return 1;
}
int OmBrowserFactory::SupportNonLockingInterface()
{
return 1;
}
int OmBrowserFactory::ServiceNotify(int msg, int param1, int param2)
{
return 1;
}
HRESULT OmBrowserFactory::Register( api_service *service )
{
if ( service == NULL )
return E_INVALIDARG;
service->service_register( this );
return S_OK;
}
HRESULT OmBrowserFactory::Unregister( api_service *service )
{
if ( service == NULL )
return E_INVALIDARG;
service->service_deregister( this );
return S_OK;
}
#define CBCLASS OmBrowserFactory
START_DISPATCH;
CB( WASERVICEFACTORY_GETSERVICETYPE, GetServiceType )
CB( WASERVICEFACTORY_GETSERVICENAME, GetServiceName )
CB( WASERVICEFACTORY_GETGUID, GetGUID )
CB( WASERVICEFACTORY_GETINTERFACE, GetInterface )
CB( WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface )
CB( WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface )
CB( WASERVICEFACTORY_GETTESTSTRING, GetTestString )
CB( WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify )
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,40 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_SERVICEFACTORY_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_SERVICEFACTORY_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <api/service/waservicefactory.h>
#include <api/service/services.h>
class obj_ombrowser;
class OmBrowserFactory : public waServiceFactory
{
public:
OmBrowserFactory() {}
~OmBrowserFactory() {}
FOURCC GetServiceType();
const char *GetServiceName();
const char *GetTestString();
GUID GetGUID();
void *GetInterface( int global_lock = 1 );
int ReleaseInterface( void *ifc );
int SupportNonLockingInterface();
int ServiceNotify( int msg, int param1, int param2 );
HRESULT Register( api_service *service );
HRESULT Unregister( api_service *service );
protected:
RECVS_DISPATCH;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_SERVICEFACTORY_HEADER

File diff suppressed because it is too large Load Diff

180
Src/omBrowser/browserHost.h Normal file
View File

@ -0,0 +1,180 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_BROWSERHOST_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_BROWSERHOST_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
class obj_ombrowser;
typedef void (CALLBACK *DISPATCHAPC)(IDispatch *pDisp, ULONG_PTR /*param*/);
HWND BrowserHost_CreateWindow(obj_ombrowser *browserManager, HWND hParent, UINT fStyle, INT x, INT y, INT cx, INT cy, INT controlId, HACCEL hAccel);
#define NBHS_POPUP 0x00000001
#define NBHS_SCRIPTMODE 0x00000002
#define NBHS_DISABLECONTEXTMENU 0x00000004
#define NBHS_DIALOGMODE 0x00000008
#define NBHS_DISABLEHOSTCSS 0x00000010
#define NBHS_BROWSERMASK 0x0000F000
#define NBHS_BROWSERREADY 0x00001000
#define NBHS_BROWSERACTIVE 0x00002000
#define NBHM_FIRST (WM_USER + 200)
#define NBHM_DESTROY (NBHM_FIRST + 10) // wParam = (WPARAM)(BOOL)fImmediate, lParam - not used. Preffered way to close it. Returns TRUE if processed
// Post this messages
#define NBHM_CONTAINERCOMMAND (NBHM_FIRST + 11) // wParam = (WPARAM)(INT)browserCommandId, lParam - not used
#define NBHM_UPDATESKIN (NBHM_FIRST + 12) // wParam - not used, lParam - not used.
#define NBHM_NAVIGATE (NBHM_FIRST + 13) // wParam - (WPARAM)(UINT)navigateFlags, lParam = (LPARAM)(BSTR)navigateUrl.
#define NBHM_ENABLECONTAINERUPDATE (NBHM_FIRST + 14) // wParam - (WPARAM)(BOOL)fEnable, lParam = (WPARAM)(BOOL)fRedraw
#define NBHM_QUEUEAPC (NBHM_FIRST + 15) // wParam = (WPARAM)userData, lParam = (LPARAM)(PAPCFUNC)pfnAPC
#define NBHM_SHOWHISTORYPOPUP (NBHM_FIRST + 16) //wParam = (WPARAM)popupFlags, lParam =(LPARAM)MAKELPARAM(popupPos).
#define NBHM_GETDISPATCHAPC (NBHM_FIRST + 17) // wParam = (WPARAM)param, lParam = (LPARAM)(DISPATCHAPC)callback
#define NBHM_ACTIVATE (NBHM_FIRST + 18) // wParam - not used, lParam - not used. Activates browser (OLEIVERB_UIACTIVATE)
#define NBHM_QUERYTITLE (NBHM_FIRST + 19) // wParam - not used, lParam - not used. Will query for current title and send NBHN_TITLECHANGE back
#define NBHM_TOGGLEFULLSCREEN (NBHM_FIRST + 20) // wParam - not used, lParam - not used.
#define NBHM_WRITEDOCUMENT (NBHM_FIRST + 21) // wParam - not used, lParam = (LPARAM)(BSTR)bstrDocument;
#define NBHM_ENABLEWINDOW (NBHM_FIRST + 22) // wParam - not used, lParam = (LPARAM)(BOOL)fEnabled;
#define NBHM_UPDATEEXTERNAL (NBHM_FIRST + 23) // wParam - not used, lParam - not used.
#define NBHN_FIRST (200)
#define NBHN_READY (NBHN_FIRST + 0)
typedef struct __BHNNAVCOMPLETE
{
NMHDR hdr;
IDispatch *pDispatch;
VARIANT *URL;
BOOL fTopFrame;
} BHNNAVCOMPLETE;
#define NBHN_DOCUMENTREADY (NBHN_FIRST + 1)
#define NBHN_NAVIGATECOMPLETE (NBHN_FIRST + 2)
typedef struct __BHNACTIVE
{
NMHDR hdr;
BOOL fActive;
} BHNACTIVE;
#define NBHN_BROWSERACTIVE (NBHN_FIRST + 3)
typedef struct __BHNCMDSTATE
{
NMHDR hdr;
UINT commandId;
BOOL fEnabled;
} BHNCMDSTATE;
#define NBHN_COMMANDSTATECHANGE (NBHN_FIRST + 4)
typedef struct __BHNTEXTCHANGE
{
NMHDR hdr;
LPCWSTR pszText;
} BHNTEXTCHANGE;
#define NBHN_STATUSCHANGE (NBHN_FIRST + 5)
#define NBHN_TITLECHANGE (NBHN_FIRST + 6)
typedef struct __BHNSECUREICON
{
NMHDR hdr;
UINT iconId;
} BHNSECUREICON;
#define NBHN_SECUREICONCHANGE (NBHN_FIRST + 7)
typedef struct __BHNSERVICE
{
NMHDR hdr;
void *instance;
} BHNSERVICE;
#define NBHN_GETOMSERVICE (NBHN_FIRST + 8) // call service->AddRef() and return TRUE if you support this
typedef struct __BHNCREATEPOPUP
{
NMHDR hdr;
DISPATCHAPC callback;
ULONG_PTR param;
} BHNCREATEPOPUP;
#define NBHN_CREATEPOPUP (NBHN_FIRST + 9)
typedef struct __BHNVISIBLE
{
NMHDR hdr;
BOOL fVisible;
} BHNVISIBLE;
#define NBHN_VISIBLECHANGE (NBHN_FIRST + 10) // send to popup
typedef struct __BHNRESIZABLE
{
NMHDR hdr;
BOOL fEnabled;
} BHNRESIZABLE;
#define NBHN_RESIZABLE (NBHN_FIRST + 11)
typedef struct __BHNCLOSING
{
NMHDR hdr;
BOOL isChild;
BOOL cancel;
} BHNCLOSING;
#define NBHN_CLOSING (NBHN_FIRST + 12)
typedef struct __BHNSHOWUI
{
NMHDR hdr;
UINT elementId;
BOOL fShow;
} BHNSHOWUI;
#define NBHN_SHOWUI (NBHN_FIRST + 13)
typedef struct __BHNCLIENTTOHOST
{
NMHDR hdr;
LONG cx;
LONG cy;
} BHNCLIENTTOHOST;
#define NBHN_CLIENTTOHOST (NBHN_FIRST + 14)
typedef struct __BHNSETWINDOWPOS
{
NMHDR hdr;
UINT flags;
LONG x;
LONG y;
LONG cx;
LONG cy;
} BHNSETWINDOWPOS;
#define NBHN_SETWINDOWPOS (NBHN_FIRST + 15)
typedef struct __BHNFOCUSCHANGE
{
NMHDR hdr;
BOOL fAllow;
} BHNFOCUSCHANGE;
#define NBHN_FOCUSCHANGE (NBHN_FIRST + 16)
typedef struct __BHNFULLSCREEN
{
NMHDR hdr;
BOOL fEnable;
} BHNFULLSCREEN;
#define NBHN_FULLSCREEN (NBHN_FIRST + 17)
#define NBHN_CLOSEPOPUP (NBHN_FIRST + 18) // param = NMHDR
#endif // NULLSOFT_WINAMP_OMBROWSER_BROWSERHOST_HEADER

View File

@ -0,0 +1,45 @@
#include "main.h"
#include "./browserInternal.h"
#include "./resource.h"
#include <exdisp.h>
#include <strsafe.h>
#if (_MSC_VER < 1500)
// {D81F90A3-8156-44F7-AD28-5ABB87003274}
EXTERN_C const IID IID_IProtectFocus =
{ 0xd81f90a3, 0x8156, 0x44f7, { 0xad, 0x28, 0x5a, 0xbb, 0x87, 0x00, 0x32, 0x74 } };
#endif
HRESULT FormatEncryptionString(UINT encryptionId, LPWSTR pszBuffer, INT cchBufferMax)
{
HRESULT hr = S_OK;
if (secureLockIconUnsecure == encryptionId)
{
Plugin_LoadString(IDS_CONNECTION_UNSECURE, pszBuffer, cchBufferMax);
return S_OK;
}
Plugin_LoadString(IDS_CONNECTION_ENCRYPTED, pszBuffer, cchBufferMax);
INT resId = 0;
switch(encryptionId)
{
case secureLockIconMixed: resId = IDS_ENCRYPTION_MIXED; break;
case secureLockIconSecure40Bit: resId = IDS_ENCRYPTION_40BIT; break;
case secureLockIconSecure56Bit: resId = IDS_ENCRYPTION_56BIT; break;
case secureLockIconSecureFortezza: resId = IDS_ENCRYPTION_FORTEZZA; break;
case secureLockIconSecure128Bit: resId = IDS_ENCRYPTION_128BIT; break;
}
if (0 != resId)
{
WCHAR szEncryption[96] = {0};
Plugin_LoadString(resId, szEncryption, ARRAYSIZE(szEncryption));
if (L'\0' != szEncryption[0])
{
INT cchLen = lstrlen(pszBuffer);
hr = StringCchPrintf(pszBuffer + cchLen, cchBufferMax - cchLen, L": %s", szEncryption);
}
}
return hr;
}

View File

@ -0,0 +1,34 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_INTERNAL_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_INTERNAL_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#ifndef __IProtectFocus_INTERFACE_DEFINED__
#define __IProtectFocus_INTERFACE_DEFINED__
/* interface IProtectFocus */
/* [unique][uuid][object] */
EXTERN_C const IID IID_IProtectFocus;
MIDL_INTERFACE("d81f90a3-8156-44f7-ad28-5abb87003274")
IProtectFocus : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE AllowFocusChange(/* [out] */ BOOL *pfAllow) = 0;
};
#endif /* __IProtectFocus_INTERFACE_DEFINED__ */
#define SID_SProtectFocus IID_IProtectFocus
typedef void (CALLBACK *DISPATCHAPC)(IDispatch *pDisp, ULONG_PTR /*param*/);
HRESULT FormatEncryptionString(UINT encryptionId, LPWSTR pszBuffer, INT cchBufferMax);
#endif //NULLSOFT_WINAMP_OMBROWSER_INTERNAL_HEADER

View File

@ -0,0 +1,503 @@
#include "main.h"
#include "./browserObject.h"
#include "./ifc_menucustomizer.h"
#include "./ifc_wasabihelper.h"
#include "./ifc_omconfig.h"
#include "./browserView.h"
#include "./browserPopup.h"
#include "./options.h"
#include "./ifc_ombrowserconfig.h"
#include "./ifc_ombrowserregistry.h"
#include "./ifc_ombrowserevent.h"
#include "./ifc_omtoolbarconfig.h"
#include "./ifc_omstatusbarconfig.h"
#include "./ifc_ombrowserclass.h"
#include "./ifc_omservice.h"
#include "./ieversion.h"
#include "./browserWndEnum.h"
#include "./browserWndRecord.h"
#include <strsafe.h>
OmBrowserObject::OmBrowserObject() : ref(1), flags(0), browserClass(NULL)
{
InitializeCriticalSection(&lock);
}
OmBrowserObject::~OmBrowserObject()
{
if (NULL != browserClass)
browserClass->Release();
DeleteCriticalSection(&lock);
}
HRESULT OmBrowserObject::CreateInstance(OmBrowserObject **instance)
{
if (NULL == instance) return E_POINTER;
*instance = new OmBrowserObject();
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t OmBrowserObject::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t OmBrowserObject::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int OmBrowserObject::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, OBJ_OmBrowser))
*object = static_cast<obj_ombrowser*>(this);
else if (IsEqualIID(interface_guid, IFC_OmBrowserWindowManager))
*object = static_cast<ifc_ombrowserwndmngr*>(this);
else if (IsEqualIID(interface_guid, IFC_OmBrowserEventManager))
*object = static_cast<ifc_ombrowsereventmngr*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT OmBrowserObject::Initialize(LPCWSTR pszName, HWND hwndWinamp)
{
if ( browserClass != NULL )
return S_FALSE;
HRESULT hr = Plugin_Initialize(hwndWinamp);
if (SUCCEEDED(hr))
{
if (NULL == pszName || L'\0' == *pszName)
pszName = OMBROWSER_NAME;
hr = Plugin_GetBrowserClass(pszName, &browserClass);
}
return hr;
}
HRESULT OmBrowserObject::Finish(void)
{
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
flags |= flagFinishing;
size_t index = windowList.size();
while(index--)
{
OmBrowserWndRecord *r = windowList[index];
if (FALSE == DestroyWindow(r->GetHwnd()))
{
hr = E_FAIL;
}
else
{
windowList.erase(windowList.begin() + index);
r->Release();
}
}
while(!eventList.empty())
{
ifc_ombrowserevent *e = eventList.back();
if (NULL == e) break;
eventList.pop_back();
e->Release();
}
if (NULL != browserClass)
{
browserClass->Release();
browserClass = NULL;
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserObject::RegisterWinampHook(ifc_winamphook *hook, UINT *cookieOut)
{
return Plugin_RegisterWinampHook(hook, cookieOut);
}
HRESULT OmBrowserObject::UnregisterWinampHook(UINT cookie)
{
return Plugin_UnregisterWinampHook(cookie);
}
HRESULT OmBrowserObject::GetConfig(const GUID *configIfc, void **configOut)
{
if (NULL == configOut) return E_POINTER;
if (NULL == browserClass) return E_UNEXPECTED;
ifc_omconfig *config = NULL;
HRESULT hr = browserClass->GetConfig(&config);
if (SUCCEEDED(hr) && config != NULL)
{
if (NULL == configIfc || IsEqualIID(*configIfc, GUID_NULL))
*configOut = config;
else
{
hr = config->QueryInterface(*configIfc, configOut);
config->Release();
}
}
return hr;
}
HRESULT OmBrowserObject::GetSessionId(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
*pszBuffer = L'\0';
ifc_wasabihelper *wasabi = NULL;
HRESULT hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr) && wasabi != NULL)
{
api_application *app = NULL;
hr = wasabi->GetApplicationApi(&app);
if (SUCCEEDED(hr))
{
UUID uid;
if (API_APPLICATION_SUCCESS == app->GetSessionID(&uid))
{
hr = Plugin_FormatUuidString(uid, pszBuffer, cchBufferMax);
}
else
{
hr = E_FAIL;
}
app->Release();
}
wasabi->Release();
}
if (FAILED(hr))
hr = StringCchCopy(pszBuffer, cchBufferMax, L"0123456789ABCDEF");
return hr;
}
HRESULT OmBrowserObject::GetClientId(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
*pszBuffer = L'\0';
ifc_ombrowserconfig *browserConfig;
if (FAILED(GetConfig(&IFC_OmBrowserConfig, (void**)&browserConfig)))
return E_NOINTERFACE;
HRESULT hr = browserConfig->GetClientId(pszBuffer, cchBufferMax);
if (S_OK != hr)
{
UUID uid;
LPWSTR cursor = NULL;
size_t remaining = 0;
StringCchCopyEx(pszBuffer, cchBufferMax, L"WA-", &cursor, &remaining, 0);
if (RPC_S_OK != UuidCreate(&uid) ||
FAILED(Plugin_FormatUuidString(uid, cursor, remaining)) ||
FAILED(browserConfig->SetClientId(pszBuffer)))
{
*pszBuffer = L'\0';
hr = E_FAIL;
}
}
browserConfig->Release();
return hr;
}
HRESULT OmBrowserObject::GetRegistry(ifc_ombrowserregistry **registryOut)
{
if (NULL == registryOut) return E_POINTER;
if (NULL == browserClass) return E_UNEXPECTED;
return browserClass->GetRegistry(registryOut);
}
HRESULT OmBrowserObject::CreateView(ifc_omservice *service, HWND hParent, LPCWSTR forceUrl, UINT viewStyle, HWND *hView)
{
if (NULL == hView) return E_POINTER;
*hView = NULL;
if (NULL == hParent) return E_INVALIDARG;
*hView = BrowserView_Create(this, service, hParent, forceUrl, viewStyle);
if (NULL == *hView) return E_FAIL;
BrowserView_UpdateSkin(*hView, FALSE);
return S_OK;
}
HRESULT OmBrowserObject::CreatePopup(ifc_omservice *service, INT x, INT y, INT cx, INT cy, HWND hOwner, LPCWSTR forceUrl, UINT viewStyle, HWND *hWindow)
{
if (NULL == hWindow) return E_POINTER;
*hWindow = NULL;
if (NULL == hOwner && FAILED(Plugin_GetWinampWnd(&hOwner)))
return E_INVALIDARG;
HWND hPopup = BrowserPopup_Create(this, service, viewStyle, x, y, cx, cy, hOwner, NULL, 0L);
if (NULL == hPopup) return E_FAIL;
*hWindow = hPopup;
BrowserPopup_UpdateSkin(hPopup, FALSE);
if (NULL != forceUrl)
{
BrowserPopup_Navigate(hPopup, forceUrl, 0L);
}
else
{
BrowserPopup_Navigate(hPopup, NAVIGATE_HOME, 0L);
}
return S_OK;
}
HRESULT OmBrowserObject::IsFinishing(void)
{
return (0 != (flagFinishing & flags)) ? S_OK : S_FALSE;
}
HRESULT OmBrowserObject::GetClass(ifc_ombrowserclass **instance)
{
if (NULL == instance)
return E_POINTER;
*instance = browserClass;
if (NULL == *instance) return E_UNEXPECTED;
browserClass->AddRef();
return S_OK;
}
HRESULT OmBrowserObject::GetVersion(int *major, int *minor)
{
if (NULL != major) *major = OMBROWSER_VERSION_MAJOR;
if (NULL != minor) *minor = OMBROWSER_VERSION_MINOR;
return S_OK;
}
HRESULT OmBrowserObject::GetIEVersion(int *major, int *minor, int *build, int *subbuild)
{
return MSIE_GetVersion(major, minor, build, subbuild);
}
HRESULT OmBrowserObject::ShowOptions(HWND hOwner, UINT style, BROWSEROPTIONSCALLBACK callback, ULONG_PTR user)
{
return BrowserOptions_ShowDialog(this, hOwner, style, callback, user);
}
HRESULT OmBrowserObject::RegisterWindow(HWND hwnd, const GUID *windowType)
{
if (NULL == hwnd) return E_INVALIDARG;
if (S_FALSE != IsFinishing())
return E_UNEXPECTED;
EnterCriticalSection(&lock);
size_t index = windowList.size();
while(index--)
{
if (windowList[index]->GetHwnd() == hwnd)
{
LeaveCriticalSection(&lock);
return S_FALSE;
}
}
OmBrowserWndRecord *r = NULL;
HRESULT hr = OmBrowserWndRecord::CreateInstance(hwnd, windowType, &r);
if (SUCCEEDED(hr) && r != NULL)
{
windowList.push_back(r);
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserObject::UnregisterWindow(HWND hwnd)
{
if (NULL == hwnd) return E_INVALIDARG;
if (S_FALSE != IsFinishing())
return E_PENDING;
EnterCriticalSection(&lock);
size_t index = windowList.size();
while(index--)
{
OmBrowserWndRecord *r = windowList[index];
if (r->GetHwnd() == hwnd)
{
windowList.erase(windowList.begin() + index);
r->Release();
LeaveCriticalSection(&lock);
return S_OK;
}
}
LeaveCriticalSection(&lock);
return S_FALSE;
}
HRESULT OmBrowserObject::Enumerate(const GUID *windowType, UINT *serviceIdFilter, ifc_ombrowserwndenum **enumerator)
{
EnterCriticalSection(&lock);
HRESULT hr = OmBrowserWndEnumerator::CreateInstance(windowType, serviceIdFilter, windowList.size() ? &windowList.at(0) : nullptr,
windowList.size(), (OmBrowserWndEnumerator**)enumerator);
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserObject::RegisterEventHandler(ifc_ombrowserevent *eventHandler)
{
if (NULL == eventHandler)
return E_INVALIDARG;
if (S_FALSE != IsFinishing())
return E_PENDING;
EnterCriticalSection(&lock);
size_t index = eventList.size();
while (index--)
{
if (eventList[index] == eventHandler)
{
LeaveCriticalSection(&lock);
return E_FAIL;
}
}
eventList.push_back(eventHandler);
eventHandler->AddRef();
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT OmBrowserObject::UnregisterEventHandler(ifc_ombrowserevent *eventHandler)
{
if (NULL == eventHandler)
return E_INVALIDARG;
if (S_FALSE != IsFinishing())
return E_PENDING;
EnterCriticalSection(&lock);
size_t index = eventList.size();
while (index--)
{
if (eventList[index] == eventHandler)
{
eventList.erase(eventList.begin() + index);
eventHandler->Release();
LeaveCriticalSection(&lock);
return S_OK;
}
}
LeaveCriticalSection(&lock);
return S_FALSE;
}
HRESULT OmBrowserObject::Signal_WindowCreate(HWND hwnd, const GUID *windowType)
{
EnterCriticalSection(&lock);
size_t index = eventList.size();
while (index--)
{
eventList[index]->WindowCreate(hwnd, windowType);
}
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT OmBrowserObject::Signal_WindowClose(HWND hwnd, const GUID *windowType)
{
EnterCriticalSection(&lock);
size_t index = eventList.size();
while (index--)
{
eventList[index]->WindowClose(hwnd, windowType);
}
LeaveCriticalSection(&lock);
return S_OK;
}
#define CBCLASS OmBrowserObject
START_MULTIPATCH;
START_PATCH(MPIID_OMBROWSER)
M_CB(MPIID_OMBROWSER, obj_ombrowser, ADDREF, AddRef);
M_CB(MPIID_OMBROWSER, obj_ombrowser, RELEASE, Release);
M_CB(MPIID_OMBROWSER, obj_ombrowser, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_INITIALIZE, Initialize);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_FINISH, Finish);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_REGISTERWINAMPHOOK, RegisterWinampHook);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_UNREGISTERWINAMPHOOK, UnregisterWinampHook);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETCONFIG, GetConfig);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETSESSIONID, GetSessionId);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETCLIENTID, GetClientId);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETREGISTRY, GetRegistry);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_CREATEVIEW, CreateView);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_CREATEPOPUP, CreatePopup);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_ISFINISHING, IsFinishing);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETCLASS, GetClass);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETVERSION, GetVersion);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_GETIEVERSION, GetIEVersion);
M_CB(MPIID_OMBROWSER, obj_ombrowser, API_SHOWOPTIONS, ShowOptions);
NEXT_PATCH(MPIID_OMBROWSERWNDMNGR)
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, ADDREF, AddRef);
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, RELEASE, Release);
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, API_REGISTERWINDOW, RegisterWindow);
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, API_UNREGISTERWINDOW, UnregisterWindow);
M_CB(MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr, API_ENUMERATE, Enumerate);
NEXT_PATCH(MPIID_OMBROWSEREVENTMNGR)
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, ADDREF, AddRef);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, RELEASE, Release);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, API_REGISTERHANDLER, RegisterEventHandler);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, API_UNREGISTERHANDLER, UnregisterEventHandler);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, API_SIGNAL_WINDOWCREATE, Signal_WindowCreate);
M_CB(MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr, API_SIGNAL_WINDOWCLOSE, Signal_WindowClose);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

View File

@ -0,0 +1,95 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_OBJECT_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_OBJECT_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./obj_ombrowser.h"
#include "./ifc_ombrowserwndmngr.h"
#include "./ifc_ombrowsereventmngr.h"
#include <bfc/multipatch.h>
#include <vector>
#define MPIID_OMBROWSER 10
#define MPIID_OMBROWSERWNDMNGR 20
#define MPIID_OMBROWSEREVENTMNGR 30
class OmBrowserWndRecord;
class OmBrowserObject : public MultiPatch<MPIID_OMBROWSER, obj_ombrowser>,
public MultiPatch<MPIID_OMBROWSERWNDMNGR, ifc_ombrowserwndmngr>,
public MultiPatch<MPIID_OMBROWSEREVENTMNGR, ifc_ombrowsereventmngr>
{
public:
typedef enum
{
flagFinishing = 0x0001,
} Falgs;
protected:
OmBrowserObject();
~OmBrowserObject();
public:
static HRESULT CreateInstance(OmBrowserObject **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* obj_ombrowser */
HRESULT Initialize(LPCWSTR pszName, HWND hwndWinamp);
HRESULT Finish(void);
HRESULT RegisterWinampHook(ifc_winamphook *hook, UINT *cookieOut);
HRESULT UnregisterWinampHook(UINT cookie);
HRESULT GetConfig(const GUID *configIfc, void **configOut);
HRESULT GetSessionId(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT GetClientId(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT GetRegistry(ifc_ombrowserregistry **registryOut);
HRESULT CreateView(ifc_omservice *service, HWND hParent, LPCWSTR forceUrl, UINT viewStyle, HWND *hView);
HRESULT CreatePopup(ifc_omservice *service, INT x, INT y, INT cx, INT cy, HWND hOwner, LPCWSTR forceUrl, UINT viewStyle, HWND *hWindow);
HRESULT ShowOptions(HWND hOwner, UINT style, BROWSEROPTIONSCALLBACK callback, ULONG_PTR user);
HRESULT IsFinishing(void);
HRESULT GetClass(ifc_ombrowserclass **instance);
HRESULT GetVersion(int *major, int *minor);
HRESULT GetIEVersion(int *major, int *minor, int *build, int *subbuild);
/* ifc_ombrowserwndmngr */
HRESULT RegisterWindow(HWND hwnd, const GUID *windowType);
HRESULT UnregisterWindow(HWND hwnd);
HRESULT Enumerate(const GUID *windowType, UINT *serviceIdFilter, ifc_ombrowserwndenum **enumerator);
/* ifc_ombrowsereventmngr */
HRESULT RegisterEventHandler(ifc_ombrowserevent *eventHandler);
HRESULT UnregisterEventHandler(ifc_ombrowserevent *eventHandler);
HRESULT Signal_WindowCreate(HWND hwnd, const GUID *windowType);
HRESULT Signal_WindowClose(HWND hwnd, const GUID *windowType);
protected:
LPCWSTR GetConfigFileInt(void);
protected:
typedef struct __WindowRecord
{
HWND hwnd;
GUID type;
} WindowRecord;
typedef std::vector<OmBrowserWndRecord*> WindowList;
typedef std::vector<ifc_ombrowserevent*> EventList;
protected:
ULONG ref;
UINT flags;
WindowList windowList;
ifc_ombrowserclass *browserClass;
EventList eventList;
CRITICAL_SECTION lock;
protected:
RECVS_MULTIPATCH;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_OBJECT_HEADER

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_POPUP_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_POPUP_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./browserUiCommon.h"
#define NWC_OMBROWSERPOPUP L"Nullsoft_omBrowserPopup"
// {6EFB8AF7-C54F-43fb-B1DD-DF2EE7E67703}
static const GUID WTID_BrowserPopup =
{ 0x6efb8af7, 0xc54f, 0x43fb, { 0xb1, 0xdd, 0xdf, 0x2e, 0xe7, 0xe6, 0x77, 0x3 } };
// {00000010-0000-00FF-8000-C5E2FB8CD50B} // guid will be incremented for each instance
static const GUID SkinClass_BrowserPopup =
{ 0x00000010, 0x0000, 0x00FF, { 0x80, 0x00, 0xc5, 0xe2, 0xfb, 0x8c, 0xd5, 0xb } };
typedef void (CALLBACK *DISPATCHAPC)(IDispatch *pDisp, ULONG_PTR /*param*/);
HWND BrowserPopup_Create(obj_ombrowser *browserManager, ifc_omservice *service, UINT fStyle, INT x, INT y, INT cx, INT cy, HWND hOwner, DISPATCHAPC callback, ULONG_PTR param);
// browser common messages
#define BrowserPopup_GetToolbar(/*HWND*/ __hwndPopup)\
BrowserControl_GetToolbar(__hwndPopup)
#define BrowserPopup_GetStatusbar(/*HWND*/ __hwndPopup)\
BrowserControl_GetStatusbar(__hwndPopup)
#define BrowserPopup_GetHost(/*HWND*/ __hwndPopup)\
BrowserControl_GetHost(__hwndPopup)
#define BrowserPopup_UpdateSkin(/*HWND*/ __hwndPopup, /*BOOL*/ __fRedraw)\
BrowserControl_UpdateSkin(__hwndPopup, __fRedraw)
#define BrowserPopup_GetService(/*HWND*/ __hwndPopup, /*ifc_omservice** */ __serviceOut)\
BrowserControl_GetService(__hwndPopup, __serviceOut)
#define BrowserPopup_Navigate(/*HWND*/ __hwndPopup, /*LPCWSTR*/ __navigateUrl, /*BOOL*/ __scheduleBlocked)\
BrowserControl_Navigate(__hwndPopup, __navigateUrl, __scheduleBlocked)
#define BrowserPopup_NavigateHome(/*HWND*/ __hwndPopup, /*BOOL*/ __scheduleBlocked)\
BrowserPopup_Navigate((__hwndPopup), NAVIGATE_HOME, (__scheduleBlocked))
#define BrowserPopup_WriteDocument(/*HWND*/ __hwndPopup, /*BSTR*/ __documentData, /*BOOL*/ __scheduleBlocked)\
BrowserControl_WriteDocument(__hwndPopup, __documentData, __scheduleBlocked)
#define BrowserPopup_ShowOperation(/*HWND*/ __hwndView, /*const OPERATIONINFO* */ __pOperationInfo)\
BrowserControl_ShowOperation(__hwndView, __pOperationInfo)
// browser popup messages
#define NBPM_PARENTCHANGED (NBPM_FIRST + 1) // wParam = not used, lParam = not used
#define NBPM_SKINREFRESHING (NBPM_FIRST + 2) // wParam = not used, lParam = not used. Return 0 to allow, non zero to prevent.
#define BrowserPopup_SkinRefreshing(/*HWND*/ __hwndPopup)\
SENDMSG((__hwndPopup), NBPM_SKINREFRESHING, 0, 0L)
#define NBPM_SKINREFRESHED (NBPM_FIRST + 3) // wParam = not used, lParam = not used.
#define BrowserPopup_SkinRefreshed(/*HWND*/ __hwndPopup)\
SENDMSG((__hwndPopup), NBPM_SKINREFRESHED, 0, 0L)
#define NBPM_SETFRAMEPOS (NBPM_FIRST + 4) // wParam = not used, lParam = (LPARAM)(WINDOWPOS*)pwp;
#define BrowserPopup_SetFramePos(/*HWND*/ __hwndPopup, /*HWND*/__hwndInsertAfter, /*INT*/ __x, /*INT*/ __y, /*INT*/__cx, /*INT*/ __cy, /*UINT*/ __flags)\
{ WINDOWPOS wp; wp.hwndInsertAfter = (__hwndInsertAfter); wp.x = (__x); wp.y = (__y); wp.cx = (__cx); wp.cy = (__cy); wp.flags = (__flags);\
SENDMSG((__hwndPopup), NBPM_SETFRAMEPOS, 0, (LPARAM)(&wp));}
#define NBPM_ACTIVATEFRAME (NBPM_FIRST + 5) // wParam = not used, lParam = not used.
#define BrowserPopup_ActivateFrame(/*HWND*/ __hwndPopup)\
SENDMSG((__hwndPopup), NBPM_ACTIVATEFRAME, 0, 0L)
#define NBPM_REFRESHTITLE (NBPM_FIRST + 6) // wParam - not used, lParam - not used, return TRUE on success
#define BrowserPopup_RefreshTitle(/*HWND*/ __hwndPopup)\
((BOOL)SENDMSG((__hwndPopup), NBPM_REFRESHTITLE, 0, 0L))
#endif //NULLSOFT_WINAMP_OMBROWSER_POPUP_HEADER

View File

@ -0,0 +1,356 @@
#include "main.h"
#include "./browserRegistry.h"
#include "./obj_ombrowser.h"
#include "./ifc_wasabihelper.h"
#include "./ifc_skinhelper.h"
#include "./ifc_skinnedbrowser.h"
#include "./ifc_ombrowserclass.h"
#include "./ifc_omconfig.h"
#include "./ifc_omdebugconfig.h"
#include "../Plugins/General/gen_ml/colors.h"
#include <shlwapi.h>
#include <strsafe.h>
#define YES L"yes"
#define NO L"no"
#define REGVAL_DWORD(__regKey, __valueName, __data) { DWORD __iVal = (__data); RegSetValueExW((__regKey), (__valueName), NULL, REG_DWORD, (LPCBYTE)&__iVal, sizeof(DWORD)); }
#define REGVAL_STR(__regKey, __valueName, __data, __cbData) RegSetValueExW((__regKey), (__valueName), NULL, REG_SZ, (LPCBYTE)(__data), (__cbData))
#define REGVAL_ONE(__regKey, __valueName) REGVAL_DWORD(__regKey, __valueName, 1)
#define REGVAL_ZERO(__regKey, __valueName) REGVAL_DWORD(__regKey, __valueName, 0)
#define REGVAL_YES(__regKey, __valueName) REGVAL_STR(__regKey, __valueName, YES, sizeof(YES))
#define REGVAL_NO(__regKey, __valueName) REGVAL_STR(__regKey, __valueName, NO, sizeof(NO))
#define REGVAL_YESNO(__regKey, __valueName, __condition) ((0 != (__condition)) ? REGVAL_YES(__regKey, __valueName) : REGVAL_NO(__regKey, __valueName))
#define REGVAL_RGB(__regKey, __valueName, __rgb)\
{ WCHAR szRGB[64] = {0}; COLORREF c = (__rgb);\
StringCchPrintfW(szRGB, ARRAYSIZE(szRGB), L"%d,%d,%d", GetRValue(c), GetGValue(c), GetBValue(c));\
INT cbLen = lstrlenW(szRGB) * sizeof(WCHAR);\
REGVAL_STR(__regKey, __valueName, szRGB, cbLen);}
OmBrowserRegistry::OmBrowserRegistry(LPCWSTR pszName)
: ref(1), name(NULL), path(NULL)
{
name = Plugin_CopyString(pszName);
}
OmBrowserRegistry::~OmBrowserRegistry()
{
Plugin_FreeString(name);
Plugin_FreeString(path);
}
HRESULT OmBrowserRegistry::CreateInstance(LPCWSTR pszName, OmBrowserRegistry **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
if (NULL == pszName || L'\0' == *pszName)
pszName = OMBROWSER_NAME;
*instance = new OmBrowserRegistry(pszName);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t OmBrowserRegistry::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t OmBrowserRegistry::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int OmBrowserRegistry::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmBrowserRegistry))
*object = static_cast<ifc_ombrowserregistry*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT OmBrowserRegistry::Write()
{
HKEY hKey = NULL;
HKEY hKey2 = NULL;
LONG result;
DWORD disposition;
if (FAILED(CreateRoot(&hKey, NULL)))
return E_FAIL;
result = RegCreateKeyExW(hKey, L"Main", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
REGVAL_ONE(hKey2, L"AllowWindowReuse");
HRESULT hr(S_FALSE);
ifc_ombrowserclass *browserClass;
if (SUCCEEDED(Plugin_GetBrowserClass(name, &browserClass)))
{
ifc_omconfig *config;
if (SUCCEEDED(browserClass->GetConfig(&config)))
{
ifc_omdebugconfig *debugConfig;
if (SUCCEEDED(config->QueryInterface(IFC_OmDebugConfig, (void**)&debugConfig)))
{
hr = debugConfig->GetScriptDebuggerEnabled();
debugConfig->Release();
}
config->Release();
}
browserClass->Release();
}
REGVAL_YESNO(hKey2, L"Disable Script Debugger", (S_FALSE == hr));
REGVAL_NO(hKey2, L"Check_Associations");
REGVAL_ZERO(hKey2, L"EnableSearchPane");
REGVAL_NO(hKey2, L"Friendly http errors");
REGVAL_NO(hKey2, L"FullScreen");
REGVAL_NO(hKey2, L"Save_Session_History_On_Exit");
REGVAL_NO(hKey2, L"Use_DlgBox_Colors");
REGVAL_YES(hKey2, L"ShowedCheckBrowser");
REGVAL_STR(hKey2, L"Start Page", L"", sizeof(L""));
REGVAL_STR(hKey2, L"Default_Page_URL", L"about:blank", sizeof(L"about:blank"));
REGVAL_STR(hKey2, L"Default_Search_URL", L"about:blank", sizeof(L"about:blank"));
REGVAL_NO(hKey2, L"Enable Browser Extensions");
REGVAL_NO(hKey2, L"Error Dlg Details Pane Open");
REGVAL_NO(hKey2, L"Error Dlg Displayed On Every Error");
REGVAL_ONE(hKey2, L"NoUpdateCheck");
REGVAL_NO(hKey2, L"Save_Session_History_On_Exit");
REGVAL_ONE(hKey2, L"NoJITSetup");
REGVAL_ONE(hKey2, L"NoWebJITSetup");
REGVAL_ONE(hKey2, L"RunOnceComplete");
REGVAL_ONE(hKey2, L"RunOnceHasShown");
REGVAL_ONE(hKey2, L"SearchMigrated");
RegCloseKey(hKey2);
}
result = RegCreateKeyExW(hKey, L"MenuExt", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
RegCloseKey(hKey2);
}
result = RegCreateKeyExW(hKey, L"New Windows", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
REGVAL_ZERO(hKey2, L"PlaySound");
REGVAL_ONE(hKey2, L"PopupMgr");
RegCloseKey(hKey2);
}
result = RegCreateKeyExW(hKey, L"SearchScopes", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
RegCloseKey(hKey2);
}
result = RegCreateKeyExW(hKey, L"SearchUrl", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
RegCloseKey(hKey2);
}
result = RegCreateKeyExW(hKey, L"URLSearchHooks", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
RegCloseKey(hKey2);
}
HRESULT hr = WriteColors(hKey);
RegCloseKey(hKey);
return hr;
}
HRESULT OmBrowserRegistry::Delete()
{
HRESULT hr;
WCHAR szBuffer[512] = {0};
hr = GetPath(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
LONG result = SHDeleteKey(HKEY_CURRENT_USER, szBuffer);
hr = (ERROR_SUCCESS != result) ? E_FAIL : S_OK;
return hr;
}
HRESULT OmBrowserRegistry::UpdateColors()
{
HKEY hKey;
HRESULT hr = CreateRoot(&hKey, NULL);
if (FAILED(hr)) return hr;
hr = WriteColors(hKey);
RegCloseKey(hKey);
return hr;
}
HRESULT OmBrowserRegistry::GetPath(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer)
return E_POINTER;
if (NULL == path)
{
HRESULT hr = CreatePath(pszBuffer, cchBufferMax);
if (FAILED(hr)) return hr;
path = Plugin_CopyString(pszBuffer);
}
return StringCchPrintfW(pszBuffer, cchBufferMax, path);
}
HRESULT OmBrowserRegistry::CreatePath(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
if (NULL == name || L'\0' == *name) return E_INVALIDARG;
HRESULT hr;
WCHAR szApp[128] = {0}, szSessionId[128] = {0};
ifc_wasabihelper *wasabi;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr))
{
api_application *app;
hr = wasabi->GetApplicationApi(&app);
if (SUCCEEDED(hr))
{
if (FAILED(StringCchCopyEx(szApp, ARRAYSIZE(szApp), app->main_getAppName(), NULL, NULL, STRSAFE_IGNORE_NULLS)))
szApp[0] = L'\0';
UUID uid;
if (API_APPLICATION_SUCCESS == app->GetSessionID(&uid))
{
RPC_WSTR pszUid;
if (RPC_S_OK == UuidToString(&uid, &pszUid))
{
if(FAILED(StringCchCopy(szSessionId, ARRAYSIZE(szSessionId), (LPCWSTR)pszUid)))
szSessionId[0] = L'\0';
RpcStringFree(&pszUid);
}
}
app->Release();
}
wasabi->Release();
}
if (L'\0' == szApp[0])
hr = StringCchCopy(szApp, ARRAYSIZE(szApp), L"Winamp");
if (L'\0' == szSessionId[0])
hr = StringCchPrintf(szSessionId, ARRAYSIZE(szSessionId), L"%u", GetCurrentProcessId());
if (SUCCEEDED(hr))
hr = StringCchPrintfW(pszBuffer, cchBufferMax, L"Software\\%s\\%s\\%s", szApp, name, szSessionId);
if (FAILED(hr))
*pszBuffer = L'\0';
return hr;
}
HRESULT OmBrowserRegistry::CreateRoot(HKEY *hKey, DWORD *pDisposition)
{
if (NULL == path)
{
WCHAR szBuffer[2048] = {0};
HRESULT hr = CreatePath(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
path = Plugin_CopyString(szBuffer);
if (NULL == path) return E_OUTOFMEMORY;
}
if (NULL == path || L'\0' == *path)
return E_UNEXPECTED;
DWORD disposition;
LONG result = RegCreateKeyExW(HKEY_CURRENT_USER, path, NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, hKey, &disposition);
if (ERROR_SUCCESS != result)
{
return E_FAIL;
}
if (NULL != pDisposition)
*pDisposition = disposition;
return S_OK;
}
HRESULT OmBrowserRegistry::WriteColors(HKEY hKey)
{
return S_OK;
ifc_skinnedbrowser *skinnedBrowser;
HRESULT hr = Plugin_GetBrowserSkin(&skinnedBrowser);
if (FAILED(hr)) return E_FAIL;
LONG result;
DWORD disposition;
HKEY hKey2 = NULL;
result = RegCreateKeyExW(hKey, L"Settings", NULL, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hKey2, &disposition);
if (ERROR_SUCCESS == result)
{
REGVAL_RGB(hKey2, L"Text Color", skinnedBrowser->GetTextColor());
REGVAL_RGB(hKey2, L"Background Color", skinnedBrowser->GetBackColor());
REGVAL_RGB(hKey2, L"Anchor Color", skinnedBrowser->GetLinkColor());
REGVAL_RGB(hKey2, L"Anchor Color Hover", skinnedBrowser->GetHoveredLinkColor());
REGVAL_YES(hKey2, L"Use Anchor Hover Color");
REGVAL_RGB(hKey2, L"Anchor Color Visited", skinnedBrowser->GetVisitedLinkColor());
RegCloseKey(hKey2);
}
skinnedBrowser->Release();
return hr;
}
#define CBCLASS OmBrowserRegistry
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETPATH, GetPath)
CB(API_WRITE, Write)
CB(API_DELETE, Delete)
CB(API_UPDATECOLORS, UpdateColors)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,49 @@
#ifndef NULLSOFT_WINAMP_BROWSER_REGISTRY_HEADER
#define NULLSOFT_WINAMP_BROWSER_REGISTRY_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_ombrowserregistry.h"
class obj_ombrowser;
class OmBrowserRegistry : public ifc_ombrowserregistry
{
protected:
OmBrowserRegistry(LPCWSTR pszName);
~OmBrowserRegistry();
public:
static HRESULT CreateInstance(LPCWSTR pszName, OmBrowserRegistry **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_ombrowserregistry */
HRESULT GetPath(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT Write(void);
HRESULT Delete(void);
HRESULT UpdateColors(void);
protected:
HRESULT CreatePath(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT CreateRoot(HKEY *hKey, DWORD *pDisposition);
HRESULT WriteColors(HKEY hKey);
protected:
RECVS_DISPATCH;
protected:
ULONG ref;
LPWSTR name;
LPWSTR path;
};
#endif //NULLSOFT_WINAMP_BROWSER_REGISTRY_HEADER

View File

@ -0,0 +1,413 @@
#include "main.h"
#include "./browserThread.h"
#include "../nu/threadname.h"
#include <exdisp.h>
typedef struct __BROWSERTHREADCRAEATEPARAM
{
BTCREATEWNDPROC fnCreateWnd;
BTKEYFILTERPROC fnKeyFilter;
ULONG_PTR user;
HANDLE readyEvent;
HWND hHost;
HWND hWinamp;
} BROWSERTHREADCREATEPARAM;
typedef struct __BROWSERTHREAD
{
HHOOK messageHook;
HANDLE wakeupEvent;
UINT flags;
} BROWSERTHREAD;
#define NAVIGATE_WAITTIMEOUT 30
static size_t tlsIndex = TLS_OUT_OF_INDEXES;
static UINT BHTM_DESTROY = 0xFEFE;
static DWORD CALLBACK BrowserThread_MainLoop(LPVOID param);
#define GetThreadInstance() ((TLS_OUT_OF_INDEXES != tlsIndex) ? (BROWSERTHREAD*)Plugin_TlsGetValue(tlsIndex) : NULL)
BOOL BrowserThread_IsQuiting()
{
BROWSERTHREAD *thread = GetThreadInstance();
return (NULL == thread || 0 != ((BHTF_BEGINDESTROY | BHTF_QUITLOOP) & thread->flags));
}
BOOL BrowserThread_SetFlags(UINT flags, UINT flagsMask, BOOL fAlarm)
{
BROWSERTHREAD *thread = GetThreadInstance();
if (NULL == thread) return FALSE;
thread->flags = ((thread->flags & flagsMask) | flags);
if (FALSE == fAlarm)
return TRUE;
return (NULL != thread->wakeupEvent && SetEvent(thread->wakeupEvent));
}
HANDLE BrowserThread_Create(HWND hWinamp, BTCREATEWNDPROC fnCreateWnd, ULONG_PTR user, BTKEYFILTERPROC fnKeyFilter, HWND *pWnd, DWORD *pThreadId)
{
if (NULL == fnCreateWnd)
return NULL;
if (TLS_OUT_OF_INDEXES == tlsIndex)
{
tlsIndex = Plugin_TlsAlloc();
if (TLS_OUT_OF_INDEXES == tlsIndex)
return NULL;
}
DWORD threadId;
BROWSERTHREADCREATEPARAM param;
ZeroMemory(&param, sizeof(BROWSERTHREADCREATEPARAM));
param.fnCreateWnd = fnCreateWnd;
param.fnKeyFilter = fnKeyFilter;
param.user = user;
param.readyEvent = CreateEvent(0, TRUE, FALSE, 0);
param.hWinamp = hWinamp;
HANDLE hThread = CreateThread(NULL, 0, BrowserThread_MainLoop, (LPVOID)&param, 0, &threadId);
if (NULL != hThread)
{
if (NULL != param.readyEvent)
WaitForSingleObject(param.readyEvent, INFINITE);
}
else
{
if (NULL != param.hHost)
{
DestroyWindow(param.hHost);
param.hHost = NULL;
}
threadId = 0;
}
if (NULL != param.readyEvent)
CloseHandle(param.readyEvent);
if (NULL != pThreadId)
*pThreadId = threadId;
if (NULL != pWnd)
*pWnd = param.hHost;
return hThread;
}
BOOL BrowserThread_PostDestroyEx(DWORD threadId, HWND hHost)
{
if (0 == BHTM_DESTROY)
BHTM_DESTROY = RegisterWindowMessage(L"omBrowserDestroyMsg");
if (0 == BHTM_DESTROY ||
FALSE == PostThreadMessage(threadId, BHTM_DESTROY, 0, (LPARAM)hHost))
{
return FALSE;
}
BrowserThread_SetFlags(BHTF_BEGINDESTROY, BHTF_BEGINDESTROY, FALSE);
return TRUE;
}
BOOL BrowserThread_PostDestroy(HWND hHost)
{
return BrowserThread_PostDestroyEx(GetCurrentThreadId(), hHost);
}
BOOL BrowserThread_WaitNavigateComplete(IWebBrowser2 *pWeb2, UINT waitMax)
{
MSG msg;
READYSTATE state;
if (NULL == pWeb2)
return FALSE;
BOOL resultOk = FALSE;
DWORD tickStart = GetTickCount();
for(;;)
{
if (FAILED(pWeb2->get_ReadyState(&state)))
break;
if (READYSTATE_INTERACTIVE <= state)
{
resultOk = TRUE;
break;
}
else
{
DWORD tickNow = GetTickCount();
if (tickNow < tickStart || (tickNow - tickStart) >= waitMax)
{
break; // time out
}
}
DWORD status = MsgWaitForMultipleObjectsEx(0, NULL, NAVIGATE_WAITTIMEOUT, QS_POSTMESSAGE | QS_TIMER | QS_SENDMESSAGE, MWMO_ALERTABLE);
switch(status)
{
case (WAIT_OBJECT_0 + 0):
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!CallMsgFilter(&msg, MSGF_BROWSERLOOP))
{
DispatchMessageW(&msg);
}
}
break;
}
}
return resultOk;
}
static BOOL BrowserThread_HandleMessage(MSG *pMsg)
{
switch(pMsg->message)
{
case WM_QUIT:
BrowserThread_SetFlags(BHTF_QUITLOOP, BHTF_QUITLOOP, TRUE);
return TRUE;
}
if (0 != BHTM_DESTROY && BHTM_DESTROY == pMsg->message)
{
HWND hHost = (HWND)pMsg->lParam;
if (NULL != hHost)
{
BrowserThread_SetFlags(BHTF_BEGINDESTROY, BHTF_BEGINDESTROY, FALSE);
SendMessage(hHost, BTM_RELEASECONTAINER, 0, 0L);
DestroyWindow(hHost);
}
return TRUE;
}
return FALSE;
}
static LRESULT CALLBACK BrowserThread_MessageFilterProc(INT code, WPARAM wParam, LPARAM lParam)
{
BROWSERTHREAD *thread = GetThreadInstance();
if (code >= 0)
{
if (BrowserThread_HandleMessage((MSG*)lParam))
{
return TRUE;
}
}
return (NULL != thread && NULL != thread->messageHook) ?
CallNextHookEx(thread->messageHook, code, wParam, lParam) :
FALSE;
}
static BOOL CALLBACK BrowserThread_DefaultKeyFilter(HWND hwnd, MSG *pMsg)
{
return FALSE;
}
inline static BOOL BrowserThread_ProcessMessage(HWND hHost, HWND hWinamp, MSG *pMsg, BTKEYFILTERPROC IsHostMessage)
{
if (hHost != pMsg->hwnd && FALSE == IsChild(hHost, pMsg->hwnd))
return FALSE;
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
{
if (FALSE != IsHostMessage(hHost, pMsg))
return TRUE;
switch(pMsg->wParam)
{
case VK_TAB:
{
HWND hOwner = (HWND)(LONG_PTR)GetWindowLongPtr(hHost, GWLP_HWNDPARENT);
if (NULL == hOwner || hWinamp == hOwner)
hOwner = hHost;
return IsDialogMessageW(hOwner, pMsg);
}
break;
}
}
if (pMsg->message == WM_MOUSEWHEEL)
{
POINT cursor;
HWND targetWindow;
POINTSTOPOINT(cursor, pMsg->lParam);
targetWindow = WindowFromPoint(cursor);
if (NULL != targetWindow &&
FALSE == IsChild(hHost, targetWindow ) &&
GetWindowThreadProcessId(targetWindow, NULL) != GetWindowThreadProcessId(hHost, NULL))
{
PostMessage(hWinamp, pMsg->message, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
return FALSE;
}
static void BrowserThread_FinishThread(BROWSERTHREAD *thread)
{
if (NULL != thread)
{
if (NULL != thread->messageHook)
{
UnhookWindowsHookEx(thread->messageHook);
thread->messageHook = NULL;
}
if (NULL != thread->wakeupEvent)
{
CloseHandle(thread->wakeupEvent);
thread->wakeupEvent = NULL;
}
}
if (TLS_OUT_OF_INDEXES != tlsIndex)
Plugin_TlsSetValue(tlsIndex, NULL);
OleUninitialize();
#ifdef _DEBUG
aTRACE_FMT("[%d] %S: thread exit\r\n", GetCurrentThreadId(), OMBROWSER_NAME);
#endif // _DEBUG
}
static DWORD CALLBACK BrowserThread_MainLoop(LPVOID param)
{
#ifdef _DEBUG
SetThreadName(GetCurrentThreadId(), "omBrowserThread");
aTRACE_FMT("[%d] %S: thread created\r\n", GetCurrentThreadId(), OMBROWSER_NAME);
#endif //_DEBUG
BROWSERTHREADCREATEPARAM *createParam = (BROWSERTHREADCREATEPARAM*)param;
HWND hWinamp = createParam->hWinamp;
BROWSERTHREAD thread;
ZeroMemory(&thread, sizeof(BROWSERTHREAD));
if (TLS_OUT_OF_INDEXES != tlsIndex)
Plugin_TlsSetValue(tlsIndex, &thread);
MSG msg;
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
BTKEYFILTERPROC IsHostMessage = (NULL != createParam->fnKeyFilter) ? createParam->fnKeyFilter : BrowserThread_DefaultKeyFilter;
thread.messageHook = SetWindowsHookEx(WH_MSGFILTER, BrowserThread_MessageFilterProc, NULL, GetCurrentThreadId());
thread.wakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
HWND hHost = createParam->fnCreateWnd(createParam->user);
createParam->hHost = hHost;
#ifdef _DEBUG
if (NULL != hHost)
aTRACE_FMT("[%d] %S: host created\r\n", GetCurrentThreadId(), OMBROWSER_NAME);
else
aTRACE_FMT("[%d] %S: host creation fialed\r\n", GetCurrentThreadId(), OMBROWSER_NAME);
#endif //_DEBUG
if (NULL != createParam->readyEvent)
SetEvent(createParam->readyEvent);
if (NULL != hHost && FAILED(OleInitialize(0)))
{
DestroyWindow(hHost);
hHost = NULL;
}
if (NULL == hHost)
{
BrowserThread_FinishThread(&thread);
return -1;
}
SendMessage(hHost, BTM_INITCONTAINER, (WPARAM)hWinamp, 0L);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
while (0 == (BHTF_QUITLOOP & thread.flags))
{
DWORD status = MsgWaitForMultipleObjectsEx(1, &thread.wakeupEvent, INFINITE,
QS_ALLPOSTMESSAGE | QS_ALLINPUT, MWMO_ALERTABLE | MWMO_INPUTAVAILABLE);
switch(status)
{
case (WAIT_OBJECT_0 + 0):
// wake up!!!
break;
case (WAIT_OBJECT_0 + 1):
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!CallMsgFilter(&msg, MSGF_BROWSERLOOP) && NULL != msg.hwnd)
{
if (0 == (BHTF_BEGINDESTROY & thread.flags))
{
if (FALSE == BrowserThread_ProcessMessage(hHost, hWinamp, &msg, IsHostMessage))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
else
{
DispatchMessageW(&msg);
}
}
}
break;
}
}
BrowserThread_FinishThread(&thread);
return 0;
}
INT BrowserThread_ModalLoop(HWND hwnd, HANDLE hCancel, DWORD timeout)
{
MSG msg;
for (;;)
{
DWORD status = MsgWaitForMultipleObjectsEx(1, &hCancel, timeout, QS_ALLINPUT, MWMO_ALERTABLE | MWMO_INPUTAVAILABLE);
if (WAIT_OBJECT_0 == status)
{
return 0;
}
else if ((WAIT_OBJECT_0 + 1) == status)
{
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
PostQuitMessage((INT)msg.wParam);
return (INT)msg.wParam;
}
if (!IsDialogMessageW(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
}
}
return 0;
}

View File

@ -0,0 +1,34 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_BROWSERTHREAD_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_BROWSERTHREAD_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
interface IWebBrowser2;
#define MSGF_BROWSERLOOP (MSGF_USER + 1)
#define BHTF_QUITLOOP 0x00000001
#define BHTF_BEGINDESTROY 0x00000002
typedef HWND (CALLBACK *BTCREATEWNDPROC)(ULONG_PTR /*user*/);
typedef BOOL (CALLBACK *BTKEYFILTERPROC)(HWND /*hwnd*/, MSG* /*pMsg*/);
HANDLE BrowserThread_Create(HWND hWinamp, BTCREATEWNDPROC fnCreateWnd, ULONG_PTR user, BTKEYFILTERPROC fnKeyFilter, HWND *pWnd, DWORD *pThreadId);
BOOL BrowserThread_IsQuiting();
BOOL BrowserThread_SetFlags(UINT flags, UINT flagsMask, BOOL fAlarm);
BOOL BrowserThread_WaitNavigateComplete(IWebBrowser2 *pWeb2, UINT waitMax);
BOOL BrowserThread_PostDestroy(HWND hHost);
BOOL BrowserThread_PostDestroyEx(DWORD threadId, HWND hHost);
INT BrowserThread_ModalLoop(HWND hwnd, HANDLE hCancel, DWORD timeout);
#define BTM_FIRST (WM_APP - 10)
#define BTM_INITCONTAINER (BTM_FIRST + 0) // wParam - not used, lParam - not used, return - ignored
#define BTM_RELEASECONTAINER (BTM_FIRST + 1) // wParam - not used, lParam - not used; return - ignored;
#endif //NULLSOFT_WINAMP_OMBROWSER_BROWSERTHREAD_HEADER

View File

@ -0,0 +1,694 @@
#include "main.h"
#include "./browserUiCommon.h"
#include "./browserUiInternal.h"
#include "./toolbar.h"
#include "./statusbar.h"
#include "./curtain.h"
#include "./browserHost.h"
#include "./obj_ombrowser.h"
#include "./ifc_omservice.h"
#include "./ifc_omservicecommand.h"
#include "./ifc_omtoolbarconfig.h"
#include "./ifc_omstatusbarconfig.h"
#include "./resource.h"
#define IDC_OPERATIONWIDGET 0x1010
static HACCEL commonTable = NULL;
static HACCEL popupTable = NULL;
static BOOL regiterUnload = TRUE;
static void CALLBACK BrowserControl_OnPluginUnload()
{
if (NULL != commonTable)
{
DestroyAcceleratorTable(commonTable);
commonTable = NULL;
}
if (NULL != popupTable)
{
DestroyAcceleratorTable(popupTable);
popupTable = NULL;
}
}
static HACCEL BrowserControl_LoadCommonAccel()
{
if (NULL != commonTable)
return commonTable;
commonTable = Plugin_LoadAccelerators(MAKEINTRESOURCE(IDR_BROWSERACCEL));
if (FALSE != regiterUnload && NULL != commonTable)
{
Plugin_RegisterUnloadCallback(BrowserControl_OnPluginUnload);
regiterUnload = FALSE;
}
return commonTable;
}
static HACCEL BrowserControl_LoadPoppupAccel()
{
if (NULL != popupTable)
return popupTable;
UINT cCommon, cPopup, cTotal = 0;
HACCEL hCommon = Plugin_LoadAccelerators(MAKEINTRESOURCE(IDR_BROWSERACCEL));
cCommon = (NULL != hCommon) ? CopyAcceleratorTable(hCommon, NULL, 0) : 0;
HACCEL hPopup = Plugin_LoadAccelerators(MAKEINTRESOURCE(IDR_BROWSERPOPUPACCEL));
cPopup = (NULL != hPopup) ? CopyAcceleratorTable(hPopup, NULL, 0) : 0;
cTotal += (cCommon + cPopup);
if (0 != cTotal)
{
ACCEL *pAccel = (ACCEL*)calloc(cTotal, sizeof(ACCEL));
if (NULL != pAccel)
{
UINT copied = 0;
if (NULL != hCommon)
copied += CopyAcceleratorTable(hCommon, pAccel + copied, cTotal - copied);
if (NULL != hPopup)
copied += CopyAcceleratorTable(hPopup, pAccel + copied, cTotal - copied);
if (0 != copied)
popupTable = CreateAcceleratorTable(pAccel, copied);
free(pAccel);
}
}
if (NULL != hCommon)
DestroyAcceleratorTable(hCommon);
if (NULL != hPopup)
DestroyAcceleratorTable(hPopup);
if (FALSE != regiterUnload && NULL != popupTable)
{
Plugin_RegisterUnloadCallback(BrowserControl_OnPluginUnload);
regiterUnload = FALSE;
}
return popupTable;
}
HACCEL BrowserControl_GetAccelTable(UINT tableType)
{
switch(tableType)
{
case ACCELTABLE_VIEW:
return BrowserControl_LoadCommonAccel();
case ACCELTABLE_POPUP:
return BrowserControl_LoadPoppupAccel();
}
return NULL;
}
static void BrowserControl_ShowHistoryPopup(HWND hControl)
{
HWND hBrowser = BrowserControl_GetHost(hControl);
if (NULL == hBrowser) return;
UINT flags = TPM_LEFTALIGN;
POINT pt = {0, 0};
BOOL fUseHost = TRUE;;
HWND hToolbar = BrowserControl_GetToolbar(hControl);
DWORD toolbarStyle = (NULL != hToolbar) ? GetWindowStyle(hToolbar) : 0;
if (NULL != hToolbar && 0 != (WS_VISIBLE & toolbarStyle))
{
fUseHost = FALSE;
RECT toolbarRect;
GetWindowRect(hToolbar, &toolbarRect);
pt.x = toolbarRect.left + 2;
if (0 != (TBS_BOTTOMDOCK & toolbarStyle))
{
pt.y = toolbarRect.top + 1;
flags |= TPM_VERNEGANIMATION | TPM_BOTTOMALIGN;
}
else
{
pt.y = toolbarRect.bottom - 1;
flags |= TPM_VERPOSANIMATION | TPM_TOPALIGN;
}
}
if (FALSE != fUseHost)
{
RECT windowRect;
GetClientRect(hControl, &windowRect);
pt.x = windowRect.left;
pt.y = windowRect.top;
MapWindowPoints(hControl, HWND_DESKTOP, &pt, 1);
flags |= TPM_VERPOSANIMATION | TPM_TOPALIGN;
}
if (NULL != hToolbar && 0 != (TBS_AUTOHIDE & toolbarStyle))
SetWindowLongPtr(hToolbar, GWL_STYLE, toolbarStyle & ~TBS_AUTOHIDE);
HWND hStatusbar = BrowserControl_GetStatusbar(hControl);
DWORD statusStyle = (NULL != hStatusbar) ? GetWindowStyle(hStatusbar) : 0;
if (NULL != hStatusbar && 0 == (WS_DISABLED & statusStyle))
SetWindowLongPtr(hStatusbar, GWL_STYLE, WS_DISABLED | statusStyle);
SendMessage(hBrowser, NBHM_SHOWHISTORYPOPUP, (WPARAM)flags, MAKELPARAM(pt.x, pt.y));
if (NULL != hToolbar && 0 != (TBS_AUTOHIDE & toolbarStyle))
{
SetWindowLongPtr(hToolbar, GWL_STYLE, toolbarStyle);
TRACKMOUSEEVENT tm;
tm.cbSize = sizeof(TRACKMOUSEEVENT);
tm.dwFlags = TME_LEAVE;
tm.hwndTrack = hToolbar;
TrackMouseEvent(&tm);
}
if (NULL != hStatusbar && 0 == (WS_DISABLED & statusStyle))
SetWindowLongPtr(hStatusbar, GWL_STYLE, statusStyle);
}
static BOOL BrowserControl_ExecServiceCommand(HWND hControl, ifc_omservicecommand *command, const GUID *group, UINT id, ULONG_PTR arg)
{
if (NULL == command) return FALSE;
HRESULT state = command->QueryState(hControl, group, id);
if (CMDSTATE_ENABLED == state)
{
command->Exec(hControl, group, id, arg);
return TRUE;
}
return (CMDSTATE_DISABLED == state) ? TRUE : FALSE;
}
BOOL BrowserControl_ProcessCommonCommand(HWND hControl, INT commandId)
{
if (NULL == hControl)
return FALSE;
UINT controlStyle = GetWindowStyle(hControl);
ifc_omservice *service;
if (0 != (NBCS_NOSERVICECOMMANDS & controlStyle) ||
FALSE == BrowserControl_GetService(hControl, &service))
{
service = NULL;
}
ifc_omservicecommand *serviceCommand;
if (NULL == service ||
FAILED(service->QueryInterface(IFC_OmServiceCommand, (void**)&serviceCommand)))
{
serviceCommand = NULL;
}
BOOL fProcessed = FALSE;
switch(commandId)
{
case ID_NAVIGATION_HOME:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_HOME, 0))
BrowserControl_Navigate(hControl, NAVIGATE_HOME, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_BACK:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_BACKFORWARD, FALSE))
BrowserControl_Navigate(hControl, NAVIGATE_BACK, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_FORWARD:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_BACKFORWARD, TRUE))
BrowserControl_Navigate(hControl, NAVIGATE_FORWARD, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_REFRESH:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_REFRESH, FALSE))
BrowserControl_Navigate(hControl, NAVIGATE_REFRESH, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_REFRESH_COMPLETELY:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_REFRESH, TRUE))
BrowserControl_Navigate(hControl, NAVIGATE_REFRESH_COMPLETELY, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_STOP:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_STOP, 0L))
BrowserControl_Navigate(hControl, NAVIGATE_STOP, 0L);
fProcessed = TRUE;
break;
case ID_NAVIGATION_HISTORY:
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_NAVIGATION, NAVCOMMAND_HISTORY, 0L))
BrowserControl_ShowHistoryPopup(hControl);
fProcessed = TRUE;
break;
case ID_SERVICE_GETINFO:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_SHOWINFO, 0);
fProcessed = TRUE;
break;
case ID_SERVICE_REPORT:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_REPORT, 0);
fProcessed = TRUE;
break;
case ID_SERVICE_UNSUBSCRIBE:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_UNSUBSCRIBE, 0);
fProcessed = TRUE;
break;
case ID_RATING_VALUE_1:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_RATE, 1);
fProcessed = TRUE;
break;
case ID_RATING_VALUE_2:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_RATE, 2);
fProcessed = TRUE;
break;
case ID_RATING_VALUE_3:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_RATE, 3);
fProcessed = TRUE;
break;
case ID_RATING_VALUE_4:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_RATE, 4);
fProcessed = TRUE;
break;
case ID_RATING_VALUE_5:
BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_SERVICE, SVCCOMMAND_RATE, 5);
fProcessed = TRUE;
break;
case ID_WINDOW_CLOSE:
if (FALSE != BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_WINDOW, WNDCOMMAND_CLOSE, 0))
fProcessed = TRUE;
break;
case ID_WINDOW_FULLSCREEN:
if (FALSE != BrowserControl_ExecServiceCommand(hControl, serviceCommand, &CMDGROUP_WINDOW, WNDCOMMAND_FULLSCREEN, 0))
fProcessed = TRUE;
break;
case ID_ADDRESSBAR_ACTIVATE:
{
HWND hToolbar = BrowserControl_GetToolbar(hControl);
if(NULL != hToolbar)
{
Toolbar_NextItem(hToolbar, TOOLITEM_ADDRESSBAR, TRUE);
}
}
fProcessed = TRUE;
break;
case ID_ADDRESSBAR_CHANGED:
{
HWND hToolbar = BrowserControl_GetToolbar(hControl);
if(NULL != hToolbar)
{
INT itemId = Toolbar_FindItem(hToolbar, TOOLITEM_ADDRESSBAR);
if (ITEM_ERR != itemId)
{
size_t cchBufferMax;
if (FALSE == Toolbar_GetTextLength(hToolbar, MAKEINTRESOURCE(itemId), &cchBufferMax))
cchBufferMax = 8192;
cchBufferMax++;
LPWSTR pszBuffer = Plugin_MallocString(cchBufferMax);
if (NULL != pszBuffer)
{
TBITEMINFO itemInfo;
ZeroMemory(&itemInfo, sizeof(itemInfo));
itemInfo.pszText = pszBuffer;
itemInfo.cchText = (INT)cchBufferMax;
if (FALSE != Toolbar_GetItemInfo(hToolbar, MAKEINTRESOURCE(itemId), &itemInfo))
{
if (FALSE == BrowserControl_ExecServiceCommand(hControl, serviceCommand,
&CMDGROUP_ADDRESSBAR, ADDRESSCOMMAND_EXECUTE, (ULONG_PTR)itemInfo.pszText))
{
BrowserControl_Navigate(hControl, NAVIGATE_STOP, 0L);
BrowserControl_Navigate(hControl, itemInfo.pszText, 0L);
}
}
Plugin_FreeString(pszBuffer);
}
}
}
}
fProcessed = TRUE;
break;
}
if (NULL != serviceCommand)
serviceCommand->Release();
if (NULL != service)
service->Release();
return fProcessed;
}
BOOL BrowserControl_ProcessStatusbarCommand(HWND hControl, INT commandId)
{
HWND hStatusbar = BrowserControl_GetStatusbar(hControl);
if (NULL == hStatusbar) return FALSE;
BOOL fProcessed = FALSE;
obj_ombrowser *browserManager;
if (FALSE != BrowserControl_GetBrowserObject(hControl, &browserManager) && NULL != browserManager)
{
ifc_omstatusbarconfig *statusbarConfig;
if (SUCCEEDED(browserManager->GetConfig(&IFC_OmStatusbarConfig, (void**)&statusbarConfig)))
{
UINT statusbarStyle = GetWindowStyle(hStatusbar);
switch(commandId)
{
case SBN_ENABLECHANGED:
statusbarConfig->EnableStatusbar(0 == (WS_DISABLED & statusbarStyle));
fProcessed = TRUE;
break;
}
statusbarConfig->Release();
}
browserManager->Release();
}
return fProcessed;
}
BOOL BrowserControl_ProcessToolbarCommand(HWND hControl, INT commandId)
{
HWND hToolbar = BrowserControl_GetToolbar(hControl);
if (NULL == hToolbar) return FALSE;
BOOL fProcessed = FALSE;
obj_ombrowser *browserManager;
if (FALSE != BrowserControl_GetBrowserObject(hControl, &browserManager) && NULL != browserManager)
{
ifc_omtoolbarconfig *toolbarConfig;
if (SUCCEEDED(browserManager->GetConfig(&IFC_OmToolbarConfig, (void**)&toolbarConfig)))
{
UINT toolbarStyle = GetWindowStyle(hToolbar);
switch(commandId)
{
case TBN_DOCKCHANGED:
toolbarConfig->EnableBottomDock(0 != (TBS_BOTTOMDOCK & toolbarStyle));
fProcessed = TRUE;
break;
case TBN_AUTOHIDECHANGED:
toolbarConfig->EnableAutoHide(0 != (TBS_AUTOHIDE & toolbarStyle));
fProcessed = TRUE;
break;
case TBN_TABSTOPCHANGED:
toolbarConfig->EnableTabStop(0 != (TBS_TABSTOP & toolbarStyle));
fProcessed = TRUE;
break;
}
toolbarConfig->Release();
}
browserManager->Release();
}
return fProcessed;
}
BOOL BrowserControl_ProcessAppCommand(HWND hControl, INT commandId)
{
if (NULL == hControl)
return FALSE;
switch(commandId)
{
case APPCOMMAND_BROWSER_BACKWARD: BrowserControl_ProcessCommonCommand(hControl, ID_NAVIGATION_BACK); return TRUE;
case APPCOMMAND_BROWSER_FORWARD: BrowserControl_ProcessCommonCommand(hControl, ID_NAVIGATION_FORWARD); return TRUE;
case APPCOMMAND_BROWSER_HOME: BrowserControl_ProcessCommonCommand(hControl, ID_NAVIGATION_HOME); return TRUE;
case APPCOMMAND_BROWSER_REFRESH: BrowserControl_ProcessCommonCommand(hControl, ID_NAVIGATION_REFRESH); return TRUE;
case APPCOMMAND_BROWSER_STOP: BrowserControl_ProcessCommonCommand(hControl, ID_NAVIGATION_STOP); return TRUE;
case APPCOMMAND_BROWSER_FAVORITES: return TRUE;
case APPCOMMAND_BROWSER_SEARCH: return TRUE;
}
return FALSE;
}
HWND BrowserControl_GetOperationWidget(HWND hControl)
{
return GetDlgItem(hControl, IDC_OPERATIONWIDGET);
}
HWND BrowserControl_CreateOperationWidget(HWND hControl)
{
if (FALSE == Curtain_RegisterClass(Plugin_GetInstance()))
return NULL;
RECT rc;
HWND hTarget = BrowserControl_GetHost(hControl);
if (NULL == hTarget) hTarget = hControl;
if (FALSE == GetWindowRect(hTarget, &rc))
return NULL;
MapWindowPoints(HWND_DESKTOP, hControl, (POINT*)&rc, 2);
HWND hWidget = CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_CONTROLPARENT,
NWC_ONLINEMEDIACURTAIN, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS /*| WS_VISIBLE*/,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hControl,
(HMENU)IDC_OPERATIONWIDGET, Plugin_GetInstance(), NULL);
return hWidget;
}
BOOL BrowserControl_OnShowOperation(HWND hControl, OPERATIONINFO *poi)
{
if (NULL == poi) return FALSE;
if (poi->cbSize != sizeof(OPERATIONINFO))
return FALSE;
BOOL updateSkin = FALSE;
HWND hWidget = BrowserControl_GetOperationWidget(hControl);
if (0 != (NBCOM_FLAGS & poi->mask))
{
if (0 != (NBCOF_SHOWWIDGET & poi->flags))
{
if (NULL == hWidget)
{
hWidget = BrowserControl_CreateOperationWidget(hControl);
if (NULL != hWidget)
updateSkin = TRUE;
}
}
if (0 != (NBCOF_HIDEWIDGET & poi->flags))
{
if (NULL != hWidget)
{
DestroyWindow(hWidget);
hWidget = NULL;
SetWindowPos(hControl, NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_DEFERERASE);
}
}
}
if (0 != (NBCOM_TITLE & poi->mask))
{
if (NULL != hWidget)
SetWindowText(hWidget, poi->title);
}
if (0 != (NBCOM_TEXT & poi->mask))
{
if (NULL != hWidget)
Curtain_SetOperationText(hWidget, poi->text);
}
if (NULL != hWidget && 0 != (NBCOM_FLAGS & poi->mask) && 0 != (NBCOF_SHOWWIDGET & poi->flags))
{
if (FALSE != updateSkin)
{
PostMessage(hWidget, CWM_UPDATESKIN, 0, 0L);
SetWindowPos(hControl, NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_DEFERERASE);
}
ShowWindowAsync(hWidget, SW_SHOWNA);
}
return TRUE;
}
BOOL BrowserControl_UpdateLayout(HWND hControl, BOOL fRedraw, BOOL fFrame, HRGN updateRegion, const POINT *updateOffset)
{
RECT clientRect;
if (!GetClientRect(hControl, &clientRect))
return FALSE;
UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE;
if (FALSE == fRedraw) uFlags |= SWP_NOREDRAW;
if (FALSE != fFrame) uFlags |= SWP_FRAMECHANGED;
HWND hToolbar, hBrowser, hStatusbar, hWidget;
BOOL toolbarSet = FALSE;
TOOLBARLAYOUT layout;
layout.prcParent = &clientRect;
HDWP hdwp = BeginDeferWindowPos(2);
if (NULL == hdwp) return FALSE;
if (NULL != (hToolbar = BrowserControl_GetToolbar(hControl)))
{
if (Toolbar_Layout(hToolbar, &layout))
{
toolbarSet = TRUE;
hdwp = DeferWindowPos(hdwp, hToolbar, layout.insertAfter, layout.toolbarRect.left, layout.toolbarRect.top,
layout.toolbarRect.right - layout.toolbarRect.left,
layout.toolbarRect.bottom - layout.toolbarRect.top, uFlags & ~SWP_NOZORDER);
if (NULL == hdwp) return FALSE;
}
}
if (FALSE == toolbarSet)
CopyRect(&layout.clientRect, layout.prcParent);
if (NULL != (hBrowser = BrowserControl_GetHost(hControl)))
{
if (0 != (NBHS_BROWSERREADY & GetWindowStyle(hBrowser)))
{
SetWindowPos(hBrowser, NULL, layout.clientRect.left, layout.clientRect.top,
layout.clientRect.right - layout.clientRect.left, layout.clientRect.bottom - layout.clientRect.top,
uFlags | SWP_ASYNCWINDOWPOS | SWP_DEFERERASE);
}
}
if (NULL != (hWidget = BrowserControl_GetOperationWidget(hControl)))
{
HWND hInsertAfter;
if (NULL != hBrowser) hInsertAfter = GetWindow(hBrowser, GW_HWNDPREV);
else if( NULL != hToolbar) hInsertAfter = GetWindow(hBrowser, GW_HWNDPREV);
else hInsertAfter = HWND_TOP;
UINT flags;
flags = uFlags;
if (hInsertAfter != hWidget)
flags &= ~SWP_NOZORDER;
hdwp = DeferWindowPos(hdwp, hWidget, hInsertAfter, layout.clientRect.left, layout.clientRect.top,
layout.clientRect.right - layout.clientRect.left, layout.clientRect.bottom - layout.clientRect.top, flags);
if (NULL == hdwp) return FALSE;
}
EndDeferWindowPos(hdwp);
if (NULL != (hStatusbar = BrowserControl_GetStatusbar(hControl)))
Statusbar_SetParentRect(hStatusbar, &layout.clientRect);
////////////////////////////////////
if (NULL != updateRegion)
{
RECT rect;
HRGN rgnValid = NULL;
if (NULL != hBrowser && 0 != (WS_VISIBLE & GetWindowStyle(hBrowser)) &&
FALSE != GetWindowRect(hBrowser, &rect))
{
MapWindowPoints(HWND_DESKTOP, hControl, (POINT*)&rect, 2);
rgnValid = CreateRectRgnIndirect(&rect);
}
if (NULL != rgnValid)
{
HRGN rgn = NULL;
HWND szControls[] = {hToolbar, hStatusbar, hWidget};
for (INT i = 0; i < ARRAYSIZE(szControls); i++)
{
if (NULL != szControls[i] && 0 != (WS_VISIBLE & GetWindowStyle(szControls[i])) &&
FALSE != GetWindowRect(szControls[i], &rect))
{
MapWindowPoints(HWND_DESKTOP, hControl, (POINT*)&rect, 2);
if (NULL == rgn) rgn = CreateRectRgnIndirect(&rect);
else SetRectRgn(rgn, rect.left, rect.top, rect.right, rect.bottom);
if (NULL != rgn)
CombineRgn(rgnValid, rgnValid, rgn, RGN_DIFF);
}
}
if (NULL != updateOffset)
OffsetRgn(rgnValid, -updateOffset->x, -updateOffset->y);
CombineRgn(updateRegion, updateRegion, rgnValid, RGN_DIFF);
if (NULL != rgn) DeleteObject(rgn);
DeleteObject(rgnValid);
}
}
return TRUE;
}
BOOL BrowserControl_EnableChildren(HWND hControl, BOOL fEnable)
{
HWND hChild;
if (NULL != (hChild = BrowserControl_GetHost(hControl)))
PostMessage(hChild, NBHM_ENABLEWINDOW, 0, fEnable);
if (NULL != (hChild = BrowserControl_GetToolbar(hControl)))
EnableWindow(hChild, fEnable);
if (NULL != (hChild = BrowserControl_GetStatusbar(hControl)))
EnableWindow(hChild, fEnable);
return TRUE;
}
BOOL BrowserControl_SetBlockedState(HWND hControl, BOOL fBlocked)
{
if (NULL == hControl)
return FALSE;
UINT prevStyle = BrowserControl_SetExtendedStyle(hControl, NBCS_EX_BLOCKNAVIGATION, (FALSE != fBlocked) ? NBCS_EX_BLOCKNAVIGATION : 0);
if (FALSE != fBlocked)
{
if (0 == (NBCS_EX_BLOCKNAVIGATION & prevStyle))
{
BrowserControl_EnableChildren(hControl, FALSE);
}
}
else
{
if (0 != (NBCS_EX_BLOCKNAVIGATION & prevStyle))
{
BrowserControl_EnableChildren(hControl, TRUE);
}
BrowserControl_NavigateStoredUrl(hControl);
}
return TRUE;
}

View File

@ -0,0 +1,111 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_UI_COMMON_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_UI_COMMON_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
class ifc_omservice;
// styles
#define NBCS_DISABLEHOSTCSS 0x00000001 // no coloring
#define NBCS_POPUPOWNER 0x00000002 // every created popup owner by window
#define NBCS_DISABLEFULLSCREEN 0x00000004 // disable fullscreen mode (popup only)
#define NBCS_NOTOOLBAR 0x00000100 // force no toolbar
#define NBCS_NOSTATUSBAR 0x00000200 // force no statusbar
#define NBCS_NOSERVICECOMMANDS 0x00000400 // force disable service commands
#define NBCS_DISABLECONTEXTMENU 0x00001000 // disable context menu
#define NBCS_DIALOGMODE 0x00002000 // enable dialog mode
#define NBCS_BLOCKPOPUP 0x00004000 // block any popup creation
// messages
#define NBCM_FIRST (WM_USER + 20)
#define NBVM_FIRST (NBCM_FIRST + 100)
#define NBPM_FIRST (NBCM_FIRST + 200)
#define NBCM_GETTOOLBAR (NBCM_FIRST + 1) // wParam - not used; lParam - not used; Return: toolbar hwnd.
#define BrowserControl_GetToolbar(/*HWND*/ __hwndControl)\
((HWND)SENDMSG((__hwndControl), NBCM_GETTOOLBAR, 0, 0L))
#define NBCM_GETSTATUSBAR (NBCM_FIRST + 2) // wParam - not used; lParam - not used; Return: statusbar hwnd.
#define BrowserControl_GetStatusbar(/*HWND*/ __hwndControl)\
((HWND)SENDMSG((__hwndControl), NBCM_GETSTATUSBAR, 0, 0L))
#define NBCM_UPDATESKIN (NBCM_FIRST + 3) // wParam - not used; lParam - (LPARAM)(BOOL)fRedraw; Return: not used.
#define BrowserControl_UpdateSkin(/*HWND*/ __hwndControl, /*BOOL*/ __fRedraw)\
(SENDMSG((__hwndControl), NBCM_UPDATESKIN, 0, (LPARAM)(__fRedraw)))
#define NBCM_GETSERVICE (NBCM_FIRST + 4) // wParam - not used; lParam = (LPARAM)(ifc_omservice**)serviceOut; Return: TRUE on success.
#define BrowserControl_GetService(/*HWND*/ __hwndControl, /*ifc_omservice** */ __serviceOut)\
((BOOL)SENDMSG((__hwndControl), NBCM_GETSERVICE, 0, (LPARAM)(__serviceOut)))
#define NAVIGATE_BLANK MAKEINTRESOURCEW(0)
#define NAVIGATE_HOME MAKEINTRESOURCEW(1)
#define NAVIGATE_BACK MAKEINTRESOURCEW(2)
#define NAVIGATE_FORWARD MAKEINTRESOURCEW(3)
#define NAVIGATE_REFRESH MAKEINTRESOURCEW(4)
#define NAVIGATE_STOP MAKEINTRESOURCEW(5)
#define NAVIGATE_REFRESH_COMPLETELY MAKEINTRESOURCEW(6)
#define NBCM_NAVIGATE (NBCM_FIRST + 5) // wParam = (WPARAM)(BOOL)fScheduleIfBlocked; lParam = (LPARAM)(LPWSTR)navigateUrl; Return: TRUE on success.
#define BrowserControl_Navigate(/*HWND*/ __hwndControl, /*LPCWSTR*/ __navigateUrl, /*BOOL*/ __scheduleBlocked)\
((BOOL)SENDMSG((__hwndControl), NBCM_NAVIGATE, (WPARAM)__scheduleBlocked, (LPARAM)(__navigateUrl)))
#define NBCM_WRITEDOCUMENT (NBCM_FIRST + 6) // wParam = (WPARAM)(BOOL)fScheduleIfBlocked; lParam = (LPARAM)(BSTR)documentData; Return: TRUE on success.
#define BrowserControl_WriteDocument(/*HWND*/ __hwndControl, /*BSTR*/ __documentData, /*BOOL*/ __scheduleBlocked)\
((BOOL)SENDMSG((__hwndControl), NBCM_WRITEDOCUMENT, (WPARAM)__scheduleBlocked, (LPARAM)(__documentData)))
#define NBCM_GETHOST (NBCM_FIRST + 7) // wParam - not used; lParam - not used; Return: host hwnd.
#define BrowserControl_GetHost(/*HWND*/ __hwndControl)\
((HWND)SENDMSG((__hwndControl), NBCM_GETHOST, 0, 0L))
#define NBCM_GETBROWSEROBJECT (NBCM_FIRST + 8) // wParam - not used; lParam = (LPARAM)(obj_ombrowser**)browserOut; Return: TRUE on success.
#define BrowserControl_GetBrowserObject(/*HWND*/ __hwndControl, /*obj_ombrowser** */ __browserOut)\
((BOOL)SENDMSG((__hwndControl), NBCM_GETBROWSEROBJECT, 0, (LPARAM)(__browserOut)))
// operation flags
#define NBCOF_HIDEWIDGET 0x00000001
#define NBCOF_SHOWWIDGET 0x00000002
// operation valid fields mask
#define NBCOM_FLAGS 0x00000001
#define NBCOM_TITLE 0x00000002
#define NBCOM_TEXT 0x00000004
typedef struct __OPERATIONINFO
{
UINT cbSize; //sizeof(OPERATIONINFO)
UINT mask; //
UINT flags; // show flags;
LPCWSTR title; // operation title
LPCWSTR text; // operation text
} OPERATIONINFO;
#define NBCM_SHOWOPERATION (NBCM_FIRST + 9) // wParam - not sued, lParam - (LPARAM)(OPERATIONINFO*)__pOperationInfo.
#define BrowserControl_ShowOperation(/*HWND*/ __hwndControl, /*const OPERATIONINFO* */ __pOperationInfo)\
((BOOL)SENDMSG((__hwndControl), NBCM_SHOWOPERATION, 0, (LPARAM)(__pOperationInfo)))
#define NBCM_NAVSTOREDURL (NBCM_FIRST + 10) // wParam - not used, lParam - not used
#define BrowserControl_NavigateStoredUrl(/*HWND*/ __hwndControl)\
((BOOL)SNDMSG((__hwndControl), NBCM_NAVSTOREDURL, 0, 0L))
#define NBCM_BLOCK (NBCM_FIRST + 11) //wParam - not used, lParam = (LPARAM)(BOOL)fBlock;
#define BrowserControl_Block(/*HWND*/ __hwndControl, /*BOOL*/ __fBlock)\
(SNDMSG((__hwndControl), NBCM_BLOCK, 0, (LPARAM)(__fBlock)))
#define NBCM_SETEXTSTYLE (NBCM_FIRST + 12) //wParam = (WPARAM)(UINT)extMask, lParam = (LPARAM)(UINT)extStyle; Return UINT with prevoius extended style
#define BrowserControl_SetExtendedStyle(/*HWND*/ __hwndControl, /*UINT*/ __extMask, /*UINT*/__extStyle)\
((UINT)SNDMSG((__hwndControl), NBCM_SETEXTSTYLE, (WPARAM)(__extMask), (LPARAM)(__extStyle)))
#define NBCM_GETEXTSTYLE (NBCM_FIRST + 13) //wParam - not used, lParam - not used; Return UINT extended style.
#define BrowserControl_GetExtendedStyle(/*HWND*/ __hwndControl)\
((UINT)SNDMSG((__hwndControl), NBCM_GETTEXTSTYLE, 0, 0L))
#endif // NULLSOFT_WINAMP_OMBROWSER_UI_COMMON_HEADER

View File

@ -0,0 +1,321 @@
#include "main.h"
#include "./browserUiHook.h"
#include "./browserUiCommon.h"
#include "./browserUiInternal.h"
#include "./browserPopup.h"
#include "./browserHost.h"
#include "./ifc_omservice.h"
#include "./ifc_omserviceeventmngr.h"
#include "./ifc_omservicecommand.h"
#include "./ifc_omtoolbarconfig.h"
#include "./ifc_omstatusbarconfig.h"
#include "./ifc_omserviceeditor.h"
#include "./ifc_omconfig.h"
#include "./obj_ombrowser.h"
#include "./toolbar.h"
#include "./statusbar.h"
#include "../winamp/IWasabiDispatchable.h"
#include "../winamp/JSAPI_Info.h"
#include <strsafe.h>
BrowserUiHook::BrowserUiHook(HWND hTarget, BOOL fPopupMode)
: ref(1), popupMode(fPopupMode), hwnd(hTarget), winampCookie(NULL), configCookie(NULL)
{
}
BrowserUiHook::~BrowserUiHook()
{
}
HRESULT BrowserUiHook::CreateInstance(HWND hTarget, BOOL fPopupMode, BrowserUiHook **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
if (NULL == hTarget || FALSE == IsWindow(hTarget))
return E_INVALIDARG;
*instance = new BrowserUiHook(hTarget, fPopupMode);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t BrowserUiHook::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t BrowserUiHook::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int BrowserUiHook::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_WinampHook))
*object = static_cast<ifc_winamphook*>(this);
else if (IsEqualIID(interface_guid, IFC_OmServiceEvent))
*object = static_cast<ifc_omserviceevent*>(this);
else if (IsEqualIID(interface_guid, IFC_OmConfigCallback))
*object = static_cast<ifc_omconfigcallback*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT BrowserUiHook::SkinChanging(void)
{
if (FALSE != popupMode)
{
BrowserPopup_SkinRefreshing(hwnd);
PostMessage(hwnd, NBPM_SKINREFRESHED, 0, 0L);
}
return S_OK;
}
HRESULT BrowserUiHook::SkinChanged(const wchar_t *skinName)
{
PostMessage(hwnd, NBCM_UPDATESKIN, 0, TRUE);
return S_OK;
}
HRESULT BrowserUiHook::SkinColorChange(const wchar_t *colorTheme)
{
PostMessage(hwnd, NBCM_UPDATESKIN, 0, TRUE);
return S_OK;
}
HRESULT BrowserUiHook::ResetFont(void)
{
PostMessage(hwnd, NBCM_UPDATESKIN, 0, TRUE);
return S_OK;
}
void BrowserUiHook::ServiceChange(ifc_omservice *service, UINT nModified)
{
ifc_omservice *windowService;
if (FALSE == (BOOL)SendMessage(hwnd, NBCM_GETSERVICE, 0, (LPARAM)&windowService) || NULL == windowService)
return;
if (windowService != service) return;
if (0 != (ifc_omserviceeditor::modifiedName & nModified))
{
IDispatch *pDispatch;
if (SUCCEEDED(windowService->GetExternal(&pDispatch) && NULL != pDispatch))
{
IWasabiDispatchable *pWasabi;
if (SUCCEEDED(pDispatch->QueryInterface(IID_IWasabiDispatchable, (void**)&pWasabi)))
{
JSAPI::ifc_info *info = NULL;
if (SUCCEEDED(pWasabi->QueryDispatchable(JSAPI::IID_JSAPI_ifc_info, (Dispatchable**)&info)))
{
WCHAR szName[512] = {0};
if (FAILED(service->GetName(szName, ARRAYSIZE(szName))))
StringCchCopy(szName, ARRAYSIZE(szName), L"Unknown");
info->SetName(szName);
info->Release();
}
pWasabi->Release();
}
pDispatch->Release();
}
if (FALSE != popupMode)
PostMessage(hwnd, NBPM_REFRESHTITLE, 0, 0L);
}
if (0 != (ifc_omserviceeditor::modifiedRating & nModified))
{
HWND hToolbar = BrowserControl_GetToolbar(hwnd);
if (NULL != hToolbar)
{
UINT rating;
if(SUCCEEDED(service->GetRating(&rating)))
{
Toolbar_SetItemInt(hToolbar, TOOLITEM_USERRATING, rating);
}
}
}
if (0 != (ifc_omserviceeditor::modifiedGeneration & nModified))
{
HWND hHost = BrowserControl_GetHost(hwnd);
if (NULL != hHost) PostMessage(hHost, NBHM_UPDATEEXTERNAL, 0 , 0L);
}
}
void BrowserUiHook::CommandStateChange(ifc_omservice *service, const GUID *commandGroup, unsigned int commandId)
{
if (NULL != commandGroup)
{
if (IsEqualGUID(CMDGROUP_SERVICE, *commandGroup))
{
switch(commandId)
{
case SVCCOMMAND_BLOCKNAV:
CheckBlockedState(service);
break;
}
}
}
}
HRESULT BrowserUiHook::ValueChanged(const GUID *configUid, UINT valueId, ULONG_PTR value)
{
if (NULL == configUid)
return E_UNEXPECTED;
if (IsEqualIID(IFC_OmToolbarConfig, *configUid))
{
HWND hToolbar = (HWND)SendMessage(hwnd, NBCM_GETTOOLBAR, 0, 0L);
if (NULL == hToolbar) return S_FALSE;
switch(valueId)
{
case CFGID_TOOLBAR_BOTTOMDOCK: Toolbar_EnableBottomDock(hToolbar, (BOOL)value); break;
case CFGID_TOOLBAR_AUTOHIDE: Toolbar_EnableAutoHide(hToolbar, (BOOL)value); break;
case CFGID_TOOLBAR_TABSTOP: Toolbar_EnableTabStop(hToolbar, (BOOL)value); break;
case CFGID_TOOLBAR_FORCEADDRESS: Toolbar_EnableForceAddress(hToolbar, (BOOL)value); break;
case CFGID_TOOLBAR_FANCYADDRESS: Toolbar_EnableFancyAddress(hToolbar, (BOOL)value); break;
}
}
else if (IsEqualIID(IFC_OmStatusbarConfig, *configUid))
{
HWND hStatusbar = (HWND)SendMessage(hwnd, NBCM_GETSTATUSBAR, 0, 0L);
if (NULL == hStatusbar) return S_FALSE;
switch(valueId)
{
case CFGID_STATUSBAR_ENABLED: Statusbar_Enable(hStatusbar, (BOOL)value); break;
}
}
return S_OK;
}
HRESULT BrowserUiHook::Register(obj_ombrowser *browserManager, ifc_omservice *service)
{
Plugin_RegisterWinampHook(this, &winampCookie);
ifc_omconfig *config;
if (NULL != browserManager && SUCCEEDED(browserManager->GetConfig(NULL, (void**)&config)))
{
config->RegisterCallback(this, &configCookie);
config->Release();
}
ifc_omserviceeventmngr *eventManager;
if (NULL != service && SUCCEEDED(service->QueryInterface(IFC_OmServiceEventMngr, (void**)&eventManager)))
{
eventManager->RegisterHandler(this);
eventManager->Release();
}
return S_OK;
}
HRESULT BrowserUiHook::Unregister(obj_ombrowser *browserManager, ifc_omservice *service)
{
if (0 != configCookie)
{
ifc_omconfig *config;
if (NULL != browserManager && SUCCEEDED(browserManager->GetConfig(NULL, (void**)&config)))
{
config->UnregisterCallback(configCookie);
config->Release();
}
configCookie = 0;
}
ifc_omserviceeventmngr *eventManager;
if (NULL != service && SUCCEEDED(service->QueryInterface(IFC_OmServiceEventMngr, (void**)&eventManager)))
{
eventManager->UnregisterHandler(this);
eventManager->Release();
}
if (0 != winampCookie)
{
Plugin_UnregisterWinampHook(winampCookie);
winampCookie = 0;
}
return S_OK;
}
HRESULT BrowserUiHook::CheckBlockedState(ifc_omservice *service)
{
if (NULL == service)
return E_INVALIDARG;
HRESULT hr;
ifc_omservicecommand *serviceCommand;
hr = service->QueryInterface(IFC_OmServiceCommand, (void**)&serviceCommand);
if (SUCCEEDED(hr))
{
HRESULT state = serviceCommand->QueryState(hwnd, &CMDGROUP_SERVICE, SVCCOMMAND_BLOCKNAV);
PostMessage(hwnd, NBCM_BLOCK, 0, (CMDSTATE_ENABLED == state));
serviceCommand->Release();
}
return hr;
}
#define CBCLASS BrowserUiHook
START_MULTIPATCH;
START_PATCH(MPIID_WINAMPHOOK)
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, ADDREF, AddRef);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, RELEASE, Release);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_SKINCHANGING, SkinChanging);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_SKINCHANGED, SkinChanged);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_SKINCOLORCHANGE, SkinColorChange);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_RESETFONT, ResetFont);
NEXT_PATCH(MPIID_SERVICEEVENT)
M_CB(MPIID_SERVICEEVENT, ifc_omserviceevent, ADDREF, AddRef);
M_CB(MPIID_SERVICEEVENT, ifc_omserviceevent, RELEASE, Release);
M_CB(MPIID_SERVICEEVENT, ifc_omserviceevent, QUERYINTERFACE, QueryInterface);
M_VCB(MPIID_SERVICEEVENT, ifc_omserviceevent, API_SERVICECHANGE, ServiceChange);
M_VCB(MPIID_SERVICEEVENT, ifc_omserviceevent, API_COMMANDSTATECHANGE, CommandStateChange);
NEXT_PATCH(MPIID_CONFIGCALLBACK)
M_CB(MPIID_CONFIGCALLBACK, ifc_omconfigcallback, ADDREF, AddRef);
M_CB(MPIID_CONFIGCALLBACK, ifc_omconfigcallback, RELEASE, Release);
M_CB(MPIID_CONFIGCALLBACK, ifc_omconfigcallback, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_CONFIGCALLBACK, ifc_omconfigcallback, API_VALUECHANGED, ValueChanged);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

View File

@ -0,0 +1,70 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_UI_HOOK_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_UI_HOOK_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_winamphook.h"
#include "./ifc_omserviceevent.h"
#include "./ifc_omconfigcallback.h"
#include <bfc/multipatch.h>
#define MPIID_WINAMPHOOK 10
#define MPIID_SERVICEEVENT 20
#define MPIID_CONFIGCALLBACK 30
class ifc_omservice;
class obj_ombrowser;
class BrowserUiHook : public MultiPatch<MPIID_WINAMPHOOK, ifc_winamphook>,
public MultiPatch<MPIID_SERVICEEVENT, ifc_omserviceevent>,
public MultiPatch<MPIID_CONFIGCALLBACK, ifc_omconfigcallback>
{
protected:
BrowserUiHook(HWND hTarget, BOOL fPopupMode);
~BrowserUiHook();
public:
static HRESULT CreateInstance(HWND hTarget, BOOL fPopupMode, BrowserUiHook **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/*ifc_winamphook (partial) */
HRESULT SkinChanging(void);
HRESULT SkinChanged(const wchar_t *skinName);
HRESULT SkinColorChange(const wchar_t *colorTheme);
HRESULT ResetFont(void);
/* ifc_omserviceevent */
void ServiceChange(ifc_omservice *service, UINT nModified);
void CommandStateChange(ifc_omservice *service, const GUID *commandGroup, unsigned int commandId);
/* ifc_omconfigcallback */
HRESULT ValueChanged(const GUID *configUid, UINT valueId, ULONG_PTR value);
public:
HRESULT Register(obj_ombrowser *browserManager, ifc_omservice *service);
HRESULT Unregister(obj_ombrowser *browserManager, ifc_omservice *service);
HRESULT CheckBlockedState(ifc_omservice *service);
protected:
ULONG ref;
BOOL popupMode;
HWND hwnd;
UINT winampCookie;
UINT configCookie;
protected:
RECVS_MULTIPATCH;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_UI_HOOK_HEADER

View File

@ -0,0 +1,37 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_UI_INTERNAL_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_UI_INTERNAL_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
//styles ex
#define NBCS_EX_BROWSERREADY 0x00000001
#define NBCS_EX_NAVCOMPLETED 0x00000002
#define NBCS_EX_BLOCKNAVIGATION 0x00000004
// popup only
#define NBCS_EX_NAVIGATEDONCE 0x00000100
#define NBCS_EX_FULLSCREEN 0x00000200
#define NBCS_EX_SCRIPTMODE 0x00000400
#define ACCELTABLE_VIEW 0
#define ACCELTABLE_POPUP 1
HACCEL BrowserControl_GetAccelTable(UINT tableType);
BOOL BrowserControl_ProcessCommonCommand(HWND hControl, INT commandId);
BOOL BrowserControl_ProcessToolbarCommand(HWND hControl, INT commandId);
BOOL BrowserControl_ProcessStatusbarCommand(HWND hControl, INT commandId);
BOOL BrowserControl_ProcessAppCommand(HWND hControl, INT commandId);
typedef struct __OPERATIONINFO OPERATIONINFO;
BOOL BrowserControl_OnShowOperation(HWND hControl, OPERATIONINFO *poi);
HWND BrowserControl_GetOperationWidget(HWND hControl);
BOOL BrowserControl_UpdateLayout(HWND hControl, BOOL fRedraw, BOOL fFrame, HRGN updateRegion,const POINT *updateOffset);
BOOL BrowserControl_EnableChildren(HWND hControl, BOOL fEnable);
BOOL BrowserControl_SetBlockedState(HWND hControl, BOOL fBlocked);
#endif // NULLSOFT_WINAMP_OMBROWSER_UI_INTERNAL_HEADER

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_VIEW_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_VIEW_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./browserUiCommon.h"
#define NWC_OMBROWSERVIEW L"Nullsoft_omBrowserView"
// {13A6B4C7-1881-4a55-B375-26DF2A830825}
static const GUID WTID_BrowserView =
{ 0x13a6b4c7, 0x1881, 0x4a55, { 0xb3, 0x75, 0x26, 0xdf, 0x2a, 0x83, 0x8, 0x25 } };
class obj_ombrowser;
HWND BrowserView_Create(obj_ombrowser *browserManager, ifc_omservice *service, HWND hParent, LPCWSTR redirectUrl, UINT style);
// browser common messages
#define BrowserView_GetToolbar(/*HWND*/ __hwndView)\
BrowserControl_GetToolbar(__hwndView)
#define BrowserView_GetStatusbar(/*HWND*/ __hwndView)\
BrowserControl_GetStatusbar(__hwndView)
#define BrowserView_GetHost(/*HWND*/ __hwndView)\
BrowserControl_GetHost(__hwndView)
#define BrowserView_UpdateSkin(/*HWND*/ __hwndView, /*BOOL*/ __fRedraw)\
BrowserControl_UpdateSkin(__hwndView, __fRedraw)
#define BrowserView_GetService(/*HWND*/ __hwndView, /*ifc_omservice** */ __serviceOut)\
BrowserControl_GetService(__hwndView, __serviceOut)
#define BrowserView_Navigate(/*HWND*/ __hwndView, /*LPCWSTR*/ __navigateUrl, /*BOOL*/ __scheduleBlocked)\
BrowserControl_Navigate(__hwndView, __navigateUrl, __scheduleBlocked)
#define BrowserView_NavigateHome(/*HWND*/ __hwndView, /*BOOL*/ __scheduleBlocked)\
BrowserView_Navigate((__hwndView), NAVIGATE_HOME, (__scheduleBlocked))
#define BrowserView_WriteDocument(/*HWND*/ __hwndView, /*BSTR*/ __documentData, /*BOOL*/ __scheduleBlocked)\
BrowserControl_WriteDocument(__hwndView, __documentData, __scheduleBlocked)
#define BrowserView_ShowOperation(/*HWND*/ __hwndView, /*const OPERATIONINFO* */ __pOperationInfo)\
BrowserControl_ShowOperation(__hwndView, __pOperationInfo)
#endif // NULLSOFT_WINAMP_OMBROWSER_VIEW_HEADER

View File

@ -0,0 +1,179 @@
#include "main.h"
#include "./browserWndEnum.h"
#include "./browserWndRecord.h"
#include "./browserView.h"
#include "./browserPopup.h"
#include "./ifc_omservice.h"
OmBrowserWndEnumerator::OmBrowserWndEnumerator(const GUID *windowTypeFilter, const UINT *serviceIdFilter, OmBrowserWndRecord * const *windowList, size_t windowListSize)
: ref(1), index(0), list(NULL), size(0), filterId(FALSE), filterType(FALSE)
{
if (NULL != serviceIdFilter)
{
serviceId = *serviceIdFilter;
filterId = TRUE;
}
else
serviceId = 0;
if (NULL != windowTypeFilter)
{
windowType = *windowTypeFilter;
filterType = TRUE;
}
else
windowType = GUID_NULL;
if (NULL != windowList && 0 != windowListSize)
{
list = (OmBrowserWndRecord**)calloc(windowListSize, sizeof(OmBrowserWndRecord*));
if (NULL != list)
{
for (size_t i = 0; i < windowListSize; i++)
{
list[i] = windowList[i];
list[i]->AddRef();
}
size = windowListSize;
}
}
}
OmBrowserWndEnumerator::~OmBrowserWndEnumerator()
{
if (NULL != list)
{
for (size_t i = 0; i < size; i++)
{
list[i]->Release();
}
free(list);
}
}
HRESULT OmBrowserWndEnumerator::CreateInstance(const GUID *windowTypeFilter, const UINT *serviceIdFilter, OmBrowserWndRecord * const* windowList, size_t windowListSize, OmBrowserWndEnumerator **instance)
{
if (NULL == instance) return E_POINTER;
*instance = new OmBrowserWndEnumerator(windowTypeFilter, serviceIdFilter, windowList, windowListSize);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t OmBrowserWndEnumerator::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t OmBrowserWndEnumerator::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int OmBrowserWndEnumerator::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmBrowserWindowEnumerator))
*object = static_cast<ifc_ombrowserwndenum*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT OmBrowserWndEnumerator::Next(ULONG listSize, HWND *elementList, ULONG *elementCount)
{
if (NULL == elementList || 0 == listSize) return E_INVALIDARG;
if (index >= size)
{
if (NULL != elementCount) *elementCount = 0;
return S_FALSE;
}
ULONG count = 0;
for (;index < size && count < listSize; index++)
{
OmBrowserWndRecord *r = list[index];
if (FALSE != filterType)
{
if (S_OK != r->IsEqualType(&windowType))
continue;
}
if (FALSE != filterId)
{
BOOL passOk = FALSE;
if (S_OK == r->IsEqualType(&WTID_BrowserView) ||
S_OK == r->IsEqualType(&WTID_BrowserPopup))
{
ifc_omservice *service;
if (FALSE != SendMessage(r->GetHwnd(), NBCM_GETSERVICE, 0, (LPARAM)&service) && NULL != service)
{
if (serviceId == service->GetId())
passOk = TRUE;
service->Release();
}
}
if (FALSE == passOk)
continue;
}
elementList[count] = r->GetHwnd();
count++;
}
if (NULL != elementCount) *elementCount = count;
return (count == listSize) ? S_OK : S_FALSE;
}
HRESULT OmBrowserWndEnumerator::Reset(void)
{
index = 0;
return S_OK;
}
HRESULT OmBrowserWndEnumerator::Skip(ULONG elementCount)
{
index += elementCount;
if (index >= size)
{
index = (size - 1);
return S_FALSE;
}
return S_OK;
}
#define CBCLASS OmBrowserWndEnumerator
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_NEXT, Next)
CB(API_RESET, Reset)
CB(API_SKIP, Skip)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,48 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_ombrowserwndenum.h"
class OmBrowserWndRecord;
class OmBrowserWndEnumerator : public ifc_ombrowserwndenum
{
protected:
OmBrowserWndEnumerator(const GUID *windowTypeFilter, const UINT *serviceIdFilter, OmBrowserWndRecord * const *windowList, size_t windowListSize);
~OmBrowserWndEnumerator();
public:
static HRESULT CreateInstance(const GUID *windowTypeFilter, const UINT *serviceIdFilter, OmBrowserWndRecord * const *windowList, size_t windowListSize, OmBrowserWndEnumerator **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_ombrowserwndenum */
HRESULT Next(ULONG listSize, HWND *elementList, ULONG *elementCount);
HRESULT Reset(void);
HRESULT Skip(ULONG elementCount);
protected:
ULONG ref;
size_t index;
OmBrowserWndRecord **list;
size_t size;
UINT serviceId;
GUID windowType;
BOOL filterId;
BOOL filterType;
protected:
RECVS_DISPATCH;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_HEADER

View File

@ -0,0 +1,67 @@
#include "main.h"
#include "./browserWndRecord.h"
OmBrowserWndRecord::OmBrowserWndRecord(HWND hwnd, const GUID *type)
: ref(1)
{
this->hwnd = hwnd;
this->type = (NULL != type) ? *type : GUID_NULL;
}
OmBrowserWndRecord::~OmBrowserWndRecord()
{
}
HRESULT OmBrowserWndRecord::CreateInstance(HWND hwnd, const GUID *type, OmBrowserWndRecord **instance)
{
if (NULL == instance) return E_POINTER;
if (NULL == hwnd)
{
*instance = NULL;
return E_INVALIDARG;
}
*instance = new OmBrowserWndRecord(hwnd, type);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
ULONG OmBrowserWndRecord::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
ULONG OmBrowserWndRecord::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
HWND OmBrowserWndRecord::GetHwnd()
{
return hwnd;
}
HRESULT OmBrowserWndRecord::GetType(GUID *windowType)
{
if (NULL == windowType) return E_POINTER;
*windowType = type;
return S_OK;
}
HRESULT OmBrowserWndRecord::IsEqualType(const GUID *windowType)
{
if (NULL == windowType)
{
return (FALSE != IsEqualGUID(GUID_NULL, type)) ? S_OK : S_FALSE;
}
return (FALSE != IsEqualGUID(*windowType, type)) ? S_OK : S_FALSE;
}

View File

@ -0,0 +1,33 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_WINDOW_RECORD_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_WINDOW_RECORD_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
class OmBrowserWndRecord
{
protected:
OmBrowserWndRecord(HWND hwnd, const GUID *type);
~OmBrowserWndRecord();
public:
static HRESULT CreateInstance(HWND hwnd, const GUID *type, OmBrowserWndRecord **instance);
public:
ULONG AddRef();
ULONG Release();
HWND GetHwnd();
HRESULT GetType(GUID *windowType);
HRESULT IsEqualType(const GUID *windowType);
protected:
ULONG ref;
HWND hwnd;
GUID type;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_WINDOW_RECORD_HEADER

View File

@ -0,0 +1,274 @@
#include "main.h"
#include "./cacheDownloader.h"
#include "./cacheRecord.h"
#include "./ifc_wasabihelper.h"
#include "..\Components\wac_network\wac_network_http_receiver_api.h"
#include <strsafe.h>
CacheDownloader::CacheDownloader(CacheRecord *record, BOOL fEnableCompression)
: ref(1), manager(NULL), cookie(NULL), owner(record), state(stateReady), enableCompression(fEnableCompression)
{
InitializeCriticalSection(&lock);
}
CacheDownloader::~CacheDownloader()
{
EnterCriticalSection( &lock );
if ( manager != NULL )
{
if ( NULL != cookie )
{
Abort();
}
ifc_wasabihelper *wasabi;
if ( SUCCEEDED( Plugin_GetWasabiHelper( &wasabi ) ) )
{
wasabi->ReleaseWasabiInterface( &DownloadManagerGUID, (void **)&manager );
wasabi->Release();
}
manager = NULL;
}
LeaveCriticalSection( &lock );
DeleteCriticalSection( &lock );
}
HRESULT CacheDownloader::CreateInstance(CacheRecord *record, LPCWSTR pszAddress, BOOL fEnableCompression, CacheDownloader **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
if (NULL == record || NULL == pszAddress || L'\0' == *pszAddress)
return E_INVALIDARG;
HRESULT hr;
*instance = new CacheDownloader(record, fEnableCompression);
if (NULL == *instance)
{
hr = E_OUTOFMEMORY;
}
else
{
hr = (*instance)->Start(pszAddress);
if (FAILED(hr))
{
(*instance)->Release();
*instance = NULL;
}
}
return hr;
}
size_t CacheDownloader::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t CacheDownloader::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int CacheDownloader::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
*object = NULL;
return E_NOINTERFACE;
}
HRESULT CacheDownloader::Start(LPCWSTR pszAddress)
{
HRESULT hr = S_OK;
LPSTR address = Plugin_WideCharToMultiByte(CP_ACP, 0, pszAddress, -1, NULL, NULL);
if (NULL == address) return E_OUTOFMEMORY;
EnterCriticalSection(&lock);
state = stateInitializing;
LeaveCriticalSection(&lock);
if ( manager == NULL )
{
ifc_wasabihelper *wasabi;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr))
{
hr = wasabi->QueryWasabiInterface(&DownloadManagerGUID, (void**)&manager);
wasabi->Release();
}
}
if (SUCCEEDED(hr))
{
cookie = manager->DownloadEx(address, this, api_downloadManager::DOWNLOADEX_TEMPFILE);
if (NULL == cookie)
{
hr = E_FAIL;
}
}
if (FAILED(hr))
{
EnterCriticalSection(&lock);
state = stateCompleted;
LeaveCriticalSection(&lock);
}
Plugin_FreeAnsiString(address);
return hr;
}
HRESULT CacheDownloader::Abort()
{
HRESULT hr;
EnterCriticalSection(&lock);
if (NULL == manager || NULL == cookie)
{
hr = E_UNEXPECTED;
}
else if (stateCompleted == state)
{
hr = S_FALSE;
}
else
{
state = stateAborting;
manager->CancelDownload(cookie);
hr = S_OK;
}
LeaveCriticalSection(&lock);
return hr;
}
UINT CacheDownloader::GetState()
{
return state;
}
HRESULT CacheDownloader::SetOwner(CacheRecord *record)
{
owner = record;
return S_OK;
}
HRESULT CacheDownloader::DownloadCompleted(INT errorCode)
{
AddRef();
EnterCriticalSection(&lock);
state = stateCompleted;
if (NULL != owner)
{
LPCWSTR pszFile = (api_downloadManager::TICK_SUCCESS == errorCode) ? manager->GetLocation(cookie) : NULL;
owner->DownloadCompleted(pszFile, errorCode);
owner = NULL;
}
manager->ReleaseDownload(cookie);
cookie = NULL;
ifc_wasabihelper *wasabi;
if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabi)))
{
wasabi->ReleaseWasabiInterface(&DownloadManagerGUID, (void**)&manager);
wasabi->Release();
manager = NULL;
}
LeaveCriticalSection(&lock);
Release();
return S_OK;
}
void CacheDownloader::OnInit(DownloadToken token)
{
EnterCriticalSection(&lock);
cookie = token;
if (NULL != cookie)
{
manager->RetainDownload(cookie);
}
state = stateConnecting;
if (FALSE != enableCompression)
{
api_httpreceiver *receiver = manager->GetReceiver(token);
if (NULL != receiver)
receiver->AllowCompression();
}
LeaveCriticalSection(&lock);
}
void CacheDownloader::OnFinish(DownloadToken token)
{
DownloadCompleted(api_downloadManager::TICK_SUCCESS);
}
void CacheDownloader::OnError(DownloadToken token, int errorCode)
{
DownloadCompleted(errorCode);
}
void CacheDownloader::OnCancel(DownloadToken token)
{
DownloadCompleted(api_downloadManager::TICK_NODATA);
}
void CacheDownloader::OnTick(DownloadToken token)
{
EnterCriticalSection(&lock);
if (stateConnecting == state)
state = stateReceiving;
LeaveCriticalSection(&lock);
}
void CacheDownloader::OnConnect(DownloadToken dlToken)
{
EnterCriticalSection(&lock);
state = stateReceiving;
LeaveCriticalSection(&lock);
}
#define CBCLASS CacheDownloader
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONFINISH, OnFinish)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONTICK, OnTick)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONERROR, OnError)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONCANCEL, OnCancel)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONCONNECT, OnConnect)
VCB(IFC_DOWNLOADMANAGERCALLBACK_ONINIT, OnInit)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,73 @@
#ifndef NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER
#define NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "../Components/wac_downloadManager/wac_downloadManager_api.h"
class CacheCallback;
class CacheRecord;
class CacheDownloader : public ifc_downloadManagerCallback
{
public:
typedef enum
{
stateReady = 0,
stateInitializing = 1,
stateConnecting = 2,
stateReceiving = 3,
stateCompleted = 4,
stateAborting = 5,
} States;
protected:
CacheDownloader(CacheRecord *record, BOOL fEnableCompression);
~CacheDownloader();
public:
static HRESULT CreateInstance(CacheRecord *record, LPCWSTR pszAddress, BOOL fEnableCompression, CacheDownloader **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
HRESULT Abort();
UINT GetState();
HRESULT SetOwner(CacheRecord *record);
protected:
HRESULT Start(LPCWSTR pszAddress);
HRESULT DownloadCompleted(INT errorCode);
/* ifc_downloadManagerCallback */
void OnFinish(DownloadToken token);
void OnTick(DownloadToken token);
void OnError(DownloadToken token, int errorCode);
void OnCancel(DownloadToken token);
void OnConnect(DownloadToken token);
void OnInit(DownloadToken token);
protected:
RECVS_DISPATCH;
protected:
ULONG ref;
api_downloadManager *manager;
DownloadToken cookie;
CacheRecord *owner; // owner not ref counted
UINT state;
BOOL enableCompression;
CRITICAL_SECTION lock;
};
#endif //NULLSOFT_WINAMP_CACHE_DOWNLOADER_HEADER

View File

@ -0,0 +1,472 @@
#include "main.h"
#include "./cacheGroup.h"
#include "./cacheRecord.h"
#include "./cacheManager.h"
#include <wininet.h>
#include <shlwapi.h>
#include <strsafe.h>
#include <algorithm>
CacheGroup::CacheGroup(LPCWSTR pszName)
: ref(1), name(NULL), owner(NULL)
{
name = Plugin_CopyString(pszName);
}
CacheGroup::~CacheGroup()
{
Clear();
Plugin_FreeString(name);
}
HRESULT CacheGroup::CreateInstance(LPCWSTR pszName, CacheGroup **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
*instance = new CacheGroup(pszName);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t CacheGroup::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t CacheGroup::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int CacheGroup::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmCacheGroup))
*object = static_cast<ifc_omcachegroup*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT CacheGroup::SetOwner(CacheManager *group)
{
owner = group;
return S_OK;
}
HRESULT CacheGroup::GetName(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
return StringCchCopyEx(pszBuffer, cchBufferMax, name, NULL, NULL, STRSAFE_IGNORE_NULLS);
}
HRESULT CacheGroup::IsEqualName(LPCWSTR pszGroup)
{
if (NULL == pszGroup)
return (NULL == name) ? S_OK : S_FALSE;
if (NULL == name) return S_FALSE;
INT result = CompareString(CSTR_INVARIANT, NORM_IGNORECASE, pszGroup, -1, name, -1);
if (0 == result)
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
return (CSTR_EQUAL == result) ? S_OK : S_FALSE;
}
HRESULT CacheGroup::IsEqual(CacheGroup *group)
{
return (NULL != group) ? IsEqualName(group->name) : E_INVALIDARG;
}
HRESULT CacheGroup::IsEmpty()
{
return (0 == recordList.size()) ? S_OK : S_FALSE;
}
HRESULT CacheGroup::Delete(LPCWSTR pszName)
{
HRESULT hr = S_FALSE;
size_t index = recordList.size();
while(index--)
{
CacheRecord *record = recordList[index];
if (NULL != record && S_OK == record->IsEqualName(pszName))
{
recordList.erase(recordList.begin() + index);
record->Release();
hr = S_OK;
break;
}
}
return hr;
}
HRESULT CacheGroup::Clear()
{
size_t index = recordList.size();
while(index--)
{
CacheRecord *record = recordList[index];
if (NULL != record) record->Release();
}
recordList.clear();
return S_OK;
}
__inline static int __cdecl CacheGroup_RecordSearch(const void *elem1, const void *elem2)
{
int r = ((CacheRecord*)elem2)->CompareTo((LPCWSTR)elem1);
return -r;
}
HRESULT CacheGroup::Find(LPCWSTR pszName, BOOL fInsertMissing, CacheRecord **recordOut, BOOL *created)
{
if (NULL != created)
*created = FALSE;
if (NULL == recordOut)
return E_POINTER;
HRESULT hr = S_FALSE;
size_t index = recordList.size();
if (0 != index)
{
//CacheRecord *rec = (CacheRecord*)bsearch(pszName, recordList.at(0), recordList.size(), sizeof(CacheRecord*), CacheGroup_RecordSearch);
auto it = std::find_if(recordList.begin(), recordList.end(),
[&](CacheRecord* upT) -> bool
{
return upT->CompareTo(pszName) == 0;
}
);
if (it != recordList.end())
{
*recordOut = *it;
(*recordOut)->AddRef();
hr = S_OK;
}
}
if (S_FALSE == hr && FALSE != fInsertMissing)
{
hr = CacheRecord::CreateInstance(pszName, NULL, 0, recordOut);
if (SUCCEEDED(hr))
{
recordList.push_back(*recordOut);
Sort();
(*recordOut)->AddRef();
(*recordOut)->SetOwner(this);
if (NULL != created)
*created = TRUE;
}
}
if (S_OK != hr)
*recordOut = NULL;
return hr;
}
HRESULT CacheGroup::GetPath(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
HRESULT hr;
if (NULL != owner)
{
hr = owner->GetPath(pszBuffer, cchBufferMax);
if (SUCCEEDED(hr) && NULL != name)
{
if (FALSE == PathAppend(pszBuffer, name))
hr = E_OUTOFMEMORY;
}
}
else
{
*pszBuffer = L'\0';
hr = E_UNEXPECTED;
}
return hr;
}
static HRESULT CacheGroup_FormatStoreData(LPWSTR pszBuffer, size_t cchBufferMax, LPCWSTR pszPath, UINT *cchLength)
{
if (NULL == pszBuffer)
return E_INVALIDARG;
size_t remaining = cchBufferMax;
HRESULT hr;
hr = StringCchCopyEx(pszBuffer, remaining, L"path=", &pszBuffer, &remaining, 0);
if (FAILED(hr)) return hr;
hr = StringCchCopyEx(pszBuffer, remaining, pszPath, &pszBuffer, &remaining, 0);
if (FAILED(hr)) return hr;
if (0 == remaining)
return E_OUTOFMEMORY;
remaining--;
pszBuffer++;
*pszBuffer = L'\0';
if (NULL != cchLength)
*cchLength = (UINT)(cchBufferMax - remaining) + 1;
return S_OK;
}
HRESULT CacheGroup::Store(LPCWSTR pszName, LPCWSTR pszPath)
{
HRESULT hr;
WCHAR szBuffer[2048] = {0};
hr = GetPath(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
Plugin_EnsurePathExist(szBuffer);
if (FALSE == PathAppend(szBuffer, L"cache.ini"))
return E_OUTOFMEMORY;
LPSTR pathAnsi = Plugin_WideCharToMultiByte(CP_UTF8, 0, szBuffer, -1, NULL, NULL);
if (NULL == pathAnsi) return E_OUTOFMEMORY;
LPSTR nameAnsi = Plugin_WideCharToMultiByte(CP_UTF8, 0, pszName, -1, NULL, NULL);
if (NULL == nameAnsi) return E_OUTOFMEMORY;
LPSTR dataAnsi = NULL;
if (NULL != pszPath)
{
UINT cchData;
hr = CacheGroup_FormatStoreData(szBuffer, ARRAYSIZE(szBuffer), pszPath, &cchData);
if (SUCCEEDED(hr))
{
dataAnsi = Plugin_WideCharToMultiByte(CP_UTF8, 0, szBuffer, cchData, NULL, NULL);
if (NULL == dataAnsi)
hr = E_OUTOFMEMORY;
}
}
if (SUCCEEDED(hr) && 0 == WritePrivateProfileSectionA(nameAnsi, dataAnsi, pathAnsi))
{
DWORD error = GetLastError();
hr = HRESULT_FROM_WIN32(error);
}
Plugin_FreeAnsiString(dataAnsi);
Plugin_FreeAnsiString(nameAnsi);
Plugin_FreeAnsiString(pathAnsi);
return hr;
}
HRESULT CacheGroup::Load()
{
HRESULT hr;
WCHAR szBuffer[4096] = {0};
hr = GetPath(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
if (FALSE == PathAppend(szBuffer, L"cache.ini"))
return E_OUTOFMEMORY;
HANDLE hFile = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (INVALID_HANDLE_VALUE == hFile)
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
DWORD read = 0;
CHAR szLine[INTERNET_MAX_URL_LENGTH + 3] = {0};
WCHAR szUnicode[ARRAYSIZE(szLine)] = {0};
UINT lineIndex = 0;
CacheRecord *record = NULL;
UINT recordSet = 0;
size_t inserted = 0;
RecordList cleanupList;
while (0 != ReadFile(hFile, szBuffer, sizeof(szBuffer), &read, NULL))
{
LPCSTR cursor = (LPCSTR)szBuffer;
LPCSTR end = cursor + read;
for(;;)
{
if (cursor >= end)
break;
if (cursor == end || ('\r' == *cursor && '\n' == *(cursor+1)))
{
szLine[lineIndex] = '\0';
if (lineIndex > 0)
{
if ('[' == szLine[0] && ']' == szLine[lineIndex-1])
{
if (NULL != record)
{
if (0 != (0x00000001 & recordSet))
{
recordList.push_back(record);
inserted++;
}
else
{
cleanupList.push_back(record);
}
record = NULL;
}
szLine[lineIndex-1] = '\0';
if (0 != MultiByteToWideChar(CP_UTF8, 0, szLine + 1, -1, szUnicode, ARRAYSIZE(szUnicode)) &&
SUCCEEDED(CacheRecord::CreateInstance(szUnicode, NULL, 0, &record)))
{
record->SetOwner(this);
recordSet = 0;
}
}
else
{
const char kw_path[] = "path=";
UINT cchKey = ARRAYSIZE(kw_path) - 1;
if (NULL != record &&
lineIndex > cchKey &&
CSTR_EQUAL == CompareStringA(CSTR_INVARIANT, NORM_IGNORECASE, kw_path, cchKey, szLine, cchKey) &&
0 != MultiByteToWideChar(CP_UTF8, 0, szLine + cchKey, -1, szUnicode, ARRAYSIZE(szUnicode)))
{
if(SUCCEEDED(record->SetPath(szUnicode)) &&
SUCCEEDED(record->GetPath(szUnicode, ARRAYSIZE(szUnicode))) &&
FALSE != PathFileExists(szUnicode))
{
recordSet |= 0x00000001;
}
}
}
}
lineIndex = 0;
cursor += 2;
continue;
}
if (lineIndex < ARRAYSIZE(szLine) - 2)
{
szLine[lineIndex++] = *cursor;
}
cursor++;
}
if (0 == read)
{
if (NULL != record)
{
if (0 != (0x00000001 & recordSet))
{
recordList.push_back(record);
inserted++;
}
else
record->Release();
}
break;
}
}
CloseHandle(hFile);
if (0 != inserted)
{
Sort();
}
size_t i = cleanupList.size();
if (0 != i)
{
while (i--)
{
aTRACE_LINE("ADD CACHE CLEANUP!!!!");
cleanupList[i]->Release();
}
}
return S_OK;
}
__inline static int __cdecl CacheGroup_RecordComparer(const void *elem1, const void *elem2)
{
return CacheRecord::Compare((CacheRecord*)elem1, (CacheRecord*)elem2);
}
__inline static bool __cdecl CacheGroup_RecordComparer_V2(const void* elem1, const void* elem2)
{
return CacheGroup_RecordComparer(elem1, elem2) < 0;
}
HRESULT CacheGroup::Sort()
{
HRESULT hr;
if (0 == recordList.size())
{
hr = S_FALSE;
}
else
{
//qsort(recordList.first(), recordList.size(), sizeof(CacheRecord*), CacheGroup_RecordComparer);
std::sort(recordList.begin(), recordList.end(), CacheGroup_RecordComparer_V2);
hr = S_OK;
}
return hr;
}
#define CBCLASS CacheGroup
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETNAME, GetName)
CB(API_FIND, Find)
CB(API_DELETE, Delete)
CB(API_CLEAR, Clear)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,63 @@
#ifndef NULLSOFT_WINAMP_CACHE_GROUP_HEADER
#define NULLSOFT_WINAMP_CACHE_GROUP_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "./ifc_omcachegroup.h"
#include <vector>
class CacheRecord;
class CacheManager;
class CacheGroup : public ifc_omcachegroup
{
protected:
CacheGroup(LPCWSTR pszName);
~CacheGroup();
public:
static HRESULT CreateInstance(LPCWSTR pszName, CacheGroup **instace);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
HRESULT SetOwner(CacheManager *group);
HRESULT IsEqual(CacheGroup *group);
HRESULT IsEqualName(LPCWSTR pszGroup);
HRESULT IsEmpty();
HRESULT GetName(LPWSTR pszBuffer, UINT cchBufferMax);
HRESULT Find(LPCWSTR pszName, BOOL fInsertMissing, CacheRecord **recordOut, BOOL *created);
HRESULT Delete(LPCWSTR pszName);
HRESULT Clear();
HRESULT Store(LPCWSTR pszName, LPCWSTR pszPath);
HRESULT Load();
HRESULT GetPath(LPWSTR pszBuffer, UINT cchBufferMax);
protected:
HRESULT Sort();
protected:
RECVS_DISPATCH;
typedef std::vector<CacheRecord*> RecordList;
protected:
size_t ref;
LPWSTR name;
CacheManager *owner;
RecordList recordList;
};
#endif //NULLSOFT_WINAMP_CACHE_HEADER

View File

@ -0,0 +1,192 @@
#include "main.h"
#include "./cacheManager.h"
#include "./cacheGroup.h"
#include "./ifc_wasabihelper.h"
#include <shlwapi.h>
#include <strsafe.h>
CacheManager::CacheManager()
: ref(1)
{
}
CacheManager::~CacheManager()
{
Clear();
}
HRESULT CacheManager::CreateInstance(CacheManager **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
*instance = new CacheManager();
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t CacheManager::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t CacheManager::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int CacheManager::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmCacheManager))
*object = static_cast<ifc_omcachemanager*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT CacheManager::Clear()
{
size_t index = groupList.size();
while(index--)
{
CacheGroup *group = groupList[index];
if (NULL != group) group->Release();
}
groupList.clear();
return S_OK;
}
HRESULT CacheManager::Delete(LPCWSTR pszGroup)
{
HRESULT hr = S_FALSE;
size_t index = groupList.size();
while(index--)
{
CacheGroup *group = groupList[index];
if (NULL != group && S_OK == group->IsEqualName(pszGroup))
{
groupList.erase(groupList.begin() + index);
group->Release();
hr = S_OK;
break;
}
}
return hr;
}
HRESULT CacheManager::Find(LPCWSTR pszGroup, BOOL fInsertMissing, CacheGroup **groupOut, BOOL *created)
{
if (NULL != created) *created = FALSE;
if (NULL == groupOut) return E_POINTER;
HRESULT hr = S_FALSE;
size_t index = groupList.size();
CacheGroup *group;
while(index--)
{
group = groupList[index];
if (NULL != group && S_OK == group->IsEqualName(pszGroup))
{
*groupOut = group;
group->AddRef();
hr = S_OK;
break;
}
}
if (S_FALSE == hr && FALSE != fInsertMissing)
{
hr = CacheGroup::CreateInstance(pszGroup, &group);
if (SUCCEEDED(hr))
{
groupList.push_back(group);
group->SetOwner(this);
group->Load();
group->AddRef();
*groupOut = group;
if (NULL != created) *created = TRUE;
}
}
if (S_OK != hr)
*groupOut = NULL;
return hr;
}
HRESULT CacheManager::Load()
{
return S_OK;
}
HRESULT CacheManager::GetPath(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
HRESULT hr;
ifc_wasabihelper *wasabi;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr))
{
api_application *application;
hr = wasabi->GetApplicationApi(&application);
if (SUCCEEDED(hr))
{
LPCWSTR pszUser = application->path_getUserSettingsPath();
if (NULL != pszUser)
{
if (NULL == PathCombine(pszBuffer, pszUser, L"Plugins\\omBrowser\\cache"))
hr = E_OUTOFMEMORY;
}
else
{
hr = E_UNEXPECTED;
}
application->Release();
}
wasabi->Release();
}
return hr;
}
#define CBCLASS CacheManager
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_FIND, Find)
CB(API_DELETE, Delete)
CB(API_CLEAR, Clear)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,47 @@
#ifndef NULLSOFT_WINAMP_CACHE_MANAGER_HEADER
#define NULLSOFT_WINAMP_CACHE_MANAGER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "./ifc_omcachemanager.h"
#include <vector>
class CacheGroup;
class CacheManager : public ifc_omcachemanager
{
protected:
CacheManager();
~CacheManager();
public:
static HRESULT CreateInstance(CacheManager **instace);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
HRESULT Load();
/* group managment */
HRESULT Find(LPCWSTR pszGroup, BOOL fInsertMissing, CacheGroup **groupOut, BOOL *created);
HRESULT Delete(LPCWSTR pszGroup);
HRESULT Clear();
HRESULT GetPath(LPWSTR pszBuffer, UINT cchBufferMax);
protected:
RECVS_DISPATCH;
typedef std::vector<CacheGroup*> GroupList;
protected:
size_t ref;
GroupList groupList;
};
#endif //NULLSOFT_WINAMP_CACHE_MANAGER_HEADER

View File

@ -0,0 +1,496 @@
#include "main.h"
#include "./cacheRecord.h"
#include "./cacheDownloader.h"
#include "./cacheGroup.h"
#include "./ifc_omcachecallback.h"
#include <shlwapi.h>
#include <strsafe.h>
CacheRecord::CacheRecord(LPCWSTR pszName, LPCWSTR pszAddress, UINT uFlags)
: ref(1), owner(NULL), name(NULL), path(NULL), flags(uFlags), downloader(NULL), callbackList(NULL)
{
name = Plugin_CopyString(pszName);
path = Plugin_CopyString(pszAddress);
InitializeCriticalSection(&lock);
}
CacheRecord::~CacheRecord()
{
Plugin_FreeString(name);
Plugin_FreeString(path);
EnterCriticalSection(&lock);
if (NULL != downloader)
{
downloader->SetOwner(NULL);
downloader->Release();
}
if (NULL != callbackList)
{
size_t index = callbackList->size();
while(index--)
{
ifc_omcachecallback *callback = callbackList->at(index);
if (NULL != callback) callback->Release();
}
delete(callbackList);
}
LeaveCriticalSection(&lock);
DeleteCriticalSection(&lock);
}
HRESULT CacheRecord::CreateInstance(LPCWSTR pszName, LPCWSTR pszAddress, UINT uFlags, CacheRecord **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
if (NULL == pszName || L'\0' == *pszName) return E_INVALIDARG;
*instance = new CacheRecord(pszName, pszAddress, uFlags);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
INT CacheRecord::Compare(CacheRecord *record1, CacheRecord *record2)
{
if (NULL == record1 || NULL == record2)
return (INT)(INT_PTR)(record1 - record2);
return record1->CompareTo(record2->name);
}
size_t CacheRecord::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t CacheRecord::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int CacheRecord::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmCacheRecord))
*object = static_cast<ifc_omcacherecord*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT CacheRecord::SetOwner(CacheGroup *group)
{
EnterCriticalSection(&lock);
owner = group;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT CacheRecord::GetName(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
return StringCchCopyEx(pszBuffer, cchBufferMax, name, NULL, NULL, STRSAFE_IGNORE_NULLS);
}
HRESULT CacheRecord::GetPath(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
HRESULT hr;
EnterCriticalSection(&lock);
if (NULL == path)
{
*pszBuffer = L'\0';
if (NULL != downloader)
{
hr = E_PENDING;
}
else if (0 != (flagDownloadFailed & flags))
{
hr = E_FAIL;
}
else if (NULL != name && L'\0' != *name && PathIsURL(name) &&
CSTR_EQUAL != CompareString(CSTR_INVARIANT, NORM_IGNORECASE, name, 6, L"res://", 6))
{
hr = Download();
if (SUCCEEDED(hr)) hr = E_PENDING;
}
else
{
hr = E_FAIL;
}
}
else if (FALSE == PathIsRelative(path))
{
hr = StringCchCopy(pszBuffer, cchBufferMax, path);
}
else
{
if (NULL == owner)
{
hr = E_FAIL;
}
else if (FAILED(owner->GetPath(pszBuffer, cchBufferMax)) ||
FALSE == PathAppend(pszBuffer, path))
{
hr = E_OUTOFMEMORY;
}
else
{
hr = S_OK;
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT CacheRecord::SetPath(LPCWSTR pszPath)
{
EnterCriticalSection(&lock);
if (NULL != downloader)
{
downloader->Abort();
downloader->Release();
downloader = NULL;
}
Plugin_FreeString(path);
if (NULL == pszPath)
{
path = NULL;
}
else
{
INT cchCommon = 0;
if (0 != owner)
{
WCHAR szBase[MAX_PATH*2] = {0};
if (SUCCEEDED(owner->GetPath(szBase, ARRAYSIZE(szBase))))
cchCommon = PathCommonPrefix(szBase, pszPath, NULL);
}
if (0 != cchCommon)
{
LPCWSTR p = pszPath + cchCommon;
INT cchSource = lstrlenW(p) + 1/* \0 */;
path = Plugin_MallocString(cchSource + 1 /*to add '.'*/);
if (NULL != path)
{
*path = L'.';
CopyMemory(path + 1, p, sizeof(WCHAR) * cchSource);
}
}
else
{
path = Plugin_CopyString(pszPath);
}
if (NULL == path) return E_OUTOFMEMORY;
}
if (0 == (flagNoStore & flags) && NULL != owner)
owner->Store(name, path);
if (NULL != callbackList)
{
size_t index = callbackList->size();
while(index--)
{
ifc_omcachecallback *cb = callbackList->at(index);
if (NULL != cb) cb->PathChanged(this);
}
}
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT CacheRecord::Download()
{
HRESULT hr;
EnterCriticalSection(&lock);
if (NULL != downloader)
hr = E_PENDING;
else
{
flags &= ~flagDownloadFailed;
hr = CacheDownloader::CreateInstance(this, name, FALSE, &downloader);
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT CacheRecord::DownloadCompleted(LPCWSTR pszFile, INT errorCode)
{
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
CacheDownloader *temp = downloader;
downloader = NULL;
if (api_downloadManager::TICK_SUCCESS == errorCode)
{
WCHAR szTarget[MAX_PATH] = {0};
hr = GetBasePath(szTarget, ARRAYSIZE(szTarget));
if(SUCCEEDED(hr))
{
Plugin_EnsurePathExist(szTarget);
LPCWSTR fileName = PathFindFileName(name);
if (NULL == fileName)
{
WCHAR szTemp[32] = {0};
StringCchPrintf(szTemp, ARRAYSIZE(szTemp), L"%08u.cache", GetTickCount());
PathAppend(szTarget, szTemp);
}
else
{
PathAppend(szTarget, fileName);
}
WCHAR szExt[64] = {0};
UINT attempt = 0;
UINT pExtMax = 0;
LPWSTR pExt = PathFindExtension(szTarget);
if (pExt == szTarget || L'.' != *pExt || FAILED(StringCchCopy(szExt, ARRAYSIZE(szExt), pExt)))
{
szExt[0] = L'\0';
}
else
{
pExtMax = ARRAYSIZE(szTarget) - (UINT)(pExt - szTarget);
}
while(FALSE == CopyFile(pszFile, szTarget, TRUE))
{
DWORD error = GetLastError();
if (ERROR_FILE_EXISTS != error)
{
hr = HRESULT_FROM_WIN32(error);
break;
}
hr = StringCchPrintf(pExt, pExtMax, L"(%u)%s", ++attempt, szExt);
if (FAILED(hr)) break;
}
}
if (SUCCEEDED(hr))
{
SetPath(szTarget);
}
}
else
{
flags |= flagDownloadFailed;
}
if (NULL != temp)
temp->Release();
LeaveCriticalSection(&lock);
return S_OK;
}
INT CacheRecord::CompareTo(LPCWSTR pszName)
{
if (NULL == pszName || NULL == name)
return (INT)(INT_PTR)(name - pszName);
return CompareString(CSTR_INVARIANT, NORM_IGNORECASE, name, -1, pszName, -1) - 2;
}
HRESULT CacheRecord::IsEqualName(LPCWSTR pszName)
{
HRESULT hr;
EnterCriticalSection(&lock);
if (NULL == pszName)
{
hr = (NULL == name) ? S_OK : S_FALSE;
}
else if (NULL == name)
{
hr = S_FALSE;
}
else
{
INT result = CompareString(CSTR_INVARIANT, NORM_IGNORECASE, pszName, -1, name, -1);
if (0 == result)
{
DWORD error = GetLastError();
hr = HRESULT_FROM_WIN32(error);
}
else
{
hr = (CSTR_EQUAL == result) ? S_OK : S_FALSE;
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT CacheRecord::IsEqual(CacheRecord *record)
{
if (NULL == record) return E_INVALIDARG;
HRESULT hr;
EnterCriticalSection(&record->lock);
hr = IsEqualName(record->name);
LeaveCriticalSection(&record->lock);
return hr;
}
HRESULT CacheRecord::RegisterCallback(ifc_omcachecallback *callback)
{
if (NULL == callback)
return E_INVALIDARG;
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
if (NULL == callbackList)
{
callbackList = new CallbackList();
if (NULL == callbackList) hr = E_OUTOFMEMORY;
}
else
{
size_t index = callbackList->size();
while(index--)
{
if (callbackList->at(index) == callback)
hr = E_FAIL;
}
}
if (SUCCEEDED(hr) && NULL != callbackList)
{
callbackList->push_back(callback);
callback->AddRef();
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT CacheRecord::UnregisterCallback(ifc_omcachecallback *callback)
{
if (NULL == callback)
return E_INVALIDARG;
HRESULT hr = S_FALSE;
EnterCriticalSection(&lock);
if (NULL != callbackList)
{
size_t index = callbackList->size();
while(index--)
{
ifc_omcachecallback *test = callbackList->at(index);
if (test == callback)
{
callbackList->erase(callbackList->begin() + index);
test->Release();
hr = S_OK;
if (0 == callbackList->size())
{
delete(callbackList);
callbackList = NULL;
}
}
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT CacheRecord::GetFlags(UINT *puFlags)
{
if (NULL == puFlags) return E_POINTER;
*puFlags = flags;
return S_OK;
}
HRESULT CacheRecord::SetFlags(UINT uFlags, UINT uMask)
{
EnterCriticalSection(&lock);
flags = (flags & ~uMask) | (uFlags & uMask);
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT CacheRecord::GetBasePath(LPWSTR pszBuffer, UINT cchBufferMax)
{
if (NULL == pszBuffer || 0 == cchBufferMax)
return E_INVALIDARG;
HRESULT hr;
EnterCriticalSection(&lock);
if (NULL != owner)
{
hr = owner->GetPath(pszBuffer, cchBufferMax);
}
else
{
*pszBuffer = L'\0';
hr = E_UNEXPECTED;
}
LeaveCriticalSection(&lock);
return hr;
}
#define CBCLASS CacheRecord
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETNAME, GetName)
CB(API_GETPATH, GetPath)
CB(API_SETPATH, SetPath)
CB(API_GETFLAGS, GetFlags)
CB(API_SETFLAGS, SetFlags)
CB(API_DOWNLOAD, Download)
CB(API_REGISTERCALLBACK, RegisterCallback)
CB(API_UNREGISTERCALLBACK, UnregisterCallback)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,73 @@
#ifndef NULLSOFT_WINAMP_CACHE_RECORD_HEADER
#define NULLSOFT_WINAMP_CACHE_RECORD_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "./ifc_omcacherecord.h"
#include <vector>
class CacheGroup;
class CacheDownloader;
class CacheRecord : public ifc_omcacherecord
{
public:
typedef enum
{
flagDownloadFailed = 0x80000000,
} Flags;
protected:
CacheRecord(LPCWSTR pszName, LPCWSTR pszAddress, UINT uFlags);
~CacheRecord();
public:
static HRESULT CreateInstance(LPCWSTR pszName, LPCWSTR pszAddress, UINT uFlags, CacheRecord **instance);
static INT Compare(CacheRecord *record1, CacheRecord *record2);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
HRESULT SetOwner(CacheGroup *group);
HRESULT IsEqual(CacheRecord *record);
HRESULT IsEqualName(LPCWSTR pszName);
INT CompareTo(LPCWSTR pszName);
HRESULT GetName(LPWSTR pszBuffer, UINT cchBufferMax);
HRESULT GetPath(LPWSTR pszBuffer, UINT cchBufferMax);
HRESULT SetPath(LPCWSTR pszPath);
HRESULT GetFlags(UINT *puFlags);
HRESULT SetFlags(UINT uFlags, UINT uMask);
HRESULT Download();
HRESULT RegisterCallback(ifc_omcachecallback *callback);
HRESULT UnregisterCallback(ifc_omcachecallback *callback);
HRESULT DownloadCompleted(LPCWSTR pszFile, INT errorCode);
HRESULT GetBasePath(LPWSTR pszBuffer, UINT cchBufferMax);
protected:
RECVS_DISPATCH;
typedef std::vector<ifc_omcachecallback*> CallbackList;
protected:
size_t ref;
CacheGroup *owner;
LPWSTR name;
LPWSTR path;
UINT flags;
CacheDownloader *downloader;
CallbackList *callbackList;
CRITICAL_SECTION lock;
};
#endif //NULLSOFT_WINAMP_CACHE_RECORD_HEADER

53
Src/omBrowser/common.h Normal file
View File

@ -0,0 +1,53 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_COMMON_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_COMMON_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#ifndef _WIN32_IE_IE70
#define _WIN32_IE_IE70 0x0700
#endif //_WIN32_IE_IE70
#include <wtypes.h>
#include "../nu/trace.h"
#define CSTR_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
#ifndef ARRAYSIZE
#define ARRAYSIZE(blah) (sizeof(blah)/sizeof(*blah))
#endif
#ifndef LONGX86
#ifdef _WIN64
#define LONGX86 LONG_PTR
#else /*_WIN64*/
#define LONGX86 LONG
#endif /*_WIN64*/
#endif // LONGX86
#define __WTEXT(quote) L##quote
#define WTEXT(quote) __WTEXT(quote)
#ifdef __cplusplus
#define SENDMSG(__hwnd, __msgId, __wParam, __lParam) ::SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
#else
#define SENDMSG(__hwnd, __msgId, __wParam, __lParam) SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
#endif // __cplusplus
#define SENDMLIPC(__hwndML, __ipcMsgId, __param) SENDMSG((__hwndML), WM_ML_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
#define SENDWAIPC(__hwndWA, __ipcMsgId, __param) SENDMSG((__hwndWA), WM_WA_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
#define MSGRESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWLP_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
#define SENDCMD(__hwnd, __ctrlId, __eventId, __hctrl) (SENDMSG((__hwnd), WM_COMMAND, MAKEWPARAM(__ctrlId, __eventId), (LPARAM)(__hctrl)))
#ifndef GetWindowStyle
#define GetWindowStyle(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_STYLE))
#endif //GetWindowStyle
#ifndef GetWindowStyleEx
#define GetWindowStyleEx(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_EXSTYLE))
#endif // GetWindowStyleEx
#endif //NULLSOFT_WINAMP_OMBROWSER_COMMON_HEADER

549
Src/omBrowser/component.cpp Normal file
View File

@ -0,0 +1,549 @@
#include "./main.h"
#include "./component.h"
#include "./browserFactory.h"
#include "./serviceFactory.h"
#include "./utilityFactory.h"
#include "./wasabiHelper.h"
#include "./winampHook.h"
#include "./skinHelper.h"
#include "./browserClass.h"
#include "./internetFeatures.h"
#include "./ieVersion.h"
#include <wininet.h>
#include <strsafe.h>
static OmBrowserFactory browserFactory;
static OmServiceFactory serviceFactory;
static OmUtilityFactory utilityFactory;
OmBrowserComponent::OmBrowserComponent()
: wasabiHelper(NULL), winampHook(NULL), skinHelper(NULL), hookCookie(0), internetFeatures(NULL)
{
InitializeCriticalSection(&lock);
}
OmBrowserComponent::~OmBrowserComponent()
{
ReleaseServices();
if (NULL != internetFeatures)
{
delete(internetFeatures);
internetFeatures = NULL;
InternetSetOption(NULL, INTERNET_OPTION_END_BROWSER_SESSION, NULL, 0);
}
DeleteCriticalSection(&lock);
}
size_t OmBrowserComponent::AddRef()
{
return 1;
}
size_t OmBrowserComponent::Release()
{
return 1;
}
int OmBrowserComponent::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_WinampHook))
*object = static_cast<ifc_winamphook*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
void OmBrowserComponent::RegisterServices(api_service *service)
{
EnterCriticalSection(&lock);
if (NULL == wasabiHelper)
WasabiHelper::CreateInstance(service, &wasabiHelper);
aTRACE_LINE("omBrowser Registered");
browserFactory.Register(service);
serviceFactory.Register(service);
utilityFactory.Register(service);
LeaveCriticalSection(&lock);
}
void OmBrowserComponent::ReleaseServices()
{
EnterCriticalSection(&lock);
if (NULL != wasabiHelper)
{
wasabiHelper->Release();
wasabiHelper = NULL;
}
if (NULL != winampHook)
{
winampHook->Release();
winampHook = NULL;
}
if (0 != hookCookie)
{
UnregisterWinampHook(hookCookie);
hookCookie = 0;
}
if (NULL != skinHelper)
{
skinHelper->Release();
skinHelper = NULL;
}
LeaveCriticalSection(&lock);
}
int OmBrowserComponent::RegisterServicesSafeModeOk()
{
return 1;
}
void OmBrowserComponent::DeregisterServices(api_service *service)
{
browserFactory.Unregister(service);
serviceFactory.Unregister(service);
utilityFactory.Unregister(service);
ReleaseServices();
size_t index = unloadCallbacks.size();
while(index--)
{
PLUGINUNLOADCALLBACK callback = unloadCallbacks[index];
if (NULL != callback) callback();
}
unloadCallbacks.clear();
}
HRESULT OmBrowserComponent::InitializeComponent(HWND hwndWinamp)
{
HRESULT hr(S_FALSE);
EnterCriticalSection(&lock);
if(NULL == winampHook)
{
HRESULT hookResult = WinampHook::CreateInstance(hwndWinamp, &winampHook);
if (FAILED(hookResult) && SUCCEEDED(hr)) hr = hookResult;
}
if (SUCCEEDED(hr) && 0 == hookCookie)
{
hr = winampHook->RegisterCallback(this, &hookCookie);
}
if (NULL == skinHelper)
{
HRESULT skinResult = SkinHelper::CreateInstance(hwndWinamp, &skinHelper);
if (FAILED(skinResult) && SUCCEEDED(hr)) hr = skinResult;
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserComponent::GetWasabiHelper( ifc_wasabihelper **wasabiOut )
{
if ( NULL == wasabiOut ) return E_POINTER;
EnterCriticalSection( &lock );
*wasabiOut = wasabiHelper;
if ( NULL != wasabiHelper )
wasabiHelper->AddRef();
LeaveCriticalSection( &lock );
return ( NULL != *wasabiOut ) ? S_OK : E_NOINTERFACE;
}
HRESULT OmBrowserComponent::GetSkinHelper(ifc_skinhelper **skinOut)
{
if (NULL == skinOut) return E_POINTER;
EnterCriticalSection(&lock);
*skinOut = skinHelper;
if (NULL != skinHelper)
skinHelper->AddRef();
LeaveCriticalSection(&lock);
return (NULL != *skinOut) ? S_OK : E_NOINTERFACE;
}
HRESULT OmBrowserComponent::RegisterWinampHook(ifc_winamphook *hook, UINT *cookieOut)
{
if (NULL == cookieOut) return E_POINTER;
*cookieOut = NULL;
EnterCriticalSection(&lock);
HRESULT hr = (NULL != winampHook) ? winampHook->RegisterCallback(hook, cookieOut) : E_FAIL;
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserComponent::UnregisterWinampHook(UINT cookie)
{
EnterCriticalSection(&lock);
HRESULT hr = (NULL != winampHook) ? winampHook->UnregisterCallback(cookie) : E_FAIL;
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserComponent::GetWinampWnd(HWND *hwndWinamp)
{
if (NULL == hwndWinamp) return E_POINTER;
EnterCriticalSection(&lock);
*hwndWinamp = (NULL != winampHook) ? winampHook->GetWinamp() : NULL;
LeaveCriticalSection(&lock);
HRESULT hr;
if (NULL == *hwndWinamp)
hr = E_FAIL;
else
hr = S_OK;
return hr;
}
HRESULT OmBrowserComponent::ResetFont(void)
{
if (NULL != skinHelper)
skinHelper->ResetFontCache();
return S_OK;
}
HRESULT OmBrowserComponent::SkinChanged(const wchar_t *skinName)
{
UpdateColors();
return S_OK;
}
HRESULT OmBrowserComponent::SkinColorChange(const wchar_t *colorTheme)
{
UpdateColors();
return S_OK;
}
HRESULT OmBrowserComponent::RegisterUnloadCallback(PLUGINUNLOADCALLBACK callback)
{
if(NULL == callback) return E_INVALIDARG;
unloadCallbacks.push_back(callback);
return S_OK;
}
HRESULT OmBrowserComponent::GetBrowserClass(LPCWSTR pszName, ifc_ombrowserclass **instance)
{
if (NULL == instance) return E_POINTER;
HRESULT hr(S_OK);
ifc_ombrowserclass *browserClass = NULL;
EnterCriticalSection(&lock);
size_t index = browserClasses.size();
while(index--)
{
browserClass = browserClasses[index];
if (S_OK == browserClass->IsEqual(pszName))
{
browserClass->AddRef();
break;
}
}
if (((size_t)-1) == index)
{
hr = OmBrowserClass::CreateInstance(pszName, (OmBrowserClass**)&browserClass);
if (SUCCEEDED(hr) && browserClass != NULL)
{
if (0 == browserClasses.size())
{
SetUserAgent();
SetInternetFeautures();
}
browserClasses.push_back(browserClass);
}
}
*instance = (SUCCEEDED(hr) && browserClass != NULL) ? browserClass : NULL;
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmBrowserComponent::UnregisterBrowserClass(LPCWSTR pszName)
{
HRESULT hr(S_FALSE);
EnterCriticalSection(&lock);
size_t index = browserClasses.size();
while(index--)
{
ifc_ombrowserclass *browserClass = browserClasses[index];
if (S_OK == browserClass->IsEqual(pszName))
{
browserClasses.erase(browserClasses.begin() + index);
hr = S_OK;
break;
}
}
LeaveCriticalSection(&lock);
return hr;
}
void OmBrowserComponent::UpdateColors()
{
if (NULL != skinHelper)
skinHelper->ResetColorCache();
EnterCriticalSection(&lock);
size_t index = browserClasses.size();
while(index--)
{
browserClasses[index]->UpdateRegColors();
}
LeaveCriticalSection(&lock);
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0 );
}
typedef struct __INTERNETFEATUREREC
{
INTERNETFEATURELIST entry;
DWORD flags;
BOOL enabled;
} INTERNETFEATUREREC;
void OmBrowserComponent::SetInternetFeautures()
{
const INTERNETFEATUREREC szFeatures[] =
{
{ FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_PROCESS, TRUE },
{ FEATURE_TABBED_BROWSING, SET_FEATURE_ON_PROCESS, TRUE },
{ FEATURE_WINDOW_RESTRICTIONS, SET_FEATURE_ON_PROCESS, FALSE },
{ FEATURE_SSLUX, SET_FEATURE_ON_PROCESS, TRUE },
{ FEATURE_FORCE_ADDR_AND_STATUS, SET_FEATURE_ON_PROCESS, FALSE },
{ FEATURE_BLOCK_INPUT_PROMPTS, SET_FEATURE_ON_PROCESS, FALSE },
{ FEATURE_MIME_HANDLING, SET_FEATURE_ON_PROCESS, TRUE },
{ FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE },
};
EnterCriticalSection(&lock);
if (NULL == internetFeatures)
{
internetFeatures = new InternetFeatures();
if (NULL == internetFeatures)
{
LeaveCriticalSection(&lock);
return;
}
}
UINT modified = 0;
HRESULT hr;
for (INT i = 0; i < ARRAYSIZE(szFeatures); i++)
{
const INTERNETFEATUREREC *rec = &szFeatures[i];
hr = internetFeatures->IsEnabled(rec->entry, rec->flags);
if ((S_OK == hr && FALSE == rec->enabled) || (S_FALSE == hr && FALSE != rec->enabled))
{
if (SUCCEEDED(internetFeatures->SetEnabled(rec->entry, rec->flags, rec->enabled)))
modified++;
}
}
int majorVersion = 0;
if (SUCCEEDED(MSIE_GetVersion(&majorVersion, NULL, NULL, NULL)))
{
unsigned long browserEmulation = 0;
if (8 == majorVersion)
browserEmulation = 8000;
else if (9 == majorVersion)
browserEmulation = 9000;
else if (10 <= majorVersion)
browserEmulation = 10000;
else
browserEmulation = 0;
unsigned long valueAlreadySet = 0;
hr = internetFeatures->GetDWORDFeature(L"FEATURE_BROWSER_EMULATION", TRUE, &valueAlreadySet);
if (FAILED(hr) || valueAlreadySet != browserEmulation)
{
if (0 == browserEmulation)
{
if (0x80070002 /*ERROR_FILE_NOT_FOUND */ != hr)
internetFeatures->DeleteFeature(L"FEATURE_BROWSER_EMULATION", TRUE);
}
else
{
if (SUCCEEDED(internetFeatures->SetDWORDFeature(L"FEATURE_BROWSER_EMULATION", TRUE, browserEmulation)))
modified++;
}
}
}
LeaveCriticalSection(&lock);
if (0 != modified)
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0 );
}
static HRESULT
Component_PrintWinampUA(char *buffer, size_t bufferMax)
{
char *cursor = buffer;
size_t remaining = bufferMax;
HRESULT hr = StringCchPrintfExA(cursor, remaining,
&cursor, &remaining,
STRSAFE_NULL_ON_FAILURE,
"%S/%d.%d",
OMBROWSER_NAME,
OMBROWSER_VERSION_MAJOR,
OMBROWSER_VERSION_MINOR);
if (SUCCEEDED(hr))
{
ifc_wasabihelper *wasabi = NULL;
if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabi)) && wasabi != NULL)
{
api_application *app = NULL;
if (SUCCEEDED(wasabi->GetApplicationApi(&app)) && app != NULL)
{
char *rollback = cursor;
hr = StringCchPrintfExA(cursor, remaining,
&cursor, &remaining,
STRSAFE_NULL_ON_FAILURE,
" (%S)",
app->main_getVersionString());
if (FAILED(hr))
*rollback = '\0';
app->Release();
}
wasabi->Release();
}
}
if (FAILED(hr))
buffer[0] = '\0';
return hr;
}
BOOL OmBrowserComponent::SetUserAgent(void)
{
unsigned long bufferSize = 0;
HRESULT hr = UrlMkGetSessionOption(URLMON_OPTION_USERAGENT,
NULL,
0,
&bufferSize,
0);
if(E_OUTOFMEMORY == hr)
hr = S_OK;
if (FAILED(hr))
return FALSE;
bufferSize += 512;
char *buffer = (char *)calloc(bufferSize, sizeof(char));
if (NULL == buffer)
return FALSE;
unsigned long bufferLength = 0;
hr = UrlMkGetSessionOption(URLMON_OPTION_USERAGENT,
buffer,
bufferSize,
&bufferLength,
0);
if (E_OUTOFMEMORY == hr
&& bufferLength <= bufferSize)
{
hr = S_OK;
}
if (SUCCEEDED(hr))
{
if (bufferLength > 0
&& bufferLength < bufferSize)
{
buffer[bufferLength - 1] = ' ';
}
hr = Component_PrintWinampUA(buffer + bufferLength,
bufferSize - bufferLength);
if (FAILED(hr))
{
if (bufferLength > 0)
buffer[bufferLength - 1] = '\0';
}
else
{
bufferLength = lstrlenA(buffer);
hr = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT,
buffer,
bufferLength,
0);
}
}
free(buffer);
return SUCCEEDED(hr);
}
#define CBCLASS OmBrowserComponent
START_MULTIPATCH;
START_PATCH(MPIID_WA5COMPONENT)
M_CB(MPIID_WA5COMPONENT, ifc_wa5component, ADDREF, AddRef);
M_CB(MPIID_WA5COMPONENT, ifc_wa5component, RELEASE, Release);
M_CB(MPIID_WA5COMPONENT, ifc_wa5component, QUERYINTERFACE, QueryInterface);
M_VCB(MPIID_WA5COMPONENT, ifc_wa5component, API_WA5COMPONENT_REGISTERSERVICES, RegisterServices);
M_CB(MPIID_WA5COMPONENT, ifc_wa5component, 15, RegisterServicesSafeModeOk)
M_VCB(MPIID_WA5COMPONENT, ifc_wa5component, API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices);
NEXT_PATCH(MPIID_WINAMPHOOK)
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, ADDREF, AddRef);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, RELEASE, Release);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_RESETFONT, ResetFont);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_SKINCHANGED, SkinChanged);
M_CB(MPIID_WINAMPHOOK, ifc_winamphook, API_SKINCOLORCHANGE, SkinColorChange);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

84
Src/omBrowser/component.h Normal file
View File

@ -0,0 +1,84 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_COMPONENT_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_COMPONENT_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "../Agave/Component/ifc_wa5component.h"
#include "./ifc_winamphook.h"
#include <bfc/multipatch.h>
#include <vector>
class WasabiHelper;
class WinampHook;
class SkinHelper;
class ifc_wasabihelper;
class ifc_skinhelper;
class ifc_ombrowserclass;
class InternetFeatures;
#define MPIID_WA5COMPONENT 10
#define MPIID_WINAMPHOOK 20
class OmBrowserComponent : public MultiPatch<MPIID_WA5COMPONENT, ifc_wa5component>,
public MultiPatch<MPIID_WINAMPHOOK, ifc_winamphook>
{
public:
OmBrowserComponent();
~OmBrowserComponent();
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_wa5component */
void RegisterServices(api_service *service);
int RegisterServicesSafeModeOk();
void DeregisterServices(api_service *service);
/* ifc_winamphook (partial) */
HRESULT ResetFont(void);
HRESULT SkinChanged(const wchar_t *skinName);
HRESULT SkinColorChange(const wchar_t *colorTheme);
public:
HRESULT InitializeComponent(HWND hwndWinamp);
HRESULT GetWasabiHelper(ifc_wasabihelper **wasabiOut);
HRESULT GetSkinHelper(ifc_skinhelper **skinOut);
HRESULT RegisterWinampHook(ifc_winamphook *hook, UINT *cookieOut);
HRESULT UnregisterWinampHook(UINT cookie);
HRESULT GetWinampWnd(HWND *hwndWinamp);
HRESULT RegisterUnloadCallback(PLUGINUNLOADCALLBACK callback);
HRESULT GetBrowserClass(LPCWSTR pszName, ifc_ombrowserclass **instance);
HRESULT UnregisterBrowserClass(LPCWSTR pszName);
protected:
void ReleaseServices(void);
void UpdateColors(void);
void SetInternetFeautures(void);
BOOL SetUserAgent(void);
protected:
RECVS_MULTIPATCH;
private:
typedef std::vector<PLUGINUNLOADCALLBACK> UnloadCallbackList;
typedef std::vector<ifc_ombrowserclass*> BrowserClassList;
private:
WasabiHelper *wasabiHelper;
WinampHook *winampHook;
SkinHelper *skinHelper;
UINT hookCookie;
CRITICAL_SECTION lock;
UnloadCallbackList unloadCallbacks;
BrowserClassList browserClasses;
InternetFeatures *internetFeatures;
};
#endif //NULLSOFT_WINAMP_OMBROWSER_COMPONENT_HEADER

704
Src/omBrowser/configIni.cpp Normal file
View File

@ -0,0 +1,704 @@
#include "./main.h"
#include "./configIni.h"
#include "./ifc_wasabihelper.h"
#include "./ifc_omconfigcallback.h"
#include <api/application/api_application.h>
#include <shlwapi.h>
#include <strsafe.h>
#define BROWSER_SECTION L"OmBrowser"
#define BROWSER_CLIENTID L"clientId"
#define BROWSER_XPOS L"x"
#define BROWSER_YPOS L"y"
#define DEBUG_SECTION L"Debug"
#define DEBUG_BROWSERPATH L"browserPath"
#define DEBUG_FILTERCONTEXTMENU L"filterContextMenu"
#define DEBUG_SHOWSCRIPTDEBUGGER L"showScriptDebugger"
#define DEBUG_SHOWSCRIPTERROR L"showScriptErrors"
#define TOOLBAR_SECTION L"Toolbar"
#define TOOLBAR_BOTTOMDOCK L"bottomDock"
#define TOOLBAR_AUTOHIDE L"autoHide"
#define TOOLBAR_TABSTOP L"tabStop"
#define TOOLBAR_FORCEADDRESSBAR L"addressbarForce"
#define TOOLBAR_FANCYADDRESSBAR L"addressbarFancy"
#define STATUSBAR_SECTION L"Statusbar"
#define STATUSBAR_ENABLED L"enabled"
#define BOOL2HRESULT(__result) ((FALSE != (__result)) ? S_OK : S_FALSE)
OmConfigIni::OmConfigIni(LPCWSTR pszPath)
: ref(1), configPath(NULL), lastCookie(0),
pathValidated(FALSE)
{
InitializeCriticalSection(&lock);
configPath = Plugin_CopyString(pszPath);
}
OmConfigIni::~OmConfigIni()
{
EnterCriticalSection(&lock);
for(CallbackMap::iterator iter = callbackMap.begin(); iter != callbackMap.end(); iter++)
{
ifc_omconfigcallback *callback = iter->second;
if (NULL != callback) callback->Release();
}
LeaveCriticalSection(&lock);
Plugin_FreeString(configPath);
DeleteCriticalSection(&lock);
}
static HRESULT OmConfigIni_MakeFileName(LPWSTR pszBuffer, INT cchBufferMax, LPCWSTR pszName)
{
if (NULL == pszBuffer)
return E_POINTER;
if (NULL == pszName || L'\0' == *pszName ||
FAILED(StringCchCopy(pszBuffer, cchBufferMax, pszName)))
{
return E_INVALIDARG;
}
PathRemoveBlanks(pszBuffer);
INT cchBuffer = lstrlen(pszBuffer);
if (0 == cchBuffer)
return E_INVALIDARG;
if (FAILED(StringCchCopy(pszBuffer + cchBuffer, cchBufferMax - cchBuffer, L".ini")))
return E_FAIL;
return S_OK;
}
HRESULT OmConfigIni::CreateInstance(LPCWSTR pszName, OmConfigIni **instanceOut)
{
if (NULL == instanceOut) return E_POINTER;
*instanceOut = NULL;
WCHAR szFile[MAX_PATH] = {0};
HRESULT hr = OmConfigIni_MakeFileName(szFile, ARRAYSIZE(szFile), pszName);
if (FAILED(hr)) return hr;
ifc_wasabihelper *wasabi = NULL;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr) && wasabi != NULL)
{
api_application *app = NULL;
hr = wasabi->GetApplicationApi(&app);
if (SUCCEEDED(hr) && app != NULL)
{
WCHAR szBuffer[1024] = {0};
LPCWSTR userPath = app->path_getUserSettingsPath();
if (NULL == userPath || L'\0' == *userPath ||
NULL == PathCombine(szBuffer, userPath, L"Plugins\\omBrowser") ||
FALSE == PathAppend(szBuffer, szFile))
{
hr = E_UNEXPECTED;
}
else
{
*instanceOut = new OmConfigIni(szBuffer);
if (NULL == *instanceOut) hr = E_OUTOFMEMORY;
}
app->Release();
}
wasabi->Release();
}
return hr;
}
size_t OmConfigIni::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t OmConfigIni::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int OmConfigIni::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmConfig))
*object = static_cast<ifc_omconfig*>(this);
else if (IsEqualIID(interface_guid, IFC_OmBrowserConfig))
*object = static_cast<ifc_ombrowserconfig*>(this);
else if (IsEqualIID(interface_guid, IFC_OmDebugConfig))
*object = static_cast<ifc_omdebugconfig*>(this);
else if (IsEqualIID(interface_guid, IFC_OmToolbarConfig))
*object = static_cast<ifc_omtoolbarconfig*>(this);
else if (IsEqualIID(interface_guid, IFC_OmStatusbarConfig))
*object = static_cast<ifc_omstatusbarconfig*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT OmConfigIni::GetPath(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
return StringCchCopy(pszBuffer, cchBufferMax, configPath);
}
DWORD OmConfigIni::ReadStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize)
{
return GetPrivateProfileStringW(lpSectionName, lpKeyName, lpDefault, lpReturnedString, nSize, configPath);
}
UINT OmConfigIni::ReadInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nDefault)
{
return GetPrivateProfileIntW(lpSectionName, lpKeyName, nDefault, configPath);
}
BOOL OmConfigIni::ReadBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bDefault)
{
WCHAR szBuffer[32] = {0};
INT cchLen = ReadStr(lpSectionName, lpKeyName, NULL, szBuffer, ARRAYSIZE(szBuffer));
if (0 == cchLen) return bDefault;
if (1 == cchLen)
{
switch(*szBuffer)
{
case L'0':
case L'n':
case L'f':
return FALSE;
case L'1':
case L'y':
case L't':
return TRUE;
}
}
else
{
if (CSTR_EQUAL == CompareString(CSTR_INVARIANT, NORM_IGNORECASE, L"yes", -1, szBuffer, cchLen) ||
CSTR_EQUAL == CompareString(CSTR_INVARIANT, NORM_IGNORECASE, L"true", -1, szBuffer, cchLen))
{
return TRUE;
}
if (CSTR_EQUAL == CompareString(CSTR_INVARIANT, NORM_IGNORECASE, L"no", -1, szBuffer, cchLen) ||
CSTR_EQUAL == CompareString(CSTR_INVARIANT, NORM_IGNORECASE, L"false", -1, szBuffer, cchLen))
{
return FALSE;
}
}
INT v = 0;
if (FALSE != StrToIntEx(szBuffer, STIF_SUPPORT_HEX, &v))
return (0 != v);
return bDefault;
}
HRESULT OmConfigIni::WriteStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString)
{
if (NULL == configPath || L'\0' == *configPath)
return E_UNEXPECTED;
if (FALSE == pathValidated)
{
WCHAR szDirectory[MAX_PATH*2] = {0};
if (SUCCEEDED(StringCchCopy(szDirectory, ARRAYSIZE(szDirectory), configPath)))
{
PathRemoveFileSpec(szDirectory);
Plugin_EnsurePathExist(szDirectory);
pathValidated = TRUE;
}
}
if (0 != WritePrivateProfileStringW(lpSectionName, lpKeyName, lpString, configPath))
return S_OK;
DWORD errorCode = GetLastError();
return HRESULT_FROM_WIN32(errorCode);
}
HRESULT OmConfigIni::WriteInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nValue)
{
wchar_t szBuffer[32] = {0};
HRESULT hr = StringCchPrintf(szBuffer, ARRAYSIZE(szBuffer), L"%d", nValue);
if (FAILED(hr)) return hr;
return WriteStr(lpSectionName, lpKeyName, szBuffer);
}
HRESULT OmConfigIni::WriteBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bValue)
{
return WriteStr(lpSectionName, lpKeyName, (0 != bValue) ? L"yes" : L"no");
}
HRESULT OmConfigIni::GetClientId(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
INT cchLen = ReadStr(BROWSER_SECTION, BROWSER_CLIENTID, NULL, pszBuffer, cchBufferMax);
if (0 == cchLen) return S_FALSE;
INT cchPrefix = lstrlen(L"WA-");
if (cchLen <= cchPrefix ||
CSTR_EQUAL != CompareString(CSTR_INVARIANT, NORM_IGNORECASE, pszBuffer, cchPrefix, L"WA-", cchPrefix))
{
pszBuffer[0] = L'\0';
return E_INVALIDARG;
}
return S_OK;
}
HRESULT OmConfigIni::SetClientId(LPWSTR pszClientId)
{
EnterCriticalSection(&lock);
WCHAR szBuffer[128] = {0};
HRESULT hr = GetClientId(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr) || CSTR_EQUAL != CompareString(CSTR_INVARIANT, NORM_IGNORECASE, pszClientId, -1, szBuffer, -1))
{
hr = WriteStr(BROWSER_SECTION, BROWSER_CLIENTID, pszClientId);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmBrowserConfig, CFGID_BROWSER_CLIENTID, (ULONG_PTR)pszClientId);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::GetMenuFilterEnabled(void)
{
BOOL result = ReadBool(DEBUG_SECTION, DEBUG_FILTERCONTEXTMENU, TRUE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::GetScriptErrorEnabled(void)
{
BOOL result = ReadBool(DEBUG_SECTION, DEBUG_SHOWSCRIPTERROR, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::GetScriptDebuggerEnabled(void)
{
BOOL result = ReadBool(DEBUG_SECTION, DEBUG_SHOWSCRIPTDEBUGGER, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::GetBrowserPath(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_POINTER;
INT cchLen = ReadStr(DEBUG_SECTION, DEBUG_BROWSERPATH, NULL, pszBuffer, cchBufferMax);
if (0 == cchLen) return S_FALSE;
if ((L'.' == pszBuffer[0] && L'\\' == pszBuffer[1]) ||
(L'.' == pszBuffer[0] && L'.' == pszBuffer[1] && L'\\' == pszBuffer[2]))
{
WCHAR szTemp[2*MAX_PATH] = {0};
StringCchCopy(szTemp, ARRAYSIZE(szTemp), configPath);
PathRemoveFileSpec(szTemp);
if (FALSE == PathAppend(szTemp, pszBuffer) ||
FAILED(StringCchCopy(pszBuffer, cchBufferMax, szTemp)))
{
pszBuffer[0] = L'\0';
return E_FAIL;
}
}
return S_OK;
}
HRESULT OmConfigIni::EnableMenuFilter(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = GetMenuFilterEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(DEBUG_SECTION, DEBUG_FILTERCONTEXTMENU, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmDebugConfig, CFGID_DEBUG_FILTERMENU, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::EnableScriptError(BOOL fEnable)
{
HRESULT hr;
EnterCriticalSection(&lock);
hr = GetScriptErrorEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(DEBUG_SECTION, DEBUG_SHOWSCRIPTERROR, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmDebugConfig, CFGID_DEBUG_SCRIPTERROR, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::EnableScriptDebugger(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = GetScriptDebuggerEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(DEBUG_SECTION, DEBUG_SHOWSCRIPTDEBUGGER, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmDebugConfig, CFGID_DEBUG_SCRIPTDEBUGGER, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::SetBrowserPath(LPCWSTR pszPath)
{
EnterCriticalSection(&lock);
WCHAR szBuffer[MAX_PATH * 2] = {0};
HRESULT hr = GetBrowserPath(szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr) ||
CSTR_EQUAL != CompareString(CSTR_INVARIANT, 0, szBuffer, -1, pszPath, -1))
{
hr = WriteString(DEBUG_SECTION, DEBUG_SHOWSCRIPTDEBUGGER, pszPath);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmDebugConfig, CFGID_DEBUG_BROWSERPATH, (ULONG_PTR)pszPath);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Toolbar_GetBottomDockEnabled(void)
{
BOOL result = ReadBool(TOOLBAR_SECTION, TOOLBAR_BOTTOMDOCK, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Toolbar_GetAutoHideEnabled(void)
{
BOOL result = ReadBool(TOOLBAR_SECTION, TOOLBAR_AUTOHIDE, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Toolbar_GetTabStopEnabled(void)
{
BOOL result = ReadBool(TOOLBAR_SECTION, TOOLBAR_TABSTOP, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Toolbar_GetForceAddressbarEnabled(void)
{
BOOL result = ReadBool(TOOLBAR_SECTION, TOOLBAR_FORCEADDRESSBAR, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Toolbar_GetFancyAddressbarEnabled(void)
{
BOOL result = ReadBool(TOOLBAR_SECTION, TOOLBAR_FANCYADDRESSBAR, TRUE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Toolbar_EnableBottomDock(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Toolbar_GetBottomDockEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(TOOLBAR_SECTION, TOOLBAR_BOTTOMDOCK, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmToolbarConfig, CFGID_TOOLBAR_BOTTOMDOCK, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Toolbar_EnableAutoHide(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Toolbar_GetAutoHideEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(TOOLBAR_SECTION, TOOLBAR_AUTOHIDE, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmToolbarConfig, CFGID_TOOLBAR_AUTOHIDE, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Toolbar_EnableTabStop(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Toolbar_GetTabStopEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(TOOLBAR_SECTION, TOOLBAR_TABSTOP, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmToolbarConfig, CFGID_TOOLBAR_TABSTOP, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Toolbar_EnableForceAddressbar(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Toolbar_GetForceAddressbarEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(TOOLBAR_SECTION, TOOLBAR_FORCEADDRESSBAR, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmToolbarConfig, CFGID_TOOLBAR_FORCEADDRESS, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Toolbar_EnableFancyAddressbar(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Toolbar_GetFancyAddressbarEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(TOOLBAR_SECTION, TOOLBAR_FANCYADDRESSBAR, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmToolbarConfig, CFGID_TOOLBAR_FANCYADDRESS, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::Statusbar_GetEnabled(void)
{
BOOL result = ReadBool(STATUSBAR_SECTION, STATUSBAR_ENABLED, FALSE);
return BOOL2HRESULT(result);
}
HRESULT OmConfigIni::Statusbar_EnableStatusbar(BOOL fEnable)
{
EnterCriticalSection(&lock);
HRESULT hr = Statusbar_GetEnabled();
if (FAILED(hr) || ((S_OK == hr) != (FALSE != fEnable)))
{
hr = WriteBool(STATUSBAR_SECTION, STATUSBAR_ENABLED, fEnable);
if (SUCCEEDED(hr))
{
NotifyChange(&IFC_OmStatusbarConfig, CFGID_STATUSBAR_ENABLED, (ULONG_PTR)fEnable);
}
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT OmConfigIni::RegisterCallback(ifc_omconfigcallback *callback, UINT *cookie)
{
if (NULL == cookie) return E_POINTER;
*cookie = 0;
if (NULL == callback)
return E_INVALIDARG;
EnterCriticalSection(&lock);
*cookie = ++lastCookie;
callbackMap.insert({ *cookie, callback });
callback->AddRef();
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT OmConfigIni::UnregisterCallback(UINT cookie)
{
if (0 == cookie) return E_INVALIDARG;
ifc_omconfigcallback *callback = NULL;
EnterCriticalSection(&lock);
for(CallbackMap::iterator iter = callbackMap.begin(); iter != callbackMap.end(); iter++)
{
if (cookie == iter->first)
{
callback = iter->second;
callbackMap.erase(iter);
break;
}
}
LeaveCriticalSection(&lock);
if (NULL != callback)
{
callback->Release();
return S_OK;
}
return S_FALSE;
}
void OmConfigIni::NotifyChange(const GUID *configUid, UINT valueId, ULONG_PTR value)
{
EnterCriticalSection(&lock);
for(CallbackMap::iterator iter = callbackMap.begin(); iter != callbackMap.end(); iter++)
{
ifc_omconfigcallback *callback = iter->second;
callback->ValueChanged(configUid, valueId, value);
}
LeaveCriticalSection(&lock);
}
UINT OmConfigIni::GetX(void)
{
return ReadInt(BROWSER_SECTION, BROWSER_XPOS, -1);
}
UINT OmConfigIni::GetY(void)
{
return ReadInt(BROWSER_SECTION, BROWSER_YPOS, -1);
}
HRESULT OmConfigIni::SetX(UINT x)
{
return WriteInt(BROWSER_SECTION, BROWSER_XPOS, x);
}
HRESULT OmConfigIni::SetY(UINT y)
{
return WriteInt(BROWSER_SECTION, BROWSER_YPOS, y);
}
#define CBCLASS OmConfigIni
START_MULTIPATCH
START_PATCH(MPIID_OMCONFIG)
M_CB(MPIID_OMCONFIG, ifc_omconfig, ADDREF, AddRef);
M_CB(MPIID_OMCONFIG, ifc_omconfig, RELEASE, Release);
M_CB(MPIID_OMCONFIG, ifc_omconfig, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_GETPATH, GetPath);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_READSTRING, ReadStr);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_READINT, ReadInt);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_READBOOL, ReadBool);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_WRITESTRING, WriteStr);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_WRITEINT, WriteInt);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_WRITEBOOL, WriteBool);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_REGISTERCALLBACK, RegisterCallback);
M_CB(MPIID_OMCONFIG, ifc_omconfig, API_UNREGISTERCALLBACK, UnregisterCallback);
NEXT_PATCH(MPIID_OMBROWSERCONFIG)
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, ADDREF, AddRef);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, RELEASE, Release);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_GETCLIENTID, GetClientId);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_SETCLIENTID, SetClientId);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_GETX, GetX);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_SETX, SetX);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_GETY, GetY);
M_CB(MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig, API_SETY, SetY);
NEXT_PATCH(MPIID_OMDEBUGCONFIG)
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, ADDREF, AddRef);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, RELEASE, Release);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_GETMENUFILTERENABLED, GetMenuFilterEnabled);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_GETSCRIPTERRORENABLED, GetScriptErrorEnabled);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_GETSCRIPTDEBUGGERENABLED, GetScriptDebuggerEnabled);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_GETBROWSERPATH, GetBrowserPath);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_ENABLEMENUFILTER, EnableMenuFilter);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_ENABLESCRIPTERROR, EnableScriptError);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_ENABLESCRIPTDEBUGGER, EnableScriptDebugger);
M_CB(MPIID_OMDEBUGCONFIG, ifc_omdebugconfig, API_SETBROWSERPATH, SetBrowserPath);
NEXT_PATCH(MPIID_OMTOOLBARCONFIG)
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, ADDREF, AddRef);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, RELEASE, Release);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_GETBOTTOMDOCKENABLED, Toolbar_GetBottomDockEnabled);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_ENABLEBOTTOMDOCK, Toolbar_EnableBottomDock);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_GETAUTOHIDEENABLED, Toolbar_GetAutoHideEnabled);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_ENABLEAUTOHIDE, Toolbar_EnableAutoHide);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_GETTABSTOPENABLED, Toolbar_GetTabStopEnabled);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_ENABLETABSTOP, Toolbar_EnableTabStop);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_GETFORCEADDRESSBARENABLED, Toolbar_GetForceAddressbarEnabled);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_ENABLEFORCEADDRESSBAR, Toolbar_EnableForceAddressbar);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_GETFANCYADDRESSBARENABLED, Toolbar_GetFancyAddressbarEnabled);
M_CB(MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig, API_ENABLEFANCYADDRESSBAR, Toolbar_EnableFancyAddressbar);
NEXT_PATCH(MPIID_OMSTATUSBARCONFIG)
M_CB(MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig, ADDREF, AddRef);
M_CB(MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig, RELEASE, Release);
M_CB(MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig, API_GETENABLED, Statusbar_GetEnabled);
M_CB(MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig, API_ENABLESTATUSBAR, Statusbar_EnableStatusbar);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

106
Src/omBrowser/configIni.h Normal file
View File

@ -0,0 +1,106 @@
#ifndef NULLSOFT_WINAMP_OMCONFIG_INI_HEADER
#define NULLSOFT_WINAMP_OMCONFIG_INI_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_omconfig.h"
#include "./ifc_ombrowserconfig.h"
#include "./ifc_omdebugconfig.h"
#include "./ifc_omtoolbarconfig.h"
#include "./ifc_omstatusbarconfig.h"
#include <bfc/multipatch.h>
#include <map>
class api_application;
#define MPIID_OMCONFIG 10
#define MPIID_OMBROWSERCONFIG 20
#define MPIID_OMDEBUGCONFIG 30
#define MPIID_OMTOOLBARCONFIG 40
#define MPIID_OMSTATUSBARCONFIG 50
class OmConfigIni : public MultiPatch<MPIID_OMCONFIG, ifc_omconfig>,
public MultiPatch<MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig>,
public MultiPatch<MPIID_OMDEBUGCONFIG, ifc_omdebugconfig>,
public MultiPatch<MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig>,
public MultiPatch<MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig>
{
protected:
OmConfigIni(LPCWSTR pszPath);
~OmConfigIni();
public:
static HRESULT CreateInstance(LPCWSTR pszName, OmConfigIni **instanceOut);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omconfig */
HRESULT GetPath(LPWSTR pszBuffer, INT cchBufferMax);
DWORD ReadStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize);
UINT ReadInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nDefault);
BOOL ReadBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bDefault);
HRESULT WriteStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString);
HRESULT WriteInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nValue);
HRESULT WriteBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bValue);
HRESULT RegisterCallback(ifc_omconfigcallback *callback, UINT *cookie);
HRESULT UnregisterCallback(UINT cookie);
/* ifc_ombrowserconfig */
HRESULT GetClientId(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT SetClientId(LPWSTR pszClientId);
UINT GetX(void);
UINT GetY(void);
HRESULT SetX(UINT x);
HRESULT SetY(UINT y);
/* ifc_omdebugconfig */
HRESULT GetMenuFilterEnabled(void);
HRESULT GetScriptErrorEnabled(void);
HRESULT GetScriptDebuggerEnabled(void);
HRESULT GetBrowserPath(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT EnableMenuFilter(BOOL fEnable);
HRESULT EnableScriptError(BOOL fEnable);
HRESULT EnableScriptDebugger(BOOL fEnable);
HRESULT SetBrowserPath(LPCWSTR pszPath);
/* ifc_omtoolbarconfig */
HRESULT Toolbar_GetBottomDockEnabled(void);
HRESULT Toolbar_GetAutoHideEnabled(void);
HRESULT Toolbar_GetTabStopEnabled(void);
HRESULT Toolbar_GetForceAddressbarEnabled(void);
HRESULT Toolbar_GetFancyAddressbarEnabled(void);
HRESULT Toolbar_EnableBottomDock(BOOL fEnable);
HRESULT Toolbar_EnableAutoHide(BOOL fEnable);
HRESULT Toolbar_EnableTabStop(BOOL fEnable);
HRESULT Toolbar_EnableForceAddressbar(BOOL fEnable);
HRESULT Toolbar_EnableFancyAddressbar(BOOL fEnable);
/* ifc_omstatusbarconfig */
HRESULT Statusbar_GetEnabled(void);
HRESULT Statusbar_EnableStatusbar(BOOL fEnable);
public:
void NotifyChange(const GUID *configUid, UINT valueId, ULONG_PTR value);
protected:
typedef std::map<UINT, ifc_omconfigcallback*> CallbackMap;
protected:
RECVS_MULTIPATCH;
protected:
ULONG ref;
LPWSTR configPath;
UINT lastCookie;
CallbackMap callbackMap;
CRITICAL_SECTION lock;
BOOL pathValidated;
};
#endif //NULLSOFT_WINAMP_OMCONFIG_INI_HEADER

758
Src/omBrowser/curtain.cpp Normal file
View File

@ -0,0 +1,758 @@
#include "main.h"
#include "./curtain.h"
#include "./graphics.h"
#include "./resource.h"
#include "../winamp/wa_dlg.h"
#include "../Plugins/General/gen_ml/ml_ipc_0313.h"
#include "./ifc_imageloader.h"
#include "./ifc_skinhelper.h"
#include <strsafe.h>
#include <windows.h>
#define WIDGET_MINWIDTH_UNITS 60
#define WIDGET_MAXWIDTH_UNITS 200
#define WIDGET_FRAMECX 1
#define WIDGET_FRAMECY 1
#define WIDGET_SPACECX_UNITS 8
#define WIDGET_SPACECY_UNITS 8
#define WIDGET_CONTROLSPACE_UNITS 6
#define PROGRESS_FRAMECOUNT 24
#define ANIMATETIMER_ID 64
#define ANIMATETIMER_INTERVAL 1000 / PROGRESS_FRAMECOUNT
typedef struct __CURTAIN
{
LPWSTR pszTitle;
LPWSTR pszOperation;
HFONT textFont;
RECT widgetRect;
HBRUSH backBrush;
HBRUSH widgetBrush;
HBRUSH frameBrush;
HBITMAP progressBitmap;
INT frameNumber;
SIZE titleSize;
SIZE operationSize;
SIZE imageSize;
COLORREF rgbBk;
COLORREF rgbFg;
} CURTAIN;
#define GetCurtain(__hwnd) ((CURTAIN*)(LONG_PTR)(LONGX86)GetWindowLongPtr((__hwnd), 0))
static LRESULT CALLBACK Curtain_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL Curtain_RegisterClass(HINSTANCE hInstance)
{
WNDCLASS wc = {0};
if (GetClassInfo(hInstance, NWC_ONLINEMEDIACURTAIN, &wc)) return TRUE;
ZeroMemory(&wc, sizeof(WNDCLASS));
wc.hInstance = hInstance;
wc.lpszClassName = NWC_ONLINEMEDIACURTAIN;
wc.lpfnWndProc = Curtain_WindowProc;
wc.style = CS_DBLCLKS;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.cbWndExtra = sizeof(CURTAIN*);
return ( 0 != RegisterClassW(&wc));
}
#define RA_LEFT 0x0001
#define RA_RIGHT 0x0002
#define RA_HCENTER 0x0003
#define RA_TOP 0x0010
#define RA_BOTTOM 0x0020
#define RA_VCENTER 0x0030
#define RA_FITHORZ 0x0100
#define RA_FITVERT 0x0200
static COLORREF Curtain_GetColor(INT skinColor, INT sysColor)
{
COLORREF rgb;
ifc_skinhelper *skinHelper = NULL;
HRESULT hr = Plugin_GetSkinHelper(&skinHelper);
if (SUCCEEDED(hr) && skinHelper != NULL)
{
hr = skinHelper->GetColor(skinColor, &rgb);
skinHelper->Release();
}
if (FAILED(hr))
rgb = GetSysColor(sysColor);
return rgb;
}
static void Curtain_RectAlign(RECT *prcTarget, const RECT *prcBounds, UINT flags)
{
if (0 != (0x0F & flags)) // horz
{
LONG targetWidth = prcTarget->right - prcTarget->left;
LONG boundsWidth = prcBounds->right - prcBounds->left;
if (0 != (RA_FITHORZ & flags) && targetWidth > boundsWidth)
targetWidth = boundsWidth;
if (targetWidth == boundsWidth)
{
prcTarget->left = prcBounds->left;
prcTarget->right = prcBounds->right;
}
else
{
switch(0x0F & flags)
{
case RA_HCENTER: prcTarget->left = prcBounds->left + (boundsWidth - targetWidth)/2; break;
case RA_LEFT: prcTarget->left = prcBounds->left; break;
case RA_RIGHT: prcTarget->left = prcBounds->right - targetWidth; break;
}
prcTarget->right = prcTarget->left + targetWidth;
}
}
if (0 != (0xF0 & flags)) // horz
{
LONG targetHeight = prcTarget->bottom - prcTarget->top;
LONG boundsHeight = prcBounds->bottom - prcBounds->top;
if (0 != (RA_FITVERT & flags) && targetHeight > boundsHeight)
targetHeight = boundsHeight;
if (targetHeight == boundsHeight)
{
prcTarget->top = prcBounds->top;
prcTarget->bottom = prcBounds->bottom;
}
else
{
switch(0xF0 & flags)
{
case RA_VCENTER: prcTarget->top = prcBounds->top + (boundsHeight - targetHeight)/2; break;
case RA_TOP: prcTarget->top = prcBounds->top; break;
case RA_BOTTOM: prcTarget->top = prcBounds->bottom - targetHeight; break;
}
prcTarget->bottom = prcTarget->top + targetHeight;
}
}
}
static BOOL Curtain_SetPluginString(LPWSTR *ppDest, LPCWSTR pszSource)
{
if (NULL != *ppDest)
Plugin_FreeString(*ppDest);
if(NULL == pszSource)
{
*ppDest = NULL;
}
else
{
WCHAR szBuffer[1024] = {0};
if (IS_INTRESOURCE(pszSource))
{
Plugin_LoadString((INT)(INT_PTR)pszSource, szBuffer, ARRAYSIZE(szBuffer));
pszSource = szBuffer;
}
*ppDest = Plugin_CopyString(pszSource);
}
return TRUE;
}
static BOOL Curtain_GetTextSize(LPCWSTR pszText, HWND hwnd, SIZE *textSize)
{
if (NULL == hwnd || NULL == textSize)
return FALSE;
HFONT font = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L);
HDC hdc = GetDCEx(hwnd, NULL, DCX_CACHE);
if (NULL == hdc) return FALSE;
HFONT originalFont = (HFONT)SelectObject(hdc, font);
INT cchText = (NULL != pszText) ? lstrlen(pszText) : 0;
BOOL result = FALSE;
if ( 0 == cchText)
{
TEXTMETRIC tm = {0};
if (GetTextMetrics(hdc, &tm))
{
textSize->cy = tm.tmHeight;
textSize->cx = 0;
result = TRUE;
}
}
else
{
if (GetTextExtentPoint32(hdc, pszText, cchText, textSize))
result = TRUE;
}
SelectObject(hdc, originalFont);
ReleaseDC(hwnd, hdc);
return result;
}
static BOOL Curtain_MapDialogRectHdc(HDC hdc, RECT *prc)
{
TEXTMETRIC tm;
if (NULL == prc || !GetTextMetrics(hdc, &tm))
return FALSE;
prc->left = MulDiv(prc->left, tm.tmAveCharWidth, 4);
prc->right = MulDiv(prc->right, tm.tmAveCharWidth, 4);
prc->top = MulDiv(prc->top, tm.tmHeight, 8);
prc->bottom = MulDiv(prc->bottom, tm.tmHeight, 8);
return TRUE;
}
static BOOL Curtain_MapDialogRect(HWND hwnd, RECT *prc)
{
HFONT font = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L);
HDC hdc = GetDCEx(hwnd, NULL, DCX_CACHE);
if (NULL == hdc) return FALSE;
HFONT originalFont = (HFONT)SelectObject(hdc, font);
BOOL result = Curtain_MapDialogRectHdc(hdc, prc);
SelectObject(hdc, originalFont);
ReleaseDC(hwnd, hdc);
return result;
}
static BOOL Curtain_GetImageSize(HBITMAP bitmap, INT frameCount, SIZE *imageSize)
{
if (NULL == bitmap || 0 == frameCount || NULL == imageSize)
return FALSE;
BITMAP bm;
if (sizeof(BITMAP) != GetObject(bitmap, sizeof(BITMAP), &bm))
return FALSE;
imageSize->cx = bm.bmWidth;
imageSize->cy = bm.bmHeight / frameCount;
return TRUE;
}
HBITMAP Curtain_LoadImage(HWND hwnd, INT frameCount, COLORREF rgbBk, COLORREF rgbFg)
{
HBITMAP frameBitmap = NULL;
BITMAPINFOHEADER header = {0};
BYTE *pixelData = NULL;
ifc_omimageloader *loader = NULL;
if (SUCCEEDED(Plugin_QueryImageLoader(Plugin_GetInstance(), MAKEINTRESOURCE(IDR_CURTAINPROGRESS_IMAGE), FALSE, &loader)) && loader != NULL)
{
loader->LoadBitmapEx(&frameBitmap, &header, (void**)&pixelData);
loader->Release();
}
if (NULL == frameBitmap)
return NULL;
if (header.biHeight < 0) header.biHeight = - header.biHeight;
Image_Colorize(pixelData, header.biWidth, header.biHeight, header.biBitCount, rgbBk, rgbFg, TRUE);
HDC hdc = GetDCEx(hwnd, NULL, DCX_CACHE);
HBITMAP bitmap = Image_AnimateRotation(hdc, frameBitmap, frameCount, rgbBk, FALSE);
ReleaseDC(hwnd, hdc);
DeleteObject(frameBitmap);
return bitmap;
}
static void Curtain_UpdateLayout(HWND hwnd, BOOL fRedraw)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return;
RECT clientRect;
if (!GetClientRect(hwnd, &clientRect))
return;
InflateRect(&clientRect, -8, -8);
if (!Curtain_GetImageSize(curtain->progressBitmap, PROGRESS_FRAMECOUNT, &curtain->imageSize))
ZeroMemory(&curtain->imageSize, sizeof(SIZE));
if (!Curtain_GetTextSize(curtain->pszTitle, hwnd, &curtain->titleSize))
ZeroMemory(&curtain->titleSize, sizeof(SIZE));
if (!Curtain_GetTextSize(curtain->pszOperation, hwnd, &curtain->operationSize))
ZeroMemory(&curtain->operationSize, sizeof(SIZE));
RECT spaceRect;
SetRect(&spaceRect, WIDGET_SPACECX_UNITS, WIDGET_SPACECY_UNITS, 0, WIDGET_CONTROLSPACE_UNITS);
Curtain_MapDialogRect(hwnd, &spaceRect);
INT spaceCY = spaceRect.top;
INT intervalCY = spaceRect.bottom;
INT widgetHeight = 2 * spaceCY + curtain->titleSize.cy;
if (widgetHeight > (clientRect.bottom - clientRect.top))
{
widgetHeight = 0;
ZeroMemory(&curtain->titleSize, sizeof(SIZE));
}
if (0 != widgetHeight && curtain->operationSize.cy > 0 &&
(widgetHeight + curtain->operationSize.cy + intervalCY) < (clientRect.bottom - clientRect.top))
widgetHeight += curtain->operationSize.cy + intervalCY;
else
ZeroMemory(&curtain->operationSize, sizeof(SIZE));
if (0 != widgetHeight && curtain->imageSize.cy > 0 &&
(widgetHeight + curtain->imageSize.cy + intervalCY) < (clientRect.bottom - clientRect.top))
widgetHeight += curtain->imageSize.cy + intervalCY;
else
ZeroMemory(&curtain->imageSize, sizeof(SIZE));
RECT limitRect, prevRect;
CopyRect(&prevRect, &curtain->widgetRect);
SetRect(&limitRect, WIDGET_MINWIDTH_UNITS, 0, WIDGET_MAXWIDTH_UNITS, 0);
Curtain_MapDialogRect(hwnd, &limitRect);
if ( 0 != widgetHeight && (clientRect.right - clientRect.left) >= limitRect.left)
{
curtain->widgetRect.left = clientRect.left;
curtain->widgetRect.top = clientRect.top;
curtain->widgetRect.right = ((clientRect.right - clientRect.left) >= limitRect.right) ?
(curtain->widgetRect.left + limitRect.right) :
(clientRect.right - clientRect.left);
curtain->widgetRect.bottom = clientRect.top + widgetHeight;
Curtain_RectAlign(&curtain->widgetRect, &clientRect, RA_HCENTER | RA_VCENTER);
}
else
{
SetRectEmpty(&curtain->widgetRect);
ZeroMemory(&curtain->titleSize, sizeof(SIZE));
ZeroMemory(&curtain->operationSize, sizeof(SIZE));
ZeroMemory(&curtain->imageSize, sizeof(SIZE));
}
if (FALSE != fRedraw && FALSE == EqualRect(&curtain->widgetRect, &prevRect))
{
InvalidateRect(hwnd, &prevRect, TRUE);
InvalidateRect(hwnd, &curtain->widgetRect, FALSE);
}
}
static HRGN Curtain_GetFrameRgn(RECT *prcWidget)
{
HRGN regionFrame, regionPart;
regionFrame = CreateRectRgn(prcWidget->left, prcWidget->top, prcWidget->right, prcWidget->top + WIDGET_FRAMECY);
regionPart = CreateRectRgn(prcWidget->left, prcWidget->bottom - WIDGET_FRAMECY, prcWidget->right, prcWidget->bottom);
CombineRgn(regionFrame, regionFrame, regionPart, RGN_OR);
SetRectRgn(regionPart, prcWidget->left, prcWidget->top + WIDGET_FRAMECY, prcWidget->left + WIDGET_FRAMECX, prcWidget->bottom - WIDGET_FRAMECY);
CombineRgn(regionFrame, regionFrame, regionPart, RGN_OR);
SetRectRgn(regionPart, prcWidget->right - WIDGET_FRAMECX, prcWidget->top + WIDGET_FRAMECY, prcWidget->right, prcWidget->bottom - WIDGET_FRAMECY);
CombineRgn(regionFrame, regionFrame, regionPart, RGN_OR);
DeleteObject(regionPart);
return regionFrame;
}
static void Curtain_PaintWidgetBack(CURTAIN *curtain, HDC hdc, HRGN regionPaint)
{
HRGN regionFrame = Curtain_GetFrameRgn(&curtain->widgetRect);
if (NULL == curtain->frameBrush)
curtain->frameBrush = CreateSolidBrush(Curtain_GetColor(WADLG_HILITE, COLOR_3DHILIGHT));
if (FillRgn(hdc, regionFrame, curtain->frameBrush))
CombineRgn(regionPaint, regionPaint, regionFrame, RGN_DIFF);
DeleteObject(regionFrame);
if (NULL == curtain->widgetBrush)
curtain->widgetBrush = CreateSolidBrush(Curtain_GetColor(WADLG_WNDBG, COLOR_WINDOW));
FillRgn(hdc, regionPaint, curtain->widgetBrush);
}
static BOOL Curtain_PaintImage(HBITMAP bitmap, INT frame, const RECT *bitmapRect, HDC hdc, const RECT *paintRect)
{
RECT blitRect;
if (!IntersectRect(&blitRect, bitmapRect, paintRect))
return TRUE;
BOOL success = FALSE;
HDC hdcSrc = CreateCompatibleDC(hdc);
if (NULL != hdcSrc)
{
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcSrc, bitmap);
success = BitBlt(hdc, blitRect.left, blitRect.top,
blitRect.right - blitRect.left, blitRect.bottom - blitRect.top,
hdcSrc,
blitRect.left - bitmapRect->left,
(bitmapRect->bottom - bitmapRect->top)*frame + blitRect.top - bitmapRect->top,
SRCCOPY);
SelectObject(hdcSrc, hbmpOld);
DeleteDC(hdcSrc);
}
return success;
}
static BOOL Curtain_PaintWidget(CURTAIN *curtain, HDC hdc, RECT *prcPaint, BOOL fErase)
{
HRGN regionPaint = CreateRectRgnIndirect(prcPaint);
HRGN regionPart = CreateRectRgn(0,0,0,0);
COLORREF originalBk = SetBkColor(hdc, curtain->rgbBk);
COLORREF originalFg = SetTextColor(hdc, curtain->rgbFg);
RECT clientRect;
CopyRect(&clientRect, &curtain->widgetRect);
HFONT originalFont = (HFONT)SelectObject(hdc, (NULL != curtain->textFont) ?
curtain->textFont :
(HFONT)GetStockObject(DEFAULT_GUI_FONT));
RECT spaceRect;
SetRect(&spaceRect, WIDGET_SPACECX_UNITS, WIDGET_SPACECY_UNITS, 0, 0);
Curtain_MapDialogRectHdc(hdc, &spaceRect);
InflateRect(&clientRect, -spaceRect.left, -spaceRect.top);
if (NULL != curtain->progressBitmap && 0 != curtain->imageSize.cx && 0 != curtain->imageSize.cy)
{
RECT imageRect;
SetRect(&imageRect, 0, 0, curtain->imageSize.cx, curtain->imageSize.cy);
Curtain_RectAlign(&imageRect, &clientRect, RA_HCENTER | RA_VCENTER);
if (Curtain_PaintImage(curtain->progressBitmap, curtain->frameNumber, &imageRect, hdc,prcPaint))
{
SetRectRgn(regionPart, imageRect.left, imageRect.top, imageRect.right, imageRect.bottom);
CombineRgn(regionPaint, regionPaint, regionPart, RGN_DIFF);
}
}
if (NULL != curtain->pszTitle && 0 != curtain->titleSize.cx && 0 != curtain->titleSize.cy)
{
RECT textRect, paintRect;;
SetRect(&textRect, 0, 0, curtain->titleSize.cx, curtain->titleSize.cy);
Curtain_RectAlign(&textRect, &clientRect, RA_HCENTER | RA_TOP | RA_FITHORZ);
if (IntersectRect(&paintRect, &textRect, prcPaint))
{
INT cchText = lstrlen(curtain->pszTitle);
if (ExtTextOut(hdc, textRect.left, textRect.top, ETO_CLIPPED | ETO_OPAQUE, &paintRect, curtain->pszTitle, cchText, NULL))
{
SetRectRgn(regionPart, paintRect.left, paintRect.top, paintRect.right, paintRect.bottom);
CombineRgn(regionPaint, regionPaint, regionPart, RGN_DIFF);
}
}
}
if (NULL != curtain->pszOperation && 0 != curtain->operationSize.cx && 0 != curtain->operationSize.cy)
{
RECT textRect, paintRect;
SetRect(&textRect, 0, 0, curtain->operationSize.cx, curtain->operationSize.cy);
Curtain_RectAlign(&textRect, &clientRect, RA_HCENTER | RA_BOTTOM | RA_FITHORZ);
if (IntersectRect(&paintRect, &textRect, prcPaint))
{
INT cchText = lstrlen(curtain->pszOperation);
if (ExtTextOut(hdc, textRect.left, textRect.top, ETO_CLIPPED | ETO_OPAQUE, &paintRect, curtain->pszOperation, cchText, NULL))
{
SetRectRgn(regionPart, paintRect.left, paintRect.top, paintRect.right, paintRect.bottom);
CombineRgn(regionPaint, regionPaint, regionPart, RGN_DIFF);
}
}
}
SelectObject(hdc, originalFont);
if (originalBk != curtain->rgbBk) SetBkColor(hdc, originalBk);
if (originalFg != curtain->rgbFg) SetTextColor(hdc, originalFg);
if (NULL != fErase)
Curtain_PaintWidgetBack(curtain, hdc, regionPaint);
DeleteObject(regionPaint);
DeleteObject(regionPart);
return TRUE;
}
static void Curtain_Paint(HWND hwnd, HDC hdc, const RECT *prcPaint, BOOL fErase)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return;
HRGN regionPaint = CreateRectRgnIndirect(prcPaint);
if (!IsRectEmpty(&curtain->widgetRect))
{
RECT widgetPaintRect;
if (IntersectRect(&widgetPaintRect, &curtain->widgetRect, prcPaint) &&
FALSE != Curtain_PaintWidget(curtain, hdc, &widgetPaintRect, fErase))
{
HRGN regionWidget = CreateRectRgnIndirect(&widgetPaintRect);
CombineRgn(regionPaint, regionPaint, regionWidget, RGN_DIFF);
DeleteObject(regionWidget);
}
}
if (FALSE != fErase)
{
if (NULL == curtain->backBrush)
{
curtain->backBrush = CreateSolidBrush(Curtain_GetColor(WADLG_ITEMBG, COLOR_WINDOW));
}
FillRgn(hdc, regionPaint, curtain->backBrush);
}
DeleteObject(regionPaint);
}
static void CALLBACK Curtain_AnimateTimerElpased(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain)
{
KillTimer(hwnd, idEvent);
return;
}
if (NULL != curtain->progressBitmap && 0 != curtain->imageSize.cx && 0 != curtain->imageSize.cy)
{
curtain->frameNumber++;
if (curtain->frameNumber >= PROGRESS_FRAMECOUNT)
curtain->frameNumber = 0;
RECT imageRect;
SetRect(&imageRect, 0, 0, curtain->imageSize.cx, curtain->imageSize.cy);
Curtain_RectAlign(&imageRect, &curtain->widgetRect, RA_HCENTER | RA_VCENTER);
InvalidateRect(hwnd, &imageRect, FALSE);
}
}
static LRESULT Curtain_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
{
CURTAIN *curtain = (CURTAIN*)calloc(1, sizeof(CURTAIN));
if (NULL != curtain)
{
SetLastError(ERROR_SUCCESS);
if (!SetWindowLongPtr(hwnd, 0, (LONGX86)(LONG_PTR)curtain) && ERROR_SUCCESS != GetLastError())
{
free(curtain);
curtain = NULL;
}
}
if (NULL == curtain)
{
DestroyWindow(hwnd);
return -1;
}
SetTimer(hwnd, ANIMATETIMER_ID, ANIMATETIMER_INTERVAL, Curtain_AnimateTimerElpased);
return 0;
}
static void Curtain_OnDestroy(HWND hwnd)
{
CURTAIN *curtain = GetCurtain(hwnd);
SetWindowLongPtr(hwnd, 0, 0L);
if (NULL != curtain)
{
if (NULL != curtain->pszTitle)
Plugin_FreeString(curtain->pszTitle);
if (NULL != curtain->pszOperation)
Plugin_FreeString(curtain->pszOperation);
if (NULL != curtain->backBrush)
DeleteObject(curtain->backBrush);
if (NULL != curtain->widgetBrush)
DeleteObject(curtain->widgetBrush);
if (NULL != curtain->frameBrush)
DeleteObject(curtain->frameBrush);
if (NULL != curtain->progressBitmap)
DeleteObject(curtain->progressBitmap);
free(curtain);
}
}
static void Curtain_OnPaint(HWND hwnd)
{
PAINTSTRUCT ps = {0};
if (BeginPaint(hwnd, &ps))
{
if (ps.rcPaint.left != ps.rcPaint.right)
Curtain_Paint(hwnd, ps.hdc, &ps.rcPaint, ps.fErase);
EndPaint(hwnd, &ps);
}
}
static void Curtain_OnPrintClient(HWND hwnd, HDC hdc, UINT options)
{
RECT clientRect;
if (GetClientRect(hwnd, &clientRect))
Curtain_Paint(hwnd, hdc, &clientRect, 0 != (PRF_ERASEBKGND & options));
}
static void Curtain_OnWindowPosChanged(HWND hwnd, WINDOWPOS *pwp)
{
if (SWP_NOSIZE == ((SWP_NOSIZE | SWP_FRAMECHANGED) & pwp->flags))
return;
Curtain_UpdateLayout(hwnd, 0 == (SWP_NOREDRAW & pwp->flags));
}
static void Curtain_OnCommand(HWND hwnd, INT controlId, INT eventId, HWND hControl)
{
}
static BOOL Curtain_OnSetText(HWND hwnd, LPCWSTR pszText)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return FALSE;
Curtain_SetPluginString(&curtain->pszTitle, pszText);
InvalidateRect(hwnd, &curtain->widgetRect, FALSE);
return TRUE;
}
static INT Curtain_OnGetText(HWND hwnd, LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer || cchBufferMax)
return 0;
pszBuffer[0] = L'\0';
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain || NULL == curtain->pszTitle) return FALSE;
INT cchTitle = lstrlenW(curtain->pszTitle);
if (cchTitle > 0)
{
if (cchTitle >= cchBufferMax)
cchTitle = (cchBufferMax - 1);
StringCchCopyN(pszBuffer, cchBufferMax, curtain->pszTitle, cchTitle);
}
return cchTitle;
}
static INT Curtain_OnGetTextLength(HWND hwnd)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain || NULL == curtain->pszTitle) return FALSE;
return lstrlenW(curtain->pszTitle);
}
static BOOL Curtain_OnSetOperationText(HWND hwnd, LPCWSTR pszText)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return FALSE;
Curtain_SetPluginString(&curtain->pszOperation, pszText);
InvalidateRect(hwnd, &curtain->widgetRect, FALSE);
return TRUE;
}
static void Curtain_OnUpdateSkin(HWND hwnd, BOOL fRedraw)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return;
ifc_skinhelper *skinHelper = NULL;
if (FAILED(Plugin_GetSkinHelper(&skinHelper)))
skinHelper = NULL;
curtain->textFont = (NULL != skinHelper) ? skinHelper->GetFont() : NULL;
if (NULL != curtain->backBrush)
{
DeleteObject(curtain->backBrush);
curtain->backBrush = NULL;
}
if (NULL != curtain->widgetBrush)
{
DeleteObject(curtain->widgetBrush);
curtain->widgetBrush = NULL;
}
if (NULL != curtain->frameBrush)
{
DeleteObject(curtain->frameBrush);
curtain->frameBrush = NULL;
}
if (NULL != curtain->progressBitmap)
DeleteObject(curtain->progressBitmap);
if (NULL == skinHelper || FAILED(skinHelper->GetColor(WADLG_WNDBG, &curtain->rgbBk)))
curtain->rgbBk = GetSysColor(COLOR_WINDOW);
if (NULL == skinHelper || FAILED(skinHelper->GetColor(WADLG_WNDFG, &curtain->rgbFg)))
curtain->rgbFg = GetSysColor(COLOR_WINDOWTEXT);
if (NULL != skinHelper)
skinHelper->Release();
curtain->progressBitmap = Curtain_LoadImage(hwnd, PROGRESS_FRAMECOUNT, curtain->rgbBk, curtain->rgbFg);
Curtain_UpdateLayout(hwnd, fRedraw);
}
static LRESULT Curtain_OnGetFont(HWND hwnd)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return NULL;
return (LRESULT)curtain->textFont;
}
static void Curtain_OnSetFont(HWND hwnd, HFONT hFont, BOOL fRedraw)
{
CURTAIN *curtain = GetCurtain(hwnd);
if (NULL == curtain) return;
curtain->textFont = hFont;
if (FALSE != fRedraw)
InvalidateRect(hwnd, &curtain->widgetRect, FALSE);
}
static LRESULT CALLBACK Curtain_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE: return Curtain_OnCreate(hwnd, (CREATESTRUCT*)lParam);
case WM_DESTROY: Curtain_OnDestroy(hwnd); break;
case WM_PAINT: Curtain_OnPaint(hwnd); return 0;
case WM_PRINTCLIENT: Curtain_OnPrintClient(hwnd, (HDC)wParam, (UINT)lParam); return 0;
case WM_ERASEBKGND: return 0;
case WM_WINDOWPOSCHANGED: Curtain_OnWindowPosChanged(hwnd, (WINDOWPOS*)lParam); return 0;
case WM_SETTEXT: return Curtain_OnSetText(hwnd, (LPCWSTR)lParam);
case WM_GETTEXT: return Curtain_OnGetText(hwnd, (LPWSTR)lParam, (INT)wParam);
case WM_GETTEXTLENGTH: return Curtain_OnGetTextLength(hwnd);
case WM_GETFONT: return Curtain_OnGetFont(hwnd);
case WM_SETFONT: Curtain_OnSetFont(hwnd, (HFONT)wParam, (BOOL)LOWORD(lParam));
case WM_COMMAND: Curtain_OnCommand(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam); break;
case CWM_SETOPERATIONTEXT: return Curtain_OnSetOperationText(hwnd, (LPCWSTR)lParam);
case CWM_UPDATESKIN: Curtain_OnUpdateSkin(hwnd, (BOOL)lParam); return 0;
}
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}

24
Src/omBrowser/curtain.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_CURTAIN_CONTROL_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_CURTAIN_CONTROL_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#define NWC_ONLINEMEDIACURTAIN L"Nullsoft_omBrowserCurtain"
BOOL Curtain_RegisterClass(HINSTANCE hInstance);
#define CWM_FIRST (WM_USER + 20)
#define CWM_SETOPERATIONTEXT (CWM_FIRST + 0) //wParam = not used, lParam = (LPARAM)(LPCWSTR)pszOperationText.
#define Curtain_SetOperationText(/*HWND*/ __hCurtain, /*LPCWSTR*/__operationText)\
((BOOL)SENDMSG(__hCurtain, CWM_SETOPERATIONTEXT, 0, (LPARAM)(__operationText)))
#define CWM_UPDATESKIN (CWM_FIRST + 1) //wParam = not used, lParam = (LPARAM)(BOOL)fRedraw.
#define Curtain_UpdateSkin(/*HWND*/ __hCurtain, /*BOOL*/ __fRedraw)\
(SENDMSG(__hCurtain, CWM_UPDATESKIN, 0, (LPARAM)(__fRedraw)))
#endif //NULLSOFT_WINAMP_OMBROWSER_CURTAIN_CONTROL_HEADER

347
Src/omBrowser/enumAsync.cpp Normal file
View File

@ -0,0 +1,347 @@
#include "main.h"
#include "./enumAsync.h"
#include "./ifc_omservice.h"
#include "./ifc_omserviceenum.h"
#include "./ifc_wasabihelper.h"
#include "./serviceList.h"
EnumAsyncWrapper::EnumAsyncWrapper(ifc_omserviceenum *enumerator)
: ref(1), enumerator(enumerator), userCallback(NULL), userData(NULL),
completed(NULL), state(stateReady), resultCode(E_PENDING), serviceList(NULL)
{
if (NULL != enumerator)
enumerator->AddRef();
InitializeCriticalSection(&lock);
}
EnumAsyncWrapper::~EnumAsyncWrapper()
{
EnterCriticalSection(&lock);
if (NULL != enumerator)
enumerator->Release();
if (NULL != completed)
CloseHandle(completed);
if (NULL != serviceList)
serviceList->Release();
LeaveCriticalSection(&lock);
DeleteCriticalSection(&lock);
}
HRESULT EnumAsyncWrapper::CreateInstance(ifc_omserviceenum *enumerator, EnumAsyncWrapper **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
if (NULL == enumerator)
return E_INVALIDARG;
*instance = new EnumAsyncWrapper(enumerator);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t EnumAsyncWrapper::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t EnumAsyncWrapper::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int EnumAsyncWrapper::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmStorageAsync))
*object = static_cast<ifc_omstorageasync*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT EnumAsyncWrapper::GetState(UINT *state)
{
if (NULL == state)
return E_POINTER;
EnterCriticalSection(&lock);
*state = this->state;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT EnumAsyncWrapper::GetWaitHandle(HANDLE *handle)
{
if (NULL == handle)
return E_POINTER;
HRESULT hr = S_OK;
EnterCriticalSection(&lock);
if (NULL == completed)
{
completed = CreateEvent(NULL, TRUE, FALSE, NULL);
if (NULL == completed)
{
*handle = NULL;
DWORD error = GetLastError();
hr = HRESULT_FROM_WIN32(error);
}
}
if (SUCCEEDED(hr) && FALSE == DuplicateHandle(GetCurrentProcess(), completed,
GetCurrentProcess(), handle, 0, FALSE, DUPLICATE_SAME_ACCESS))
{
*handle = NULL;
DWORD error = GetLastError();
hr = HRESULT_FROM_WIN32(error);
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT EnumAsyncWrapper::GetData(void **data)
{
if (NULL == data)
return E_POINTER;
EnterCriticalSection(&lock);
*data = userData;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT EnumAsyncWrapper::GetCallback(AsyncCallback *callback)
{
if (NULL == callback)
return E_POINTER;
EnterCriticalSection(&lock);
*callback = userCallback;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT EnumAsyncWrapper::SetData(void *data)
{
EnterCriticalSection(&lock);
userData = data;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT EnumAsyncWrapper::SetCallback(AsyncCallback callback)
{
EnterCriticalSection(&lock);
userCallback = callback;
LeaveCriticalSection(&lock);
return S_OK;
}
HRESULT EnumAsyncWrapper::RequestAbort(BOOL fDrop)
{
HRESULT hr = S_FALSE;
EnterCriticalSection(&lock);
if (stateInitializing == state || stateReceiving == state)
{
state = stateAborting;
if (FALSE != fDrop)
{
userCallback = NULL;
userData = NULL;
}
}
LeaveCriticalSection(&lock);
return hr;
}
static int EnumAsyncWrapper_ThreadFunc(HANDLE handle, void *user_data, intptr_t id)
{
EnumAsyncWrapper *instance = (EnumAsyncWrapper*)user_data;
if (NULL != instance) instance->Enumerate();
return 0;
}
HRESULT EnumAsyncWrapper::BeginEnumerate()
{
ifc_wasabihelper *wasabi = NULL;
HRESULT hr;
EnterCriticalSection(&lock);
if (stateReady != state && stateCompleted != state)
{
hr = E_PENDING;
}
else
{
state = stateInitializing;
if (NULL != serviceList)
{
serviceList->Release();
serviceList = NULL;
}
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr) && wasabi != NULL)
{
api_threadpool *threadpool;
hr = wasabi->GetThreadpoolApi(&threadpool);
if (SUCCEEDED(hr))
{
if (0 != threadpool->RunFunction(NULL, EnumAsyncWrapper_ThreadFunc, this, 0, 0))
{
hr = E_FAIL;
}
else
{
AddRef();
}
threadpool->Release();
}
else
{
hr = E_NOINTERFACE;
}
wasabi->Release();
}
if (FAILED(hr))
state = stateCompleted;
}
LeaveCriticalSection(&lock);
return hr;
}
HRESULT EnumAsyncWrapper::Enumerate()
{
EnterCriticalSection(&lock);
state = stateReceiving;
resultCode = OmServiceList::CreateInstance(&serviceList);
LeaveCriticalSection(&lock);
if (SUCCEEDED(resultCode))
{
if (NULL == enumerator)
{
resultCode = E_UNEXPECTED;
}
else
{
ifc_omservice *service;
while(S_OK == enumerator->Next(1, &service, NULL))
{
if (stateAborting == state)
{
resultCode = E_ABORT;
break;
}
if (NULL != service)
{
serviceList->Add(service);
service->Release();
}
}
}
}
EnterCriticalSection(&lock);
state = stateCompleted;
HANDLE event = completed;
LeaveCriticalSection(&lock);
if (NULL != event)
{
SetEvent(event);
}
EnterCriticalSection(&lock);
AsyncCallback cb = userCallback;
LeaveCriticalSection(&lock);
if (NULL != cb)
{
cb(this);
}
Release();
return resultCode;
}
HRESULT EnumAsyncWrapper::GetResultCode()
{
return resultCode;
}
HRESULT EnumAsyncWrapper::GetServiceList(ifc_omserviceenum **list)
{
if (NULL == list)
return E_POINTER;
if (NULL == serviceList)
{
*list = NULL;
return E_UNEXPECTED;
}
EnterCriticalSection(&lock);
*list = serviceList;
serviceList->AddRef();
LeaveCriticalSection(&lock);
return S_OK;
}
#define CBCLASS EnumAsyncWrapper
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETSTATE, GetState)
CB(API_GETWAITHANDLE, GetWaitHandle)
CB(API_GETDATA, GetData)
END_DISPATCH;
#undef CBCLASS

63
Src/omBrowser/enumAsync.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_ASYNC_ENUMERATOR_WRAPPER_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_ASYNC_ENUMERATOR_WRAPPER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
#include "./ifc_omstorageasync.h"
class ifc_omservicehost;
class ifc_omserviceenum;
class ifc_omservice;
class OmServiceList;
class EnumAsyncWrapper : public ifc_omstorageasync
{
protected:
EnumAsyncWrapper(ifc_omserviceenum *enumerator);
~EnumAsyncWrapper();
public:
static HRESULT CreateInstance(ifc_omserviceenum *enumerator, EnumAsyncWrapper **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omstorageasync */
HRESULT GetState(UINT *state);
HRESULT GetWaitHandle(HANDLE *handle);
HRESULT GetData(void **data);
public:
HRESULT SetData(void *data);
HRESULT SetCallback(AsyncCallback callback);
HRESULT GetCallback(AsyncCallback *callback);
HRESULT RequestAbort(BOOL fDrop);
HRESULT BeginEnumerate();
HRESULT Enumerate();
HRESULT GetResultCode();
HRESULT GetServiceList(ifc_omserviceenum **list);
protected:
size_t ref;
ifc_omserviceenum *enumerator;
AsyncCallback userCallback;
void *userData;
HANDLE completed;
UINT state;
HRESULT resultCode;
CRITICAL_SECTION lock;
OmServiceList *serviceList;
protected:
RECVS_DISPATCH;
};
#endif //NULLSOFT_WINAMP_OMSTORAGE_ASYNC_ENUMERATOR_WRAPPER_HEADER

View File

@ -0,0 +1,215 @@
#include "main.h"
#include "./enumIniFile.h"
#include "./service.h"
#include "./ifc_omservicehost.h"
#include "./ifc_omstorage.h"
#include "./ifc_omstoragehandlerenum.h"
#include "./ifc_omstorageext.h"
#include "./ifc_omfilestorage.h"
#include <shlwapi.h>
#include <strsafe.h>
#define OMS_GROUP "OnlineService"
#define OMS_ID "id"
#define OMS_NAME "name"
#define OMS_URL "url"
#define OMS_ICON "icon"
#define OMS_FLAGS "flags"
#define OMS_RATING "rating"
#define OMS_VERSION "version"
#define OMS_DESCRIPTION "description"
#define OMS_AUTHORFIRST "authorFirst"
#define OMS_AUTHORLAST "authorLast"
#define OMS_PUBLISHED "publishedDate"
#define OMS_UPDATED "updatedDate"
#define OMS_THUMBNAIL "thumbnail"
#define OMS_SCREENSHOT "screenshot"
#define OMS_GENERATION "generation"
EnumIniFile::EnumIniFile(LPCWSTR pszAddress, ifc_omservicehost *serviceHost)
: ref(1), address(NULL), host(serviceHost), hFind(NULL)
{
address = Plugin_CopyString(pszAddress);
if (NULL != host)
{
host->AddRef();
ifc_omstorageext *storageExt = NULL;
if (SUCCEEDED(host->QueryInterface(IFC_OmStorageExt, (void**)&storageExt)) && storageExt != NULL)
{
ifc_omstoragehandlerenum *handlerEnum = NULL;
if (SUCCEEDED(storageExt->Enumerate(&SUID_OmStorageIni, &handlerEnum)) && handlerEnum != NULL)
{
reader.RegisterHandlers(handlerEnum);
handlerEnum->Release();
}
storageExt->Release();
}
}
}
EnumIniFile::~EnumIniFile()
{
Plugin_FreeString(address);
if (NULL != host)
host->Release();
if (NULL != hFind)
FindClose(hFind);
}
HRESULT EnumIniFile::CreateInstance(LPCWSTR pszAddress, ifc_omservicehost *host, EnumIniFile **instance)
{
if (NULL == instance)
return E_POINTER;
WCHAR szBuffer[MAX_PATH * 2] = {0};
HRESULT hr = Plugin_ResolveRelativePath(pszAddress, host, szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
// test if we can load this one
if (FALSE == PathIsDirectory(szBuffer) && PathFileExists(szBuffer))
{
UINT id = GetPrivateProfileInt(TEXT(OMS_GROUP), WTEXT(OMS_ID), 0, pszAddress);
if (0 == id) return OMSTORAGE_E_UNKNOWN_FORMAT;
}
*instance = new EnumIniFile(szBuffer, host);
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t EnumIniFile::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t EnumIniFile::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int EnumIniFile::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmServiceEnum))
*object = static_cast<ifc_omserviceenum*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT EnumIniFile::Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount)
{
if(NULL != elementCount)
*elementCount = 0;
if (0 == listSize || NULL == elementList)
return E_INVALIDARG;
ULONG counter = 0;
BOOL bFoundNext = FALSE;
HRESULT hr = S_OK;
if (NULL == hFind)
{
hFind = FindFirstFile(address, &fData);
if (INVALID_HANDLE_VALUE == hFind)
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
bFoundNext = TRUE;
}
else
{
bFoundNext = FindNextFile(hFind, &fData);
}
if (bFoundNext)
{
do
{
LPCWSTR p = address;
while(p && L'.' == *p && L'\0' != *p) p++;
if (p && L'\0' != *p)
{
WCHAR base[MAX_PATH] = {0};
StringCchCopy(base, MAX_PATH, address);
PathRemoveFileSpec(base);
int baseLen = lstrlen(base);
base[baseLen] = L'\0';
if (!PathAppend(base, fData.cFileName))
{
base[baseLen] = L'\0';
PathAppend(base, fData.cAlternateFileName);
}
hr = reader.Load(base, host, &elementList[counter]);
if (S_OK == hr)
{
listSize--;
counter++;
if (0 == listSize) break;
}
}
bFoundNext = FindNextFile(hFind, &fData);
} while(bFoundNext);
}
if(NULL != elementCount)
*elementCount = counter;
return (counter > 0) ? S_OK : S_FALSE;
}
HRESULT EnumIniFile::Reset(void)
{
if (NULL != hFind)
{
FindClose(hFind);
hFind = NULL;
}
return S_OK;
}
HRESULT EnumIniFile::Skip(ULONG elementCount)
{
return E_NOTIMPL;
}
#define CBCLASS EnumIniFile
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_NEXT, Next)
CB(API_RESET, Reset)
CB(API_SKIP, Skip)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,44 @@
#ifndef NULLSOFT_WINAMP_ENUMERATOR_INI_HEADER
#define NULLSOFT_WINAMP_ENUMERATOR_INI_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_omserviceenum.h"
#include "./loaderIni.h"
class ifc_omservicehost;
class EnumIniFile : public ifc_omserviceenum
{
protected:
EnumIniFile(LPCWSTR pszAddress, ifc_omservicehost *serviceHost);
~EnumIniFile();
public:
static HRESULT CreateInstance(LPCWSTR pszAddress, ifc_omservicehost *host, EnumIniFile **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omserviceenum */
HRESULT Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount);
HRESULT Reset(void);
HRESULT Skip(ULONG elementCount);
protected:
RECVS_DISPATCH;
protected:
ULONG ref;
LPWSTR address;
ifc_omservicehost *host;
LoaderIni reader;
WIN32_FIND_DATA fData;
HANDLE hFind;
};
#endif //NULLSOFT_WINAMP_ENUMERATOR_INI_HEADER

View File

@ -0,0 +1,243 @@
#include "main.h"
#include "./enumXmlBuffer.h"
#include "./service.h"
#include "./ifc_omservicehost.h"
#include "./ifc_omstorage.h"
#include "./ifc_wasabihelper.h"
#include "../xml/obj_xml.h"
#include <shlwapi.h>
#include <strsafe.h>
#define XMLSIG "<?xml"
#define XMLSIG_LEN 5
ULONG ref;
const void *buffer;
size_t bufferSize;
size_t cursor;
obj_xml *reader;
INT readerError;
XmlResponseParser parser;
Dispatchable *bufferOwner;
EnumXmlBuffer::EnumXmlBuffer(obj_xml *xmlReader, const void *buffer, size_t bufferSize, Dispatchable *bufferOwner, ifc_omservicehost *serviceHost)
: ref(1), buffer(buffer), bufferSize(bufferSize), cursor(0), reader(xmlReader), readerError(OBJ_XML_SUCCESS), bufferOwner(bufferOwner)
{
if (NULL != reader)
reader->AddRef();
if (NULL != bufferOwner)
bufferOwner->AddRef();
parser.Initialize(reader, serviceHost);
}
EnumXmlBuffer::~EnumXmlBuffer()
{
parser.Finish();
if (NULL != reader)
{
if (OBJ_XML_SUCCESS == readerError)
{
reader->xmlreader_feed(0, 0);
}
reader->xmlreader_close();
ifc_wasabihelper *wasabi;
if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabi)))
{
wasabi->ReleaseWasabiInterface(&obj_xmlGUID, reader);
wasabi->Release();
}
}
if (NULL != bufferOwner)
bufferOwner->Release();
}
HRESULT EnumXmlBuffer::CheckXmlHeader(const void *buffer, size_t bufferSize)
{
if (NULL == buffer)
return E_INVALIDARG;
if (bufferSize >= XMLSIG_LEN)
{
if (CSTR_EQUAL == CompareStringA(CSTR_INVARIANT, NORM_IGNORECASE, XMLSIG, XMLSIG_LEN, (LPSTR)buffer, XMLSIG_LEN) ||
CSTR_EQUAL == CompareStringW(CSTR_INVARIANT, NORM_IGNORECASE, WTEXT(XMLSIG), XMLSIG_LEN, (LPWSTR)buffer, XMLSIG_LEN))
{
return S_OK;
}
}
return OMSTORAGE_E_UNKNOWN_FORMAT;
}
HRESULT EnumXmlBuffer::CreateInstance(const void *buffer, size_t bufferSize, Dispatchable *bufferOwner, ifc_omservicehost *host, EnumXmlBuffer **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
HRESULT hr = CheckXmlHeader(buffer, bufferSize);
if (SUCCEEDED(hr))
{
ifc_wasabihelper *wasabi;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr))
{
obj_xml *reader;
wasabi->QueryWasabiInterface(&obj_xmlGUID, (void**)&reader);
if (NULL != reader && OBJ_XML_SUCCESS == reader->xmlreader_open())
{
*instance = new EnumXmlBuffer(reader, buffer, bufferSize, bufferOwner, host);
if (NULL == *instance)
{
hr = E_OUTOFMEMORY;
// reader stil has no support for AddRef()/Release()
wasabi->ReleaseWasabiInterface(&obj_xmlGUID, reader);
}
reader->Release();
}
else
{
hr = E_UNEXPECTED;
}
wasabi->Release();
}
}
return hr;
}
size_t EnumXmlBuffer::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t EnumXmlBuffer::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int EnumXmlBuffer::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmServiceEnum))
*object = static_cast<ifc_omserviceenum*>(this);
else if (IsEqualIID(interface_guid, IFC_OmXmlServiceEnum))
*object = static_cast<ifc_omxmlserviceenum*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT EnumXmlBuffer::Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount)
{
if(NULL != elementCount)
*elementCount = 0;
if (0 == listSize || NULL == elementList)
return E_INVALIDARG;
ULONG counter = 0;
HRESULT hr = S_OK;
ifc_omservice *service;
while(counter < listSize)
{
hr = parser.PeekService(&service);
if (FAILED(hr)) return hr;
if (S_OK == hr)
{
elementList[counter] = service;
counter++;
}
else
{
if (cursor < bufferSize)
{
readerError = reader->xmlreader_feed((BYTE*)buffer + cursor, bufferSize - cursor);
if (OBJ_XML_SUCCESS != readerError) return E_FAIL;
cursor = bufferSize;
}
else
{
if (OBJ_XML_SUCCESS == readerError)
reader->xmlreader_feed(0, 0);
break;
}
}
}
if(NULL != elementCount)
*elementCount = counter;
return (counter > 0) ? S_OK : S_FALSE;
}
HRESULT EnumXmlBuffer::Reset(void)
{
cursor = 0;
readerError = OBJ_XML_SUCCESS;
reader->xmlreader_reset();
parser.Reset();
return E_NOTIMPL;
}
HRESULT EnumXmlBuffer::Skip(ULONG elementCount)
{
return E_NOTIMPL;
}
HRESULT EnumXmlBuffer::GetStatusCode(UINT *code)
{
return parser.GetCode(code);
}
HRESULT EnumXmlBuffer::GetStatusText(LPWSTR pszBuffer, UINT cchBufferMax)
{
return parser.GetText(pszBuffer, cchBufferMax);
}
#define CBCLASS EnumXmlBuffer
START_MULTIPATCH;
START_PATCH(MPIID_OMSERVICEENUM)
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, ADDREF, AddRef);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, RELEASE, Release);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_NEXT, Next);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_RESET, Reset);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_SKIP, Skip);
NEXT_PATCH(MPIID_OMXMLSERVICEENUM)
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, ADDREF, AddRef);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, RELEASE, Release);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, API_GETSTATUSCODE, GetStatusCode);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, API_GETSTATUSTEXT, GetStatusText);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

View File

@ -0,0 +1,62 @@
#ifndef NULLSOFT_WINAMP_ENUMERATOR_XML_BUFFER_HEADER
#define NULLSOFT_WINAMP_ENUMERATOR_XML_BUFFER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_omserviceenum.h"
#include "./ifc_omxmlserviceenum.h"
#include "./xmlResponseParser.h"
#include <bfc/multipatch.h>
class ifc_omservicehost;
class obj_xml;
#define MPIID_OMSERVICEENUM 10
#define MPIID_OMXMLSERVICEENUM 20
class EnumXmlBuffer : public MultiPatch<MPIID_OMSERVICEENUM, ifc_omserviceenum>,
public MultiPatch<MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum>
{
protected:
EnumXmlBuffer(obj_xml *xmlReader, const void *buffer, size_t bufferSize, Dispatchable *bufferOwner, ifc_omservicehost *serviceHost);
~EnumXmlBuffer();
public:
static HRESULT CreateInstance(const void *buffer, size_t bufferSize, Dispatchable *bufferOwner, ifc_omservicehost *host, EnumXmlBuffer **instance);
static HRESULT CheckXmlHeader(const void *buffer, size_t bufferSize);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omserviceenum */
HRESULT Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount);
HRESULT Reset(void);
HRESULT Skip(ULONG elementCount);
/* ifc_omxmlserviceenum */
HRESULT GetStatusCode(UINT *code);
HRESULT GetStatusText(LPWSTR pszBuffer, UINT cchBufferMax);
protected:
ULONG ref;
const void *buffer;
size_t bufferSize;
size_t cursor;
obj_xml *reader;
INT readerError;
XmlResponseParser parser;
Dispatchable *bufferOwner;
protected:
RECVS_MULTIPATCH;
};
#endif //NULLSOFT_WINAMP_ENUMERATOR_XML_BUFFER_HEADER

View File

@ -0,0 +1,275 @@
#include "main.h"
#include "./enumXmlFile.h"
#include "./service.h"
#include "./ifc_omservicehost.h"
#include "./ifc_omstorage.h"
#include "./ifc_wasabihelper.h"
#include "../xml/obj_xml.h"
#include <shlwapi.h>
#include <strsafe.h>
#define XMLSIG "<?xml"
#define XMLSIG_LEN 5
EnumXmlFile::EnumXmlFile(HANDLE xmlHandle, obj_xml *xmlReader, LPCWSTR pszAddress, ifc_omservicehost *serviceHost)
: ref(1), address(NULL), hFile(xmlHandle), reader(xmlReader), readerError(OBJ_XML_SUCCESS),
buffer(NULL), bufferMax(4096)
{
address = Plugin_CopyString(pszAddress);
if (NULL != reader)
reader->AddRef();
parser.Initialize(reader, serviceHost);
}
EnumXmlFile::~EnumXmlFile()
{
Plugin_FreeString(address);
if (NULL != hFile)
CloseHandle(hFile);
parser.Finish();
if (NULL != reader)
{
if (OBJ_XML_SUCCESS == readerError)
{
reader->xmlreader_feed(0, 0);
}
reader->xmlreader_close();
ifc_wasabihelper *wasabi;
if (SUCCEEDED(Plugin_GetWasabiHelper(&wasabi)))
{
wasabi->ReleaseWasabiInterface(&obj_xmlGUID, reader);
wasabi->Release();
}
}
if (NULL != buffer)
free(buffer);
}
HRESULT EnumXmlFile::CheckXmlHeader(HANDLE hFile)
{
DWORD read = 0;
BYTE szBuffer[XMLSIG_LEN * 2] = {0};
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
if (FALSE == ReadFile(hFile, (void*)szBuffer, sizeof(szBuffer), &read, NULL))
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
if (read >= XMLSIG_LEN)
{
if (CSTR_EQUAL == CompareStringA(CSTR_INVARIANT, NORM_IGNORECASE, XMLSIG, XMLSIG_LEN, (LPSTR)szBuffer, XMLSIG_LEN) ||
CSTR_EQUAL == CompareStringW(CSTR_INVARIANT, NORM_IGNORECASE, WTEXT(XMLSIG), XMLSIG_LEN, (LPWSTR)szBuffer, XMLSIG_LEN))
{
return S_OK;
}
}
return OMSTORAGE_E_UNKNOWN_FORMAT;
}
HRESULT EnumXmlFile::CreateInstance(LPCWSTR pszAddress, ifc_omservicehost *host, EnumXmlFile **instance)
{
if (NULL == instance) return E_POINTER;
*instance = NULL;
HRESULT hr;
WCHAR szBuffer[MAX_PATH * 2] = {0};
hr = Plugin_ResolveRelativePath(pszAddress, host, szBuffer, ARRAYSIZE(szBuffer));
if (FAILED(hr)) return hr;
HANDLE hFile = CreateFile(szBuffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (INVALID_HANDLE_VALUE == hFile)
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
hr = CheckXmlHeader(hFile);
if (SUCCEEDED(hr))
{
ifc_wasabihelper *wasabi;
hr = Plugin_GetWasabiHelper(&wasabi);
if (SUCCEEDED(hr))
{
obj_xml *reader;
wasabi->QueryWasabiInterface(&obj_xmlGUID, (void**)&reader);
if (NULL != reader && OBJ_XML_SUCCESS == reader->xmlreader_open())
{
*instance = new EnumXmlFile(hFile, reader, szBuffer, host);
if (NULL == *instance)
{
hr = E_OUTOFMEMORY;
// reader stil has no support for AddRef()/Release()
wasabi->ReleaseWasabiInterface(&obj_xmlGUID, reader);
}
reader->Release();
}
else
{
hr = E_UNEXPECTED;
}
wasabi->Release();
}
}
if (FAILED(hr))
{
if (NULL != hFile) CloseHandle(hFile);
}
return hr;
}
size_t EnumXmlFile::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t EnumXmlFile::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int EnumXmlFile::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmServiceEnum))
*object = static_cast<ifc_omserviceenum*>(this);
else if (IsEqualIID(interface_guid, IFC_OmXmlServiceEnum))
*object = static_cast<ifc_omxmlserviceenum*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT EnumXmlFile::Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount)
{
if(NULL != elementCount)
*elementCount = 0;
if (0 == listSize || NULL == elementList)
return E_INVALIDARG;
ULONG counter = 0;
HRESULT hr = S_OK;
ifc_omservice *service;
while(counter < listSize)
{
hr = parser.PeekService(&service);
if (FAILED(hr)) return hr;
if (S_OK == hr)
{
elementList[counter] = service;
counter++;
}
else
{
if (NULL == buffer)
{
buffer = (BYTE*)calloc(bufferMax, sizeof(BYTE));
if (NULL == buffer) return E_OUTOFMEMORY;
}
DWORD read = 0;
if (FALSE == ReadFile(hFile, buffer, bufferMax, &read, NULL))
{
DWORD error = GetLastError();
return HRESULT_FROM_WIN32(error);
}
if (0 == read)
{
if (OBJ_XML_SUCCESS == readerError)
reader->xmlreader_feed(0, 0);
break;
}
readerError = reader->xmlreader_feed(buffer, read);
if (OBJ_XML_SUCCESS != readerError) return E_FAIL;
}
}
if(NULL != elementCount)
*elementCount = counter;
return (counter > 0) ? S_OK : S_FALSE;
}
HRESULT EnumXmlFile::Reset(void)
{
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
readerError = OBJ_XML_SUCCESS;
reader->xmlreader_reset();
parser.Reset();
return E_NOTIMPL;
}
HRESULT EnumXmlFile::Skip(ULONG elementCount)
{
return E_NOTIMPL;
}
HRESULT EnumXmlFile::GetStatusCode(UINT *code)
{
return parser.GetCode(code);
}
HRESULT EnumXmlFile::GetStatusText(LPWSTR pszBuffer, UINT cchBufferMax)
{
return parser.GetText(pszBuffer, cchBufferMax);
}
#define CBCLASS EnumXmlFile
START_MULTIPATCH;
START_PATCH(MPIID_OMSERVICEENUM)
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, ADDREF, AddRef);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, RELEASE, Release);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_NEXT, Next);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_RESET, Reset);
M_CB(MPIID_OMSERVICEENUM, ifc_omserviceenum, API_SKIP, Skip);
NEXT_PATCH(MPIID_OMXMLSERVICEENUM)
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, ADDREF, AddRef);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, RELEASE, Release);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, QUERYINTERFACE, QueryInterface);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, API_GETSTATUSCODE, GetStatusCode);
M_CB(MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum, API_GETSTATUSTEXT, GetStatusText);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS

View File

@ -0,0 +1,61 @@
#ifndef NULLSOFT_WINAMP_ENUMERATOR_XML_HEADER
#define NULLSOFT_WINAMP_ENUMERATOR_XML_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_omserviceenum.h"
#include "./ifc_omxmlserviceenum.h"
#include "./xmlResponseParser.h"
#include <bfc/multipatch.h>
class ifc_omservicehost;
class obj_xml;
#define MPIID_OMSERVICEENUM 10
#define MPIID_OMXMLSERVICEENUM 20
class EnumXmlFile : public MultiPatch<MPIID_OMSERVICEENUM, ifc_omserviceenum>,
public MultiPatch<MPIID_OMXMLSERVICEENUM, ifc_omxmlserviceenum>
{
protected:
EnumXmlFile(HANDLE xmlHandle, obj_xml *xmlReader, LPCWSTR pszAddress, ifc_omservicehost *serviceHost);
~EnumXmlFile();
public:
static HRESULT CreateInstance(LPCWSTR pszAddress, ifc_omservicehost *host, EnumXmlFile **instance);
static HRESULT CheckXmlHeader(HANDLE hFile);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omserviceenum */
HRESULT Next(ULONG listSize, ifc_omservice **elementList, ULONG *elementCount);
HRESULT Reset(void);
HRESULT Skip(ULONG elementCount);
/* ifc_omxmlserviceenum */
HRESULT GetStatusCode(UINT *code);
HRESULT GetStatusText(LPWSTR pszBuffer, UINT cchBufferMax);
protected:
RECVS_MULTIPATCH;
protected:
ULONG ref;
LPWSTR address;
HANDLE hFile;
obj_xml *reader;
INT readerError;
XmlResponseParser parser;
BYTE *buffer;
UINT bufferMax;
};
#endif //NULLSOFT_WINAMP_ENUMERATOR_XML_HEADER

View File

@ -0,0 +1,20 @@
/////////////////////////////////////////////////////////////////////////////
//
// Data
//
DNSERROR.HTM HTML
".\\resources\\pages\\dnsError.htm"
ERRORPAGEFUNCTIONS.JS HTML
".\\resources\\pages\\errorPageFunctions.js"
ERRORPAGESTRINGS.JS HTML
".\\resources\\pages\\errorPageStrings.js"
HTTPERROR.HTM HTML
".\\resources\\pages\\httpError.htm"
ERRORICON.PNG 2110
".\\resources\\pages\\errorIcon.png"
NAVCANCEL.HTM HTML
".\\resources\\pages\\navCancel.htm"
WINAMPERROR.CSS HTML
".\\resources\\pages\\winampError.css"
INETDISABLED.HTM HTML
".\\resources\\pages\\inetDisabled.htm"

View File

@ -0,0 +1,96 @@
#include "main.h"
#include "./flagTracker.h"
FlagTracker::FlagTracker()
: flags(0), cache(0), updateRef(0), eventHandler(NULL), eventParam(0)
{
InitializeCriticalSection(&lock);
}
FlagTracker::~FlagTracker()
{
DeleteCriticalSection(&lock);
}
void FlagTracker::Set(UINT nFlags, UINT nMask)
{
EnterCriticalSection(&lock);
nFlags &= nMask;
UINT clearMask = ~(nFlags ^ nMask);
flags &= clearMask;
cache &= clearMask;
if (0 != nFlags)
{
Mark(nFlags);
}
LeaveCriticalSection(&lock);
}
UINT FlagTracker::Get()
{
return flags;
}
void FlagTracker::Mark(UINT nFlags)
{
EnterCriticalSection(&lock);
flags |= nFlags;
if (0 == updateRef)
{
if (NULL != eventHandler && 0 != nFlags)
{
eventHandler(nFlags, this, eventParam);
}
}
else
{
cache |= nFlags;
}
LeaveCriticalSection(&lock);
}
ULONG FlagTracker::BeginUpdate()
{
EnterCriticalSection(&lock);
ULONG r = InterlockedIncrement((LONG*)&updateRef);
LeaveCriticalSection(&lock);
return r;
}
ULONG FlagTracker::EndUpdate()
{
EnterCriticalSection(&lock);
ULONG r;
if (0 == updateRef)
{
r = 0;
}
else
{
r = InterlockedDecrement((LONG*)&updateRef);
if (0 == r && 0 != cache)
{
Mark(cache);
cache = 0;
}
}
LeaveCriticalSection(&lock);
return r;
}
void FlagTracker::SetEventHandler(EventHandler handler, ULONG_PTR user)
{
EnterCriticalSection(&lock);
eventHandler = handler;
eventParam = user;
LeaveCriticalSection(&lock);
}

View File

@ -0,0 +1,37 @@
#ifndef NULLSOFT_WINAMP_FLAG_TRACKER_HEADER
#define NULLSOFT_WINAMP_FLAG_TRACKER_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
class FlagTracker
{
public:
typedef void (CALLBACK *EventHandler)(UINT /*nMarked*/, FlagTracker* /*instance*/, ULONG_PTR /*user*/);
public:
FlagTracker();
~FlagTracker();
public:
void Set(UINT nFlags, UINT nMask);
UINT Get();
void Mark(UINT nFlags);
ULONG BeginUpdate();
ULONG EndUpdate();
void SetEventHandler(EventHandler handler, ULONG_PTR user);
protected:
UINT flags;
UINT cache;
ULONG updateRef;
CRITICAL_SECTION lock;
EventHandler eventHandler;
ULONG_PTR eventParam;
};
#endif //NULLSOFT_WINAMP_MODIFY_TRACKER_HEADER

309
Src/omBrowser/graphics.cpp Normal file
View File

@ -0,0 +1,309 @@
#include "./main.h"
#include "./graphics.h"
#include <math.h>
#include <strsafe.h>
INT GetColorDistance(COLORREF rgb1, COLORREF rgb2)
{
return (1000 * ((GetRValue(rgb1) - GetRValue(rgb2)) +
(GetGValue(rgb1) - GetGValue(rgb2)) +
(GetBValue(rgb1) - GetBValue(rgb2))))/ (3 * 255);
}
COLORREF GetDarkerColor(COLORREF rgb1, COLORREF rgb2)
{
INT g1 = (GetRValue(rgb1)*299 + GetGValue(rgb1)*587 + GetBValue(rgb1)*114);
INT g2 = (GetRValue(rgb2)*299 + GetGValue(rgb2)*587 + GetBValue(rgb2)*114);
return (g1 < g2) ? rgb1 : rgb2;
}
COLORREF BlendColors(COLORREF rgbTop, COLORREF rgbBottom, INT alpha)
{
if (alpha > 254) return rgbTop;
if (alpha < 0) return rgbBottom;
WORD k = (((255 - alpha)*255 + 127)/255);
return RGB( (GetRValue(rgbTop)*alpha + k*GetRValue(rgbBottom) + 127)/255,
(GetGValue(rgbTop)*alpha + k*GetGValue(rgbBottom) + 127)/255,
(GetBValue(rgbTop)*alpha + k*GetBValue(rgbBottom) + 127)/255);
}
BOOL Image_Colorize(BYTE *pPixels, LONG cx, LONG cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha)
{
LONG pitch, x;
INT step;
BYTE rFg, gFg, bFg;
LPBYTE cursor, line;
if (bpp < 24) return FALSE;
step = (bpp>>3);
pitch = cx*step;
while (pitch%4) pitch++;
rFg = GetRValue(rgbFg); gFg = GetGValue(rgbFg); bFg = GetBValue(rgbFg);
INT bK = (bFg - GetBValue(rgbBk));
INT gK = (gFg - GetGValue(rgbBk));
INT rK = (rFg - GetRValue(rgbBk));
if (24 == bpp)
{
for (line = pPixels; cy-- != 0; line += pitch )
{
for (x = cx, cursor = line; x-- != 0; cursor += 3)
{
cursor[0] = bFg - (bK*(255 - cursor[0])>>8);
cursor[1] = gFg - (gK*(255 - cursor[1])>>8);
cursor[2] = rFg - (rK*(255 - cursor[2])>>8);
}
}
}
else if (32 == bpp)
{
if (removeAlpha)
{
BYTE rBk, gBk, bBk;
rBk = GetRValue(rgbBk); gBk = GetGValue(rgbBk); bBk = GetBValue(rgbBk);
for (line = pPixels; cy-- != 0; line += pitch )
{
for (x = cx, cursor = line; x-- != 0; cursor += 4)
{
if (0x00 == cursor[3])
{
cursor[0] = bBk;
cursor[1] = gBk;
cursor[2] = rBk;
cursor[3] = 0xFF;
}
else if (0xFF == cursor[3])
{
cursor[0] = bFg - (bK*(255 - cursor[0])>>8);
cursor[1] = gFg - (gK*(255 - cursor[1])>>8);
cursor[2] = rFg - (rK*(255 - cursor[2])>>8);
}
else
{
cursor[0] = ((bFg - (bK*(255 - cursor[0])>>8))*cursor[3] + (((255 - cursor[3])*255 + 127)/255)*bBk + 127)/255;
cursor[1] = ((gFg - (gK*(255 - cursor[1])>>8))*cursor[3] + (((255 - cursor[3])*255 + 127)/255)*gBk + 127)/255;
cursor[2] = ((rFg - (rK*(255 - cursor[2])>>8))*cursor[3] + (((255 - cursor[3])*255 + 127)/255)*rBk + 127)/255;
cursor[3] = 0xFF;
}
}
}
}
else
{
for (line = pPixels; cy-- != 0; line += pitch )
{
for (x = cx, cursor = line; x-- != 0; cursor += 4)
{
cursor[0] = bFg - (bK*(255 - cursor[0])>>8);
cursor[1] = gFg - (gK*(255 - cursor[1])>>8);
cursor[2] = rFg - (rK*(255 - cursor[2])>>8);
}
}
}
}
return TRUE;
}
BOOL Image_BlendOnColorEx(BYTE *pPixels, INT bitmapCX, INT bitmapCY, LONG x, LONG y, LONG cx, LONG cy, WORD bpp, BOOL premult, COLORREF rgb)
{
LONG pitch;
WORD r, g, b;
INT step = (bpp>>3);
LPBYTE line, cursor;
pitch = bitmapCX * step;
while (pitch%4) pitch++;
if (bpp != 32)
return TRUE;
if (cy < 0) cy -= cy;
r = GetRValue(rgb); g = GetGValue(rgb); b = GetBValue(rgb);
INT ofs = (bitmapCY > 0) ? (bitmapCY - (y + cy)) : y;
line = pPixels + pitch * ofs + x*step;
if (premult)
{
for (; cy-- != 0; line += pitch)
{
for (x = cx, cursor = line; x-- != 0; cursor += 4)
{
if (0x00 == cursor[3])
{
cursor[0] = (BYTE)b;
cursor[1] = (BYTE)g;
cursor[2] = (BYTE)r;
cursor[3] = 0xFF;
}
else if (cursor[3] != 0xFF)
{
WORD a = 255 - cursor[3];
WORD destB = (cursor[0] * 255 + a * b + 127) / 255;
WORD destG = (cursor[1] * 255 + a * g + 127) / 255;
WORD destR = (cursor[2] * 255 + a * r + 127) / 255;
cursor[0] = (destB > 0xFF) ? 0xFF : destB;
cursor[1] = (destG > 0xFF) ? 0xFF : destG;
cursor[2] = (destR > 0xFF) ? 0xFF : destR;
cursor[3] = 0xFF;
}
}
}
}
else
{
for (; cy-- != 0; line += pitch)
{
for (x = cx, cursor = line; x-- != 0; cursor += 4)
{
if (0x00 == cursor[3])
{
cursor[0] = (BYTE)b;
cursor[1] = (BYTE)g;
cursor[2] = (BYTE)r;
cursor[3] = 0xFF;
}
else if (cursor[3] != 0xFF)
{
WORD a = (((255 - cursor[3])*255 + 127)/255);
cursor[0] = (cursor[0]*cursor[3] + a*b + 127)/255;
cursor[1] = (cursor[1]*cursor[3] + a*g + 127)/255;
cursor[2] = (cursor[2]*cursor[3] + a*r + 127)/255;
cursor[3] = 0xFF;
}
}
}
}
return TRUE;
}
BOOL Image_BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb)
{
DIBSECTION dibsec;
if (!hbmp || sizeof(DIBSECTION) != GetObject(hbmp, sizeof(DIBSECTION), &dibsec) ||
BI_RGB != dibsec.dsBmih.biCompression || 1 != dibsec.dsBmih.biPlanes || dibsec.dsBm.bmBitsPixel != 32)
return FALSE;
return Image_BlendOnColorEx((BYTE*)dibsec.dsBm.bmBits, dibsec.dsBm.bmWidth, dibsec.dsBm.bmHeight,
prcPart->left, prcPart->top,
prcPart->right - prcPart->left, prcPart->bottom - prcPart->top,
dibsec.dsBm.bmBitsPixel, premult, rgb);
}
HBITMAP Image_AnimateRotation(HDC hdc, HBITMAP bitmapFrame, INT frameCount, COLORREF rgbBk, BOOL fKeepSize)
{
if (NULL == bitmapFrame)
return NULL;
BITMAP bm;
if (sizeof(BITMAP) != GetObject(bitmapFrame, sizeof(BITMAP), &bm))
return NULL;
if (bm.bmHeight < 0) bm.bmHeight = -bm.bmHeight;
HBITMAP hbmp = NULL;
HDC hdcDst = CreateCompatibleDC(hdc);
HDC hdcSrc = CreateCompatibleDC(hdc);
if (NULL != hdcDst && NULL != hdcSrc)
{
INT side;
if (FALSE == fKeepSize)
side = (INT)ceil(_hypot(bm.bmWidth, bm.bmHeight));
else
{
side = bm.bmWidth;
if (bm.bmHeight > side)
side = bm.bmHeight;
}
hbmp = CreateCompatibleBitmap(hdc, side, side * frameCount);
if (NULL != hbmp)
{
LONG centerX, centerY;
centerX = side/2;
centerY = side/2;
XFORM xForm;
ZeroMemory(&xForm, sizeof(XFORM));
HBITMAP hbmpFrameOld = (HBITMAP)SelectObject(hdcSrc, bitmapFrame);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDst, hbmp);
RECT rcFill;
SetRect(&rcFill, 0, 0, side, side * frameCount);
SetBkColor(hdcDst, rgbBk);
ExtTextOut(hdcDst, 0, 0, ETO_OPAQUE, &rcFill, NULL, 0, NULL);
INT graphicsMode = SetGraphicsMode(hdcDst, GM_ADVANCED);
INT top = (side - bm.bmHeight)/2;
INT left = (side - bm.bmWidth)/2;
for (INT i = 0; i < frameCount; i++)
{
double fangle = (double)(360/frameCount * i)/180. * 3.1415926;
xForm.eM11 = (float)cos(fangle);
xForm.eM12 = (float)sin(fangle);
xForm.eM21 = (float)-sin(fangle);
xForm.eM22 = (float)cos(fangle);
xForm.eDx = (float)(centerX - cos(fangle)*centerX + sin(fangle)*centerY);
xForm.eDy = (float)(centerY - cos(fangle)*centerY - sin(fangle)*centerX);
SetWorldTransform(hdcDst, &xForm);
BitBlt(hdcDst, left, top, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);
centerY += side;
top += side;
}
SetGraphicsMode(hdcDst, graphicsMode);
ModifyWorldTransform(hdcDst, NULL, MWT_IDENTITY);
SelectObject(hdcSrc, hbmpFrameOld);
SelectObject(hdcDst, hbmpOld);
}
}
if (NULL != hdcDst) DeleteDC(hdcDst);
if (NULL != hdcSrc) DeleteDC(hdcSrc);
return hbmp;
}
BOOL Image_Premultiply(BYTE *pPixels, LONG cx, LONG cy)
{
LONG pitch, x;
pitch = cx* 4;
LPBYTE cursor, line;
for (line = pPixels; cy-- != 0; line += pitch )
{
for (x = cx, cursor = line; x-- != 0; cursor += 4)
{
if (0x00 == cursor[3])
{
cursor[0] = 0x00;
cursor[1] = 0x00;
cursor[2] = 0x00;
}
else if (0xFF != cursor[3])
{
cursor[0] = (cursor[0] * cursor[3]) >> 8;
cursor[1] = (cursor[1] * cursor[3]) >> 8;
cursor[2] = (cursor[2] * cursor[3]) >> 8;
}
}
}
return TRUE;
}
BOOL Image_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction)
{
return AlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction);
}

23
Src/omBrowser/graphics.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef NULLOSFT_ONLINEMEDIA_GRAPHICS_HEADER
#define NULLOSFT_ONLINEMEDIA_GRAPHICS_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <wtypes.h>
INT GetColorDistance(COLORREF rgb1, COLORREF rgb2);
COLORREF GetDarkerColor(COLORREF rgb1, COLORREF rgb2);
COLORREF BlendColors(COLORREF rgbTop, COLORREF rgbBottom, INT alpha);
BOOL Image_Colorize(BYTE *pPixels, LONG cx, LONG cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha);
BOOL Image_BlendOnColorEx(BYTE *pPixels, INT bitmapCX, INT bitmapCY, LONG x, LONG y, LONG cx, LONG cy, WORD bpp, BOOL premult, COLORREF rgb);
BOOL Image_BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb);
BOOL Image_Premultiply(BYTE *pPixels, LONG cx, LONG cy);
BOOL Image_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
HBITMAP Image_AnimateRotation(HDC hdc, HBITMAP bitmapFrame, INT frameCount, COLORREF rgbBk, BOOL fKeepSize);
#endif //NULLOSFT_ONLINEMEDIA_GRAPHICS_HEADER

View File

@ -0,0 +1,135 @@
#include "./common.h"
#include "./graphicsObject.h"
#include "./graphics.h"
GraphicsObject::GraphicsObject()
: ref(1)
{
}
GraphicsObject::~GraphicsObject()
{
}
HRESULT GraphicsObject::CreateInstance(GraphicsObject **instance)
{
if (NULL == instance) return E_POINTER;
*instance = new GraphicsObject();
if (NULL == *instance) return E_OUTOFMEMORY;
return S_OK;
}
size_t GraphicsObject::AddRef()
{
return InterlockedIncrement((LONG*)&ref);
}
size_t GraphicsObject::Release()
{
if (0 == ref)
return ref;
LONG r = InterlockedDecrement((LONG*)&ref);
if (0 == r)
delete(this);
return r;
}
int GraphicsObject::QueryInterface(GUID interface_guid, void **object)
{
if (NULL == object) return E_POINTER;
if (IsEqualIID(interface_guid, IFC_OmGrpahics))
*object = static_cast<ifc_omgraphics*>(this);
else
{
*object = NULL;
return E_NOINTERFACE;
}
if (NULL == *object)
return E_UNEXPECTED;
AddRef();
return S_OK;
}
HRESULT GraphicsObject::GetDistance(COLORREF rgb1, COLORREF rgb2, int *distance)
{
if (NULL == distance) return E_POINTER;
*distance = GetColorDistance(rgb1, rgb2);
return S_OK;
}
HRESULT GraphicsObject::GetDarker(COLORREF rgb1, COLORREF rgb2, COLORREF *result)
{
if (NULL == result) return E_POINTER;
*result = GetDarkerColor(rgb1, rgb2);
return S_OK;
}
HRESULT GraphicsObject::BlendColor(COLORREF rgbTop, COLORREF rgbBottom, int alpha, COLORREF *result)
{
if (NULL == result) return E_POINTER;
*result = BlendColors(rgbTop, rgbBottom, alpha);
return S_OK;
}
HRESULT GraphicsObject::Colorize(BYTE *pixels, long cx, long cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha)
{
BOOL result = Image_Colorize(pixels, cx, cy, bpp, rgbBk, rgbFg, removeAlpha);
return (FALSE != result) ? S_OK : S_FALSE;
}
HRESULT GraphicsObject::BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb)
{
BOOL result = Image_BlendOnColor(hbmp, prcPart, premult, rgb);
return (FALSE != result) ? S_OK : S_FALSE;
}
HRESULT GraphicsObject::BlendOnColor2(BYTE *pixels, int bitmapCX, int bitmapCY, long x, long y, long cx, long cy, WORD bpp, BOOL premult, COLORREF rgb)
{
BOOL result = Image_BlendOnColorEx(pixels, bitmapCX, bitmapCY, x, y, cx, cy, bpp, premult, rgb);
return (FALSE != result) ? S_OK : S_FALSE;
}
HRESULT GraphicsObject::Premultiply(BYTE *pixels, long cx, long cy)
{
BOOL result = Image_Premultiply(pixels, cx, cy);
return (FALSE != result) ? S_OK : S_FALSE;
}
HRESULT GraphicsObject::AlphaBlend(HDC hdcDest, const RECT *rectDest, HDC hdcSrc, const RECT *rectSrc, BLENDFUNCTION blendFunction)
{
if (NULL == rectDest || NULL == rectSrc)
return E_INVALIDARG;
BOOL result = Image_AlphaBlend(hdcDest, rectDest->left, rectDest->top, rectDest->right, rectDest->bottom, hdcSrc, rectSrc->left, rectSrc->top, rectSrc->right, rectSrc->bottom, blendFunction);
return (FALSE != result) ? S_OK : S_FALSE;
}
HRESULT GraphicsObject::AnimateRotation(HDC hdc, HBITMAP bitmapFrame, int frameCount, COLORREF rgbBk, BOOL fKeepSize, HBITMAP *result)
{
if (NULL == result) return E_POINTER;
*result = Image_AnimateRotation(hdc, bitmapFrame, frameCount, rgbBk, fKeepSize);
if (NULL == *result) return E_FAIL;
return S_OK;
}
#define CBCLASS GraphicsObject
START_DISPATCH;
CB(ADDREF, AddRef)
CB(RELEASE, Release)
CB(QUERYINTERFACE, QueryInterface)
CB(API_GETDISTANCE, GetDistance)
CB(API_GETDARKER, GetDarker)
CB(API_BLENDCOLOR, BlendColor)
CB(API_COLORIZE, Colorize)
CB(API_BLENDONCOLOR, BlendOnColor)
CB(API_BLENDONCOLOR2, BlendOnColor2)
CB(API_PREMULTIPLY, Premultiply)
CB(API_ALPHABLEND, AlphaBlend)
CB(API_ANIMATEROTATION, AnimateRotation)
END_DISPATCH;
#undef CBCLASS

View File

@ -0,0 +1,45 @@
#ifndef NULLSOFT_WINAMP_UTILITY_GRAPHICS_OBJECT_HEADER
#define NULLSOFT_WINAMP_UTILITY_GRAPHICS_OBJECT_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "./ifc_omgraphics.h"
class GraphicsObject : public ifc_omgraphics
{
protected:
GraphicsObject();
~GraphicsObject();
public:
static HRESULT CreateInstance(GraphicsObject **instance);
public:
/* Dispatchable */
size_t AddRef();
size_t Release();
int QueryInterface(GUID interface_guid, void **object);
/* ifc_omgraphics */
HRESULT GetDistance(COLORREF rgb1, COLORREF rgb2, int *distance);
HRESULT GetDarker(COLORREF rgb1, COLORREF rgb2, COLORREF *result);
HRESULT BlendColor(COLORREF rgbTop, COLORREF rgbBottom, int alpha, COLORREF *result);
HRESULT Colorize(BYTE *pixels, long cx, long cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha);
HRESULT BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb);
HRESULT BlendOnColor2(BYTE *pixels, int bitmapCX, int bitmapCY, long x, long y, long cx, long cy, WORD bpp, BOOL premult, COLORREF rgb);
HRESULT Premultiply(BYTE *pixels, long cx, long cy);
HRESULT AlphaBlend(HDC hdcDest, const RECT *rectDest, HDC hdcSrc, const RECT *rectSrc, BLENDFUNCTION blendFunction);
HRESULT AnimateRotation(HDC hdc, HBITMAP bitmapFrame, int frameCount, COLORREF rgbBk, BOOL fKeepSize, HBITMAP *result);
protected:
size_t ref;
protected:
RECVS_DISPATCH;
};
#endif // NULLSOFT_WINAMP_UTILITY_GRAPHICS_OBJECT_HEADER

View File

@ -0,0 +1,81 @@
#include "main.h"
#include "./ieversion.h"
#include <shlwapi.h>
#include <strsafe.h>
HRESULT MSIE_GetVersionString(LPWSTR pszBuffer, INT cchBufferMax)
{
if (NULL == pszBuffer) return E_INVALIDARG;
HKEY hKey = NULL;
LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Internet Explorer", 0,
STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &hKey);
if (ERROR_SUCCESS == result)
{
DWORD cbBuffer = sizeof(WCHAR) * cchBufferMax;
result = RegQueryValueEx(hKey, L"svcVersion", NULL, NULL, (BYTE*)pszBuffer, &cbBuffer);
if (ERROR_SUCCESS != result
|| L'\0' == *pszBuffer)
{
cbBuffer = sizeof(WCHAR) * cchBufferMax;
result = RegQueryValueEx(hKey, L"Version", NULL, NULL, (BYTE*)pszBuffer, &cbBuffer);
}
RegCloseKey(hKey);
}
if (ERROR_SUCCESS != result)
{
*pszBuffer = L'\0';
return HRESULT_FROM_WIN32(result);
}
return S_OK;
}
HRESULT MSIE_GetVersion(INT *majorOut, INT *minorOut, INT *buildOut, INT *subBuildOut)
{
INT szVersion[4] = { 0, 0, 0, 0};
WCHAR szBuffer[64] = {0};
HRESULT hr = MSIE_GetVersionString(szBuffer, ARRAYSIZE(szBuffer));
if (SUCCEEDED(hr))
{
INT index = 0;
LPWSTR block = szBuffer;
LPWSTR cursor = block;
for(;;)
{
if (L'\0' == *cursor)
{
if (block != cursor && FALSE != StrToIntEx(block,STIF_DEFAULT, &szVersion[index]))
index++;
break;
}
else if (L'.' == *cursor)
{
*cursor = L'\0';
if (block != cursor && FALSE != StrToIntEx(block,STIF_DEFAULT, &szVersion[index]))
{
index++;
if (index == ARRAYSIZE(szVersion))
break; // too many numbers
}
cursor++;
block = cursor;
}
cursor++;
}
if (index < ARRAYSIZE(szVersion))
hr = E_FAIL;
}
if (NULL != majorOut) *majorOut = szVersion[0];
if (NULL != minorOut) *minorOut = szVersion[1];
if (NULL != buildOut) *buildOut = szVersion[2];
if (NULL != subBuildOut) *subBuildOut = szVersion[3];
return hr;
}

11
Src/omBrowser/ieversion.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_IEVERSION_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_IEVERSION_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
HRESULT MSIE_GetVersionString(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT MSIE_GetVersion(INT *majorOut, INT *minorOut, INT *buildOut, INT *subBuildOut);
#endif //NULLSOFT_WINAMP_OMBROWSER_IEVERSION_HEADER

View File

@ -0,0 +1,53 @@
#ifndef NULLSOFT_WINAMP_OMIMAGELOADER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMIMAGELOADER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omimageloader : public Dispatchable
{
protected:
ifc_omimageloader() {}
~ifc_omimageloader() {}
public:
HRESULT LoadData(int *widthOut, int *heightOut, void **dataOut);
HRESULT FreeData(void *data);
HRESULT LoadBitmapEx(HBITMAP *bitmapOut, BITMAPINFOHEADER *headerInfo, void **dataOut);
HRESULT LoadBitmap(HBITMAP *bitmapOut, int *widthOut, int *heightOut);
public:
DISPATCH_CODES
{
API_LOADDATA = 10,
API_FREEDATA = 20,
API_LOADBITMAP = 30,
API_LOADBITMAPEX = 40,
};
};
inline HRESULT ifc_omimageloader::LoadData(int *widthOut, int *heightOut, void **dataOut)
{
return _call(API_LOADDATA, (HRESULT)E_NOTIMPL, widthOut, heightOut, dataOut);
}
inline HRESULT ifc_omimageloader::FreeData(void *data)
{
return _call(API_FREEDATA, (HRESULT)E_NOTIMPL, data);
}
inline HRESULT ifc_omimageloader::LoadBitmapEx(HBITMAP *bitmapOut, BITMAPINFOHEADER *headerInfo, void **dataOut)
{
return _call(API_LOADBITMAPEX, (HRESULT)E_NOTIMPL, bitmapOut, headerInfo, dataOut, bitmapOut);
}
inline HRESULT ifc_omimageloader::LoadBitmap(HBITMAP *bitmapOut, int *widthOut, int *heightOut)
{
return _call(API_LOADBITMAP, (HRESULT)E_NOTIMPL, bitmapOut, widthOut, heightOut);
}
#endif //NULLSOFT_WINAMP_OMIMAGELOADER_INTERFACE_HEADER

View File

@ -0,0 +1,60 @@
#ifndef NULLSOFT_WINAMP_MENU_CUSTOMIZER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_MENU_CUSTOMIZER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {780C1929-76FD-4a06-934B-C85CC285A4DE}
static const GUID IFC_MenuCustomizer =
{ 0x780c1929, 0x76fd, 0x4a06, { 0x93, 0x4b, 0xc8, 0x5c, 0xc2, 0x85, 0xa4, 0xde } };
#include "main.h"
#include <bfc/dispatch.h>
typedef LPVOID HMLIMGLST;
class __declspec(novtable) ifc_menucustomizer : public Dispatchable
{
protected:
ifc_menucustomizer() {}
~ifc_menucustomizer() {}
public:
HMLIMGLST GetImageList(void);
UINT GetSkinStyle(void);
HRESULT GetWidth(INT *widthOut);
INT CustomDraw(HMENU menuInstance, INT action, HDC hdc, LPARAM param);
public:
DISPATCH_CODES
{
API_GETIMAGELIST = 10,
API_GETSKINSTYLE = 20,
API_GETWIDTH = 30,
API_CUSTOMDRAW = 40,
};
};
inline HMLIMGLST ifc_menucustomizer::GetImageList(void)
{
return _call(API_GETIMAGELIST, (HMLIMGLST)NULL);
}
inline UINT ifc_menucustomizer::GetSkinStyle(void)
{
return (UINT)_call(API_GETSKINSTYLE, (UINT)/*SMS_USESKINFONT*/0x00000001);
}
inline HRESULT ifc_menucustomizer::GetWidth(INT *widthOut)
{
return _call(API_GETWIDTH, (HRESULT)E_NOTIMPL, widthOut);
}
inline INT ifc_menucustomizer::CustomDraw(HMENU menuInstance, INT action, HDC hdc, LPARAM param)
{
return _call(API_CUSTOMDRAW, (INT)FALSE, menuInstance, action, hdc, param);
}
#endif // NULLSOFT_WINAMP_MENU_CUSTOMIZER_INTERFACE_HEADER

View File

@ -0,0 +1,35 @@
#ifndef NULLSOFT_WINAMP_ML_NAVIGATION_CALLBACK_INTERFACE_HEADER
#define NULLSOFT_WINAMP_ML_NAVIGATION_CALLBACK_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {9CBB5A7C-CEC9-4f12-9615-49BC7BEFE8CB}
static const GUID IFC_MlNavigationCallback =
{ 0x9cbb5a7c, 0xcec9, 0x4f12, { 0x96, 0x15, 0x49, 0xbc, 0x7b, 0xef, 0xe8, 0xcb } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_mlnavigationcallback : public Dispatchable
{
protected:
ifc_mlnavigationcallback() {}
~ifc_mlnavigationcallback() {}
public:
void ImageChanged(const wchar_t *name, int index);
public:
DISPATCH_CODES
{
API_IMAGECHANGED = 10,
};
};
inline void ifc_mlnavigationcallback::ImageChanged(const wchar_t *name, int index)
{
_voidcall(API_IMAGECHANGED, name, index);
}
#endif // NULLSOFT_WINAMP_ML_NAVIGATION_CALLBACK_INTERFACE_HEADER

View File

@ -0,0 +1,76 @@
#ifndef NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {816290AB-A249-4b64-A192-C643D0AD68CA}
static const GUID IFC_MlNavigationHelper =
{ 0x816290ab, 0xa249, 0x4b64, { 0xa1, 0x92, 0xc6, 0x43, 0xd0, 0xad, 0x68, 0xca } };
class ifc_mlnavigationcallback;
class __declspec(novtable) ifc_mlnavigationhelper : public Dispatchable
{
protected:
ifc_mlnavigationhelper() {}
~ifc_mlnavigationhelper() {}
public:
HRESULT GetDefaultIndex(int *index);
HRESULT QueryIndex(const wchar_t *name, int *index, BOOL *defaultUsed);
HRESULT ReleaseIndex(const wchar_t *name);
HRESULT RegisterAlias(const wchar_t *name, const wchar_t *address);
HRESULT RegisterCallback(ifc_mlnavigationcallback *callback, unsigned int *cookie);
HRESULT UnregisterCallback(unsigned int cookie);
public:
DISPATCH_CODES
{
API_GETDEFAULTINDEX = 10,
API_QUERYINDEX = 20,
API_RELEASEINDEX = 30,
API_REGISTERALIAS = 40,
API_REGISTERCALLBACK = 50,
API_UNREGISTERCALLBACK = 60,
};
};
inline HRESULT ifc_mlnavigationhelper::GetDefaultIndex(int *index)
{
return _call(API_GETDEFAULTINDEX, (HRESULT)E_NOTIMPL, index);
}
inline HRESULT ifc_mlnavigationhelper::QueryIndex(const wchar_t *name, int *index, BOOL *defaultUsed)
{
return _call(API_QUERYINDEX, (HRESULT)E_NOTIMPL, name, index, defaultUsed);
}
inline HRESULT ifc_mlnavigationhelper::ReleaseIndex(const wchar_t *name)
{
return _call(API_RELEASEINDEX, (HRESULT)E_NOTIMPL, name);
}
inline HRESULT ifc_mlnavigationhelper::RegisterAlias(const wchar_t *name, const wchar_t *address)
{
return _call(API_REGISTERALIAS, (HRESULT)E_NOTIMPL, name, address);
}
inline HRESULT ifc_mlnavigationhelper::RegisterCallback(ifc_mlnavigationcallback *callback, UINT *cookie)
{
return _call(API_REGISTERCALLBACK, (HRESULT)API_REGISTERCALLBACK, callback, cookie);
}
inline HRESULT ifc_mlnavigationhelper::UnregisterCallback(UINT cookie)
{
return _call(API_UNREGISTERCALLBACK, (HRESULT)E_NOTIMPL, cookie);
}
#endif //NULLSOFT_WINAMP_ML_NAVIGATION_HELPER_INTERFACE_HEADER

View File

@ -0,0 +1,66 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_CLASS_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_CLASS_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {1B06FE2B-A1E7-43b5-B470-573CDF5D54F9}
static const GUID IFC_OmBrowserClass =
{ 0x1b06fe2b, 0xa1e7, 0x43b5, { 0xb4, 0x70, 0x57, 0x3c, 0xdf, 0x5d, 0x54, 0xf9 } };
class ifc_omconfig;
class ifc_ombrowserregistry;
class __declspec(novtable) ifc_ombrowserclass : public Dispatchable
{
protected:
ifc_ombrowserclass() {}
~ifc_ombrowserclass() {}
public:
HRESULT GetName(wchar_t *pszBuffer, int cchBufferLen);
HRESULT IsEqual(const wchar_t *pszName);
HRESULT GetConfig(ifc_omconfig **instance);
HRESULT GetRegistry(ifc_ombrowserregistry **instance);
HRESULT UpdateRegColors(void);
public:
DISPATCH_CODES
{
API_GETNAME = 10,
API_ISEQUAL = 20,
API_GETCONFIG = 30,
API_GETREGISTRY = 40,
API_UPDATEREGCOLORS = 50,
};
};
inline HRESULT ifc_ombrowserclass::GetName(wchar_t *pszBuffer, int cchBufferLen)
{
return _call(API_GETNAME, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferLen);
}
inline HRESULT ifc_ombrowserclass::IsEqual(const wchar_t *pszName)
{
return _call(API_ISEQUAL, (HRESULT)E_NOTIMPL, pszName);
}
inline HRESULT ifc_ombrowserclass::GetConfig(ifc_omconfig **instance)
{
return _call(API_GETCONFIG, (HRESULT)E_NOTIMPL, instance);
}
inline HRESULT ifc_ombrowserclass::GetRegistry(ifc_ombrowserregistry **instance)
{
return _call(API_GETREGISTRY, (HRESULT)E_NOTIMPL, instance);
}
inline HRESULT ifc_ombrowserclass::UpdateRegColors(void)
{
return _call(API_UPDATEREGCOLORS, (HRESULT)E_NOTIMPL);
}
#endif //NULLSOFT_WINAMP_OMBROWSER_CLASS_INTERFACE_HEADER

View File

@ -0,0 +1,72 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_BROWSER_CONFIG_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_BROWSER_CONFIG_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {41660B13-0547-4b8f-934B-A688306F0D4A}
static const GUID IFC_OmBrowserConfig =
{ 0x41660b13, 0x547, 0x4b8f, { 0x93, 0x4b, 0xa6, 0x88, 0x30, 0x6f, 0xd, 0x4a } };
#define CFGID_BROWSER_CLIENTID 0 //param = (LPCWSTR)pszClientId
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_ombrowserconfig : public Dispatchable
{
protected:
ifc_ombrowserconfig() {}
~ifc_ombrowserconfig() {}
public:
HRESULT GetClientId(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT SetClientId(LPWSTR pszClientId);
UINT GetX();
HRESULT SetX(UINT x);
UINT GetY();
HRESULT SetY(UINT y);
public:
DISPATCH_CODES
{
API_GETCLIENTID = 10,
API_SETCLIENTID = 20,
API_GETX = 30,
API_SETX = 40,
API_GETY = 50,
API_SETY = 60,
};
};
inline HRESULT ifc_ombrowserconfig::GetClientId(LPWSTR pszBuffer, INT cchBufferMax)
{
return _call(API_GETCLIENTID, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_ombrowserconfig::SetClientId(LPWSTR pszClientId)
{
return _call(API_SETCLIENTID, (HRESULT)E_NOTIMPL, pszClientId);
}
inline UINT ifc_ombrowserconfig::GetX(void)
{
return _call(API_GETX, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_ombrowserconfig::SetX(UINT x)
{
return _call(API_SETX, (HRESULT)E_NOTIMPL, x);
}
inline UINT ifc_ombrowserconfig::GetY(void)
{
return _call(API_GETY, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_ombrowserconfig::SetY(UINT y)
{
return _call(API_SETY, (HRESULT)E_NOTIMPL, y);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_BROWSER_CONFIG_INTERFACE_HEADER

View File

@ -0,0 +1,44 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_EVENTHANDLER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_EVENTHANDLER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {900AD92F-E2B9-4615-B1DB-ACC37FCD676C}
static const GUID IFC_OmBrowserEvent =
{ 0x900ad92f, 0xe2b9, 0x4615, { 0xb1, 0xdb, 0xac, 0xc3, 0x7f, 0xcd, 0x67, 0x6c } };
class __declspec(novtable) ifc_ombrowserevent : public Dispatchable
{
protected:
ifc_ombrowserevent() {}
~ifc_ombrowserevent() {}
public:
void WindowCreate(HWND hwnd, const GUID *windowType);
void WindowClose(HWND hwnd, const GUID *windowType);
public:
DISPATCH_CODES
{
API_WINDOWCREATE = 10,
API_WINDOWCLOSE = 20,
};
};
inline void ifc_ombrowserevent::WindowCreate(HWND hwnd, const GUID *windowType)
{
_voidcall(API_WINDOWCREATE, hwnd, windowType);
}
inline void ifc_ombrowserevent::WindowClose(HWND hwnd, const GUID *windowType)
{
_voidcall(API_WINDOWCLOSE, hwnd, windowType);
}
#endif //NULLSOFT_WINAMP_OMBROWSER_EVENTHANDLER_INTERFACE_HEADER

View File

@ -0,0 +1,61 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_EVENTMANAGER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_EVENTMANAGER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {EF73F304-7730-4e80-B938-A80B5C971CC5}
static const GUID IFC_OmBrowserEventManager =
{ 0xef73f304, 0x7730, 0x4e80, { 0xb9, 0x38, 0xa8, 0xb, 0x5c, 0x97, 0x1c, 0xc5 } };
class obj_ombrowser;
class ifc_ombrowserevent;
class __declspec(novtable) ifc_ombrowsereventmngr : public Dispatchable
{
protected:
ifc_ombrowsereventmngr() {}
~ifc_ombrowsereventmngr() {}
public:
HRESULT RegisterHandler(ifc_ombrowserevent *handler);
HRESULT UnregisterHandler(ifc_ombrowserevent *handler);
HRESULT Signal_WindowCreate(HWND hwnd, const GUID *windowType);
HRESULT Signal_WindowClose(HWND hwnd, const GUID *windowType);
public:
DISPATCH_CODES
{
API_REGISTERHANDLER = 10,
API_UNREGISTERHANDLER = 20,
API_SIGNAL_WINDOWCREATE = 30,
API_SIGNAL_WINDOWCLOSE = 40,
};
};
inline HRESULT ifc_ombrowsereventmngr::RegisterHandler(ifc_ombrowserevent *handler)
{
return _call(API_REGISTERHANDLER, (HRESULT)E_NOTIMPL, handler);
}
inline HRESULT ifc_ombrowsereventmngr::UnregisterHandler(ifc_ombrowserevent *handler)
{
return _call(API_UNREGISTERHANDLER, (HRESULT)E_NOTIMPL, handler);
}
inline HRESULT ifc_ombrowsereventmngr::Signal_WindowCreate(HWND hwnd, const GUID *windowType)
{
return _call(API_SIGNAL_WINDOWCREATE, (HRESULT)E_NOTIMPL, hwnd, windowType);
}
inline HRESULT ifc_ombrowsereventmngr::Signal_WindowClose(HWND hwnd, const GUID *windowType)
{
return _call(API_SIGNAL_WINDOWCLOSE, (HRESULT)E_NOTIMPL, hwnd, windowType);
}
#endif //NULLSOFT_WINAMP_OMBROWSER_EVENTMANAGER_INTERFACE_HEADER

View File

@ -0,0 +1,57 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_REGISTRY_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_REGISTRY_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {F6415954-AB16-4283-B530-EE94AB29E968}
static const GUID IFC_OmBrowserRegistry =
{ 0xf6415954, 0xab16, 0x4283, { 0xb5, 0x30, 0xee, 0x94, 0xab, 0x29, 0xe9, 0x68 } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_ombrowserregistry : public Dispatchable
{
protected:
ifc_ombrowserregistry() {}
~ifc_ombrowserregistry() {}
public:
HRESULT GetPath(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT Write(void);
HRESULT Delete(void);
HRESULT UpdateColors(void);
public:
DISPATCH_CODES
{
API_GETPATH = 10,
API_WRITE = 20,
API_DELETE = 30,
API_UPDATECOLORS = 40,
};
};
inline HRESULT ifc_ombrowserregistry::GetPath(LPWSTR pszBuffer, INT cchBufferMax)
{
return _call(API_GETPATH, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_ombrowserregistry::Write(void)
{
return _call(API_WRITE, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_ombrowserregistry::Delete(void)
{
return _call(API_DELETE, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_ombrowserregistry::UpdateColors(void)
{
return _call(API_UPDATECOLORS, (HRESULT)E_NOTIMPL);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_CONFIG_INTERFACE_HEADER

View File

@ -0,0 +1,50 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {8B184E07-1DC6-4d76-8FB3-A793FF4A062B}
static const GUID IFC_OmBrowserWindowEnumerator =
{ 0x8b184e07, 0x1dc6, 0x4d76, { 0x8f, 0xb3, 0xa7, 0x93, 0xff, 0x4a, 0x6, 0x2b } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_ombrowserwndenum : public Dispatchable
{
protected:
ifc_ombrowserwndenum() {}
~ifc_ombrowserwndenum() {}
public:
HRESULT Next(unsigned long listSize, HWND *elementList, unsigned long *elementCount);
HRESULT Reset(void);
HRESULT Skip(unsigned long elementCount);
public:
DISPATCH_CODES
{
API_NEXT = 10,
API_RESET = 20,
API_SKIP = 30,
};
};
inline HRESULT ifc_ombrowserwndenum::Next(unsigned long listSize, HWND *elementList, unsigned long *elementCount)
{
return _call(API_NEXT, (HRESULT)E_NOTIMPL, listSize, elementList, elementCount);
}
inline HRESULT ifc_ombrowserwndenum::Reset(void)
{
return _call(API_RESET, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_ombrowserwndenum::Skip(unsigned long elementCount)
{
return _call(API_SKIP, (HRESULT)E_NOTIMPL, elementCount);
}
#endif //NULLSOFT_WINAMP_OMBROWSER_WINDOW_ENUMERATOR_INTERFACE_HEADER

View File

@ -0,0 +1,51 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_WINDOW_MANAGER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_WINDOW_MANAGER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {81E8333B-388F-444e-8233-138E15ACC761}
static const GUID IFC_OmBrowserWindowManager =
{ 0x81e8333b, 0x388f, 0x444e, { 0x82, 0x33, 0x13, 0x8e, 0x15, 0xac, 0xc7, 0x61 } };
#include <bfc/dispatch.h>
class ifc_ombrowserwndenum;
class __declspec(novtable) ifc_ombrowserwndmngr : public Dispatchable
{
protected:
ifc_ombrowserwndmngr() {}
~ifc_ombrowserwndmngr() {}
public:
HRESULT RegisterWindow(HWND hwnd, const GUID *windowType);
HRESULT UnregisterWindow(HWND hwnd);
HRESULT Enumerate(const GUID *windowType, unsigned int *serviceIdFilter, ifc_ombrowserwndenum **enumerator); // serviceIdFilter can be NULL if you want to get all windows
public:
DISPATCH_CODES
{
API_REGISTERWINDOW = 10,
API_UNREGISTERWINDOW = 20,
API_ENUMERATE = 30,
};
};
inline HRESULT ifc_ombrowserwndmngr::RegisterWindow(HWND hwnd, const GUID *windowType)
{
return _call(API_REGISTERWINDOW, (HRESULT)E_NOTIMPL, hwnd, windowType);
}
inline HRESULT ifc_ombrowserwndmngr::UnregisterWindow(HWND hwnd)
{
return _call(API_UNREGISTERWINDOW, (HRESULT)E_NOTIMPL, hwnd);
}
inline HRESULT ifc_ombrowserwndmngr::Enumerate(const GUID *windowType, unsigned int *serviceIdFilter, ifc_ombrowserwndenum **enumerator)
{
return _call(API_ENUMERATE, (HRESULT)E_NOTIMPL, windowType, serviceIdFilter, enumerator);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_WINDOW_MANAGER_INTERFACE_HEADER

View File

@ -0,0 +1,39 @@
#ifndef NULLSOFT_WINAMP_OMCACHE_CALLBACK_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMCACHE_CALLBACK_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {A82E94C9-38BA-44ba-9879-0F3CAFCB3527}
static const GUID IFC_OmCacheCallback =
{ 0xa82e94c9, 0x38ba, 0x44ba, { 0x98, 0x79, 0xf, 0x3c, 0xaf, 0xcb, 0x35, 0x27 } };
class ifc_omcacherecord;
class __declspec(novtable) ifc_omcachecallback: public Dispatchable
{
protected:
ifc_omcachecallback() {}
~ifc_omcachecallback() {}
public:
void PathChanged(ifc_omcacherecord *record);
public:
DISPATCH_CODES
{
API_PATHCHANGED = 10,
};
};
inline void ifc_omcachecallback::PathChanged(ifc_omcacherecord *record)
{
_voidcall(API_PATHCHANGED, record);
}
#endif //NULLSOFT_WINAMP_OMCACHE_CALLBACK_INTERFACE_HEADER

View File

@ -0,0 +1,60 @@
#ifndef NULLSOFT_WINAMP_OMCACHE_GROUP_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMCACHE_GROUP_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {3249BCBE-A169-4051-8C36-2E355E63C27B}
static const GUID IFC_OmCacheGroup =
{ 0x3249bcbe, 0xa169, 0x4051, { 0x8c, 0x36, 0x2e, 0x35, 0x5e, 0x63, 0xc2, 0x7b } };
class ifc_omcacherecord;
class __declspec(novtable) ifc_omcachegroup: public Dispatchable
{
protected:
ifc_omcachegroup() {}
~ifc_omcachegroup() {}
public:
HRESULT GetName(wchar_t *buffer, unsigned int bufferMax);
HRESULT Find(const wchar_t *name, BOOL registerMissing, ifc_omcacherecord **recordOut, BOOL *created);
HRESULT Delete(const wchar_t *name);
HRESULT Clear();
public:
DISPATCH_CODES
{
API_GETNAME = 10,
API_FIND = 20,
API_DELETE = 30,
API_CLEAR = 40,
};
};
inline HRESULT ifc_omcachegroup::GetName(wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETNAME, (HRESULT)E_NOTIMPL, buffer, bufferMax);
}
inline HRESULT ifc_omcachegroup::Find(const wchar_t *name, BOOL registerMissing, ifc_omcacherecord **recordOut, BOOL *created)
{
return _call(API_FIND, (HRESULT)E_NOTIMPL, name, registerMissing, recordOut, created);
}
inline HRESULT ifc_omcachegroup::Delete(const wchar_t *name)
{
return _call(API_DELETE, (HRESULT)E_NOTIMPL, name);
}
inline HRESULT ifc_omcachegroup::Clear()
{
return _call(API_CLEAR, (HRESULT)E_NOTIMPL);
}
#endif //NULLSOFT_WINAMP_OMCACHE_GROUP_INTERFACE_HEADER

View File

@ -0,0 +1,52 @@
#ifndef NULLSOFT_WINAMP_OMCACHE_MANAGER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMCACHE_MANAGER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {95673D91-A7D3-4797-A599-2CE0E4CD2A20}
static const GUID IFC_OmCacheManager =
{ 0x95673d91, 0xa7d3, 0x4797, { 0xa5, 0x99, 0x2c, 0xe0, 0xe4, 0xcd, 0x2a, 0x20 } };
class ifc_omcachegroup;
class __declspec(novtable) ifc_omcachemanager: public Dispatchable
{
protected:
ifc_omcachemanager() {}
~ifc_omcachemanager() {}
public:
HRESULT Find(const wchar_t *group, BOOL registerMissing, ifc_omcachegroup **groupOut, BOOL *created);
HRESULT Delete(const wchar_t *group);
HRESULT Clear();
public:
DISPATCH_CODES
{
API_FIND = 10,
API_DELETE = 20,
API_CLEAR = 30,
};
};
inline HRESULT ifc_omcachemanager::Find(const wchar_t *group, BOOL registerMissing, ifc_omcachegroup **groupOut, BOOL *created)
{
return _call(API_FIND, (HRESULT)E_NOTIMPL, group, registerMissing, groupOut, created);
}
inline HRESULT ifc_omcachemanager::Delete(const wchar_t *group)
{
return _call(API_DELETE, (HRESULT)E_NOTIMPL, group);
}
inline HRESULT ifc_omcachemanager::Clear()
{
return _call(API_CLEAR, (HRESULT)E_NOTIMPL);
}
#endif //NULLSOFT_WINAMP_OMCACHE_MANAGER_INTERFACE_HEADER

View File

@ -0,0 +1,99 @@
#ifndef NULLSOFT_WINAMP_OMCACHE_RECORD_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMCACHE_RECORD_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {50C4A9E1-0F31-4692-8084-3A7835647EAE}
static const GUID IFC_OmCacheRecord =
{ 0x50c4a9e1, 0xf31, 0x4692, { 0x80, 0x84, 0x3a, 0x78, 0x35, 0x64, 0x7e, 0xae } };
class ifc_omcachecallback;
class __declspec(novtable) ifc_omcacherecord : public Dispatchable
{
public:
typedef enum
{
flagNoStore = 0x00000001,
} Flags;
protected:
ifc_omcacherecord() {}
~ifc_omcacherecord() {}
public:
HRESULT GetName(wchar_t *buffer, unsigned int bufferMax);
HRESULT GetPath(wchar_t *buffer, unsigned int bufferMax);
HRESULT SetPath(const wchar_t *path);
HRESULT SetFlags(unsigned int flags, unsigned int mask);
HRESULT GetFlags(unsigned int *flags);
HRESULT Download();
HRESULT RegisterCallback(ifc_omcachecallback *callback);
HRESULT UnregisterCallback(ifc_omcachecallback *callback);
public:
DISPATCH_CODES
{
API_GETNAME = 10,
API_GETPATH = 20,
API_SETPATH = 30,
API_SETFLAGS = 40,
API_GETFLAGS = 50,
API_DOWNLOAD = 60,
API_REGISTERCALLBACK = 70,
API_UNREGISTERCALLBACK = 80,
};
};
inline HRESULT ifc_omcacherecord::GetName(wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETNAME, (HRESULT)E_NOTIMPL, buffer, bufferMax);
}
inline HRESULT ifc_omcacherecord::GetPath(wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETPATH, (HRESULT)E_NOTIMPL, buffer, bufferMax);
}
inline HRESULT ifc_omcacherecord::SetPath(const wchar_t *path)
{
return _call(API_SETPATH, (HRESULT)E_NOTIMPL, path);
}
inline HRESULT ifc_omcacherecord::SetFlags(unsigned int flags, unsigned int mask)
{
return _call(API_SETFLAGS, (HRESULT)E_NOTIMPL, flags, mask);
}
inline HRESULT ifc_omcacherecord::GetFlags(unsigned int *flags)
{
return _call(API_GETFLAGS, (HRESULT)E_NOTIMPL, flags);
}
inline HRESULT ifc_omcacherecord::Download()
{
return _call(API_DOWNLOAD, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omcacherecord::RegisterCallback(ifc_omcachecallback *callback)
{
return _call(API_REGISTERCALLBACK, (HRESULT)E_NOTIMPL, callback);
}
inline HRESULT ifc_omcacherecord::UnregisterCallback(ifc_omcachecallback *callback)
{
return _call(API_UNREGISTERCALLBACK, (HRESULT)E_NOTIMPL, callback);
}
#endif //NULLSOFT_WINAMP_OMCACHE_RECORD_INTERFACE_HEADER

View File

@ -0,0 +1,94 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_CONFIG_INI_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_CONFIG_INI_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {73661787-0ACC-4692-B6A2-41D14E81A8CE}
static const GUID IFC_OmConfig =
{ 0x73661787, 0xacc, 0x4692, { 0xb6, 0xa2, 0x41, 0xd1, 0x4e, 0x81, 0xa8, 0xce } };
#include <bfc/dispatch.h>
class ifc_omconfigcallback;
class __declspec(novtable) ifc_omconfig : public Dispatchable
{
protected:
ifc_omconfig() {}
~ifc_omconfig() {}
public:
HRESULT GetPath(wchar_t *pszBuffer, int cchBufferMax);
DWORD ReadString(const wchar_t *lpSectionName, const wchar_t *lpKeyName, const wchar_t *lpDefault, wchar_t *lpReturnedString, DWORD nSize);
UINT ReadInt(const wchar_t *lpSectionName, const wchar_t *lpKeyName, int nDefault);
BOOL ReadBool(const wchar_t *lpSectionName, const wchar_t *lpKeyName, BOOL bDefault);
HRESULT WriteString(const wchar_t *lpSectionName, const wchar_t *lpKeyName, const wchar_t * lpString);
HRESULT WriteInt(const wchar_t *lpSectionName, const wchar_t *lpKeyName, int nValue);
HRESULT WriteBool(const wchar_t *lpSectionName, const wchar_t *lpKeyName, BOOL bValue);
HRESULT RegisterCallback(ifc_omconfigcallback *callback, unsigned int *cookie);
HRESULT UnregisterCallback(unsigned int cookie);
public:
DISPATCH_CODES
{
API_GETPATH = 10,
API_READSTRING = 20,
API_READINT = 30,
API_READBOOL = 40,
API_WRITESTRING = 50,
API_WRITEINT = 60,
API_WRITEBOOL = 70,
API_REGISTERCALLBACK = 80,
API_UNREGISTERCALLBACK = 90,
};
};
inline HRESULT ifc_omconfig::GetPath(LPWSTR pszBuffer, INT cchBufferMax)
{
return _call(API_GETPATH, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline DWORD ifc_omconfig::ReadString(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize)
{
return _call(API_READSTRING, (DWORD)0, lpSectionName, lpKeyName, lpDefault, lpReturnedString, nSize);
}
inline UINT ifc_omconfig::ReadInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nDefault)
{
return _call(API_READINT, (UINT)0, lpSectionName, lpKeyName, nDefault);
}
inline BOOL ifc_omconfig::ReadBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bDefault)
{
return _call(API_READBOOL, (BOOL)FALSE, lpSectionName, lpKeyName, bDefault);
}
inline HRESULT ifc_omconfig::WriteString(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString)
{
return _call(API_WRITESTRING, (HRESULT)E_NOTIMPL, lpSectionName, lpKeyName, lpString);
}
inline HRESULT ifc_omconfig::WriteInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nValue)
{
return _call(API_WRITEINT, (HRESULT)E_NOTIMPL, lpSectionName, lpKeyName, nValue);
}
inline HRESULT ifc_omconfig::WriteBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bValue)
{
return _call(API_WRITEBOOL, (HRESULT)E_NOTIMPL, lpSectionName, lpKeyName, bValue);
}
inline HRESULT ifc_omconfig::RegisterCallback(ifc_omconfigcallback *callback, unsigned int *cookie)
{
return _call(API_REGISTERCALLBACK, (HRESULT)API_REGISTERCALLBACK, callback, cookie);
}
inline HRESULT ifc_omconfig::UnregisterCallback(unsigned int cookie)
{
return _call(API_UNREGISTERCALLBACK, (HRESULT)E_NOTIMPL, cookie);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_CONFIG_INI_INTERFACE_HEADER

View File

@ -0,0 +1,36 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_CONFIG_CALLBACK_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_CONFIG_CALLBACK_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {FF6CA21B-FF24-4e51-B594-60BD9D9E7C3D}
static const GUID IFC_OmConfigCallback =
{ 0xff6ca21b, 0xff24, 0x4e51, { 0xb5, 0x94, 0x60, 0xbd, 0x9d, 0x9e, 0x7c, 0x3d } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omconfigcallback : public Dispatchable
{
protected:
ifc_omconfigcallback() {}
~ifc_omconfigcallback() {}
public:
HRESULT ValueChanged(const GUID *configUid, UINT valueId, ULONG_PTR value);
public:
DISPATCH_CODES
{
API_VALUECHANGED = 10,
};
};
inline HRESULT ifc_omconfigcallback::ValueChanged(const GUID *configUid, UINT valueId, ULONG_PTR value)
{
return _call(API_VALUECHANGED, (HRESULT)E_NOTIMPL, configUid, valueId, value);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_CONFIG_CALLBACK_INTERFACE_HEADER

View File

@ -0,0 +1,92 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_DEBUG_CONFIG_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_DEBUG_CONFIG_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {07057926-4DCD-4686-AE81-F74AE36B931B}
static const GUID IFC_OmDebugConfig =
{ 0x7057926, 0x4dcd, 0x4686, { 0xae, 0x81, 0xf7, 0x4a, 0xe3, 0x6b, 0x93, 0x1b } };
#define CFGID_DEBUG_FILTERMENU 0 // param = (ULONG_PTR)(BOOL)fFilter
#define CFGID_DEBUG_SCRIPTERROR 1 // param = (ULONG_PTR)(BOOL)fShow
#define CFGID_DEBUG_SCRIPTDEBUGGER 2 // param = (ULONG_PTR)(BOOL)fShow
#define CFGID_DEBUG_BROWSERPATH 3 // param = (ULONG_PTR)(LPCWSTR)pszPath
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omdebugconfig : public Dispatchable
{
protected:
ifc_omdebugconfig() {}
~ifc_omdebugconfig() {}
public:
HRESULT GetMenuFilterEnabled(void);
HRESULT GetScriptErrorEnabled(void);
HRESULT GetScriptDebuggerEnabled(void);
HRESULT GetBrowserPath(LPWSTR pszBuffer, INT cchBufferMax);
HRESULT EnableMenuFilter(BOOL fEnable);
HRESULT EnableScriptError(BOOL fEnable);
HRESULT EnableScriptDebugger(BOOL fEnable);
HRESULT SetBrowserPath(LPCWSTR pszPath);
public:
DISPATCH_CODES
{
API_GETMENUFILTERENABLED = 10,
API_GETSCRIPTERRORENABLED = 20,
API_GETSCRIPTDEBUGGERENABLED = 30,
API_GETBROWSERPATH = 40,
API_ENABLEMENUFILTER = 110,
API_ENABLESCRIPTERROR = 120,
API_ENABLESCRIPTDEBUGGER = 130,
API_SETBROWSERPATH = 140,
};
};
inline HRESULT ifc_omdebugconfig::GetMenuFilterEnabled(void)
{
return _call(API_GETMENUFILTERENABLED, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omdebugconfig::GetScriptErrorEnabled(void)
{
return _call(API_GETSCRIPTERRORENABLED, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omdebugconfig::GetScriptDebuggerEnabled(void)
{
return _call(API_GETSCRIPTDEBUGGERENABLED, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omdebugconfig::GetBrowserPath(LPWSTR pszBuffer, INT cchBufferMax)
{
return _call(API_GETBROWSERPATH, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omdebugconfig::EnableMenuFilter(BOOL fEnable)
{
return _call(API_ENABLEMENUFILTER, (HRESULT)E_NOTIMPL, fEnable);
}
inline HRESULT ifc_omdebugconfig::EnableScriptError(BOOL fEnable)
{
return _call(API_ENABLESCRIPTERROR, (HRESULT)E_NOTIMPL, fEnable);
}
inline HRESULT ifc_omdebugconfig::EnableScriptDebugger(BOOL fEnable)
{
return _call(API_ENABLESCRIPTDEBUGGER, (HRESULT)E_NOTIMPL, fEnable);
}
inline HRESULT ifc_omdebugconfig::SetBrowserPath(LPCWSTR pszPath)
{
return _call(API_SETBROWSERPATH, (HRESULT)E_NOTIMPL, pszPath);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_DEBUG_CONFIG_INTERFACE_HEADER

View File

@ -0,0 +1,45 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGETYPE_FILE_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGETYPE_FILE_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {E49678EB-9DA4-43c3-8A80-18AA5EE369BF}
static const GUID STID_OmFileStorage =
{ 0xe49678eb, 0x9da4, 0x43c3, { 0x8a, 0x80, 0x18, 0xaa, 0x5e, 0xe3, 0x69, 0xbf } };
#define IFC_OmFileStorage STID_OmFileStorage
// {E6D3D527-4721-4fb6-BAB2-304D17C549B2}
static const GUID SUID_OmStorageIni =
{ 0xe6d3d527, 0x4721, 0x4fb6, { 0xba, 0xb2, 0x30, 0x4d, 0x17, 0xc5, 0x49, 0xb2 } };
// {0F356A24-114D-4582-9005-A59E08B3164A}
static const GUID SUID_OmStorageXml =
{ 0xf356a24, 0x114d, 0x4582, { 0x90, 0x5, 0xa5, 0x9e, 0x8, 0xb3, 0x16, 0x4a } };
#include <bfc/dispatch.h>
#include <ifc_omstorage.h>
class __declspec(novtable) ifc_omfilestorage : public Dispatchable
{
protected:
ifc_omfilestorage() {}
~ifc_omfilestorage() {}
public:
HRESULT GetFilter(wchar_t *buffer, unsigned int bufferMax);
public:
DISPATCH_CODES
{
API_GETFILTER = 10,
};
};
inline HRESULT ifc_omfilestorage::GetFilter(wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETFILTER, (HRESULT)E_NOTIMPL, buffer, bufferMax);
}
#endif //NULLSOFT_WINAMP_OMSTORAGETYPE_FILE_INTERFACE_HEADER

View File

@ -0,0 +1,97 @@
#ifndef NULLSOFT_WINAMP_OMGRAPHICS_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMGRAPHICS_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {0CE26A63-B611-468b-A679-810AAD0FB124}
static const GUID IFC_OmGrpahics =
{ 0xce26a63, 0xb611, 0x468b, { 0xa6, 0x79, 0x81, 0xa, 0xad, 0xf, 0xb1, 0x24 } };
class __declspec(novtable) ifc_omgraphics: public Dispatchable
{
protected:
ifc_omgraphics() {}
~ifc_omgraphics() {}
public:
HRESULT GetDistance(COLORREF rgb1, COLORREF rgb2, int *distance);
HRESULT GetDarker(COLORREF rgb1, COLORREF rgb2, COLORREF *result);
HRESULT BlendColor(COLORREF rgbTop, COLORREF rgbBottom, int alpha, COLORREF *result);
HRESULT Colorize(BYTE *pixels, long cx, long cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha);
HRESULT BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb);
HRESULT BlendOnColor2(BYTE *pixels, int bitmapCX, int bitmapCY, long x, long y, long cx, long cy, WORD bpp, BOOL premult, COLORREF rgb);
HRESULT Premultiply(BYTE *pixels, long cx, long cy);
HRESULT AlphaBlend(HDC hdcDest, const RECT *rectDest, HDC hdcSrc, const RECT *rectSrc, BLENDFUNCTION blendFunction);
HRESULT AnimateRotation(HDC hdc, HBITMAP bitmapFrame, int frameCount, COLORREF rgbBk, BOOL fKeepSize, HBITMAP *result);
public:
DISPATCH_CODES
{
API_GETDISTANCE = 10,
API_GETDARKER = 20,
API_BLENDCOLOR = 30,
API_COLORIZE = 40,
API_BLENDONCOLOR = 50,
API_BLENDONCOLOR2 = 60,
API_PREMULTIPLY = 70,
API_ALPHABLEND = 80,
API_ANIMATEROTATION = 90,
};
};
inline HRESULT ifc_omgraphics::GetDistance(COLORREF rgb1, COLORREF rgb2, int *distance)
{
return _call(API_GETDISTANCE, (HRESULT)E_NOTIMPL, rgb1, rgb2, distance);
}
inline HRESULT ifc_omgraphics::GetDarker(COLORREF rgb1, COLORREF rgb2, COLORREF *result)
{
return _call(API_GETDARKER, (HRESULT)E_NOTIMPL, rgb1, rgb2, result);
}
inline HRESULT ifc_omgraphics::BlendColor(COLORREF rgbTop, COLORREF rgbBottom, int alpha, COLORREF *result)
{
return _call(API_BLENDCOLOR, (HRESULT)E_NOTIMPL, rgbTop, rgbBottom, alpha, result);
}
inline HRESULT ifc_omgraphics::Colorize(BYTE *pixels, long cx, long cy, WORD bpp, COLORREF rgbBk, COLORREF rgbFg, BOOL removeAlpha)
{
return _call(API_COLORIZE, (HRESULT)E_NOTIMPL, pixels, cx, cy, bpp, rgbBk, rgbFg, removeAlpha);
}
inline HRESULT ifc_omgraphics::BlendOnColor(HBITMAP hbmp, RECT *prcPart, BOOL premult, COLORREF rgb)
{
return _call(API_BLENDONCOLOR, (HRESULT)E_NOTIMPL, hbmp, prcPart, premult, rgb);
}
inline HRESULT ifc_omgraphics::BlendOnColor2(BYTE *pixels, int bitmapCX, int bitmapCY, long x, long y, long cx, long cy, WORD bpp, BOOL premult, COLORREF rgb)
{
return _call(API_BLENDONCOLOR2, (HRESULT)E_NOTIMPL, pixels, bitmapCX, bitmapCY, x, y, cx, cy, bpp, premult, rgb);
}
inline HRESULT ifc_omgraphics::Premultiply(BYTE *pixels, long cx, long cy)
{
return _call(API_PREMULTIPLY, (HRESULT)E_NOTIMPL, pixels, cx, cy);
}
inline HRESULT ifc_omgraphics::AlphaBlend(HDC hdcDest, const RECT *rectDest, HDC hdcSrc, const RECT *rectSrc, BLENDFUNCTION blendFunction)
{
return _call(API_ALPHABLEND, (HRESULT)E_NOTIMPL, hdcDest, rectDest, hdcSrc, rectSrc, blendFunction);
}
inline HRESULT ifc_omgraphics::AnimateRotation(HDC hdc, HBITMAP bitmapFrame, int frameCount, COLORREF rgBk, BOOL fKeepSize, HBITMAP *result)
{
return _call(API_ANIMATEROTATION, (HRESULT)E_NOTIMPL, bitmapFrame, frameCount, rgBk, fKeepSize, result);
}
#endif //NULLSOFT_WINAMP_OMGRAPHICS_INTERFACE_HEADER

View File

@ -0,0 +1,135 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {2999A8B2-7780-4542-9257-02D4E89310B8}
static const GUID IFC_OmService =
{ 0x2999a8b2, 0x7780, 0x4542, { 0x92, 0x57, 0x2, 0xd4, 0xe8, 0x93, 0x10, 0xb8 } };
interface IDispatch;
class ifc_omservicehost;
#define OMSVC_E_INSUFFICIENT_BUFFER MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INSUFFICIENT_BUFFER) //same as STRSAFE_E_INSUFFICIENT_BUFFER
// supports AddRef(), Release(), QueryInterface()
class __declspec(novtable) ifc_omservice : public Dispatchable
{
public:
typedef enum
{
RuntimeFlagsMask = 0xFFFF0000,
} FlagsMask;
protected:
ifc_omservice() {}
~ifc_omservice() {}
public:
unsigned int GetId();
HRESULT GetName(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetUrl(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetUrlDirect(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetIcon(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetExternal(IDispatch **ppDispatch);
HRESULT GetRating(unsigned int *rating);
HRESULT GetVersion(unsigned int *version);
HRESULT GetFlags(unsigned int *flags);
HRESULT SetAddress(const wchar_t *pszAddress);
HRESULT GetAddress(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetGeneration(unsigned int *generation);
HRESULT UpdateFlags(unsigned int flags);
public:
DISPATCH_CODES
{
API_GETID = 10,
API_GETNAME = 20,
API_GETURL = 30,
API_GETICON = 40,
API_GETEXTERNAL = 50,
API_GETRATING = 60,
API_GETVERSION = 70,
API_GETFLAGS = 80,
API_SETADDRESS = 90,
API_GETADDRESS = 100,
API_GETGENERATION = 110,
API_GETURLDIRECT = 120,
API_UPDATEFLAGS = 130,
};
};
inline unsigned int ifc_omservice::GetId()
{
return _call(API_GETID, 0);
}
inline HRESULT ifc_omservice::GetName(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETNAME, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservice::GetUrl(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETURL, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservice::GetUrlDirect(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETURLDIRECT, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservice::GetIcon(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETICON, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservice::GetExternal(IDispatch **ppDispatch)
{
return _call(API_GETEXTERNAL, (HRESULT)E_NOTIMPL, ppDispatch);
}
inline HRESULT ifc_omservice::GetRating(unsigned int *rating)
{
return _call(API_GETRATING, (HRESULT)E_NOTIMPL, rating);
}
inline HRESULT ifc_omservice::GetVersion(unsigned int *version)
{
return _call(API_GETVERSION, (HRESULT)E_NOTIMPL, version);
}
inline HRESULT ifc_omservice::GetFlags(unsigned int *flags)
{
return _call(API_GETFLAGS, (HRESULT)E_NOTIMPL, flags);
}
inline HRESULT ifc_omservice::SetAddress(const wchar_t *pszAddress)
{
return _call(API_SETADDRESS, (HRESULT)E_NOTIMPL, pszAddress);
}
inline HRESULT ifc_omservice::GetAddress(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETADDRESS, (HRESULT)E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservice::GetGeneration(unsigned int *generation)
{
return _call(API_GETGENERATION, (HRESULT)E_NOTIMPL, generation);
}
inline HRESULT ifc_omservice::UpdateFlags(unsigned int flags)
{
return _call(API_UPDATEFLAGS, (HRESULT)E_NOTIMPL, flags);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_INTERFACE_HEADER

View File

@ -0,0 +1,81 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_COMMAND_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_COMMAND_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {CA77030B-DF0F-4610-B01E-4A406A2FCD67}
static const GUID IFC_OmServiceCommand =
{ 0xca77030b, 0xdf0f, 0x4610, { 0xb0, 0x1e, 0x4a, 0x40, 0x6a, 0x2f, 0xcd, 0x67 } };
// {8E4F3281-37CA-4cbe-8753-BA7531690D07}
static const GUID CMDGROUP_SERVICE =
{ 0x8e4f3281, 0x37ca, 0x4cbe, { 0x87, 0x53, 0xba, 0x75, 0x31, 0x69, 0xd, 0x7 } };
#define SVCCOMMAND_SHOWINFO 1
#define SVCCOMMAND_REPORT 2
#define SVCCOMMAND_UNSUBSCRIBE 3
#define SVCCOMMAND_RATE 4 // commandArg = (UINT)ratingValue
#define SVCCOMMAND_BLOCKNAV 5 //used with query state
// {FA32FE7D-848D-4813-8BDE-27E19CC835B5}
static const GUID CMDGROUP_NAVIGATION =
{ 0xfa32fe7d, 0x848d, 0x4813, { 0x8b, 0xde, 0x27, 0xe1, 0x9c, 0xc8, 0x35, 0xb5 } };
#define NAVCOMMAND_BACKFORWARD 1 // arg = FALSE - backward, arg = TRUE - rofward
#define NAVCOMMAND_HISTORY 2
#define NAVCOMMAND_HOME 3
#define NAVCOMMAND_REFRESH 4 // arg = TRUE - full refresh
#define NAVCOMMAND_STOP 5
// {C04A2400-8D0D-4b3c-9271-0E042AF8C363}
static const GUID CMDGROUP_WINDOW =
{ 0xc04a2400, 0x8d0d, 0x4b3c, { 0x92, 0x71, 0xe, 0x4, 0x2a, 0xf8, 0xc3, 0x63 } };
#define WNDCOMMAND_FULLSCREEN 1 //
#define WNDCOMMAND_CLOSE 2 //
// {6A730612-A7CE-4a45-9898-2F0A807A3BB4}
static const GUID CMDGROUP_ADDRESSBAR =
{ 0x6a730612, 0xa7ce, 0x4a45, { 0x98, 0x98, 0x2f, 0xa, 0x80, 0x7a, 0x3b, 0xb4 } };
#define ADDRESSCOMMAND_EXECUTE 1 // arg = address string
#define ADDRESSCOMMAND_VISIBLE 2 // used to check state
#define ADDRESSCOMMAND_READONLY 3 // used to check state
// QueryStatus() return values
#define CMDSTATE_ENABLED S_OK
#define CMDSTATE_DISABLED S_FALSE
#define CMDSTATE_UNKNOWN E_NOINTERFACE
class __declspec(novtable) ifc_omservicecommand : public Dispatchable
{
protected:
ifc_omservicecommand() {}
~ifc_omservicecommand() {}
public:
HRESULT QueryState(HWND hBrowser, const GUID *commandGroup, unsigned int commandId); // return CMDSTATE_XXX or E_NOTIMPL if you ok with default
HRESULT Exec(HWND hBrowser, const GUID *commandGroup, unsigned int commandId, ULONG_PTR commandArg); // return SUCCEEDED() if command handled
public:
DISPATCH_CODES
{
API_QUERYSTATE = 10,
API_EXEC = 20,
};
};
inline HRESULT ifc_omservicecommand::QueryState(HWND hBrowser, const GUID *commandGroup, unsigned int commandId)
{
return _call(API_QUERYSTATE, (HRESULT)E_NOTIMPL, hBrowser, commandGroup, commandId);
}
inline HRESULT ifc_omservicecommand::Exec(HWND hBrowser, const GUID *commandGroup, unsigned int commandId, ULONG_PTR commandArg)
{
return _call(API_EXEC, (HRESULT)E_NOTIMPL, hBrowser, commandGroup, commandId, commandArg);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_COMMAND_INTERFACE_HEADER

View File

@ -0,0 +1,40 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_COPIER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_COPIER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {24E24C55-0A9D-4c54-9589-95FE07FC1FB2}
static const GUID IFC_OmServiceCopier =
{ 0x24e24c55, 0xa9d, 0x4c54, { 0x95, 0x89, 0x95, 0xfe, 0x7, 0xfc, 0x1f, 0xb2 } };
class ifc_omservice;
// supports AddRef(), Release(), QueryInterface()
class __declspec(novtable) ifc_omservicecopier: public Dispatchable
{
protected:
ifc_omservicecopier() {}
~ifc_omservicecopier() {}
public:
HRESULT CopyTo(ifc_omservice *service, unsigned int *modifiedFlags);
public:
DISPATCH_CODES
{
API_COPYTO = 10,
};
};
inline HRESULT ifc_omservicecopier::CopyTo(ifc_omservice *service, unsigned int *modifiedFlags)
{
return _call(API_COPYTO, (HRESULT)E_NOTIMPL, service, modifiedFlags);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_COPIER_INTERFACE_HEADER

View File

@ -0,0 +1,78 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_DETAILS_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_DETAILS_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {74C85447-B11A-47ea-95CB-B2ED54E8029E}
static const GUID IFC_OmServiceDetails =
{ 0x74c85447, 0xb11a, 0x47ea, { 0x95, 0xcb, 0xb2, 0xed, 0x54, 0xe8, 0x2, 0x9e } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omservicedetails : public Dispatchable
{
protected:
ifc_omservicedetails() {}
~ifc_omservicedetails() {}
public:
HRESULT GetDescription(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetAuthorFirst(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetAuthorLast(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetUpdated(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetPublished(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetThumbnail(wchar_t *pszBuffer, unsigned int cchBufferMax);
HRESULT GetScreenshot(wchar_t *pszBuffer, unsigned int cchBufferMax);
public:
DISPATCH_CODES
{
API_GETDESCRIPTION = 10,
API_GETAUTHORFIRST = 20,
API_GETAUTHORLAST = 30,
API_GETUPDATED = 40,
API_GETPUBLISHED = 50,
API_GETTHUMBNAIL = 60,
API_GETSCREENSHOT = 70,
};
};
inline HRESULT ifc_omservicedetails::GetDescription(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETDESCRIPTION, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetAuthorFirst(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETAUTHORFIRST, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetAuthorLast(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETAUTHORLAST, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetUpdated(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETUPDATED, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetPublished(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETPUBLISHED, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetThumbnail(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETTHUMBNAIL, E_NOTIMPL, pszBuffer, cchBufferMax);
}
inline HRESULT ifc_omservicedetails::GetScreenshot(wchar_t *pszBuffer, unsigned int cchBufferMax)
{
return _call(API_GETSCREENSHOT, E_NOTIMPL, pszBuffer, cchBufferMax);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_DETAILS_INTERFACE_HEADER

View File

@ -0,0 +1,177 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_EDITOR_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_EDITOR_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {D0EC78E6-3115-4171-BD99-C500CC66DDAC}
static const GUID IFC_OmServiceEditor =
{ 0xd0ec78e6, 0x3115, 0x4171, { 0xbd, 0x99, 0xc5, 0x0, 0xcc, 0x66, 0xdd, 0xac } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omserviceeditor : public Dispatchable
{
public:
typedef enum
{
modifiedName = 0x00000001,
modifiedUrl = 0x00000002,
modifiedIcon = 0x00000004,
modifiedRating = 0x00000008,
modifiedVersion = 0x00000010,
modifiedFlags = 0x00000020,
modifiedDescription = 0x00000040,
modifiedAuthorFirst = 0x00000080,
modifiedAuthorLast = 0x00000100,
modifiedUpdated = 0x00000200,
modifiedPublished = 0x00000400,
modifiedThumbnail = 0x00000800,
modifiedScreenshot = 0x00001000,
modifiedGeneration = 0x00002000,
} ModifiedFlags;
protected:
ifc_omserviceeditor() {}
~ifc_omserviceeditor() {}
public:
HRESULT SetName(const wchar_t *name, BOOL utf8);
HRESULT SetUrl(const wchar_t *url, BOOL utf8);
HRESULT SetIcon(const wchar_t *imagePath, BOOL utf8);
HRESULT SetRating(unsigned int rating);
HRESULT SetVersion(unsigned int version);
HRESULT SetFlags(unsigned int flags, unsigned int flagMask);
HRESULT SetDescription(const wchar_t *description, BOOL utf8);
HRESULT SetAuthorFirst(const wchar_t *authorName, BOOL utf8);
HRESULT SetAuthorLast(const wchar_t *authorName, BOOL utf8);
HRESULT SetUpdated(const wchar_t *date, BOOL utf8);
HRESULT SetPublished(const wchar_t *date, BOOL utf8);
HRESULT SetThumbnail(const wchar_t *imagePath, BOOL utf8);
HRESULT SetScreenshot(const wchar_t *imagePath, BOOL utf8);
HRESULT SetGeneration(unsigned int generation);
HRESULT SetModified(unsigned int modifiedFlag, unsigned int modifiedMask);
HRESULT GetModified(unsigned int *modifiedFlags);
HRESULT BeginUpdate();
HRESULT EndUpdate();
public:
DISPATCH_CODES
{
API_SETNAME = 10,
API_SETURL = 20,
API_SETICON = 30,
API_SETRATING = 40,
API_SETVERSION = 50,
API_SETFLAGS = 60,
API_SETDESCRIPTION = 70,
API_SETAUTHORFIRST = 80,
API_SETAUTHORLAST = 90,
API_SETUPDATED = 100,
API_SETPUBLISHED = 110,
API_SETTHUMBNAIL = 120,
API_SETSCREENSHOT = 130,
API_SETGENERATION = 140,
API_SETMODIFIED = 400,
API_GETMODIFIED = 410,
API_BEGINUPDATE = 420,
API_ENDUPDATE = 430,
};
};
inline HRESULT ifc_omserviceeditor::SetName(const wchar_t *name, BOOL utf8)
{
return _call(API_SETNAME, (HRESULT)E_NOTIMPL, name, utf8);
}
inline HRESULT ifc_omserviceeditor::SetUrl(const wchar_t *url, BOOL utf8)
{
return _call(API_SETURL, (HRESULT)E_NOTIMPL, url, utf8);
}
inline HRESULT ifc_omserviceeditor::SetIcon(const wchar_t *imagePath, BOOL utf8)
{
return _call(API_SETICON, (HRESULT)E_NOTIMPL, imagePath, utf8);
}
inline HRESULT ifc_omserviceeditor::SetRating(unsigned int rating)
{
return _call(API_SETRATING, (HRESULT)E_NOTIMPL, rating);
}
inline HRESULT ifc_omserviceeditor::SetVersion(unsigned int version)
{
return _call(API_SETVERSION, (HRESULT)E_NOTIMPL, version);
}
inline HRESULT ifc_omserviceeditor::SetFlags(unsigned int flags, unsigned int flagMask)
{
return _call(API_SETFLAGS, (HRESULT)E_NOTIMPL, flags, flagMask);
}
inline HRESULT ifc_omserviceeditor::SetDescription(const wchar_t *description, BOOL utf8)
{
return _call(API_SETDESCRIPTION, (HRESULT)E_NOTIMPL, description, utf8);
}
inline HRESULT ifc_omserviceeditor::SetAuthorFirst(const wchar_t *authorName, BOOL utf8)
{
return _call(API_SETAUTHORFIRST, (HRESULT)E_NOTIMPL, authorName, utf8);
}
inline HRESULT ifc_omserviceeditor::SetAuthorLast(const wchar_t *authorName, BOOL utf8)
{
return _call(API_SETAUTHORLAST, (HRESULT)E_NOTIMPL, authorName, utf8);
}
inline HRESULT ifc_omserviceeditor::SetUpdated(const wchar_t *date, BOOL utf8)
{
return _call(API_SETUPDATED, (HRESULT)E_NOTIMPL, date, utf8);
}
inline HRESULT ifc_omserviceeditor::SetPublished(const wchar_t *date, BOOL utf8)
{
return _call(API_SETPUBLISHED, (HRESULT)E_NOTIMPL, date, utf8);
}
inline HRESULT ifc_omserviceeditor::SetThumbnail(const wchar_t *imagePath, BOOL utf8)
{
return _call(API_SETTHUMBNAIL, (HRESULT)E_NOTIMPL, imagePath, utf8);
}
inline HRESULT ifc_omserviceeditor::SetScreenshot(const wchar_t *imagePath, BOOL utf8)
{
return _call(API_SETSCREENSHOT, (HRESULT)E_NOTIMPL, imagePath, utf8);
}
inline HRESULT ifc_omserviceeditor::SetModified(unsigned int modifiedFlag, unsigned int modifiedMask)
{
return _call(API_SETMODIFIED, (HRESULT)E_NOTIMPL, modifiedFlag, modifiedMask);
}
inline HRESULT ifc_omserviceeditor::GetModified(unsigned int *modifiedFlags)
{
return _call(API_GETMODIFIED, (HRESULT)E_NOTIMPL, modifiedFlags);
}
inline HRESULT ifc_omserviceeditor::BeginUpdate()
{
return _call(API_BEGINUPDATE, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omserviceeditor::EndUpdate()
{
return _call(API_ENDUPDATE, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omserviceeditor::SetGeneration(unsigned int generation)
{
return _call(API_SETGENERATION, (HRESULT)E_NOTIMPL, generation);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_EDITOR_INTERFACE_HEADER

View File

@ -0,0 +1,52 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_ENUMERATOR_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_ENUMERATOR_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {27E67F83-2E2B-4b5b-A029-2CDDFF28BD41}
static const GUID IFC_OmServiceEnum =
{ 0x27e67f83, 0x2e2b, 0x4b5b, { 0xa0, 0x29, 0x2c, 0xdd, 0xff, 0x28, 0xbd, 0x41 } };
#include <bfc/dispatch.h>
class ifc_omservice;
class __declspec(novtable) ifc_omserviceenum : public Dispatchable
{
protected:
ifc_omserviceenum() {}
~ifc_omserviceenum() {}
public:
HRESULT Next(unsigned long listSize, ifc_omservice **elementList, unsigned long *elementCount);
HRESULT Reset(void);
HRESULT Skip(unsigned long elementCount);
public:
DISPATCH_CODES
{
API_NEXT = 10,
API_RESET = 20,
API_SKIP = 30,
};
};
inline HRESULT ifc_omserviceenum::Next(unsigned long listSize, ifc_omservice **elementList, unsigned long *elementCount)
{
return _call(API_NEXT, (HRESULT)E_NOTIMPL, listSize, elementList, elementCount);
}
inline HRESULT ifc_omserviceenum::Reset(void)
{
return _call(API_RESET, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omserviceenum::Skip(unsigned long elementCount)
{
return _call(API_SKIP, (HRESULT)E_NOTIMPL, elementCount);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_ENUMERATOR_INTERFACE_HEADER

View File

@ -0,0 +1,45 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_EVENTHANDLER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_EVENTHANDLER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {82B3DD14-A2B3-4f80-A4E1-C8702E0AF70E}
static const GUID IFC_OmServiceEvent =
{ 0x82b3dd14, 0xa2b3, 0x4f80, { 0xa4, 0xe1, 0xc8, 0x70, 0x2e, 0xa, 0xf7, 0xe } };
class ifc_omservice;
class __declspec(novtable) ifc_omserviceevent : public Dispatchable
{
protected:
ifc_omserviceevent() {}
~ifc_omserviceevent() {}
public:
void ServiceChange(ifc_omservice *service, unsigned int modifiedFlags);
void CommandStateChange(ifc_omservice *service, const GUID *commandGroup, unsigned int commandId);
public:
DISPATCH_CODES
{
API_SERVICECHANGE = 10,
API_COMMANDSTATECHANGE = 20,
};
};
inline void ifc_omserviceevent::ServiceChange(ifc_omservice *service, unsigned int modifiedFlags)
{
_voidcall(API_SERVICECHANGE, service, modifiedFlags);
}
inline void ifc_omserviceevent::CommandStateChange(ifc_omservice *service, const GUID *commandGroup, unsigned int commandId)
{
_voidcall(API_COMMANDSTATECHANGE, service, commandGroup, commandId);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_EVENTHANDLER_INTERFACE_HEADER

View File

@ -0,0 +1,62 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_EVENTMANAGER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_EVENTMANAGER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {2ED54062-1442-4dfb-B0AE-C43846BE4FCE}
static const GUID IFC_OmServiceEventMngr =
{ 0x2ed54062, 0x1442, 0x4dfb, { 0xb0, 0xae, 0xc4, 0x38, 0x46, 0xbe, 0x4f, 0xce } };
class ifc_omservice;
class ifc_omserviceevent;
class __declspec(novtable) ifc_omserviceeventmngr : public Dispatchable
{
protected:
ifc_omserviceeventmngr() {}
~ifc_omserviceeventmngr() {}
public:
HRESULT RegisterHandler(ifc_omserviceevent *handler);
HRESULT UnregisterHandler(ifc_omserviceevent *handler);
HRESULT Signal_ServiceChange(unsigned int modifiedFlags);
HRESULT Signal_CommandStateChange(const GUID *commandGroup, unsigned int commandId);
public:
DISPATCH_CODES
{
API_REGISTERHANDLER = 10,
API_UNREGISTERHANDLER = 20,
API_SIGNAL_SERVICECHANGE = 30,
API_SIGNAL_COMMANDSTATECHANGE = 40,
};
};
inline HRESULT ifc_omserviceeventmngr::RegisterHandler(ifc_omserviceevent *handler)
{
return _call(API_REGISTERHANDLER, (HRESULT)E_NOTIMPL, handler);
}
inline HRESULT ifc_omserviceeventmngr::UnregisterHandler(ifc_omserviceevent *handler)
{
return _call(API_UNREGISTERHANDLER, (HRESULT)E_NOTIMPL, handler);
}
inline HRESULT ifc_omserviceeventmngr::Signal_ServiceChange(unsigned int modifiedFlags)
{
return _call(API_SIGNAL_SERVICECHANGE, (HRESULT)E_NOTIMPL, modifiedFlags);
}
inline HRESULT ifc_omserviceeventmngr::Signal_CommandStateChange( const GUID *commandGroup, unsigned int commandId)
{
return _call(API_SIGNAL_COMMANDSTATECHANGE, (HRESULT)E_NOTIMPL, commandGroup, commandId);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_EVENTMANAGER_INTERFACE_HEADER

View File

@ -0,0 +1,75 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_HOST_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_HOST_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {75339603-8A3A-490d-84B1-DD493004AAE2}
static const GUID IFC_OmServiceHost =
{ 0x75339603, 0x8a3a, 0x490d, { 0x84, 0xb1, 0xdd, 0x49, 0x30, 0x4, 0xaa, 0xe2 } };
interface IDispatch;
class ifc_omservice;
// supports AddRef(), Release(), QueryInterface()
class __declspec(novtable) ifc_omservicehost : public Dispatchable
{
protected:
ifc_omservicehost() {}
~ifc_omservicehost() {}
public:
HRESULT GetExternal(ifc_omservice *service, IDispatch **ppDispatch); // ppDispatch probably will be already set with JSAPI according to generation
HRESULT GetBasePath(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax);
HRESULT GetDefaultName(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax);
HRESULT GetUrl(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax); // buffer will be set with ifc_omservice->GetUrl() you can modify it if you want. Return: S_OK on success, E_NOTIMPL - if do not care or E_XXX for errror
HRESULT QueryCommandState(ifc_omservice *service, HWND hBrowser, const GUID *commandGroup, UINT commandId);
HRESULT ExecuteCommand(ifc_omservice *service, HWND hBrowser, const GUID *commandGroup, UINT commandId, ULONG_PTR commandArg);
public:
DISPATCH_CODES
{
API_GETEXTERNAL = 10,
API_GETBASEPATH = 20,
API_GETDEFAULTNAME = 30,
API_QUERYCOMMANDSTATE = 40,
API_EXECUTECOMMAND = 50,
API_GETURL = 60,
};
};
inline HRESULT ifc_omservicehost::GetExternal(ifc_omservice *service, IDispatch **ppDispatch)
{
return _call(API_GETEXTERNAL, (HRESULT)E_NOTIMPL, service, ppDispatch);
}
inline HRESULT ifc_omservicehost::GetBasePath(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETBASEPATH, (HRESULT)E_NOTIMPL, service, buffer, bufferMax);
}
inline HRESULT ifc_omservicehost::GetDefaultName(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETDEFAULTNAME, (HRESULT)E_NOTIMPL, service, buffer, bufferMax);
}
inline HRESULT ifc_omservicehost::QueryCommandState(ifc_omservice *service, HWND hBrowser, const GUID *commandGroup, UINT commandId)
{
return _call(API_QUERYCOMMANDSTATE, (HRESULT)E_NOTIMPL, service, hBrowser, commandGroup, commandId);
}
inline HRESULT ifc_omservicehost::ExecuteCommand(ifc_omservice *service, HWND hBrowser, const GUID *commandGroup, UINT commandId, ULONG_PTR commandArg)
{
return _call(API_EXECUTECOMMAND, (HRESULT)E_NOTIMPL, service, hBrowser, commandGroup, commandId, commandArg);
}
inline HRESULT ifc_omservicehost::GetUrl(ifc_omservice *service, wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETURL, (HRESULT)E_NOTIMPL, service, buffer, bufferMax);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_HOST_INTERFACE_HEADER

View File

@ -0,0 +1,44 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_HOST_EXTENSION_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_HOST_EXTENSION_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {0DBA9261-79B5-4803-BB29-6246DE6C92C9}
static const GUID IFC_OmServiceHostExt =
{ 0xdba9261, 0x79b5, 0x4803, { 0xbb, 0x29, 0x62, 0x46, 0xde, 0x6c, 0x92, 0xc9 } };
// supports AddRef(), Release(), QueryInterface()
class __declspec(novtable) ifc_omservicehostext : public Dispatchable
{
protected:
ifc_omservicehostext() {}
~ifc_omservicehostext() {}
public:
HRESULT GetHost(ifc_omservicehost **ppHost);
HRESULT SetHost(ifc_omservicehost *host);
public:
DISPATCH_CODES
{
API_GETHOST = 10,
API_SETHOST = 20,
};
};
inline HRESULT ifc_omservicehostext::GetHost(ifc_omservicehost **ppHost)
{
return _call(API_GETHOST, (HRESULT)E_NOTIMPL, ppHost);
}
inline HRESULT ifc_omservicehostext::SetHost(ifc_omservicehost *host)
{
return _call(API_SETHOST, (HRESULT)E_NOTIMPL, host);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_HOST_EXTENSION_INTERFACE_HEADER

View File

@ -0,0 +1,73 @@
#ifndef NULLSOFT_WINAMP_OMSERVICE_MANAGER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSERVICE_MANAGER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {BB0A9154-6D31-413b-96FB-9466E535E0C4}
static const GUID IFC_OmServiceManager =
{ 0xbb0a9154, 0x6d31, 0x413b, { 0x96, 0xfb, 0x94, 0x66, 0xe5, 0x35, 0xe0, 0xc4 } };
class ifc_omservice;
class ifc_omstorage;
class ifc_omstorageenumerator;
class ifc_omservicehost;
class ifc_omserviceeventmngr;
class __declspec(novtable) ifc_omservicemanager : public Dispatchable
{
protected:
ifc_omservicemanager() {}
~ifc_omservicemanager() {}
public:
HRESULT RegisterStorage(ifc_omstorage *storage);
HRESULT UnregisterStorage(const GUID *storageId);
HRESULT QueryStorage(const GUID *storageId, ifc_omstorage **storageOut);
HRESULT EnumStorage(const GUID *filterType, UINT filterCapabilities, ifc_omstorageenumerator **enumOut);
HRESULT CreateService(unsigned int serviceId, ifc_omservicehost *host, ifc_omservice **serviceOut);
public:
DISPATCH_CODES
{
API_REGISTERSTORAGE = 10,
API_UNREGISTERSTORAGE = 20,
API_QUERYSTORAGE = 30,
API_ENUMSTORAGE = 40,
API_CREATESERVICE = 100,
};
};
inline HRESULT ifc_omservicemanager::RegisterStorage(ifc_omstorage *storage)
{
return _call(API_REGISTERSTORAGE, (HRESULT)E_NOTIMPL, storage);
}
inline HRESULT ifc_omservicemanager::UnregisterStorage(const GUID *storageId)
{
return _call(API_UNREGISTERSTORAGE, (HRESULT)E_NOTIMPL, storageId);
}
inline HRESULT ifc_omservicemanager::QueryStorage(const GUID *storageId, ifc_omstorage **storageOut)
{
return _call(API_QUERYSTORAGE, (HRESULT)E_NOTIMPL, storageId, storageOut);
}
inline HRESULT ifc_omservicemanager::EnumStorage(const GUID *filterType, UINT filterCapabilities, ifc_omstorageenumerator **enumOut)
{
return _call(API_ENUMSTORAGE, (HRESULT)E_NOTIMPL, filterType, filterCapabilities, enumOut);
}
inline HRESULT ifc_omservicemanager::CreateService(UINT serviceId, ifc_omservicehost *host, ifc_omservice **serviceOut)
{
return _call(API_CREATESERVICE, (HRESULT)E_NOTIMPL, serviceId, host, serviceOut);
}
#endif //NULLSOFT_WINAMP_OMSERVICE_MANAGER_INTERFACE_HEADER

View File

@ -0,0 +1,46 @@
#ifndef NULLSOFT_WINAMP_OMBROWSER_STATUSBAR_CONFIG_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMBROWSER_STATUSBAR_CONFIG_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#define CFGID_STATUSBAR_ENABLED 0 // param = (ULONG_PTR)(BOOL)fEnabled
// {98ABEE7F-06F4-4652-886D-58E1769E2592}
static const GUID IFC_OmStatusbarConfig =
{ 0x98abee7f, 0x6f4, 0x4652, { 0x88, 0x6d, 0x58, 0xe1, 0x76, 0x9e, 0x25, 0x92 } };
#include <bfc/dispatch.h>
class __declspec(novtable) ifc_omstatusbarconfig : public Dispatchable
{
protected:
ifc_omstatusbarconfig() {}
~ifc_omstatusbarconfig() {}
public:
HRESULT GetEnabled(void);
HRESULT EnableStatusbar(BOOL fEnable);
public:
DISPATCH_CODES
{
API_GETENABLED = 10,
API_ENABLESTATUSBAR = 20,
};
};
inline HRESULT ifc_omstatusbarconfig::GetEnabled(void)
{
return _call(API_GETENABLED, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omstatusbarconfig::EnableStatusbar(BOOL fEnable)
{
return _call(API_ENABLESTATUSBAR, (HRESULT)E_NOTIMPL, fEnable);
}
#endif // NULLSOFT_WINAMP_OMBROWSER_STATUSBAR_CONFIG_INTERFACE_HEADER

View File

@ -0,0 +1,131 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {DEE1FCCD-8FFC-4ed2-8104-323382670BE0}
static const GUID IFC_OmStorage =
{ 0xdee1fccd, 0x8ffc, 0x4ed2, { 0x81, 0x4, 0x32, 0x33, 0x82, 0x67, 0xb, 0xe0 } };
#include <ifc_omstorageasync.h>
#include <bfc/dispatch.h>
class ifc_omservice;
class ifc_omservicehost;
class ifc_omserviceenum;
#define OMSTORAGE_E_UNKNOWN_FORMAT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, ERROR_INVALID_DATA)
class __declspec(novtable) ifc_omstorage : public Dispatchable
{
public:
typedef enum
{
capLoad = 0x00000001,
capSave = 0x00000002,
capDelete = 0x00000004,
capReload = 0x00000008,
capPublic = 0x00001000,
} Capabilities;
typedef enum
{
saveModifiedOnly = 0x00000001,
saveClearModified = 0x00000002,
} SaveFlags;
protected:
ifc_omstorage() {}
~ifc_omstorage() {}
public:
HRESULT GetId(GUID *storageUid);
HRESULT GetType(GUID *storageType);
UINT GetCapabilities();
HRESULT GetDescription(wchar_t *buffer, unsigned int bufferMax);
HRESULT Load(const wchar_t *address, ifc_omservicehost *host, ifc_omserviceenum **ppEnum);
HRESULT Save(ifc_omservice **serviceList, unsigned long listCount, unsigned int saveFlags, unsigned long *savedCount);
HRESULT Delete(ifc_omservice **serviceList, unsigned long listCount, unsigned long *deletedCount);
HRESULT Reload(ifc_omservice **serviceList, unsigned long listCount, unsigned long *reloadedCount);
/* async calls */
HRESULT BeginLoad(const wchar_t *address, ifc_omservicehost *host, ifc_omstorageasync::AsyncCallback callback, void *data, ifc_omstorageasync **async);
HRESULT EndLoad(ifc_omstorageasync *async, ifc_omserviceenum **ppEnum);
HRESULT RequestAbort(ifc_omstorageasync *async, BOOL drop);
public:
DISPATCH_CODES
{
API_GETID = 10,
API_GETTYPE = 20,
API_GETCAPABILITIES = 30,
API_GETDESCRIPTION = 40,
API_LOAD = 60,
API_SAVE = 70,
API_DELETE = 80,
API_RELOAD = 90,
API_BEGINLOAD = 100,
API_ENDLOAD = 110,
API_REQUESTABORT = 120,
};
};
inline HRESULT ifc_omstorage::GetId(GUID *storageUid)
{
return _call(API_GETID, (HRESULT)E_NOTIMPL, storageUid);
}
inline HRESULT ifc_omstorage::GetType(GUID *storageType)
{
return _call(API_GETTYPE, (HRESULT)E_NOTIMPL, storageType);
}
inline UINT ifc_omstorage::GetCapabilities()
{
return (UINT)_call(API_GETCAPABILITIES, (UINT)0);
}
inline HRESULT ifc_omstorage::GetDescription(wchar_t *buffer, unsigned int bufferMax)
{
return _call(API_GETDESCRIPTION, (HRESULT)E_NOTIMPL, buffer, bufferMax);
}
inline HRESULT ifc_omstorage::Load(const wchar_t *address, ifc_omservicehost *host, ifc_omserviceenum **ppEnum)
{
return _call(API_LOAD, (HRESULT)E_NOTIMPL, address, host, ppEnum);
}
inline HRESULT ifc_omstorage::Save(ifc_omservice **serviceList, unsigned long listCount, unsigned int saveFlags, unsigned long *savedCount)
{
return _call(API_SAVE, (HRESULT)E_NOTIMPL, serviceList, listCount, saveFlags, savedCount);
}
inline HRESULT ifc_omstorage::Delete(ifc_omservice **serviceList, unsigned long listCount, unsigned long *deletedCount)
{
return _call(API_DELETE, (HRESULT)E_NOTIMPL, serviceList, listCount, deletedCount);
}
inline HRESULT ifc_omstorage::Reload(ifc_omservice **serviceList, unsigned long listCount, unsigned long *reloadedCount)
{
return _call(API_RELOAD, (HRESULT)E_NOTIMPL, serviceList, listCount, reloadedCount);
}
inline HRESULT ifc_omstorage::BeginLoad(const wchar_t *address, ifc_omservicehost *host, ifc_omstorageasync::AsyncCallback callback, void *data, ifc_omstorageasync **async)
{
return _call(API_BEGINLOAD, (HRESULT)E_NOTIMPL, address, host, callback, data, async);
}
inline HRESULT ifc_omstorage::EndLoad(ifc_omstorageasync *async, ifc_omserviceenum **ppEnum)
{
return _call(API_ENDLOAD, (HRESULT)E_NOTIMPL, async, ppEnum);
}
inline HRESULT ifc_omstorage::RequestAbort(ifc_omstorageasync *async, BOOL drop)
{
return _call(API_REQUESTABORT, (HRESULT)E_NOTIMPL, async, drop);
}
#endif //NULLSOFT_WINAMP_OMSTORAGE_INTERFACE_HEADER

View File

@ -0,0 +1,62 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_ASYNC_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_ASYNC_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include <bfc/dispatch.h>
// {5D6C5C55-E744-4936-A31D-B9D8C0F4EF86}
static const GUID IFC_OmStorageAsync =
{ 0x5d6c5c55, 0xe744, 0x4936, { 0xa3, 0x1d, 0xb9, 0xd8, 0xc0, 0xf4, 0xef, 0x86 } };
class __declspec(novtable) ifc_omstorageasync : public Dispatchable
{
public:
typedef void (CALLBACK *AsyncCallback)(ifc_omstorageasync *result);
typedef enum
{
stateReady = 0,
stateInitializing = 1,
stateConnecting = 2,
stateReceiving = 3,
stateCompleted = 4,
stateAborting = 5,
} States;
protected:
ifc_omstorageasync() {}
~ifc_omstorageasync() {}
public:
HRESULT GetState(unsigned int *state);
HRESULT GetWaitHandle(HANDLE *handle);
HRESULT GetData(void **data);
public:
DISPATCH_CODES
{
API_GETSTATE = 10,
API_GETWAITHANDLE = 20,
API_GETDATA = 30,
};
};
inline HRESULT ifc_omstorageasync::GetWaitHandle(HANDLE *handle)
{
return _call(API_GETWAITHANDLE, (HRESULT)E_NOTIMPL, handle);
}
inline HRESULT ifc_omstorageasync::GetData(void **data)
{
return _call(API_GETDATA, (HRESULT)E_NOTIMPL, data);
}
inline HRESULT ifc_omstorageasync::GetState(unsigned int *state)
{
return _call(API_GETSTATE, (HRESULT)E_NOTIMPL, state);
}
#endif //NULLSOFT_WINAMP_OMSTORAGE_ASYNC_INTERFACE_HEADER

View File

@ -0,0 +1,50 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_ENUMERATOR_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_ENUMERATOR_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {31BF2BEF-4362-4277-A4E1-0589336BC55C}
static const GUID IFC_OmStorageEnumerator =
{ 0x31bf2bef, 0x4362, 0x4277, { 0xa4, 0xe1, 0x5, 0x89, 0x33, 0x6b, 0xc5, 0x5c } };
#include <bfc/dispatch.h>
class ifc_omstorage;
class __declspec(novtable) ifc_omstorageenumerator : public Dispatchable
{
protected:
ifc_omstorageenumerator() {}
~ifc_omstorageenumerator() {}
public:
HRESULT Next(unsigned long listSize, ifc_omstorage **elementList, unsigned long *elementCount);
HRESULT Reset(void);
HRESULT Skip(unsigned long elementCount);
public:
DISPATCH_CODES
{
API_NEXT = 10,
API_RESET = 20,
API_SKIP = 30,
};
};
inline HRESULT ifc_omstorageenumerator::Next(unsigned long listSize, ifc_omstorage **elementList, unsigned long *elementCount)
{
return _call(API_NEXT, (HRESULT)E_NOTIMPL, listSize, elementList, elementCount);
}
inline HRESULT ifc_omstorageenumerator::Reset(void)
{
return _call(API_RESET, (HRESULT)E_NOTIMPL);
}
inline HRESULT ifc_omstorageenumerator::Skip(unsigned long elementCount)
{
return _call(API_SKIP, (HRESULT)E_NOTIMPL, elementCount);
}
#endif //NULLSOFT_WINAMP_OMSTORAGE_ENUMERATOR_INTERFACE_HEADER

View File

@ -0,0 +1,37 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_EXTENDER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_EXTENDER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {8D1915C0-7925-49f1-A851-C230C634B7EE}
static const GUID IFC_OmStorageExt =
{ 0x8d1915c0, 0x7925, 0x49f1, { 0xa8, 0x51, 0xc2, 0x30, 0xc6, 0x34, 0xb7, 0xee } };
#include <bfc/dispatch.h>
class ifc_omstoragehandlerenum;
class ifc_omstorage;
class __declspec(novtable) ifc_omstorageext : public Dispatchable
{
protected:
ifc_omstorageext() {}
~ifc_omstorageext() {}
public:
HRESULT Enumerate(const GUID *storageId, ifc_omstoragehandlerenum **enumerator);
public:
DISPATCH_CODES
{
API_ENUMERATE = 10,
};
};
inline HRESULT ifc_omstorageext::Enumerate(const GUID *storageId, ifc_omstoragehandlerenum **enumerator)
{
return _call(API_ENUMERATE, (HRESULT)E_NOTIMPL, storageId, enumerator);
}
#endif //NULLSOFT_WINAMP_OMSTORAGE_EXTENDER_INTERFACE_HEADER

View File

@ -0,0 +1,45 @@
#ifndef NULLSOFT_WINAMP_OMSTORAGE_HANDLER_INTERFACE_HEADER
#define NULLSOFT_WINAMP_OMSTORAGE_HANDLER_INTERFACE_HEADER
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// {9B37B560-CF31-41c6-BB35-14F16E290AFB}
static const GUID IFC_OmStorageHandler =
{ 0x9b37b560, 0xcf31, 0x41c6, { 0xbb, 0x35, 0x14, 0xf1, 0x6e, 0x29, 0xa, 0xfb } };
#include <bfc/dispatch.h>
class ifc_omstorage;
class ifc_omservice;
class __declspec(novtable) ifc_omstoragehandler : public Dispatchable
{
protected:
ifc_omstoragehandler() {}
~ifc_omstoragehandler() {}
public:
HRESULT GetKey(const wchar_t **ppKey);
void Invoke(ifc_omservice *service, const wchar_t *key, const wchar_t * value);
public:
DISPATCH_CODES
{
API_GETKEY = 10,
API_INVOKE = 20,
};
};
inline HRESULT ifc_omstoragehandler::GetKey(const wchar_t **ppKey)
{
return _call(API_GETKEY, (HRESULT)E_NOTIMPL, ppKey);
}
inline void ifc_omstoragehandler::Invoke(ifc_omservice *service, const wchar_t *key, const wchar_t *value)
{
_voidcall(API_INVOKE, service, key, value);
}
#endif //NULLSOFT_WINAMP_OMSTORAGE_HANDLER_INTERFACE_HEADER

Some files were not shown because too many files have changed in this diff Show More