|
1 /* |
|
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions |
|
6 * are met: |
|
7 * 1. Redistributions of source code must retain the above copyright |
|
8 * notice, this list of conditions and the following disclaimer. |
|
9 * 2. Redistributions in binary form must reproduce the above copyright |
|
10 * notice, this list of conditions and the following disclaimer in the |
|
11 * documentation and/or other materials provided with the distribution. |
|
12 * |
|
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
|
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #include "config.h" |
|
27 #include "WebKitDLL.h" |
|
28 |
|
29 #include "WebNotification.h" |
|
30 |
|
31 #include <wtf/Assertions.h> |
|
32 |
|
33 // WebNotification ------------------------------------------------------------ |
|
34 |
|
35 WebNotification::WebNotification(BSTR name, IUnknown* anObject, IPropertyBag* userInfo) |
|
36 : m_refCount(0) |
|
37 , m_name(0) |
|
38 , m_anObject(anObject) |
|
39 , m_userInfo(userInfo) |
|
40 { |
|
41 if (name) |
|
42 m_name = SysAllocString(name); |
|
43 if (m_anObject) |
|
44 m_anObject->AddRef(); |
|
45 if (m_userInfo) |
|
46 m_userInfo->AddRef(); |
|
47 |
|
48 gClassCount++; |
|
49 } |
|
50 |
|
51 WebNotification::~WebNotification() |
|
52 { |
|
53 if (m_name) |
|
54 SysFreeString(m_name); |
|
55 if (m_anObject) |
|
56 m_anObject->Release(); |
|
57 if (m_userInfo) |
|
58 m_userInfo->Release(); |
|
59 |
|
60 gClassCount--; |
|
61 } |
|
62 |
|
63 WebNotification* WebNotification::createInstance(BSTR name /*=0*/, IUnknown* anObject /*=0*/, IPropertyBag* userInfo /*=0*/) |
|
64 { |
|
65 WebNotification* instance = new WebNotification(name, anObject, userInfo); |
|
66 instance->AddRef(); |
|
67 return instance; |
|
68 } |
|
69 |
|
70 // IUnknown ------------------------------------------------------------------- |
|
71 |
|
72 HRESULT STDMETHODCALLTYPE WebNotification::QueryInterface(REFIID riid, void** ppvObject) |
|
73 { |
|
74 *ppvObject = 0; |
|
75 if (IsEqualGUID(riid, IID_IUnknown)) |
|
76 *ppvObject = static_cast<IWebNotification*>(this); |
|
77 else if (IsEqualGUID(riid, IID_IWebNotification)) |
|
78 *ppvObject = static_cast<IWebNotification*>(this); |
|
79 else |
|
80 return E_NOINTERFACE; |
|
81 |
|
82 AddRef(); |
|
83 return S_OK; |
|
84 } |
|
85 |
|
86 ULONG STDMETHODCALLTYPE WebNotification::AddRef(void) |
|
87 { |
|
88 return ++m_refCount; |
|
89 } |
|
90 |
|
91 ULONG STDMETHODCALLTYPE WebNotification::Release(void) |
|
92 { |
|
93 ULONG newRef = --m_refCount; |
|
94 if (!newRef) |
|
95 delete(this); |
|
96 |
|
97 return newRef; |
|
98 } |
|
99 |
|
100 // IWebNotification ----------------------------------------------------------- |
|
101 |
|
102 HRESULT STDMETHODCALLTYPE WebNotification::notificationWithName( |
|
103 /* [in] */ BSTR /*aName*/, |
|
104 /* [in] */ IUnknown* /*anObject*/, |
|
105 /* [optional][in] */ IPropertyBag* /*userInfo*/) |
|
106 { |
|
107 ASSERT_NOT_REACHED(); |
|
108 return E_NOTIMPL; |
|
109 } |
|
110 |
|
111 HRESULT STDMETHODCALLTYPE WebNotification::name( |
|
112 /* [retval][out] */ BSTR* result) |
|
113 { |
|
114 *result = 0; |
|
115 if (m_name) { |
|
116 *result = SysAllocString(m_name); |
|
117 if (!*result) |
|
118 return E_OUTOFMEMORY; |
|
119 } |
|
120 |
|
121 return S_OK; |
|
122 } |
|
123 |
|
124 HRESULT STDMETHODCALLTYPE WebNotification::getObject( |
|
125 /* [retval][out] */ IUnknown** result) |
|
126 { |
|
127 *result = m_anObject; |
|
128 |
|
129 if (*result) |
|
130 (*result)->AddRef(); |
|
131 |
|
132 return S_OK; |
|
133 } |
|
134 |
|
135 HRESULT STDMETHODCALLTYPE WebNotification::userInfo( |
|
136 /* [retval][out] */ IPropertyBag** result) |
|
137 { |
|
138 *result = m_userInfo; |
|
139 |
|
140 if (*result) |
|
141 (*result)->AddRef(); |
|
142 |
|
143 return S_OK; |
|
144 } |