]> git.saurik.com Git - apple/mdnsresponder.git/blobdiff - Clients/ExplorerPlugin/ExplorerPlugin.cpp
mDNSResponder-878.230.2.tar.gz
[apple/mdnsresponder.git] / Clients / ExplorerPlugin / ExplorerPlugin.cpp
index 34b981e687175033607784a7f66711b4ba6ecbcb..fb1b7c2429273c7fef436766dcf6f07bd9ea4f32 100644 (file)
@@ -1,59 +1,19 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
-
-    Change History (most recent first):
-    
-$Log: ExplorerPlugin.cpp,v $
-Revision 1.8  2005/06/30 18:01:54  shersche
-<rdar://problem/4130635> Cause IE to rebuild cache so we don't have to reboot following an install.
-
-Revision 1.7  2005/02/23 02:00:45  shersche
-<rdar://problem/4014479> Delete all the registry entries when component is unregistered
-
-Revision 1.6  2005/01/25 17:56:45  shersche
-<rdar://problem/3911084> Load resource DLLs, get icons and bitmaps from resource DLLs
-Bug #: 3911084
-
-Revision 1.5  2004/09/15 10:33:54  shersche
-<rdar://problem/3721611> Install XP toolbar button (8 bit mask) if running on XP platform, otherwise install 1 bit mask toolbar button
-Bug #: 3721611
-
-Revision 1.4  2004/07/13 21:24:21  rpantos
-Fix for <rdar://problem/3701120>.
-
-Revision 1.3  2004/06/26 14:12:07  shersche
-Register the toolbar button
-
-Revision 1.2  2004/06/24 20:09:39  shersche
-Change text
-Submitted by: herscher
-
-Revision 1.1  2004/06/18 04:34:59  rpantos
-Move to Clients from mDNSWindows
-
-Revision 1.1  2004/01/30 03:01:56  bradley
-Explorer Plugin to browse for DNS-SD advertised Web and FTP servers from within Internet Explorer.
-
-*/
+ */
 
 #include       "StdAfx.h"
 
@@ -93,16 +53,6 @@ static char THIS_FILE[] = __FILE__;
 //     Prototypes
 //===========================================================================================================================
 
-// DLL Exports
-
-extern "C" BOOL WINAPI DllMain( HINSTANCE inInstance, DWORD inReason, LPVOID inReserved );
-
-// MFC Support
-
-DEBUG_LOCAL OSStatus   MFCDLLProcessAttach( HINSTANCE inInstance );
-DEBUG_LOCAL void               MFCDLLProcessDetach( HINSTANCE inInstance );
-DEBUG_LOCAL void               MFCDLLThreadDetach( HINSTANCE inInstance );
-
 // Utilities
 
 DEBUG_LOCAL OSStatus   RegisterServer( HINSTANCE inInstance, CLSID inCLSID, LPCTSTR inName );
@@ -144,9 +94,9 @@ DEFINE_GUID(CLSID_CompCatCacheDaemon,
 //     Globals
 //===========================================================================================================================
 
-HINSTANCE              gInstance               = NULL;
-int                            gDLLRefCount    = 0;
-CWinApp                        gApp;
+HINSTANCE                      gInstance               = NULL;
+int                                    gDLLRefCount    = 0;
+CExplorerPluginApp     gApp;
 
 #if 0
 #pragma mark -
@@ -154,53 +104,83 @@ CWinApp                   gApp;
 #endif
 
 //===========================================================================================================================
-//     DllMain
+//     CExplorerPluginApp::CExplorerPluginApp
 //===========================================================================================================================
 
-BOOL WINAPI    DllMain( HINSTANCE inInstance, DWORD inReason, LPVOID inReserved )
+IMPLEMENT_DYNAMIC(CExplorerPluginApp, CWinApp);
+
+CExplorerPluginApp::CExplorerPluginApp()
 {
-       BOOL                    ok;
-       OSStatus                err;
-       
-       DEBUG_UNUSED( inReserved );
-       
-       ok = TRUE;
-       switch( inReason )
-       {
-               case DLL_PROCESS_ATTACH:
-                       gInstance = inInstance;
-                       debug_initialize( kDebugOutputTypeWindowsEventLog, "DNSServices Bar", inInstance );
-                       debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
-                       dlog( kDebugLevelTrace, "\nDllMain: process attach\n" );
-                       
-                       err = MFCDLLProcessAttach( inInstance );
-                       ok = ( err == kNoErr );
-                       require_noerr( err, exit );
-                       break;
-               
-               case DLL_PROCESS_DETACH:
-                       dlog( kDebugLevelTrace, "DllMain: process detach\n" );
-                       MFCDLLProcessDetach( inInstance );
-                       break;
-               
-               case DLL_THREAD_ATTACH:
-                       dlog( kDebugLevelTrace, "DllMain: thread attach\n" );
-                       break;
-               
-               case DLL_THREAD_DETACH:
-                       dlog( kDebugLevelTrace, "DllMain: thread detach\n" );
-                       MFCDLLThreadDetach( inInstance );
-                       break;
-               
-               default:
-                       dlog( kDebugLevelTrace, "DllMain: unknown reason code (%d)\n",inReason );
-                       break;
-       }
-       
+}
+
+
+//===========================================================================================================================
+//     CExplorerPluginApp::~CExplorerPluginApp
+//===========================================================================================================================
+
+CExplorerPluginApp::~CExplorerPluginApp()
+{
+}
+
+
+//===========================================================================================================================
+//     CExplorerPluginApp::InitInstance
+//===========================================================================================================================
+
+BOOL
+CExplorerPluginApp::InitInstance()
+{
+       wchar_t                                 resource[MAX_PATH];
+       OSStatus                                err;
+       int                                             res;
+       HINSTANCE inInstance;
+
+       inInstance = AfxGetInstanceHandle();
+       gInstance = inInstance;
+
+       debug_initialize( kDebugOutputTypeWindowsEventLog, "DNSServices Bar", inInstance );
+       debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
+       dlog( kDebugLevelTrace, "\nCCPApp::InitInstance\n" );
+
+       res = PathForResource( inInstance, L"ExplorerPluginResources.dll", resource, MAX_PATH );
+
+       err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
+       require_noerr( err, exit );
+
+       g_nonLocalizedResources = LoadLibrary( resource );
+       translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
+       require_noerr( err, exit );
+
+       g_nonLocalizedResourcesName = resource;
+
+       res = PathForResource( inInstance, L"ExplorerPluginLocalized.dll", resource, MAX_PATH );
+       err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
+       require_noerr( err, exit );
+
+       g_localizedResources = LoadLibrary( resource );
+       translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
+       require_noerr( err, exit );
+
+       AfxSetResourceHandle( g_localizedResources );
+
 exit:
-       return( ok );
+
+       return TRUE;
 }
 
+
+//===========================================================================================================================
+//     CExplorerPluginApp::ExitInstance
+//===========================================================================================================================
+
+int
+CExplorerPluginApp::ExitInstance()
+{
+       return 0;
+}
+
+
+
 //===========================================================================================================================
 //     DllCanUnloadNow
 //===========================================================================================================================
@@ -308,142 +288,6 @@ exit:
        return( err );
 }
 
-#if 0
-#pragma mark -
-#pragma mark == MFC Support ==
-#endif
-
-//===========================================================================================================================
-//     MFCDLLProcessAttach
-//===========================================================================================================================
-
-DEBUG_LOCAL OSStatus   MFCDLLProcessAttach( HINSTANCE inInstance )
-{
-       wchar_t                                 resource[MAX_PATH];
-       OSStatus                                err;
-       _AFX_THREAD_STATE *             threadState;
-       AFX_MODULE_STATE *              previousModuleState;
-       BOOL                                    ok;
-       int                                             res;
-       CWinApp *                               app;
-       
-       app = NULL;
-       
-       // Simulate what is done in dllmodul.cpp.
-       
-       threadState = AfxGetThreadState();
-       check( threadState );
-       previousModuleState = threadState->m_pPrevModuleState;
-       
-       ok = AfxWinInit( inInstance, NULL, TEXT( "" ), 0 );
-       require_action( ok, exit, err = kUnknownErr );
-       
-       app = AfxGetApp();
-       require_action( ok, exit, err = kNotInitializedErr );
-       
-       // Before we load the resources, let's load the error string
-
-       // errorMessage.LoadString( IDS_REINSTALL );
-       // errorCaption.LoadString( IDS_REINSTALL_CAPTION );
-
-       // Load Resources
-
-       res = PathForResource( inInstance, L"ExplorerPluginResources.dll", resource, MAX_PATH );
-
-       err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
-       require_noerr( err, exit );
-
-       g_nonLocalizedResources = LoadLibrary( resource );
-       translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
-       require_noerr( err, exit );
-
-       g_nonLocalizedResourcesName = resource;
-
-       res = PathForResource( inInstance, L"ExplorerPluginLocalized.dll", resource, MAX_PATH );
-       err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
-       require_noerr( err, exit );
-
-       g_localizedResources = LoadLibrary( resource );
-       translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
-       require_noerr( err, exit );
-
-       AfxSetResourceHandle( g_localizedResources );
-
-       ok = app->InitInstance();
-       require_action( ok, exit, err = kUnknownErr );
-       
-       threadState->m_pPrevModuleState = previousModuleState;
-       threadState = NULL;
-       AfxInitLocalData( inInstance );
-       err = kNoErr;
-       
-exit:
-       if( err )
-       {
-               if( app )
-               {
-                       app->ExitInstance();
-               }
-               AfxWinTerm();
-       }
-       if( threadState )
-       {
-               threadState->m_pPrevModuleState = previousModuleState;
-       }
-       return( err );
-}
-
-//===========================================================================================================================
-//     MFCDLLProcessDetach
-//===========================================================================================================================
-
-DEBUG_LOCAL void       MFCDLLProcessDetach( HINSTANCE inInstance )
-{
-       CWinApp *               app;
-
-       // Simulate what is done in dllmodul.cpp.
-       
-       app = AfxGetApp();
-       if( app )
-       {
-               app->ExitInstance();
-       }
-
-#if( DEBUG )
-       if( AfxGetModuleThreadState()->m_nTempMapLock != 0 )
-       {
-               dlog( kDebugLevelWarning, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock );
-       }
-#endif
-       
-       AfxLockTempMaps();
-       AfxUnlockTempMaps( -1 );
-
-       // Terminate the library before destructors are called.
-       
-       AfxWinTerm();
-       AfxTermLocalData( inInstance, TRUE );
-}
-
-//===========================================================================================================================
-//     MFCDLLFinalize
-//===========================================================================================================================
-
-DEBUG_LOCAL void       MFCDLLThreadDetach( HINSTANCE inInstance )
-{
-       // Simulate what is done in dllmodul.cpp.
-       
-#if( DEBUG )
-       if( AfxGetModuleThreadState()->m_nTempMapLock != 0 )
-       {
-               dlog( kDebugLevelWarning, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock );
-       }
-#endif
-       
-       AfxLockTempMaps();
-       AfxUnlockTempMaps( -1 );
-       AfxTermThread( inInstance );
-}
 
 #if 0
 #pragma mark -