]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/Applications/ExplorerPlugin/ExplorerBar.cpp
2 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 Change History (most recent first):
27 $Log: ExplorerBar.cpp,v $
28 Revision 1.1 2004/01/30 03:01:56 bradley
29 Explorer Plugin to browse for Rendezvous-enabled Web and FTP servers from within Internet Explorer.
38 #include "DebugServices.h"
42 #include "ExplorerBar.h"
49 static char THIS_FILE
[] = __FILE__
;
52 //===========================================================================================================================
54 //===========================================================================================================================
59 //===========================================================================================================================
61 //===========================================================================================================================
63 ExplorerBar::ExplorerBar( void )
76 //===========================================================================================================================
78 //===========================================================================================================================
80 ExplorerBar::~ExplorerBar( void )
84 mWebBrowser
->Release();
98 #pragma mark == IUnknown implementation ==
101 //===========================================================================================================================
103 //===========================================================================================================================
105 STDMETHODIMP
ExplorerBar::QueryInterface( REFIID inID
, LPVOID
*outResult
)
109 if( IsEqualIID( inID
, IID_IUnknown
) ) // IUnknown
113 else if( IsEqualIID( inID
, IID_IOleWindow
) ) // IOleWindow
115 *outResult
= (IOleWindow
*) this;
117 else if( IsEqualIID( inID
, IID_IDockingWindow
) ) // IDockingWindow
119 *outResult
= (IDockingWindow
*) this;
121 else if( IsEqualIID( inID
, IID_IDeskBand
) ) // IDeskBand
123 *outResult
= (IDeskBand
*) this;
125 else if( IsEqualIID( inID
, IID_IInputObject
) ) // IInputObject
127 *outResult
= (IInputObject
*) this;
129 else if( IsEqualIID( inID
, IID_IObjectWithSite
) ) // IObjectWithSite
131 *outResult
= (IObjectWithSite
*) this;
133 else if( IsEqualIID( inID
, IID_IPersistStream
) ) // IPersistStream
135 *outResult
= (IPersistStream
*) this;
144 ( *( (LPUNKNOWN
*) outResult
) )->AddRef();
151 //===========================================================================================================================
153 //===========================================================================================================================
155 STDMETHODIMP_( DWORD
) ExplorerBar::AddRef( void )
157 return( ++mRefCount
);
160 //===========================================================================================================================
162 //===========================================================================================================================
164 STDMETHODIMP_( DWORD
) ExplorerBar::Release( void )
178 #pragma mark == IOleWindow implementation ==
181 //===========================================================================================================================
183 //===========================================================================================================================
185 STDMETHODIMP
ExplorerBar::GetWindow( HWND
*outWindow
)
187 *outWindow
= mWindow
.GetSafeHwnd();
191 //===========================================================================================================================
192 // ContextSensitiveHelp
193 //===========================================================================================================================
195 STDMETHODIMP
ExplorerBar::ContextSensitiveHelp( BOOL inEnterMode
)
197 DEBUG_UNUSED( inEnterMode
);
204 #pragma mark == IDockingWindow implementation ==
207 //===========================================================================================================================
209 //===========================================================================================================================
211 STDMETHODIMP
ExplorerBar::ShowDW( BOOL inShow
)
213 if( mWindow
.GetSafeHwnd() )
215 mWindow
.ShowWindow( inShow
? SW_SHOW
: SW_HIDE
);
220 //===========================================================================================================================
222 //===========================================================================================================================
224 STDMETHODIMP
ExplorerBar::CloseDW( DWORD inReserved
)
226 DEBUG_UNUSED( inReserved
);
229 if( mWindow
.GetSafeHwnd() )
231 mWindow
.SendMessage( WM_CLOSE
);
236 //===========================================================================================================================
238 //===========================================================================================================================
240 STDMETHODIMP
ExplorerBar::ResizeBorderDW( LPCRECT inBorder
, IUnknown
*inPunkSite
, BOOL inReserved
)
242 DEBUG_UNUSED( inBorder
);
243 DEBUG_UNUSED( inPunkSite
);
244 DEBUG_UNUSED( inReserved
);
251 #pragma mark == IDeskBand implementation ==
254 //===========================================================================================================================
256 //===========================================================================================================================
258 STDMETHODIMP
ExplorerBar::GetBandInfo( DWORD inBandID
, DWORD inViewMode
, DESKBANDINFO
*outInfo
)
262 require_action( outInfo
, exit
, err
= E_INVALIDARG
);
265 mViewMode
= inViewMode
;
267 if( outInfo
->dwMask
& DBIM_MINSIZE
)
269 outInfo
->ptMinSize
.x
= 100;
270 outInfo
->ptMinSize
.y
= 100;
272 if( outInfo
->dwMask
& DBIM_MAXSIZE
)
274 // Unlimited max size.
276 outInfo
->ptMaxSize
.x
= -1;
277 outInfo
->ptMaxSize
.y
= -1;
279 if( outInfo
->dwMask
& DBIM_INTEGRAL
)
281 outInfo
->ptIntegral
.x
= 1;
282 outInfo
->ptIntegral
.y
= 1;
284 if( outInfo
->dwMask
& DBIM_ACTUAL
)
286 outInfo
->ptActual
.x
= 0;
287 outInfo
->ptActual
.y
= 0;
289 if( outInfo
->dwMask
& DBIM_TITLE
)
294 ok
= s
.LoadString( IDS_NAME
);
295 require_action( ok
, exit
, err
= kNoResourcesErr
);
298 lstrcpyn( outInfo
->wszTitle
, s
, sizeof_array( outInfo
->wszTitle
) );
302 nChars
= MultiByteToWideChar( CP_ACP
, 0, s
, -1, outInfo
->wszTitle
, sizeof_array( outInfo
->wszTitle
) );
303 err
= translate_errno( nChars
> 0, (OSStatus
) GetLastError(), kUnknownErr
);
304 require_noerr( err
, exit
);
307 if( outInfo
->dwMask
& DBIM_MODEFLAGS
)
309 outInfo
->dwModeFlags
= DBIMF_NORMAL
| DBIMF_VARIABLEHEIGHT
;
312 // Force the default background color.
314 outInfo
->dwMask
&= ~DBIM_BKCOLOR
;
323 #pragma mark == IInputObject implementation ==
326 //===========================================================================================================================
328 //===========================================================================================================================
330 STDMETHODIMP
ExplorerBar::UIActivateIO( BOOL inActivate
, LPMSG inMsg
)
332 DEBUG_UNUSED( inMsg
);
341 //===========================================================================================================================
343 //===========================================================================================================================
345 STDMETHODIMP
ExplorerBar::HasFocusIO( void )
347 if( mWindow
.GetFocus()->GetSafeHwnd() == mWindow
.GetSafeHwnd() )
354 //===========================================================================================================================
355 // TranslateAcceleratorIO
356 //===========================================================================================================================
358 STDMETHODIMP
ExplorerBar::TranslateAcceleratorIO( LPMSG inMsg
)
360 DEBUG_UNUSED( inMsg
);
367 #pragma mark == IObjectWithSite implementation ==
370 //===========================================================================================================================
372 //===========================================================================================================================
374 STDMETHODIMP
ExplorerBar::SetSite( IUnknown
*inPunkSite
)
376 AFX_MANAGE_STATE( AfxGetStaticModuleState() );
380 // Release the old interfaces.
384 mWebBrowser
->Release();
393 // A non-NULL site means we're setting the site. Otherwise, the site is being released (done above).
401 // Get the parent window.
403 IOleWindow
* oleWindow
;
405 mParentWindow
= NULL
;
406 err
= inPunkSite
->QueryInterface( IID_IOleWindow
, (LPVOID
*) &oleWindow
);
407 require( SUCCEEDED( err
), exit
);
409 err
= oleWindow
->GetWindow( &mParentWindow
);
410 oleWindow
->Release();
411 require_noerr( err
, exit
);
412 require_action( mParentWindow
, exit
, err
= E_FAIL
);
414 // Get the IInputObject interface.
416 err
= inPunkSite
->QueryInterface( IID_IInputObjectSite
, (LPVOID
*) &mSite
);
417 require( SUCCEEDED( err
), exit
);
420 // Get the IWebBrowser2 interface.
422 IOleCommandTarget
* oleCommandTarget
;
424 err
= inPunkSite
->QueryInterface( IID_IOleCommandTarget
, (LPVOID
*) &oleCommandTarget
);
425 require( SUCCEEDED( err
), exit
);
427 IServiceProvider
* serviceProvider
;
429 err
= oleCommandTarget
->QueryInterface( IID_IServiceProvider
, (LPVOID
*) &serviceProvider
);
430 oleCommandTarget
->Release();
431 require( SUCCEEDED( err
), exit
);
433 err
= serviceProvider
->QueryService( SID_SWebBrowserApp
, IID_IWebBrowser2
, (LPVOID
*) &mWebBrowser
);
434 serviceProvider
->Release();
435 require( SUCCEEDED( err
), exit
);
437 // Create the main window.
440 require_noerr( err
, exit
);
446 //===========================================================================================================================
448 //===========================================================================================================================
450 STDMETHODIMP
ExplorerBar::GetSite( REFIID inID
, LPVOID
*outResult
)
455 require_action( mSite
, exit
, err
= E_FAIL
);
457 err
= mSite
->QueryInterface( inID
, outResult
);
465 #pragma mark == IPersistStream implementation ==
469 // IPersistStream implementation
471 // This is only supported to allow the desk band to be dropped on the desktop and to prevent multiple instances of
472 // the desk band from showing up in the context menu. This desk band doesn't actually persist any data.
475 //===========================================================================================================================
477 //===========================================================================================================================
479 STDMETHODIMP
ExplorerBar::GetClassID( LPCLSID outClassID
)
481 *outClassID
= CLSID_ExplorerBar
;
485 //===========================================================================================================================
487 //===========================================================================================================================
489 STDMETHODIMP
ExplorerBar::IsDirty( void )
494 //===========================================================================================================================
496 //===========================================================================================================================
498 STDMETHODIMP
ExplorerBar::Load( LPSTREAM inStream
)
500 DEBUG_UNUSED( inStream
);
505 //===========================================================================================================================
507 //===========================================================================================================================
509 STDMETHODIMP
ExplorerBar::Save( LPSTREAM inStream
, BOOL inClearDirty
)
511 DEBUG_UNUSED( inStream
);
512 DEBUG_UNUSED( inClearDirty
);
517 //===========================================================================================================================
519 //===========================================================================================================================
521 STDMETHODIMP
ExplorerBar::GetSizeMax( ULARGE_INTEGER
*outSizeMax
)
523 DEBUG_UNUSED( outSizeMax
);
530 #pragma mark == Other ==
533 //===========================================================================================================================
535 //===========================================================================================================================
537 OSStatus
ExplorerBar::SetupWindow( void )
545 window
= CWnd::FromHandle( mParentWindow
);
547 window
->GetClientRect( rect
);
549 ok
= s
.LoadString( IDS_NAME
);
550 require_action( ok
, exit
, err
= kNoResourcesErr
);
552 ok
= mWindow
.Create( NULL
, s
, WS_CHILD
| WS_VISIBLE
, rect
, window
, 100 ) != 0;
553 require_action( ok
, exit
, err
= kNoResourcesErr
);
555 mWindow
.SetOwner( this );
562 //===========================================================================================================================
564 //===========================================================================================================================
566 OSStatus
ExplorerBar::GoToURL( const CString
&inURL
)
572 s
= inURL
.AllocSysString();
573 require_action( s
, exit
, err
= kNoMemoryErr
);
575 VariantInit( &empty
);
576 err
= mWebBrowser
->Navigate( s
, &empty
, &empty
, &empty
, &empty
);
578 require_noerr( err
, exit
);