commitmonitor Code
Monitor your SVN repositories and notifies you on new commits
Brought to you by:
steveking
added | /trunk/src/Callback.cpp |
added | /trunk/src/Callback.h |
changed | /trunk/src/CommitMonitor.cpp |
changed | /trunk/src/CommitMonitor.vcproj |
changed | /trunk/src/HiddenWindow.cpp |
changed | /trunk/src/HiddenWindow.h |
--- a +++ b/trunk/src/Callback.cpp @@ -0,0 +1,35 @@ +#include "StdAfx.h" +#include "Callback.h" + +#include <urlmon.h> +#include <shlwapi.h> // for StrFormatByteSize() + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CCallback::CCallback() +{ + m_cRef = 0; +} + +CCallback::~CCallback() +{ +} + +STDMETHODIMP CCallback::Authenticate( HWND * phwnd, LPWSTR * pszUsername, LPWSTR * pszPassword) +{ + *phwnd = NULL; + *pszUsername = (LPWSTR)CoTaskMemAlloc((m_username.size()+1)*2); + _tcscpy_s(*pszUsername, m_username.size()+1, m_username.c_str()); + *pszPassword = (LPWSTR)CoTaskMemAlloc((m_password.size()+1)*2); + _tcscpy_s(*pszPassword, m_password.size()+1, m_password.c_str()); + return S_OK; +} +
--- a +++ b/trunk/src/Callback.h @@ -0,0 +1,116 @@ +#pragma once + +#include <string> + +using namespace std; + +class CCallback : public IBindStatusCallback, public IAuthenticate, public IHttpSecurity +{ +public: + CCallback(); + ~CCallback(); + + void SetAuthData(const wstring& username, const wstring& password) {m_username = username; m_password = password;} + + // IHttpSecurity method + STDMETHOD(OnSecurityProblem)(DWORD /*dwProblem*/) + { return S_OK; } + + STDMETHOD(GetWindow)( + /* [in] */ REFGUID /*rguidReason*/, + /* [out] */ HWND * /*phwnd*/) + { return E_NOTIMPL; } + + // IAuthenticate method + STDMETHOD(Authenticate)( + /* [out] */ HWND * phwnd, + /* [out] */ LPWSTR * pszUsername, + /* [out] */ LPWSTR * pszPassword); + + // IBindStatusCallback methods. Note that the only method called by IE + // is OnProgress(), so the others just return E_NOTIMPL. + + STDMETHOD(OnStartBinding)( + /* [in] */ DWORD /*dwReserved*/, + /* [in] */ IBinding __RPC_FAR * /*pib*/) + { return E_NOTIMPL; } + + STDMETHOD(GetPriority)( + /* [out] */ LONG __RPC_FAR * /*pnPriority*/) + { return E_NOTIMPL; } + + STDMETHOD(OnLowResource)( + /* [in] */ DWORD /*reserved*/) + { return E_NOTIMPL; } + + STDMETHOD(OnProgress)( + /* [in] */ ULONG /*ulProgress*/, + /* [in] */ ULONG /*ulProgressMax*/, + /* [in] */ ULONG /*ulStatusCode*/, + /* [in] */ LPCWSTR /*wszStatusText*/) + { return S_OK; } + + STDMETHOD(OnStopBinding)( + /* [in] */ HRESULT /*hresult*/, + /* [unique][in] */ LPCWSTR /*szError*/) + { return E_NOTIMPL; } + + STDMETHOD(GetBindInfo)( + /* [out] */ DWORD __RPC_FAR * /*grfBINDF*/, + /* [unique][out][in] */ BINDINFO __RPC_FAR * /*pbindinfo*/) + { return E_NOTIMPL; } + + STDMETHOD(OnDataAvailable)( + /* [in] */ DWORD /*grfBSCF*/, + /* [in] */ DWORD /*dwSize*/, + /* [in] */ FORMATETC __RPC_FAR * /*pformatetc*/, + /* [in] */ STGMEDIUM __RPC_FAR * /*pstgmed*/) + { return E_NOTIMPL; } + + STDMETHOD(OnObjectAvailable)( + /* [in] */ REFIID /*riid*/, + /* [iid_is][in] */ IUnknown __RPC_FAR * /*punk*/) + { return E_NOTIMPL; } + + // IUnknown methods. Note that IE never calls any of these methods, since + // the caller owns the IBindStatusCallback interface, so the methods all + // return zero/E_NOTIMPL. + + STDMETHOD_(ULONG,AddRef)() + { return 0; } + + STDMETHOD_(ULONG,Release)() + { return 0; } + + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR * ppvObject) + { + if ( riid == IID_IAuthenticate ) { + *ppvObject = (void*) (IAuthenticate*)this; + return S_OK; + } + else if ( riid == IID_IUnknown ) { + *ppvObject = (void*) (IUnknown*)(IBindStatusCallback*)this; + return S_OK; + } + else if ( riid == IID_IBindStatusCallback ) { + *ppvObject = (void*) (IBindStatusCallback*)this; + return S_OK; + } + else if ( riid == IID_IHttpSecurity ) { + *ppvObject = (void*) (IHttpSecurity*)this; + return S_OK; + } + else if ( riid == IID_IWindowForBindingUI ) { + *ppvObject = (void*) (IWindowForBindingUI*)this; + return S_OK; + } + return E_NOINTERFACE; + } + +private: + ULONG m_cRef; + wstring m_username; + wstring m_password; +};