]>
Commit | Line | Data |
---|---|---|
67c8f8a1 A |
1 | /* -*- Mode: C; tab-width: 4 -*- |
2 | * | |
8e92c31c A |
3 | * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved. |
4 | * | |
67c8f8a1 A |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8e92c31c | 8 | * |
67c8f8a1 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
8e92c31c | 10 | * |
67c8f8a1 A |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
8e92c31c | 15 | * limitations under the License. |
8e92c31c A |
16 | |
17 | Change History (most recent first): | |
18 | ||
19 | $Log: ClassFactory.cpp,v $ | |
67c8f8a1 A |
20 | Revision 1.3 2006/08/14 23:24:00 cheshire |
21 | Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0 | |
22 | ||
7f0064bd A |
23 | Revision 1.2 2004/07/13 21:24:21 rpantos |
24 | Fix for <rdar://problem/3701120>. | |
25 | ||
26 | Revision 1.1 2004/06/18 04:34:59 rpantos | |
27 | Move to Clients from mDNSWindows | |
28 | ||
8e92c31c | 29 | Revision 1.1 2004/01/30 03:01:56 bradley |
7f0064bd | 30 | Explorer Plugin to browse for DNS-SD advertised Web and FTP servers from within Internet Explorer. |
8e92c31c A |
31 | |
32 | */ | |
33 | ||
34 | #include "StdAfx.h" | |
35 | ||
36 | #include "DebugServices.h" | |
37 | ||
38 | #include "ExplorerBar.h" | |
39 | #include "ExplorerPlugin.h" | |
40 | ||
41 | #include "ClassFactory.h" | |
42 | ||
43 | // MFC Debugging | |
44 | ||
45 | #ifdef _DEBUG | |
46 | #define new DEBUG_NEW | |
47 | #undef THIS_FILE | |
48 | static char THIS_FILE[] = __FILE__; | |
49 | #endif | |
50 | ||
51 | //=========================================================================================================================== | |
52 | // ClassFactory | |
53 | //=========================================================================================================================== | |
54 | ||
55 | ClassFactory::ClassFactory( CLSID inCLSID ) | |
56 | { | |
57 | mCLSIDObject = inCLSID; | |
58 | mRefCount = 1; | |
59 | ++gDLLRefCount; | |
60 | } | |
61 | ||
62 | //=========================================================================================================================== | |
63 | // ~ClassFactory | |
64 | //=========================================================================================================================== | |
65 | ||
66 | ClassFactory::~ClassFactory( void ) | |
67 | { | |
68 | check( gDLLRefCount > 0 ); | |
69 | ||
70 | --gDLLRefCount; | |
71 | } | |
72 | ||
73 | #if 0 | |
74 | #pragma mark - | |
75 | #pragma mark == IUnknown methods == | |
76 | #endif | |
77 | ||
78 | //=========================================================================================================================== | |
79 | // QueryInterface | |
80 | //=========================================================================================================================== | |
81 | ||
82 | STDMETHODIMP ClassFactory::QueryInterface( REFIID inID, LPVOID *outResult ) | |
83 | { | |
84 | HRESULT err; | |
85 | ||
86 | check( outResult ); | |
87 | ||
88 | if( IsEqualIID( inID, IID_IUnknown ) ) | |
89 | { | |
90 | *outResult = this; | |
91 | } | |
92 | else if( IsEqualIID( inID, IID_IClassFactory ) ) | |
93 | { | |
94 | *outResult = (IClassFactory *) this; | |
95 | } | |
96 | else | |
97 | { | |
98 | *outResult = NULL; | |
99 | err = E_NOINTERFACE; | |
100 | goto exit; | |
101 | } | |
102 | ||
103 | ( *( (LPUNKNOWN *) outResult ) )->AddRef(); | |
104 | err = S_OK; | |
105 | ||
106 | exit: | |
107 | return( err ); | |
108 | } | |
109 | ||
110 | //=========================================================================================================================== | |
111 | // AddRef | |
112 | //=========================================================================================================================== | |
113 | ||
114 | STDMETHODIMP_( DWORD ) ClassFactory::AddRef( void ) | |
115 | { | |
116 | return( ++mRefCount ); | |
117 | } | |
118 | ||
119 | //=========================================================================================================================== | |
120 | // Release | |
121 | //=========================================================================================================================== | |
122 | ||
123 | STDMETHODIMP_( DWORD ) ClassFactory::Release( void ) | |
124 | { | |
125 | DWORD count; | |
126 | ||
127 | count = --mRefCount; | |
128 | if( count == 0 ) | |
129 | { | |
130 | delete this; | |
131 | } | |
132 | return( count ); | |
133 | } | |
134 | ||
135 | #if 0 | |
136 | #pragma mark - | |
137 | #pragma mark == IClassFactory methods == | |
138 | #endif | |
139 | ||
140 | //=========================================================================================================================== | |
141 | // CreateInstance | |
142 | //=========================================================================================================================== | |
143 | ||
144 | STDMETHODIMP ClassFactory::CreateInstance( LPUNKNOWN inUnknown, REFIID inID, LPVOID *outObject ) | |
145 | { | |
146 | HRESULT err; | |
147 | LPVOID obj; | |
148 | ||
149 | check( outObject ); | |
150 | ||
151 | obj = NULL; | |
152 | *outObject = NULL; | |
153 | require_action( !inUnknown, exit, err = CLASS_E_NOAGGREGATION ); | |
154 | ||
155 | // Create the object based on the CLSID. | |
156 | ||
157 | if( IsEqualCLSID( mCLSIDObject, CLSID_ExplorerBar ) ) | |
158 | { | |
159 | try | |
160 | { | |
161 | obj = new ExplorerBar(); | |
162 | } | |
163 | catch( ... ) | |
164 | { | |
165 | // Don't let exception escape. | |
166 | } | |
167 | require_action( obj, exit, err = E_OUTOFMEMORY ); | |
168 | } | |
169 | else | |
170 | { | |
171 | err = E_FAIL; | |
172 | goto exit; | |
173 | } | |
174 | ||
175 | // Query for the specified interface. Release the factory since QueryInterface retains it. | |
176 | ||
177 | err = ( (LPUNKNOWN ) obj )->QueryInterface( inID, outObject ); | |
178 | ( (LPUNKNOWN ) obj )->Release(); | |
179 | ||
180 | exit: | |
181 | return( err ); | |
182 | } | |
183 | ||
184 | //=========================================================================================================================== | |
185 | // LockServer | |
186 | //=========================================================================================================================== | |
187 | ||
188 | STDMETHODIMP ClassFactory::LockServer( BOOL inLock ) | |
189 | { | |
190 | DEBUG_UNUSED( inLock ); | |
191 | ||
192 | return( E_NOTIMPL ); | |
193 | } |