<rdar://problem/3807636> Firefox plugin example code
authorsherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Fri, 28 Aug 2009 05:40:45 +0000 (05:40 +0000)
committersherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Fri, 28 Aug 2009 05:40:45 +0000 (05:40 +0000)
git-svn-id: http://svn.macosforge.org/repository/mdnsresponder/trunk@6629 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

24 files changed:
Clients/FirefoxExtension/CDNSSDService.cpp [new file with mode: 0755]
Clients/FirefoxExtension/CDNSSDService.h [new file with mode: 0755]
Clients/FirefoxExtension/CDNSSDServiceModule.cpp [new file with mode: 0755]
Clients/FirefoxExtension/DNSSDService.sln [new file with mode: 0755]
Clients/FirefoxExtension/DNSSDService.vcproj [new file with mode: 0755]
Clients/FirefoxExtension/IDNSSDService.h [new file with mode: 0755]
Clients/FirefoxExtension/IDNSSDService.idl [new file with mode: 0755]
Clients/FirefoxExtension/extension/chrome.manifest [new file with mode: 0755]
Clients/FirefoxExtension/extension/components/IDNSSDService.xpt [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/bonjour4firefox.css [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/bonjour4firefox.png [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/bonjour4firefox.xul [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/browserOverlay.xul [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/listImage.png [new file with mode: 0755]
Clients/FirefoxExtension/extension/content/overlay.js [new file with mode: 0755]
Clients/FirefoxExtension/extension/defaults/preferences/bonjour4firefox.js [new file with mode: 0755]
Clients/FirefoxExtension/extension/install.rdf [new file with mode: 0755]
Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.dtd [new file with mode: 0755]
Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.properties [new file with mode: 0755]
Clients/FirefoxExtension/extension/readme.txt [new file with mode: 0755]
Clients/FirefoxExtension/extension/skin-darwin/overlay.css [new file with mode: 0644]
Clients/FirefoxExtension/extension/skin-darwin/toolbar-button.png [new file with mode: 0644]
Clients/FirefoxExtension/extension/skin/overlay.css [new file with mode: 0755]
Clients/FirefoxExtension/extension/skin/toolbar-button.png [new file with mode: 0755]

diff --git a/Clients/FirefoxExtension/CDNSSDService.cpp b/Clients/FirefoxExtension/CDNSSDService.cpp
new file mode 100755 (executable)
index 0000000..0294534
--- /dev/null
@@ -0,0 +1,393 @@
+#include "CDNSSDService.h"
+#include "nsThreadUtils.h"
+#include "nsIEventTarget.h"
+#include "private/pprio.h"
+#include <string>
+#include <stdio.h>
+
+static FILE * m_fp;
+
+
+NS_IMPL_ISUPPORTS2(CDNSSDService, IDNSSDService, nsIRunnable)
+
+CDNSSDService::CDNSSDService()
+:
+       m_threadPool( NULL ),
+       m_mainRef( NULL ),
+       m_subRef( NULL ),
+       m_listener( NULL ),
+       m_fileDesc( NULL ),
+       m_job( NULL )
+{
+       nsresult err;
+
+       //m_fp = fopen( "/Users/scott/scott.txt", "w+" );
+       m_fp = stderr;
+       fprintf( m_fp, "CDNSSDService::CDNSSDService( this = 0x%x )\n", this );
+       fflush( m_fp );
+       
+       if ( DNSServiceCreateConnection( &m_mainRef ) != kDNSServiceErr_NoError )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+
+       if ( ( m_fileDesc = PR_ImportTCPSocket( DNSServiceRefSockFD( m_mainRef ) ) ) == NULL )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+
+       if ( ( m_threadPool = PR_CreateThreadPool( 1, 1, 8192 ) ) == NULL )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+       
+       err = SetupNotifications();
+
+exit:
+
+       if ( err != NS_OK )
+       {
+               Cleanup();
+       }
+}
+
+
+CDNSSDService::CDNSSDService( DNSServiceRef ref, nsISupports * listener )
+:
+       m_threadPool( NULL ),
+       m_mainRef( ref ),
+       m_subRef( ref ),
+       m_listener( listener ),
+       m_fileDesc( NULL ),
+       m_job( NULL )
+{
+}
+
+
+CDNSSDService::~CDNSSDService()
+{
+       fprintf( m_fp, "in CDNSSDService::~CDNSSDService( this = 0x%x)\n", this );
+       fflush( m_fp );
+       
+       Cleanup();
+}
+
+
+void
+CDNSSDService::Cleanup()
+{
+       if ( m_job )
+       {
+               PR_CancelJob( m_job );
+               m_job = NULL;
+       }
+
+       if ( m_threadPool != NULL )
+       {
+               PR_ShutdownThreadPool( m_threadPool );
+               m_threadPool = NULL;
+       }
+       
+       if ( m_fileDesc != NULL )
+       {
+               PR_Close( m_fileDesc );
+               m_fileDesc = NULL;
+       }
+       
+       if ( m_subRef )
+       {
+               DNSServiceRefDeallocate( m_subRef );
+               m_subRef = NULL;
+       }
+       else if ( m_mainRef )
+       {
+               DNSServiceRefDeallocate( m_mainRef );
+               m_mainRef = NULL;
+       }
+}
+
+
+nsresult
+CDNSSDService::SetupNotifications()
+{
+       NS_PRECONDITION( m_threadPool != NULL, "m_threadPool is NULL" );
+       NS_PRECONDITION( m_fileDesc != NULL, "m_fileDesc is NULL" );
+       NS_PRECONDITION( m_job == NULL, "m_job is not NULL" );
+
+       m_iod.socket    = m_fileDesc;
+       m_iod.timeout   = PR_INTERVAL_MAX;
+       m_job                   = PR_QueueJob_Read( m_threadPool, &m_iod, Read, this, PR_FALSE );       
+       return ( m_job ) ? NS_OK : NS_ERROR_FAILURE;
+}
+
+
+/* IDNSSDService browse (in long interfaceIndex, in AString regtype, in AString domain, in IDNSSDBrowseListener listener); */
+NS_IMETHODIMP
+CDNSSDService::Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM)
+{
+       CDNSSDService   *       service = NULL;
+       DNSServiceErrorType dnsErr      = 0;
+       nsresult                        err             = 0;
+
+       *_retval = NULL;
+       
+       fprintf( m_fp, "in Browse( listener = 0x%x )\n", listener );
+       fflush( m_fp );
+       
+       if ( !m_mainRef )
+       {
+               err = NS_ERROR_NOT_AVAILABLE;
+               goto exit;
+       }
+
+       try
+       {
+               service = new CDNSSDService( m_mainRef, listener );
+       }
+       catch ( ... )
+       {
+               service = NULL;
+       }
+       
+       fprintf( m_fp, "created new service\n" );
+       fflush( m_fp );
+
+       if ( service == NULL )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+       
+       dnsErr = DNSServiceBrowse( &service->m_subRef, kDNSServiceFlagsShareConnection, interfaceIndex, NS_ConvertUTF16toUTF8( regtype ).get(), NS_ConvertUTF16toUTF8( domain ).get(), ( DNSServiceBrowseReply ) BrowseReply, service );
+       
+       if ( dnsErr != kDNSServiceErr_NoError )
+       {
+               fprintf( m_fp, "DNSServiceBrowse failed\n" );
+               fflush( m_fp );
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+       
+       listener->AddRef();
+       service->AddRef();
+       *_retval = service;
+       err = NS_OK;
+       
+       fprintf( m_fp, "did DNSServiceBrowse\n" );
+       fflush( m_fp );
+       
+exit:
+
+       if ( err && service )
+       {
+               delete service;
+               service = NULL;
+       }
+       
+       return err;
+}
+
+
+/* IDNSSDService resolve (in long interfaceIndex, in AString name, in AString regtype, in AString domain, in IDNSSDResolveListener listener); */
+NS_IMETHODIMP
+CDNSSDService::Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM)
+{
+    CDNSSDService      *       service;
+       DNSServiceErrorType dnsErr;
+       nsresult                        err;
+
+       *_retval = NULL;
+       
+       fprintf( m_fp, "in Resolve( listener = 0x%x )\n", listener );
+       fflush( m_fp );
+
+       if ( !m_mainRef )
+       {
+               err = NS_ERROR_NOT_AVAILABLE;
+               goto exit;
+       }
+
+       try
+       {
+               service = new CDNSSDService( m_mainRef, listener );
+       }
+       catch ( ... )
+       {
+               service = NULL;
+       }
+       
+       if ( service == NULL )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+
+       dnsErr = DNSServiceResolve( &service->m_subRef, kDNSServiceFlagsShareConnection, interfaceIndex, NS_ConvertUTF16toUTF8( name ).get(), NS_ConvertUTF16toUTF8( regtype ).get(), NS_ConvertUTF16toUTF8( domain ).get(), ( DNSServiceResolveReply ) ResolveReply, service );
+       
+       if ( dnsErr != kDNSServiceErr_NoError )
+       {
+               err = NS_ERROR_FAILURE;
+               goto exit;
+       }
+       
+       listener->AddRef();
+       service->AddRef();
+       *_retval = service;
+       err = NS_OK;
+       
+       fprintf( m_fp, "did DNSServiceResolve\n" );
+       fflush( m_fp );
+       
+exit:
+       
+       if ( err && service )
+       {
+               delete service;
+               service = NULL;
+       }
+       
+       return err;
+}
+
+
+/* void stop (); */
+NS_IMETHODIMP
+CDNSSDService::Stop()
+{
+    if ( m_subRef )
+       {
+               DNSServiceRefDeallocate( m_subRef );
+               m_subRef = NULL;
+       }
+       
+       return NS_OK;
+}
+
+
+void
+CDNSSDService::Read( void * arg )
+{
+       NS_PRECONDITION( arg != NULL, "arg is NULL" );
+       
+       NS_DispatchToMainThread( ( CDNSSDService* ) arg );
+}
+
+
+NS_IMETHODIMP
+CDNSSDService::Run()
+{
+       nsresult err;
+       
+       NS_PRECONDITION( m_mainRef != NULL, "m_mainRef is NULL" );
+
+       fprintf( m_fp, "in CDNSSDService::Run()\n" );
+       fflush( m_fp );
+       
+       m_job = NULL;
+
+       if ( DNSServiceProcessResult( m_mainRef ) == kDNSServiceErr_NoError )
+       {
+               err = SetupNotifications();
+       }
+       else
+       {
+               err = NS_ERROR_FAILURE;
+       }
+       
+       return err;
+}
+
+
+void DNSSD_API
+CDNSSDService::BrowseReply
+               (
+               DNSServiceRef           sdRef,
+               DNSServiceFlags         flags,
+               uint32_t                        interfaceIndex,
+               DNSServiceErrorType     errorCode,
+               const char              *       serviceName,
+               const char              *       regtype,
+               const char              *       replyDomain,
+               void                    *       context
+               )
+{
+       CDNSSDService * self = ( CDNSSDService* ) context;
+
+       fprintf( m_fp, "in browseReply: interfaceIndex = %d\n", interfaceIndex );
+       fflush( m_fp );
+
+       // This should never be NULL, but let's be defensive.
+       
+       if ( self != NULL )
+       {
+               IDNSSDBrowseListener * listener = ( IDNSSDBrowseListener* ) self->m_listener;
+
+               // Same for this
+
+               if ( listener != NULL )
+               {
+                       listener->OnBrowse( self, ( flags & kDNSServiceFlagsAdd ) ? PR_TRUE : PR_FALSE, interfaceIndex, errorCode, NS_ConvertUTF8toUTF16( serviceName ), NS_ConvertUTF8toUTF16( regtype ), NS_ConvertUTF8toUTF16( replyDomain ) );
+               }
+       }
+}
+
+
+void DNSSD_API
+CDNSSDService::ResolveReply
+               (
+               DNSServiceRef                   sdRef,
+               DNSServiceFlags                 flags,
+               uint32_t                                interfaceIndex,
+               DNSServiceErrorType             errorCode,
+               const char                      *       fullname,
+               const char                      *       hosttarget,
+               uint16_t                                port,
+               uint16_t                                txtLen,
+               const unsigned char     *       txtRecord,
+               void                            *       context
+               )
+{
+       CDNSSDService * self = ( CDNSSDService* ) context;
+       
+       fprintf( m_fp, "in CDNSSDService::ResolveReply()\n" );
+       fflush( m_fp );
+
+       // This should never be NULL, but let's be defensive.
+       
+       if ( self != NULL )
+       {
+               IDNSSDResolveListener * listener = ( IDNSSDResolveListener* ) self->m_listener;
+               
+               // Same for this
+
+               if ( listener != NULL )
+               {
+                       std::string             path = "";
+                       const void      *       value = NULL;
+                       uint8_t                 valueLen = 0;
+
+                       value = TXTRecordGetValuePtr( txtLen, txtRecord, "path", &valueLen );
+                       
+                       if ( value && valueLen )
+                       {
+                               char * temp;
+                               
+                               temp = new char[ valueLen + 1 ];
+                               
+                               if ( temp )
+                               {
+                                       memset( temp, 0, valueLen + 1 );
+                                       memcpy( temp, value, valueLen );
+                                       path = temp;
+                                       delete [] temp;
+                               }
+                       }
+
+                       listener->OnResolve( self, interfaceIndex, errorCode, NS_ConvertUTF8toUTF16( fullname ), NS_ConvertUTF8toUTF16( hosttarget ) , ntohs( port ), NS_ConvertUTF8toUTF16( path.c_str() ) );
+               }
+       }
+}
+
diff --git a/Clients/FirefoxExtension/CDNSSDService.h b/Clients/FirefoxExtension/CDNSSDService.h
new file mode 100755 (executable)
index 0000000..2a14b3d
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef _CDNSSDSERVICE_H
+#define _CDNSSDSERVICE_H
+
+#include "IDNSSDService.h"
+#include "nsCOMPtr.h"
+#include "nsComponentManagerUtils.h"
+#include "nsIThread.h"
+#include "nsIRunnable.h"
+#include "prtpool.h"
+#include <dns_sd.h>
+#include <stdio.h>
+#include <string>
+
+
+#define CDNSSDSERVICE_CONTRACTID "@apple.com/DNSSDService;1"
+#define CDNSSDSERVICE_CLASSNAME "CDNSSDService"
+#define CDNSSDSERVICE_CID { 0x944ED267, 0x465A, 0x4989, { 0x82, 0x72, 0x7E, 0xE9, 0x28, 0x6C, 0x99, 0xA5 } }
+
+
+/* Header file */
+class CDNSSDService : public IDNSSDService, nsIRunnable
+{
+public:
+       NS_DECL_ISUPPORTS
+       NS_DECL_IDNSSDSERVICE
+       NS_DECL_NSIRUNNABLE
+
+       CDNSSDService();
+       CDNSSDService( DNSServiceRef mainRef, nsISupports * listener );
+
+       virtual ~CDNSSDService();
+       
+private:
+
+       static void DNSSD_API
+       BrowseReply
+               (
+               DNSServiceRef           sdRef,
+               DNSServiceFlags         flags,
+               uint32_t                        interfaceIndex,
+               DNSServiceErrorType     errorCode,
+               const char              *       serviceName,
+               const char              *       regtype,
+               const char              *       replyDomain,
+               void                    *       context
+               );
+               
+       static void DNSSD_API
+       ResolveReply
+               (
+               DNSServiceRef                   sdRef,
+               DNSServiceFlags                 flags,
+               uint32_t                                interfaceIndex,
+               DNSServiceErrorType             errorCode,
+               const char                      *       fullname,
+               const char                      *       hosttarget,
+               uint16_t                                port,
+               uint16_t                                txtLen,
+               const unsigned char     *       txtRecord,
+               void                            *       context
+               );
+               
+       static void
+       Read
+               (
+               void * arg
+               );
+               
+       nsresult
+       SetupNotifications();
+       
+       void
+       Cleanup();
+
+       PRThreadPool    *       m_threadPool;
+       DNSServiceRef           m_mainRef;
+       DNSServiceRef           m_subRef;
+       nsISupports             *       m_listener;
+       PRFileDesc              *       m_fileDesc;
+       PRJobIoDesc                     m_iod;
+       PRJob                   *       m_job;
+};
+
+
+#endif
diff --git a/Clients/FirefoxExtension/CDNSSDServiceModule.cpp b/Clients/FirefoxExtension/CDNSSDServiceModule.cpp
new file mode 100755 (executable)
index 0000000..c114b32
--- /dev/null
@@ -0,0 +1,20 @@
+#include "nsIGenericFactory.h"
+#include "CDNSSDService.h"
+
+NS_COM_GLUE nsresult
+NS_NewGenericModule2(nsModuleInfo const *info, nsIModule* *result);
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(CDNSSDService)
+
+static nsModuleComponentInfo components[] =
+{
+    {
+       CDNSSDSERVICE_CLASSNAME, 
+       CDNSSDSERVICE_CID,
+       CDNSSDSERVICE_CONTRACTID,
+       CDNSSDServiceConstructor,
+    }
+};
+
+NS_IMPL_NSGETMODULE("CDNSSDServiceModule", components) 
+
diff --git a/Clients/FirefoxExtension/DNSSDService.sln b/Clients/FirefoxExtension/DNSSDService.sln
new file mode 100755 (executable)
index 0000000..68534f4
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DNSSDService", "DNSSDService.vcproj", "{7826EA27-D4CC-4FAA-AD23-DF813823227B}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Win32.Build.0 = Debug|Win32\r
+               {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Win32.ActiveCfg = Release|Win32\r
+               {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/Clients/FirefoxExtension/DNSSDService.vcproj b/Clients/FirefoxExtension/DNSSDService.vcproj
new file mode 100755 (executable)
index 0000000..6148c8c
--- /dev/null
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="DNSSDService"\r
+       ProjectGUID="{7826EA27-D4CC-4FAA-AD23-DF813823227B}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\$(OutDir)\DNSSDService.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="..\..\mDNSShared"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;DNSSDSERVICE_EXPORTS;XP_WIN;XP_WIN32"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=""\r
+                               AssemblerListingLocation="$(IntDir)\"\r
+                               ObjectFile="$(IntDir)\"\r
+                               ProgramDataBaseFileName="$(IntDir)\vc80.pdb"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               ForcedIncludeFiles=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="nspr4.lib xpcom.lib xpcomglue_s.lib ws2_32.lib ../../mDNSWindows/DLLStub/$(PlatformName)/$(ConfigurationName)/dnssdStatic.lib"\r
+                               OutputFile="$(OutDir)\DNSSDService.dll"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories=""\r
+                               ProgramDatabaseFile=".\$(OutDir)/DNSSDService.pdb"\r
+                               ImportLibrary=".\$(OutDir)/DNSSDService.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\$(OutDir)\DNSSDService.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="copy $(PlatformName)\$(ConfigurationName)\DNSSDService.dll extension\platform\WINNT\components"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\$(OutDir)\DNSSDService.tlb"\r
+                               HeaderFileName=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..\mDNSShared"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DNSSDSERVICE_EXPORTS;XP_WIN;XP_WIN32"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=""\r
+                               AssemblerListingLocation="$(IntDir)\"\r
+                               ObjectFile="$(IntDir)\"\r
+                               ProgramDataBaseFileName="$(IntDir)\vc80.pdb"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="3"\r
+                               ForcedIncludeFiles=""\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="nspr4.lib xpcom.lib xpcomglue_s.lib ws2_32.lib ../../mDNSWindows/DLLStub/$(PlatformName)/$(ConfigurationName)/dnssdStatic.lib"\r
+                               OutputFile="$(OutDir)\DNSSDService.dll"\r
+                               LinkIncremental="2"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories=""\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\$(OutDir)\DNSSDService.pdb"\r
+                               ImportLibrary=".\$(OutDir)/DNSSDService.lib"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                               SuppressStartupBanner="true"\r
+                               OutputFile=".\$(OutDir)\DNSSDService.bsc"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="copy $(PlatformName)\$(ConfigurationName)\DNSSDService.dll extension\platform\WINNT\components"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\CDNSSDService.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\CDNSSDServiceModule.cpp"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\CDNSSDService.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\IDNSSDService.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="IDL"\r
+                       Filter="idl"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\IDNSSDService.idl"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/Clients/FirefoxExtension/IDNSSDService.h b/Clients/FirefoxExtension/IDNSSDService.h
new file mode 100755 (executable)
index 0000000..fc7408f
--- /dev/null
@@ -0,0 +1,263 @@
+/*\r
+ * DO NOT EDIT.  THIS FILE IS GENERATED FROM IDNSSDService.idl\r
+ */\r
+\r
+#ifndef __gen_IDNSSDService_h__\r
+#define __gen_IDNSSDService_h__\r
+\r
+\r
+#ifndef __gen_nsISupports_h__\r
+#include "nsISupports.h"\r
+#endif\r
+\r
+/* For IDL files that don't want to include root IDL files. */\r
+#ifndef NS_NO_VTABLE\r
+#define NS_NO_VTABLE\r
+#endif\r
+class IDNSSDService; /* forward declaration */\r
+\r
+\r
+/* starting interface:    IDNSSDBrowseListener */\r
+#define IDNSSDBROWSELISTENER_IID_STR "27346495-a1ed-458a-a5bc-587df9a26b4f"\r
+\r
+#define IDNSSDBROWSELISTENER_IID \\r
+  {0x27346495, 0xa1ed, 0x458a, \\r
+    { 0xa5, 0xbc, 0x58, 0x7d, 0xf9, 0xa2, 0x6b, 0x4f }}\r
+\r
+class NS_NO_VTABLE NS_SCRIPTABLE IDNSSDBrowseListener : public nsISupports {\r
+ public: \r
+\r
+  NS_DECLARE_STATIC_IID_ACCESSOR(IDNSSDBROWSELISTENER_IID)\r
+\r
+  /* void onBrowse (in IDNSSDService service, in boolean add, in long interfaceIndex, in long error, in AString serviceName, in AString regtype, in AString domain); */\r
+  NS_SCRIPTABLE NS_IMETHOD OnBrowse(IDNSSDService *service, PRBool add, PRInt32 interfaceIndex, PRInt32 error, const nsAString & serviceName, const nsAString & regtype, const nsAString & domain) = 0;\r
+\r
+};\r
+\r
+  NS_DEFINE_STATIC_IID_ACCESSOR(IDNSSDBrowseListener, IDNSSDBROWSELISTENER_IID)\r
+\r
+/* Use this macro when declaring classes that implement this interface. */\r
+#define NS_DECL_IDNSSDBROWSELISTENER \\r
+  NS_SCRIPTABLE NS_IMETHOD OnBrowse(IDNSSDService *service, PRBool add, PRInt32 interfaceIndex, PRInt32 error, const nsAString & serviceName, const nsAString & regtype, const nsAString & domain); \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */\r
+#define NS_FORWARD_IDNSSDBROWSELISTENER(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD OnBrowse(IDNSSDService *service, PRBool add, PRInt32 interfaceIndex, PRInt32 error, const nsAString & serviceName, const nsAString & regtype, const nsAString & domain) { return _to OnBrowse(service, add, interfaceIndex, error, serviceName, regtype, domain); } \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */\r
+#define NS_FORWARD_SAFE_IDNSSDBROWSELISTENER(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD OnBrowse(IDNSSDService *service, PRBool add, PRInt32 interfaceIndex, PRInt32 error, const nsAString & serviceName, const nsAString & regtype, const nsAString & domain) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnBrowse(service, add, interfaceIndex, error, serviceName, regtype, domain); } \r
+\r
+#if 0\r
+/* Use the code below as a template for the implementation class for this interface. */\r
+\r
+/* Header file */\r
+class _MYCLASS_ : public IDNSSDBrowseListener\r
+{\r
+public:\r
+  NS_DECL_ISUPPORTS\r
+  NS_DECL_IDNSSDBROWSELISTENER\r
+\r
+  _MYCLASS_();\r
+\r
+private:\r
+  ~_MYCLASS_();\r
+\r
+protected:\r
+  /* additional members */\r
+};\r
+\r
+/* Implementation file */\r
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IDNSSDBrowseListener)\r
+\r
+_MYCLASS_::_MYCLASS_()\r
+{\r
+  /* member initializers and constructor code */\r
+}\r
+\r
+_MYCLASS_::~_MYCLASS_()\r
+{\r
+  /* destructor code */\r
+}\r
+\r
+/* void onBrowse (in IDNSSDService service, in boolean add, in long interfaceIndex, in long error, in AString serviceName, in AString regtype, in AString domain); */\r
+NS_IMETHODIMP _MYCLASS_::OnBrowse(IDNSSDService *service, PRBool add, PRInt32 interfaceIndex, PRInt32 error, const nsAString & serviceName, const nsAString & regtype, const nsAString & domain)\r
+{\r
+    return NS_ERROR_NOT_IMPLEMENTED;\r
+}\r
+\r
+/* End of implementation class template. */\r
+#endif\r
+\r
+\r
+/* starting interface:    IDNSSDResolveListener */\r
+#define IDNSSDRESOLVELISTENER_IID_STR "6620e18f-47f3-47c6-941f-126a5fd4fcf7"\r
+\r
+#define IDNSSDRESOLVELISTENER_IID \\r
+  {0x6620e18f, 0x47f3, 0x47c6, \\r
+    { 0x94, 0x1f, 0x12, 0x6a, 0x5f, 0xd4, 0xfc, 0xf7 }}\r
+\r
+class NS_NO_VTABLE NS_SCRIPTABLE IDNSSDResolveListener : public nsISupports {\r
+ public: \r
+\r
+  NS_DECLARE_STATIC_IID_ACCESSOR(IDNSSDRESOLVELISTENER_IID)\r
+\r
+  /* void onResolve (in IDNSSDService service, in long interfaceIndex, in long error, in AString fullname, in AString host, in short port, in AString path); */\r
+  NS_SCRIPTABLE NS_IMETHOD OnResolve(IDNSSDService *service, PRInt32 interfaceIndex, PRInt32 error, const nsAString & fullname, const nsAString & host, PRInt16 port, const nsAString & path) = 0;\r
+\r
+};\r
+\r
+  NS_DEFINE_STATIC_IID_ACCESSOR(IDNSSDResolveListener, IDNSSDRESOLVELISTENER_IID)\r
+\r
+/* Use this macro when declaring classes that implement this interface. */\r
+#define NS_DECL_IDNSSDRESOLVELISTENER \\r
+  NS_SCRIPTABLE NS_IMETHOD OnResolve(IDNSSDService *service, PRInt32 interfaceIndex, PRInt32 error, const nsAString & fullname, const nsAString & host, PRInt16 port, const nsAString & path); \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */\r
+#define NS_FORWARD_IDNSSDRESOLVELISTENER(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD OnResolve(IDNSSDService *service, PRInt32 interfaceIndex, PRInt32 error, const nsAString & fullname, const nsAString & host, PRInt16 port, const nsAString & path) { return _to OnResolve(service, interfaceIndex, error, fullname, host, port, path); } \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */\r
+#define NS_FORWARD_SAFE_IDNSSDRESOLVELISTENER(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD OnResolve(IDNSSDService *service, PRInt32 interfaceIndex, PRInt32 error, const nsAString & fullname, const nsAString & host, PRInt16 port, const nsAString & path) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnResolve(service, interfaceIndex, error, fullname, host, port, path); } \r
+\r
+#if 0\r
+/* Use the code below as a template for the implementation class for this interface. */\r
+\r
+/* Header file */\r
+class _MYCLASS_ : public IDNSSDResolveListener\r
+{\r
+public:\r
+  NS_DECL_ISUPPORTS\r
+  NS_DECL_IDNSSDRESOLVELISTENER\r
+\r
+  _MYCLASS_();\r
+\r
+private:\r
+  ~_MYCLASS_();\r
+\r
+protected:\r
+  /* additional members */\r
+};\r
+\r
+/* Implementation file */\r
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IDNSSDResolveListener)\r
+\r
+_MYCLASS_::_MYCLASS_()\r
+{\r
+  /* member initializers and constructor code */\r
+}\r
+\r
+_MYCLASS_::~_MYCLASS_()\r
+{\r
+  /* destructor code */\r
+}\r
+\r
+/* void onResolve (in IDNSSDService service, in long interfaceIndex, in long error, in AString fullname, in AString host, in short port, in AString path); */\r
+NS_IMETHODIMP _MYCLASS_::OnResolve(IDNSSDService *service, PRInt32 interfaceIndex, PRInt32 error, const nsAString & fullname, const nsAString & host, PRInt16 port, const nsAString & path)\r
+{\r
+    return NS_ERROR_NOT_IMPLEMENTED;\r
+}\r
+\r
+/* End of implementation class template. */\r
+#endif\r
+\r
+\r
+/* starting interface:    IDNSSDService */\r
+#define IDNSSDSERVICE_IID_STR "3a3539ff-f8d8-40b4-8d02-5ea73c51fa12"\r
+\r
+#define IDNSSDSERVICE_IID \\r
+  {0x3a3539ff, 0xf8d8, 0x40b4, \\r
+    { 0x8d, 0x02, 0x5e, 0xa7, 0x3c, 0x51, 0xfa, 0x12 }}\r
+\r
+class NS_NO_VTABLE NS_SCRIPTABLE IDNSSDService : public nsISupports {\r
+ public: \r
+\r
+  NS_DECLARE_STATIC_IID_ACCESSOR(IDNSSDSERVICE_IID)\r
+\r
+  /* IDNSSDService browse (in long interfaceIndex, in AString regtype, in AString domain, in IDNSSDBrowseListener listener); */\r
+  NS_SCRIPTABLE NS_IMETHOD Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM) = 0;\r
+\r
+  /* IDNSSDService resolve (in long interfaceIndex, in AString name, in AString regtype, in AString domain, in IDNSSDResolveListener listener); */\r
+  NS_SCRIPTABLE NS_IMETHOD Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM) = 0;\r
+\r
+  /* void stop (); */\r
+  NS_SCRIPTABLE NS_IMETHOD Stop(void) = 0;\r
+\r
+};\r
+\r
+  NS_DEFINE_STATIC_IID_ACCESSOR(IDNSSDService, IDNSSDSERVICE_IID)\r
+\r
+/* Use this macro when declaring classes that implement this interface. */\r
+#define NS_DECL_IDNSSDSERVICE \\r
+  NS_SCRIPTABLE NS_IMETHOD Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM); \\r
+  NS_SCRIPTABLE NS_IMETHOD Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM); \\r
+  NS_SCRIPTABLE NS_IMETHOD Stop(void); \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */\r
+#define NS_FORWARD_IDNSSDSERVICE(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM) { return _to Browse(interfaceIndex, regtype, domain, listener, _retval); } \\r
+  NS_SCRIPTABLE NS_IMETHOD Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM) { return _to Resolve(interfaceIndex, name, regtype, domain, listener, _retval); } \\r
+  NS_SCRIPTABLE NS_IMETHOD Stop(void) { return _to Stop(); } \r
+\r
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */\r
+#define NS_FORWARD_SAFE_IDNSSDSERVICE(_to) \\r
+  NS_SCRIPTABLE NS_IMETHOD Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Browse(interfaceIndex, regtype, domain, listener, _retval); } \\r
+  NS_SCRIPTABLE NS_IMETHOD Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Resolve(interfaceIndex, name, regtype, domain, listener, _retval); } \\r
+  NS_SCRIPTABLE NS_IMETHOD Stop(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Stop(); } \r
+\r
+#if 0\r
+/* Use the code below as a template for the implementation class for this interface. */\r
+\r
+/* Header file */\r
+class _MYCLASS_ : public IDNSSDService\r
+{\r
+public:\r
+  NS_DECL_ISUPPORTS\r
+  NS_DECL_IDNSSDSERVICE\r
+\r
+  _MYCLASS_();\r
+\r
+private:\r
+  ~_MYCLASS_();\r
+\r
+protected:\r
+  /* additional members */\r
+};\r
+\r
+/* Implementation file */\r
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IDNSSDService)\r
+\r
+_MYCLASS_::_MYCLASS_()\r
+{\r
+  /* member initializers and constructor code */\r
+}\r
+\r
+_MYCLASS_::~_MYCLASS_()\r
+{\r
+  /* destructor code */\r
+}\r
+\r
+/* IDNSSDService browse (in long interfaceIndex, in AString regtype, in AString domain, in IDNSSDBrowseListener listener); */\r
+NS_IMETHODIMP _MYCLASS_::Browse(PRInt32 interfaceIndex, const nsAString & regtype, const nsAString & domain, IDNSSDBrowseListener *listener, IDNSSDService **_retval NS_OUTPARAM)\r
+{\r
+    return NS_ERROR_NOT_IMPLEMENTED;\r
+}\r
+\r
+/* IDNSSDService resolve (in long interfaceIndex, in AString name, in AString regtype, in AString domain, in IDNSSDResolveListener listener); */\r
+NS_IMETHODIMP _MYCLASS_::Resolve(PRInt32 interfaceIndex, const nsAString & name, const nsAString & regtype, const nsAString & domain, IDNSSDResolveListener *listener, IDNSSDService **_retval NS_OUTPARAM)\r
+{\r
+    return NS_ERROR_NOT_IMPLEMENTED;\r
+}\r
+\r
+/* void stop (); */\r
+NS_IMETHODIMP _MYCLASS_::Stop()\r
+{\r
+    return NS_ERROR_NOT_IMPLEMENTED;\r
+}\r
+\r
+/* End of implementation class template. */\r
+#endif\r
+\r
+\r
+#endif /* __gen_IDNSSDService_h__ */\r
diff --git a/Clients/FirefoxExtension/IDNSSDService.idl b/Clients/FirefoxExtension/IDNSSDService.idl
new file mode 100755 (executable)
index 0000000..a30f741
--- /dev/null
@@ -0,0 +1,33 @@
+#include "nsISupports.idl"\r
+\r
+interface IDNSSDService;\r
+\r
+\r
+[scriptable, function, uuid(27346495-A1ED-458A-A5BC-587DF9A26B4F)]\r
+interface IDNSSDBrowseListener : nsISupports\r
+{\r
+       void\r
+       onBrowse( in IDNSSDService service, in boolean add, in long interfaceIndex, in long error, in AString serviceName, in AString regtype, in AString domain );\r
+};\r
+\r
+\r
+[scriptable, function, uuid(6620E18F-47F3-47C6-941F-126A5FD4FCF7)]\r
+interface IDNSSDResolveListener : nsISupports\r
+{\r
+       void\r
+       onResolve( in IDNSSDService service, in long interfaceIndex, in long error, in AString fullname, in AString host, in short port, in AString path );\r
+};\r
+\r
+\r
+[scriptable, uuid(3A3539FF-F8D8-40B4-8D02-5EA73C51FA12)]\r
+interface IDNSSDService : nsISupports\r
+{\r
+       IDNSSDService\r
+       browse( in long interfaceIndex, in AString regtype, in AString domain, in IDNSSDBrowseListener listener );\r
+\r
+       IDNSSDService\r
+       resolve( in long interfaceIndex, in AString name, in AString regtype, in AString domain, in IDNSSDResolveListener listener );\r
+\r
+       void\r
+       stop();\r
+};\r
diff --git a/Clients/FirefoxExtension/extension/chrome.manifest b/Clients/FirefoxExtension/extension/chrome.manifest
new file mode 100755 (executable)
index 0000000..f1daf86
--- /dev/null
@@ -0,0 +1,6 @@
+content        bonjour4firefox content/
+locale bonjour4firefox en-US   locale/en-US/
+skin   bonjour4firefox classic/1.0     skin/ 
+skin   bonjour4firefox classic/1.0 skin-darwin/ os=darwin
+overlay        chrome://browser/content/browser.xul    chrome://bonjour4firefox/content/browserOverlay.xul
+style  chrome://global/content/customizeToolbar.xul    chrome://bonjour4firefox/skin/overlay.css
diff --git a/Clients/FirefoxExtension/extension/components/IDNSSDService.xpt b/Clients/FirefoxExtension/extension/components/IDNSSDService.xpt
new file mode 100755 (executable)
index 0000000..bfda3e5
Binary files /dev/null and b/Clients/FirefoxExtension/extension/components/IDNSSDService.xpt differ
diff --git a/Clients/FirefoxExtension/extension/content/bonjour4firefox.css b/Clients/FirefoxExtension/extension/content/bonjour4firefox.css
new file mode 100755 (executable)
index 0000000..2e7eb2c
--- /dev/null
@@ -0,0 +1,16 @@
+tree.sidebar-placesTree treechildren::-moz-tree-row(selected)
+{
+       background-color: #6f81a9;
+       background-image: url("chrome://browser/skin/places/selected-gradient.png");
+       background-repeat: repeat-x;
+       background-position: bottom left;
+       border-top: 1px solid #979797;
+}
+
+
+tree.sidebar-placesTree treechildren::-moz-tree-separator
+{
+       border-top: 1px solid #505d6d;
+       margin: 0 10px;
+}
+
diff --git a/Clients/FirefoxExtension/extension/content/bonjour4firefox.png b/Clients/FirefoxExtension/extension/content/bonjour4firefox.png
new file mode 100755 (executable)
index 0000000..baf8b21
Binary files /dev/null and b/Clients/FirefoxExtension/extension/content/bonjour4firefox.png differ
diff --git a/Clients/FirefoxExtension/extension/content/bonjour4firefox.xul b/Clients/FirefoxExtension/extension/content/bonjour4firefox.xul
new file mode 100755 (executable)
index 0000000..6c1dee8
--- /dev/null
@@ -0,0 +1,221 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
+<?xml-stylesheet href="browseList.css"?>
+<!DOCTYPE page SYSTEM "chrome://bonjour4firefox/locale/bonjour4firefox.dtd">
+       <page
+               orient="vertical"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        style="background-color: transparent !important; -moz-appearance: none !important;"
+               onload="BonjourBrowser.init()"
+               onunload="BonjourBrowser.cleanup()">
+               
+
+       <menupopup id="targetmenu">
+        <menuitem label="&bonjour4firefoxSidebarOpenDefault.label;" value="current"/>
+        <menuitem label="&bonjour4firefoxSidebarOpenTab.label;" value="tab"/>
+        <menuitem label="&bonjour4firefoxSidebarOpenWindow.label;" value="window"/>
+       </menupopup>
+
+       <tree id="treeBrowseList" flex="1" class="sidebar-placesTree" hidecolumnpicker="true">
+               <treecols hide="true">
+                       <treecol id="title" flex="1" primary="true" hideheader="true"/>
+        </treecols>
+
+        <treechildren class="sidebar-placesTreechildren" context="targetmenu" flex="1" id="treeChildrenBrowseList">
+                       <treeitem>
+                               <treerow>
+                                       <treecell label="About Bonjour"/>
+                               </treerow>
+                       </treeitem>
+               </treechildren>
+       </tree>
+
+       <script><![CDATA[
+
+               var BonjourBrowser =
+               {
+                       Service: null,
+                       Browse: null,
+                       BrowseListener: null,
+                       Resolve: null,
+                       ResolveListener: null,
+
+                       init: function()
+                       {
+                               document.getElementById("treeChildrenBrowseList").addEventListener( "click", this.listListener, false );
+
+                               try
+                               {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                       const cid = "@apple.com/DNSSDService;1";
+                               Service = Components.classes[cid].createInstance();
+                                       Service = Service.QueryInterface(Components.interfaces.IDNSSDService);
+                               }
+                               catch (err)
+                               {
+                               alert(err);
+                               return;
+                       }
+
+                               BrowseListener = this.browseListener;
+                               ResolveListener = this.resolveListener;
+
+                               try
+                               {
+                                       Browse = Service.browse(0, "_http._tcp", "", BrowseListener );
+                               }
+                               catch ( err )
+                               {
+                                       alert( err );
+                                       return;
+                               }
+                       },
+
+                       cleanup: function()
+                       {
+                               if ( Browse != null )
+                               {
+                                       Browse.stop();
+                                       Browse = null;
+                               }
+                       },
+
+
+                       browseListener: function( service, add, interfaceIndex, error, serviceName, regtype, domain )
+                       {
+                               if ( error == 0 )
+                               {
+                                       // First see if we can look this guy up
+
+                                       var treeView = document.getElementById( 'treeChildrenBrowseList' );
+                                       var treeItem = null;
+
+                                       for ( i = 1; i < treeView.childNodes.length; i++ )
+                                       {
+                                               var ti = treeView.childNodes[ i ];
+                                               var tr = ti.childNodes[ 0 ];
+                                               var tc = tr.childNodes[ 0 ];
+
+                                               if ( tc.getAttribute( 'label' ) == serviceName )
+                                               {
+                                                       treeItem = ti;
+                                                       break;
+                                               }
+                                       }
+       
+                                       if ( add )
+                                       {
+                                               // If we've already seen this guy, then bump up his reference count
+
+                                               if ( treeItem )
+                                               {
+                                                       var refcnt = treeItem.getUserData( 'refcnt' );
+                                                       refcnt++;
+                                               }
+                                               else
+                                               {
+                                                       var newTreeItem = document.createElement('treeitem');
+                                                       var newTreeRow = document.createElement('treerow');
+                                                       newTreeRow.setAttribute( 'properties', 'bonjourRow' );
+                                                       var newTreeCell = document.createElement('treecell');
+                                       newTreeCell.setAttribute( 'label', serviceName );
+                               
+                                                       newTreeItem.appendChild( newTreeRow );
+                                                       newTreeRow.appendChild( newTreeCell );
+                                                       newTreeItem.setUserData( 'interfaceIndex', interfaceIndex, null );
+                                       newTreeItem.setUserData( 'serviceName', serviceName, null );
+                                                       newTreeItem.setUserData( 'regtype', regtype, null );
+                                                       newTreeItem.setUserData( 'domain', domain, null );
+                                                       newTreeItem.setUserData( 'refcnt', 1, null );
+
+                                                       // Insert in alphabetical order
+
+                                                       var insertBefore = null;
+
+                                                       for ( i = 1; i < treeView.childNodes.length; i++ )
+                                                       {
+                                                               var ti = treeView.childNodes[ i ];
+                                                               var tr = ti.childNodes[ 0 ];
+                                                               var tc = tr.childNodes[ 0 ];
+               
+                                                               if ( serviceName.toLowerCase() < tc.getAttribute( 'label' ).toLowerCase() )
+                                                               {
+                                                                       insertBefore = ti;
+                                                                       break;
+                                                               }
+                                               }
+       
+                                                       if ( insertBefore != null )
+                                                       {
+                                                               treeView.insertBefore( newTreeItem, insertBefore );
+                                                       }
+                                                       else
+                                                       {
+                                                               treeView.appendChild( newTreeItem );
+                                                       }
+                                               }
+                                       }
+                                       else if ( treeItem )
+                                       {
+                                               var refcnt = treeItem.getUserData( 'refcnt' );
+                                               
+                                               if ( --refcnt == 0 )
+                                               {
+                                                       treeView.removeChild( treeItem );
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       alert( 'There was an error browsing for websites: ' + error );
+                               }
+                       },
+
+                       listListener: function( event )
+                       {
+                               var treeBrowseList = document.getElementById( 'treeBrowseList' );
+
+                               if ( treeBrowseList.currentIndex == 0 )
+                               {
+                                       window._content.location="http://www.apple.com/bonjour";
+                               }
+                               else
+                               {
+                                       var item = treeBrowseList.view.getItemAtIndex(treeBrowseList.currentIndex);
+
+                                       var interfaceIndex = item.getUserData("interfaceIndex");
+                                       var serviceName = item.getUserData("serviceName");
+                                       var regtype = item.getUserData("regtype");
+                                       var domain = item.getUserData("domain");
+
+                                       try
+                                       {
+                                               Resolve = Service.resolve( interfaceIndex, serviceName, regtype, domain, ResolveListener );
+                                       }
+                                       catch ( err )
+                                       {
+                                               alert( err );
+                                               return;
+                                       }
+                               }
+                       },
+
+                       resolveListener: function( service, interfaceIndex, error, fullname, host, port, path )
+                       {
+                               if ( error == 0 )
+                               {
+                                       window._content.location='http://' + host + ':' + port + path;
+                               }
+                               else
+                               {
+                                       alert( 'There was an error resolving ' + fullname );
+                               }
+
+                               Resolve.stop();
+                       },
+               };
+
+       ]]></script>
+</page>
diff --git a/Clients/FirefoxExtension/extension/content/browserOverlay.xul b/Clients/FirefoxExtension/extension/content/browserOverlay.xul
new file mode 100755 (executable)
index 0000000..3b4d668
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="chrome://bonjour4firefox/skin/overlay.css" type="text/css"?>
+<!DOCTYPE overlay SYSTEM "chrome://bonjour4firefox/locale/bonjour4firefox.dtd">
+<overlay id="bonjour4firefox-overlay"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+       <script src="overlay.js"/>
+       <stringbundleset id="stringbundleset">
+       <stringbundle id="bonjour4firefox-strings" src="chrome://bonjour4firefox/locale/bonjour4firefox.properties"/>
+       </stringbundleset>
+
+       <menupopup id="viewSidebarMenu">
+               <menuitem observes="viewBonjour4FirefoxSidebar"/>
+       </menupopup>
+
+       <toolbarpalette id="BrowserToolbarPalette">
+               <toolbarbutton id="bonjour4firefox-toolbar-button"
+               label="&bonjour4firefoxToolbar.label;"
+               tooltiptext="&bonjour4firefoxToolbar.tooltip;"
+               oncommand="toggleSidebar('viewBonjour4FirefoxSidebar');"
+               class="toolbarbutton-1 chromeclass-toolbar-additional"/>
+       </toolbarpalette>
+
+       <broadcasterset id="mainBroadcasterSet">
+               <broadcaster id="viewBonjour4FirefoxSidebar"
+                       autoCheck="false"
+                       label="Bonjour"
+                       type="checkbox" group="sidebar"
+                       sidebarurl="chrome://bonjour4firefox/content/bonjour4firefox.xul"
+                       sidebartitle="&bonjour4firefox.label;"
+                       oncommand="toggleSidebar('viewBonjour4FirefoxSidebar');"/>
+       </broadcasterset>
+</overlay>
diff --git a/Clients/FirefoxExtension/extension/content/listImage.png b/Clients/FirefoxExtension/extension/content/listImage.png
new file mode 100755 (executable)
index 0000000..278efe3
Binary files /dev/null and b/Clients/FirefoxExtension/extension/content/listImage.png differ
diff --git a/Clients/FirefoxExtension/extension/content/overlay.js b/Clients/FirefoxExtension/extension/content/overlay.js
new file mode 100755 (executable)
index 0000000..f989caa
--- /dev/null
@@ -0,0 +1,21 @@
+var bonjour4firefox = 
+{
+       onLoad: function()
+       {
+       // initialization code
+       this.initialized = true;
+       this.strings = document.getElementById("bonjour4firefox-strings");
+       },
+       onMenuItemCommand: function(e)
+       {
+       var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+               promptService.alert(window, this.strings.getString("helloMessageTitle"), this.strings.getString("helloMessage"));
+       },
+       onToolbarButtonCommand: function(e)
+       {
+       // just reuse the function above.  you can change this, obviously!
+       bonjour4firefox.onMenuItemCommand(e);
+       }
+};
+
+window.addEventListener("load", function(e) { bonjour4firefox.onLoad(e); }, false);
diff --git a/Clients/FirefoxExtension/extension/defaults/preferences/bonjour4firefox.js b/Clients/FirefoxExtension/extension/defaults/preferences/bonjour4firefox.js
new file mode 100755 (executable)
index 0000000..2965608
--- /dev/null
@@ -0,0 +1,2 @@
+// See http://kb.mozillazine.org/Localize_extension_descriptions
+pref("extensions.bonjour4firefox@apple.com.description", "chrome://bonjour4firefox/locale/bonjour4firefox.properties");
diff --git a/Clients/FirefoxExtension/extension/install.rdf b/Clients/FirefoxExtension/extension/install.rdf
new file mode 100755 (executable)
index 0000000..edf060d
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>bonjour4firefox@apple.com</em:id>
+    <em:name>Bonjour Extension for Firefox</em:name>
+    <em:version>1.0</em:version>
+    <em:creator>Apple Inc.</em:creator>
+    <em:description>Bonjour Browsing Extension for Firefox</em:description>
+    <em:iconURL>chrome://bonjour4firefox/content/bonjour4firefox.png</em:iconURL>
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- firefox -->
+        <em:minVersion>1.5</em:minVersion>
+        <em:maxVersion>3.5.*</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+  </Description>
+</RDF>
diff --git a/Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.dtd b/Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.dtd
new file mode 100755 (executable)
index 0000000..2e133f9
--- /dev/null
@@ -0,0 +1,6 @@
+<!ENTITY bonjour4firefox.label "Bonjour">
+<!ENTITY bonjour4firefoxToolbar.label "Bonjour">
+<!ENTITY bonjour4firefoxToolbar.tooltip "Display Bonjour enabled websites">
+<!ENTITY bonjour4firefoxSidebarOpenDefault.label "Open in current window">
+<!ENTITY bonjour4firefoxSidebarOpenTab.label "Open in new tab">
+<!ENTITY bonjour4firefoxSidebarOpenWindow.label "Open in new window">
diff --git a/Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.properties b/Clients/FirefoxExtension/extension/locale/en-US/bonjour4firefox.properties
new file mode 100755 (executable)
index 0000000..afed1ab
--- /dev/null
@@ -0,0 +1,4 @@
+helloMessage=Hello World!
+helloMessageTitle=Hello
+prefMessage=Int Pref Value: %d
+extensions.bonjour4firefox.description=Bonjour Browsing Extension for Firefox
diff --git a/Clients/FirefoxExtension/extension/readme.txt b/Clients/FirefoxExtension/extension/readme.txt
new file mode 100755 (executable)
index 0000000..71f1edc
--- /dev/null
@@ -0,0 +1,21 @@
+This extension was generated by the Extension Wizard at
+http://ted.mielczarek.org/code/mozilla/extensionwiz/ .
+This extension is compatible only with Firefox 1.5 and
+above.  Most of the files in this package are based on
+the 'helloworld' extension from the Mozillazine Knowledge Base.
+
+You can build an XPI for installation by running the
+build.sh script located in this folder.  For development
+you should do the following:
+  1. Unzip the entire contents of this package to somewhere,
+              e.g, c:\dev or /home/user/dev
+  2. Put the full path to the folder (e.g. c:\dev\bonjour4firefox on
+     Windows, /home/user/dev/bonjour4firefox on Linux) in a file named
+     bonjour4firefox@apple.com and copy that file to
+     [your profile folder]\extensions\
+  3. Restart Firefox.
+
+For more information, see the Mozillazine Knowledge Base:
+http://kb.mozillazine.org/Getting_started_with_extension_development
+
+-Ted Mielczarek <ted.mielczarek@gmail.com>
diff --git a/Clients/FirefoxExtension/extension/skin-darwin/overlay.css b/Clients/FirefoxExtension/extension/skin-darwin/overlay.css
new file mode 100644 (file)
index 0000000..e78635b
--- /dev/null
@@ -0,0 +1,17 @@
+#bonjour4firefox-hello
+{
+  color: red ! important;
+}
+#bonjour4firefox-toolbar-button
+{
+  list-style-image: url("chrome://bonjour4firefox/skin/toolbar-button.png");
+  -moz-image-region: rect(0px 36px 23px 0px);
+}
+#bonjour4firefox-toolbar-button[disabled="true"]
+{
+  -moz-image-region: rect(23px 36px 46px 0px);
+}
+#bonjour4firefox-toolbar-button:hover:active
+{
+  -moz-image-region: rect(46px 36px 69px 0px);
+}
diff --git a/Clients/FirefoxExtension/extension/skin-darwin/toolbar-button.png b/Clients/FirefoxExtension/extension/skin-darwin/toolbar-button.png
new file mode 100644 (file)
index 0000000..2bd6c9d
Binary files /dev/null and b/Clients/FirefoxExtension/extension/skin-darwin/toolbar-button.png differ
diff --git a/Clients/FirefoxExtension/extension/skin/overlay.css b/Clients/FirefoxExtension/extension/skin/overlay.css
new file mode 100755 (executable)
index 0000000..b192b52
--- /dev/null
@@ -0,0 +1,21 @@
+#bonjour4firefox-hello
+{
+  color: black ! important;
+}
+#bonjour4firefox-toolbar-button
+{
+  list-style-image: url("chrome://bonjour4firefox/skin/toolbar-button.png");
+  -moz-image-region: rect(0px 24px 24px 0px);
+}
+#bonjour4firefox-toolbar-button:hover
+{
+  -moz-image-region: rect(24px 24px 48px  0px);
+}
+[iconsize="small"] #bonjour4firefox-toolbar-button
+{
+  -moz-image-region: rect( 0px 40px 16px 24px);
+}
+[iconsize="small"] #bonjour4firefox-toolbar-button:hover
+{
+  -moz-image-region: rect(24px 40px 40px 24px);
+}
diff --git a/Clients/FirefoxExtension/extension/skin/toolbar-button.png b/Clients/FirefoxExtension/extension/skin/toolbar-button.png
new file mode 100755 (executable)
index 0000000..d99a0c9
Binary files /dev/null and b/Clients/FirefoxExtension/extension/skin/toolbar-button.png differ