Ejemplo n.º 1
0
STDMETHODIMP	ExplorerBar::Save( LPSTREAM inStream, BOOL inClearDirty )
{
	DEBUG_UNUSED( inStream );
	DEBUG_UNUSED( inClearDirty );
	
	return( S_OK );
}
Ejemplo n.º 2
0
STDMETHODIMP	ExplorerBar::ResizeBorderDW( LPCRECT inBorder, IUnknown *inPunkSite, BOOL inReserved )
{
	DEBUG_UNUSED( inBorder );
	DEBUG_UNUSED( inPunkSite );
	DEBUG_UNUSED( inReserved );
	
	return( E_NOTIMPL );
}
Ejemplo n.º 3
0
// Not called for explorer bars
STDMETHODIMP ExplorerBar::GetCommandString(UINT idCmd, UINT uType, UINT* pwReserved, LPSTR pszName, UINT cchMax)
{
	DEBUG_UNUSED( idCmd );
	DEBUG_UNUSED( uType );
	DEBUG_UNUSED( pwReserved );
	DEBUG_UNUSED( pszName );
	DEBUG_UNUSED( cchMax );

	return E_NOTIMPL;
}
Ejemplo n.º 4
0
// ------------------------------------------------------
// OnSetCursor
//
// This is called when Windows wants to know what cursor
// to display.  So we tell it.  
//	
BOOL
CPrinterSetupWizardSheet::OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message)
{
	DEBUG_UNUSED(pWnd);
	DEBUG_UNUSED(nHitTest);
	DEBUG_UNUSED(message);

	SetCursor(m_active);
	return TRUE;
}
Ejemplo n.º 5
0
void
CPrinterSetupWizardSheet::OnContextMenu(CWnd * pWnd, CPoint pos)
{
	DEBUG_UNUSED(pWnd);
	DEBUG_UNUSED(pos);

	CAbout dlg;

	dlg.DoModal();
}
void DNSSD_API
CConfigPropertySheet::BrowseDomainsReply
							(
							DNSServiceRef			sdRef,
							DNSServiceFlags			flags,
							uint32_t				interfaceIndex,
							DNSServiceErrorType		errorCode,
							const char			*	replyDomain,
							void				*	context
							)
{
	CConfigPropertySheet	*	self = reinterpret_cast<CConfigPropertySheet*>(context);
	CString						decoded;
	OSStatus					err;

	DEBUG_UNUSED( sdRef );
	DEBUG_UNUSED( interfaceIndex );

	if ( errorCode )
	{
		goto exit;
	}

	check( replyDomain );
	
	// Ignore local domains

	if ( strcmp( replyDomain, "local." ) == 0 )
	{
		goto exit;
	}



	err = self->DecodeDomainName( replyDomain, decoded );
	require_noerr( err, exit );

	// Remove trailing '.'

	decoded.TrimRight( '.' );

	if ( flags & kDNSServiceFlagsAdd )
	{
		self->m_browseDomains.push_back( decoded );
	}
	else
	{
		self->m_browseDomains.remove( decoded );
	}

exit:

	return;
}
afx_msg LRESULT
CConfigPropertySheet::OnRegistryChanged( WPARAM inWParam, LPARAM inLParam )
{
	DEBUG_UNUSED( inWParam );
	DEBUG_UNUSED( inLParam );

	if ( GetActivePage() == &m_firstPage )
	{
		m_firstPage.OnRegistryChanged();
	}

	return 0;
}
Ejemplo n.º 8
0
OSStatus
CPrinterSetupWizardSheet::OnAddService(
								Printer		*	printer,
								uint32_t 		inInterfaceIndex,
								const char	*	inName,	
								const char	*	inType,	
								const char	*	inDomain)
{
	Service	*	service = NULL;
	OSStatus	err     = kNoErr;

	DEBUG_UNUSED( inName );
	DEBUG_UNUSED( inDomain );

	try
	{
		service = new Service;
	}
	catch (...)
	{
		service = NULL;
	}

	require_action( service, exit, err = E_OUTOFMEMORY );
	
	service->printer	=	printer;
	service->ifi		=	inInterfaceIndex;
	service->type		=	inType;
	service->domain		=	inDomain;
	service->qtotal		=	1;
	service->refs		=	1;
	service->serviceRef	=	NULL;

	printer->services.push_back( service );

	//
	// if the printer is selected, then we'll want to start a
	// resolve on this guy
	//

	if ( printer == m_selectedPrinter )
	{
		StartResolve( service );
	}

exit:

	return err;
}
Ejemplo n.º 9
0
bool
com_ximeta_driver_NDASProtocolTransport::HandleProtocolServiceFeature (
												 SCSIProtocolFeature	feature, 
												 void *				serviceValue 
												 )
{
	
	DEBUG_UNUSED ( feature );
	DEBUG_UNUSED ( serviceValue );
	
	DbgIOLog(DEBUG_MASK_DISK_TRACE, ("HandleProtocolServiceFeature: Entered. feature %d\n", (uint32_t)feature));
	
	return false;
	
}
Ejemplo n.º 10
0
LRESULT
CCPApplet::OnNewInquire(NEWCPLINFO* pInfo)
{
	DEBUG_UNUSED( pInfo );

	return 1;
}
Ejemplo n.º 11
0
void DNSSD_API
CSecondPage::OnBrowse(
				DNSServiceRef 			inRef,
				DNSServiceFlags 		inFlags,
				uint32_t 				inInterfaceIndex,
				DNSServiceErrorType 	inErrorCode,
				const char *			inName,	
				const char *			inType,	
				const char *			inDomain,	
				void *					inContext )
{
	DEBUG_UNUSED(inRef);

	CSecondPage	*	self;
	bool			moreComing = (bool) (inFlags & kDNSServiceFlagsMoreComing);

	require_noerr( inErrorCode, exit );
	
	self = reinterpret_cast <CSecondPage*>( inContext );
	require_quiet( self, exit );

	if ( inFlags & kDNSServiceFlagsAdd )
	{
		self->OnAddPrinter( inInterfaceIndex, inName, inType, inDomain, moreComing );
	}
	else
	{
		self->OnRemovePrinter( inName, inType, inDomain, moreComing );
	}

exit:
	
	return;
}
OSStatus
CPrinterSetupWizardSheet::InstallPrinterIPP(Printer * printer, Service * service)
{
	DEBUG_UNUSED( service );

	HANDLE			hPrinter = NULL;
	PRINTER_INFO_2	pInfo;
	OSStatus		err;
	
	//
	// add the printer
	//
	ZeroMemory(&pInfo, sizeof(PRINTER_INFO_2));
	
	pInfo.pPrinterName		= printer->actualName.GetBuffer();
	pInfo.pPortName			= printer->portName.GetBuffer();
	pInfo.pDriverName		= printer->model.GetBuffer();
	pInfo.pPrintProcessor	= L"winprint";
	pInfo.pLocation			= service->location.GetBuffer();
	pInfo.Attributes		= PRINTER_ATTRIBUTE_NETWORK | PRINTER_ATTRIBUTE_LOCAL;
	
	hPrinter = AddPrinter(NULL, 2, (LPBYTE)&pInfo);
	err = translate_errno( hPrinter, errno_compat(), kUnknownErr );
	require_noerr( err, exit );

exit:

	if ( hPrinter != NULL )
	{
		ClosePrinter(hPrinter);
	}

	return err;
}
Ejemplo n.º 13
0
void	ExplorerBarWindow::OnDoubleClick( NMHDR *inNMHDR, LRESULT *outResult )
{
	HTREEITEM			item;
	ServiceInfo *		service;
	OSStatus			err;
	
	DEBUG_UNUSED( inNMHDR );
	
	item = mTree.GetSelectedItem();
	require( item, exit );
	
	// Tell Internet Explorer to go to the URL if it's about item
	
	if ( item == m_about )
	{
		CString url;

		check( mOwner );

		url.LoadString( IDS_ABOUT_URL );
		mOwner->GoToURL( url );
	}
	else
	{
		service = reinterpret_cast < ServiceInfo * > ( mTree.GetItemData( item ) );
		require_quiet( service, exit );
		
		err = StartResolve( service );
		require_noerr( err, exit );
	}

exit:
	*outResult = 0;
}
Ejemplo n.º 14
0
void CSecondPage::OnTvnKeyDownBrowseList( NMHDR * pNMHDR, LRESULT * pResult)
{
	DEBUG_UNUSED( pNMHDR );

	m_gotChoice = true;

	*pResult = 0;
}
Ejemplo n.º 15
0
static IOReturn
CriticalCompleteStatic ( 
						 OSObject *	refCon, 
						 void *		val1,
						 void *		val2,
						 void *		val3,
						 void *		val4 
						 )
{
	DEBUG_UNUSED ( val2 );
	DEBUG_UNUSED ( val3 );
	DEBUG_UNUSED ( val4 );
	
	( ( com_ximeta_driver_NDASProtocolTransport * ) refCon )->CriticalComplete ( ( com_ximeta_driver_NDASSCSICommand *) val1 );
	
	return kIOReturnSuccess;
	
}
Ejemplo n.º 16
0
afx_msg BOOL
CSecondPage::OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT message)
{
	DEBUG_UNUSED(pWnd);
	DEBUG_UNUSED(nHitTest);
	DEBUG_UNUSED(message);

	CPrinterSetupWizardSheet * psheet;

	psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
	require_quiet( psheet, exit );

	SetCursor(psheet->GetCursor());

exit:

	return TRUE;
}
Ejemplo n.º 17
0
LONG
CPrinterSetupWizardSheet::OnProcessEvent(WPARAM inWParam, LPARAM inLParam)
{
	DEBUG_UNUSED(inLParam);

	m_driverThreadExitCode	=	(DWORD) inWParam;
	m_driverThreadFinished	=	true;

	return 0;
}
Ejemplo n.º 18
0
STDMETHODIMP	ExplorerBar::UIActivateIO( BOOL inActivate, LPMSG inMsg )
{
	DEBUG_UNUSED( inMsg );
	
	if( inActivate )
	{
		mWindow.SetFocus();
	}
	return( S_OK );
}
Ejemplo n.º 19
0
STDMETHODIMP  ExplorerBar::QueryContextMenu(HMENU hShellContextMenu, UINT iContextMenuFirstItem, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
	DEBUG_UNUSED( idCmdLast );
	DEBUG_UNUSED( uFlags );

	CMenu menubar;

	menubar.LoadMenu(IDR_CONTEXT_MENU);
	CMenu * menu = menubar.GetSubMenu(0);

	CMenu shellmenu;

	shellmenu.Attach(hShellContextMenu);

	UINT iShellItem = iContextMenuFirstItem;	//! remove plus one
	UINT idShellCmd = idCmdFirst;

	int n = menu->GetMenuItemCount();

	for (int i=0; i<n; ++i)
	{
		MENUITEMINFO	mii;
		TCHAR				sz[128] = {0};
		
		ZeroMemory(&mii, sizeof(mii));
		mii.fMask		= MIIM_TYPE | MIIM_ID;
		mii.fType		= MFT_STRING;
		mii.cbSize		= sizeof(mii);
		mii.cch			= LENGTHOF(sz);
		mii.dwTypeData	= sz;
		
		menu->GetMenuItemInfo(i, &mii, TRUE);

		mii.wID = idShellCmd++;

		shellmenu.InsertMenuItem(iShellItem++, &mii, TRUE);
	}

	shellmenu.Detach();

	return n;
}
Ejemplo n.º 20
0
STDMETHODIMP	ExplorerBar::CloseDW( DWORD inReserved )
{
	DEBUG_UNUSED( inReserved );

	ShowDW( FALSE );
	if( mWindow.GetSafeHwnd() )
	{
		mWindow.SendMessage( WM_CLOSE );
	}
	return( S_OK );
}
Ejemplo n.º 21
0
LRESULT
CCPApplet::OnStartParms(CWnd * pParentWnd, LPCTSTR extra)
{
	DEBUG_UNUSED( pParentWnd );

	if ( extra )
	{
		m_pageNumber = ::_ttoi( extra ) - 1;
	}

	return 0;
}
Ejemplo n.º 22
0
SCSIServiceResponse
com_ximeta_driver_NDASProtocolTransport::AbortSCSICommand (
									 SCSITaskIdentifier request 
									 )
{
	DEBUG_UNUSED ( request );
	
	SCSIServiceResponse		serviceResponse = kSCSIServiceResponse_FUNCTION_REJECTED;

	DbgIOLog(DEBUG_MASK_DISK_WARNING, ("AbortSCSICommand: Entered.\n"));
	
	return serviceResponse;
	
}
Ejemplo n.º 23
0
// -------------------------------------------------------
// MatchGeneric
//
// This function will attempt to find a generic printer
// driver for a printer that we weren't able to match
// specifically
//
BOOL
CThirdPage::MatchGeneric( Manufacturers & manufacturers, Printer * printer, Service * service, Manufacturer ** manufacturer, Model ** model )
{
    CString	pdl;
    BOOL	ok = FALSE;

    DEBUG_UNUSED( printer );

    check( service );

    Queue * q = service->SelectedQueue();

    check( q );

    Manufacturers::iterator iter = manufacturers.find( kGenericManufacturer );
    require_action_quiet( iter != manufacturers.end(), exit, ok = FALSE );

    *manufacturer = iter->second;

    pdl = q->pdl;
    pdl.MakeLower();

    if ( m_genericPCL && ( pdl.Find( kPDLPCLKey ) != -1 ) )
    {
        *model	= m_genericPCL;
        ok		= TRUE;
    }
    else if ( m_genericPostscript && ( pdl.Find( kPDLPostscriptKey ) != -1 ) )
    {
        *model	= m_genericPostscript;
        ok		= TRUE;
    }

exit:

    return ok;
}
Ejemplo n.º 24
0
void DNSSD_API
CPrinterSetupWizardSheet::OnBrowse(
							DNSServiceRef 			inRef,
							DNSServiceFlags 		inFlags,
							uint32_t 				inInterfaceIndex,
							DNSServiceErrorType 	inErrorCode,
							const char *			inName,	
							const char *			inType,	
							const char *			inDomain,	
							void *					inContext )
{
	DEBUG_UNUSED(inRef);

	CPrinterSetupWizardSheet	*	self;
	bool							moreComing = (bool) (inFlags & kDNSServiceFlagsMoreComing);
	CPropertyPage				*	active;
	Printer						*	printer = NULL;
	Service						*	service = NULL;
	OSStatus						err = kNoErr;

	require_noerr( inErrorCode, exit );
	
	self = reinterpret_cast <CPrinterSetupWizardSheet*>( inContext );
	require_quiet( self, exit );

	active = self->GetActivePage();
	require_quiet( active, exit );

	// Have we seen this printer before?

	printer = self->Lookup( inName );

	if ( printer )
	{
		service = printer->LookupService( inType );
	}

	if ( inFlags & kDNSServiceFlagsAdd )
	{
		if (printer == NULL)
		{
			// If not, then create a new one

			printer = self->OnAddPrinter( inInterfaceIndex, inName, inType, inDomain, moreComing );
			require_action( printer, exit, err = kUnknownErr );
		}

		if ( !service )
		{
			err = self->OnAddService( printer, inInterfaceIndex, inName, inType, inDomain );
			require_noerr( err, exit );
		}
		else
		{
			service->refs++;
		}
	}
	else if ( printer )
	{
		check( service );

		err = self->OnRemoveService( service );
		require_noerr( err, exit );

		if ( printer->services.size() == 0 )
		{
			err = self->OnRemovePrinter( printer, moreComing );
			require_noerr( err, exit );
		}
	}

exit:
	
	return;
}
Ejemplo n.º 25
0
Printer*
CPrinterSetupWizardSheet::OnAddPrinter(
								uint32_t 		inInterfaceIndex,
								const char *	inName,	
								const char *	inType,	
								const char *	inDomain,
								bool			moreComing)
{
	Printer	*	printer = NULL;
	DWORD		printerNameCount;
	OSStatus	err;

	DEBUG_UNUSED( inInterfaceIndex );
	DEBUG_UNUSED( inType );
	DEBUG_UNUSED( inDomain );

	try
	{
		printer = new Printer;
	}
	catch (...)
	{
		printer = NULL;
	}

	require_action( printer, exit, err = E_OUTOFMEMORY );

	printer->window		=	this;
	printer->name		=	inName;
	
	err = UTF8StringToStringObject(inName, printer->displayName);
	check_noerr( err );
	printer->actualName	=	printer->displayName;
	printer->installed	=	false;
	printer->deflt		=	false;
	printer->resolving	=	0;

	// Compare this name against printers that are already installed
	// to avoid name clashes.  Rename as necessary
	// to come up with a unique name.

	printerNameCount = 2;

	for (;;)
	{
		CPrinterSetupWizardSheet::PrinterNames::iterator it;

		// <rdar://problem/4141221> Don't use find to do comparisons because we need to
		// do a case insensitive string comparison

		for ( it = m_printerNames.begin(); it != m_printerNames.end(); it++ )
		{
			if ( (*it).CompareNoCase( printer->actualName ) == 0 )
			{
				break;
			}
		}

		if (it != m_printerNames.end())
		{
			printer->actualName.Format(L"%s (%d)", printer->displayName, printerNameCount);
		}
		else
		{
			break;
		}

		printerNameCount++;
	}

	m_printers.push_back( printer );

	if ( GetActivePage() == &m_pgSecond )
	{
		m_pgSecond.OnAddPrinter( printer, moreComing );
	}

exit:

	return printer;
}
Ejemplo n.º 26
0
void DNSSD_API
CSecondPage::OnQuery(
				DNSServiceRef		inRef, 
				DNSServiceFlags		inFlags, 
				uint32_t			inInterfaceIndex, 
				DNSServiceErrorType inErrorCode,
				const char		*	inFullName, 
				uint16_t			inRRType, 
				uint16_t			inRRClass, 
				uint16_t			inRDLen, 
				const void		*	inRData, 
				uint32_t			inTTL, 
				void			*	inContext)
{
	DEBUG_UNUSED( inTTL );
	DEBUG_UNUSED( inRRClass );
	DEBUG_UNUSED( inRRType );
	DEBUG_UNUSED( inFullName );
	DEBUG_UNUSED( inInterfaceIndex );
	DEBUG_UNUSED( inRef );

	Service		*	service = NULL;
	Queue		*	q;
	CSecondPage	*	self;
	bool			qtotalDefined = false;
	bool			moreComing = (bool) (inFlags & kDNSServiceFlagsMoreComing);
	OSStatus		err = kNoErr;

	require_noerr( inErrorCode, exit );

	service = reinterpret_cast<Service*>( inContext );
	require_quiet( service, exit);

	self = service->printer->window;
	require_quiet( self, exit );

	if ( ( inFlags & kDNSServiceFlagsAdd ) && ( inRDLen > 0 ) && ( inRData != NULL ) )
	{
		const char * inTXT = ( const char * ) inRData;

		//
		// create a new queue
		//
		try
		{
			q = new Queue;
		}
		catch (...)
		{
			q = NULL;
		}

		require_action( q, exit, err = E_OUTOFMEMORY );

		err = service->printer->window->ParseTextRecord( service, inRDLen, inTXT, qtotalDefined, q->name, q->priority );
		require_noerr( err, exit );

		if ( !qtotalDefined )
		{
			q->name = L"";
		}

		//
		// add this queue
		//

		service->queues.push_back( q );

		if ( service->queues.size() == service->qtotal )
		{
			//
			// else if moreComing is not set, then we're going
			// to assume that we're done
			//

			self->StopOperation( service->serviceRef );

			//
			// sort the queues
			//

			service->queues.sort( OrderQueueFunc );

			//
			// we've completely resolved this service
			//

			self->OnResolveService( service );
		}
	}

exit:

	if ( err && service && ( service->serviceRef != NULL ) )
	{
		service->printer->window->StopOperation( service->serviceRef );
	}

	return;
}
Ejemplo n.º 27
0
void DNSSD_API
CSecondPage::OnResolve(
				DNSServiceRef			inRef,
				DNSServiceFlags			inFlags,
				uint32_t				inInterfaceIndex,
				DNSServiceErrorType		inErrorCode,
				const char *			inFullName,	
				const char *			inHostName, 
				uint16_t 				inPort,
				uint16_t 				inTXTSize,
				const char *			inTXT,
				void *					inContext )
{
	DEBUG_UNUSED(inFullName);
	DEBUG_UNUSED(inInterfaceIndex);
	DEBUG_UNUSED(inFlags);
	DEBUG_UNUSED(inRef);

	CSecondPage	*	self;
	Service		*	service;
	Queue		*	q;
	bool			qtotalDefined = false;
	uint32_t		qpriority = kDefaultPriority;
	CString			qname;
	int				idx;
	OSStatus		err;

	require_noerr( inErrorCode, exit );

	service = reinterpret_cast<Service*>( inContext );
	require_quiet( service, exit);

	check( service->refs != 0 );

	self = service->printer->window;
	require_quiet( self, exit );

	err = self->StopOperation( service->serviceRef );
	require_noerr( err, exit );
	
	//
	// hold on to the hostname...
	//
	err = UTF8StringToStringObject( inHostName, service->hostname );
	require_noerr( err, exit );

	//
	// <rdar://problem/3739200> remove the trailing dot on hostname
	//
	idx = service->hostname.ReverseFind('.');

	if ((idx > 1) && ((service->hostname.GetLength() - 1) == idx))
	{
		service->hostname.Delete(idx, 1);
	}

	//
	// hold on to the port
	//
	service->portNumber = ntohs(inPort);

	//
	// parse the text record.
	//

	err = self->ParseTextRecord( service, inTXTSize, inTXT, qtotalDefined, qname, qpriority );
	require_noerr( err, exit );

	if ( service->qtotal == 1 )
	{	
		//
		// create a new queue
		//
		try
		{
			q = new Queue;
		}
		catch (...)
		{
			q = NULL;
		}

		require_action( q, exit, err = E_OUTOFMEMORY );

		if ( qtotalDefined )
		{
			q->name = qname;
		}

		q->priority = qpriority;
		
		service->queues.push_back( q );

		//
		// we've completely resolved this service
		//

		self->OnResolveService( service );
	}
	else
	{
		//
		// if qtotal is more than 1, then we need to get additional
		// text records.  if not, then this service is considered
		// resolved
		//

		err = DNSServiceQueryRecord(&service->serviceRef, 0, inInterfaceIndex, inFullName, kDNSServiceType_TXT, kDNSServiceClass_IN, OnQuery, (void*) service );
		require_noerr( err, exit );

		err = self->StartOperation( service->serviceRef );
		require_noerr( err, exit );
	}

exit:

	return;
}
Ejemplo n.º 28
0
void DNSSD_API
	ExplorerBarWindow::BrowseCallBack(
		DNSServiceRef 			inRef,
		DNSServiceFlags 		inFlags,
		uint32_t 				inInterfaceIndex,
		DNSServiceErrorType 	inErrorCode,
		const char *			inName,	
		const char *			inType,	
		const char *			inDomain,	
		void *					inContext )
{
	ServiceHandlerEntry *		obj;
	ServiceInfo *				service;
	OSStatus					err;
	
	DEBUG_UNUSED( inRef );
	
	obj		=	NULL;
	service = NULL;
	
	require_noerr( inErrorCode, exit );
	obj = reinterpret_cast < ServiceHandlerEntry * > ( inContext );
	check( obj );
	check( obj->obj );
	
	//
	// set the UI to hold off on updates
	//
	obj->obj->mTree.SetRedraw(FALSE);

	try
	{
		service = new ServiceInfo;
		require_action( service, exit, err = kNoMemoryErr );
		
		err = UTF8StringToStringObject( inName, service->displayName );
		check_noerr( err );

		service->name = strdup( inName );
		require_action( service->name, exit, err = kNoMemoryErr );
		
		service->type = strdup( inType );
		require_action( service->type, exit, err = kNoMemoryErr );
		
		service->domain = strdup( inDomain );
		require_action( service->domain, exit, err = kNoMemoryErr );
		
		service->ifi 		= inInterfaceIndex;
		service->handler	= obj;

		service->refs		= 1;
		
		if (inFlags & kDNSServiceFlagsAdd) obj->obj->OnServiceAdd   (service);
		else                               obj->obj->OnServiceRemove(service);
	
		service = NULL;
	}
	catch( ... )
	{
		dlog( kDebugLevelError, "BrowseCallBack: exception thrown\n" );
	}
	
exit:
	//
	// If no more coming, then update UI
	//
	if (obj && obj->obj && ((inFlags & kDNSServiceFlagsMoreComing) == 0))
	{
		obj->obj->mTree.SetRedraw(TRUE);
		obj->obj->mTree.Invalidate();
	}

	if( service )
	{
		delete service;
	}
}
Ejemplo n.º 29
0
OSStatus
CSecondPage::OnRemovePrinter(
				const char *	inName,	
				const char *	inType,	
				const char *	inDomain,
				bool			moreComing)
{
	DEBUG_UNUSED( inDomain );
	DEBUG_UNUSED( inType );

	Printer	*	printer;
	OSStatus	err = kNoErr;

	check( IsWindow( m_hWnd ) );

	m_browseList.SetRedraw(FALSE);

	printer = Lookup( inName );

	if ( printer )
	{
		Service * service;

		service = printer->LookupService( inType );

		if ( service && ( --service->refs == 0 ) )
		{
			if ( service->serviceRef != NULL )
			{
				err = StopResolve( service );
				require_noerr( err, exit );
			}

			printer->services.remove( service );

			delete service;
		}

		if ( printer->services.size() == 0 )
		{
			//
			// check to make sure if we're the only item in the control...i.e.
			// the list size is 1.
			//
			if (m_browseList.GetCount() > 1)
			{
				//
				// if we're not the only thing in the list, then
				// simply remove it from the list
				//
				m_browseList.DeleteItem( printer->item );
			}
			else
			{
				//
				// if we're the only thing in the list, then redisplay
				// it with the no rendezvous printers message
				//
				InitBrowseList();
			}

			m_printers.remove( printer );

			if ( m_selected == printer )
			{
				m_selected		= NULL;
				m_selectedName	= "";
			}

			delete printer;
		}
	}

exit:

	if (!moreComing)
	{
		m_browseList.SetRedraw(TRUE);
		m_browseList.Invalidate();
	}

	return err;
}
Ejemplo n.º 30
0
void DNSSD_API
	ExplorerBarWindow::ResolveCallBack(
		DNSServiceRef			inRef,
		DNSServiceFlags			inFlags,
		uint32_t				inInterfaceIndex,
		DNSServiceErrorType		inErrorCode,
		const char *			inFullName,	
		const char *			inHostName, 
		uint16_t 				inPort,
		uint16_t 				inTXTSize,
		const char *			inTXT,
		void *					inContext )
{
	ExplorerBarWindow *			obj;
	ServiceHandlerEntry *		handler;
	OSStatus					err;
	
	DEBUG_UNUSED( inRef );
	DEBUG_UNUSED( inFlags );
	DEBUG_UNUSED( inErrorCode );
	DEBUG_UNUSED( inFullName );
	
	require_noerr( inErrorCode, exit );
	handler = (ServiceHandlerEntry *) inContext;
	check( handler );
	obj = handler->obj;
	check( obj );
	
	try
	{
		ResolveInfo *		resolve;
		int					idx;
		
		dlog( kDebugLevelNotice, "resolved %s on ifi %d to %s\n", inFullName, inInterfaceIndex, inHostName );
		
		// Stop resolving after the first good result.
		
		obj->StopResolve();
		
		// Post a message to the main thread so it can handle it since MFC is not thread safe.
		
		resolve = new ResolveInfo;
		require_action( resolve, exit, err = kNoMemoryErr );
		
		UTF8StringToStringObject( inHostName, resolve->host );

		// rdar://problem/3841564
		// 
		// strip trailing dot from hostname because some flavors of Windows
		// have trouble parsing it.

		idx = resolve->host.ReverseFind('.');

		if ((idx > 1) && ((resolve->host.GetLength() - 1) == idx))
		{
			resolve->host.Delete(idx, 1);
		}

		resolve->port		= ntohs( inPort );
		resolve->ifi		= inInterfaceIndex;
		resolve->handler	= handler;
		
		err = resolve->txt.SetData( inTXT, inTXTSize );
		check_noerr( err );
		
		obj->OnResolve(resolve);
	}
	catch( ... )
	{
		dlog( kDebugLevelError, "ResolveCallBack: exception thrown\n" );
	}

exit:
	return;
}