]> git.saurik.com Git - apple/mdnsresponder.git/blame - Clients/ExplorerPlugin/ClassFactory.cpp
mDNSResponder-108.6.tar.gz
[apple/mdnsresponder.git] / Clients / ExplorerPlugin / ClassFactory.cpp
CommitLineData
c9d2d929 1/*
8e92c31c
A
2 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
3 *
c9d2d929 4 * @APPLE_LICENSE_HEADER_START@
8e92c31c 5 *
c9d2d929
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
8e92c31c 12 *
c9d2d929
A
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
8e92c31c 19 * limitations under the License.
c9d2d929
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
8e92c31c
A
22
23 Change History (most recent first):
24
25$Log: ClassFactory.cpp,v $
7f0064bd
A
26Revision 1.2 2004/07/13 21:24:21 rpantos
27Fix for <rdar://problem/3701120>.
28
29Revision 1.1 2004/06/18 04:34:59 rpantos
30Move to Clients from mDNSWindows
31
8e92c31c 32Revision 1.1 2004/01/30 03:01:56 bradley
7f0064bd 33Explorer Plugin to browse for DNS-SD advertised Web and FTP servers from within Internet Explorer.
8e92c31c
A
34
35*/
36
37#include "StdAfx.h"
38
39#include "DebugServices.h"
40
41#include "ExplorerBar.h"
42#include "ExplorerPlugin.h"
43
44#include "ClassFactory.h"
45
46// MFC Debugging
47
48#ifdef _DEBUG
49#define new DEBUG_NEW
50#undef THIS_FILE
51static char THIS_FILE[] = __FILE__;
52#endif
53
54//===========================================================================================================================
55// ClassFactory
56//===========================================================================================================================
57
58ClassFactory::ClassFactory( CLSID inCLSID )
59{
60 mCLSIDObject = inCLSID;
61 mRefCount = 1;
62 ++gDLLRefCount;
63}
64
65//===========================================================================================================================
66// ~ClassFactory
67//===========================================================================================================================
68
69ClassFactory::~ClassFactory( void )
70{
71 check( gDLLRefCount > 0 );
72
73 --gDLLRefCount;
74}
75
76#if 0
77#pragma mark -
78#pragma mark == IUnknown methods ==
79#endif
80
81//===========================================================================================================================
82// QueryInterface
83//===========================================================================================================================
84
85STDMETHODIMP ClassFactory::QueryInterface( REFIID inID, LPVOID *outResult )
86{
87 HRESULT err;
88
89 check( outResult );
90
91 if( IsEqualIID( inID, IID_IUnknown ) )
92 {
93 *outResult = this;
94 }
95 else if( IsEqualIID( inID, IID_IClassFactory ) )
96 {
97 *outResult = (IClassFactory *) this;
98 }
99 else
100 {
101 *outResult = NULL;
102 err = E_NOINTERFACE;
103 goto exit;
104 }
105
106 ( *( (LPUNKNOWN *) outResult ) )->AddRef();
107 err = S_OK;
108
109exit:
110 return( err );
111}
112
113//===========================================================================================================================
114// AddRef
115//===========================================================================================================================
116
117STDMETHODIMP_( DWORD ) ClassFactory::AddRef( void )
118{
119 return( ++mRefCount );
120}
121
122//===========================================================================================================================
123// Release
124//===========================================================================================================================
125
126STDMETHODIMP_( DWORD ) ClassFactory::Release( void )
127{
128 DWORD count;
129
130 count = --mRefCount;
131 if( count == 0 )
132 {
133 delete this;
134 }
135 return( count );
136}
137
138#if 0
139#pragma mark -
140#pragma mark == IClassFactory methods ==
141#endif
142
143//===========================================================================================================================
144// CreateInstance
145//===========================================================================================================================
146
147STDMETHODIMP ClassFactory::CreateInstance( LPUNKNOWN inUnknown, REFIID inID, LPVOID *outObject )
148{
149 HRESULT err;
150 LPVOID obj;
151
152 check( outObject );
153
154 obj = NULL;
155 *outObject = NULL;
156 require_action( !inUnknown, exit, err = CLASS_E_NOAGGREGATION );
157
158 // Create the object based on the CLSID.
159
160 if( IsEqualCLSID( mCLSIDObject, CLSID_ExplorerBar ) )
161 {
162 try
163 {
164 obj = new ExplorerBar();
165 }
166 catch( ... )
167 {
168 // Don't let exception escape.
169 }
170 require_action( obj, exit, err = E_OUTOFMEMORY );
171 }
172 else
173 {
174 err = E_FAIL;
175 goto exit;
176 }
177
178 // Query for the specified interface. Release the factory since QueryInterface retains it.
179
180 err = ( (LPUNKNOWN ) obj )->QueryInterface( inID, outObject );
181 ( (LPUNKNOWN ) obj )->Release();
182
183exit:
184 return( err );
185}
186
187//===========================================================================================================================
188// LockServer
189//===========================================================================================================================
190
191STDMETHODIMP ClassFactory::LockServer( BOOL inLock )
192{
193 DEBUG_UNUSED( inLock );
194
195 return( E_NOTIMPL );
196}