NB2:BLE API

11/18/04

Home
Up
AC Utilities
Clan Sway

NB2:BLE NBLite Morgue Valet


Nerfus Buffus II: Bootleg Edition has API to allow other plug-ins to request service.

Here's the example of how to do this in C++.

In order to use API, your plug-in must import NerfusBuffus2.dll by including:

#import "C:\Program Files\NerfSoft\NerfusBuffus2\NerfusBuffus2.dll" rename_namespace("NB2")

Then somewhere in your initialization, you need to acquire the handle to NB2:BLE

try
{
m_pNB2 = m_pSite->GetPlugin("{C050FED0-E7A2-4378-9536-4166B77BA2DA}");
m_pNB2->GetNB2State(); // Here we are checking to make sure NB2 we found has API

m_pNB2->Connect( (NB2::INB2EventsPtr) this );

CHAT(":: Linked to Nerfus Buffus API.");
m_log.LogMessage(6, "Found Nerfus Buffus:BLE v2.00 or later." );
}
catch(...)
{
m_pNB2 = NULL;
CHAT(":: Nerfus Buffus:BLE v2.00 or later is not installed.");
m_log.LogMessage(6, "Nerfus Buffus:BLE v2.00 or later is not installed." );
}

The Connect() call is technically not necessary if you are only interested in requesting services from NB2:BLE. But unless you call Connect(), NB2:BLE will not send you any events.

The GetNB2State() is used here to ensure that NB2 you have just acquired does indeed support the API. If it does not, it will throw an exception, and you will end up in the catch clause. The handler is then reset to NULL so you can test for the API's availability later.

There are many calls you can make to NB2:BLE's API. You can look at the IDL here.

In addition to calling Connect(), you need to prepare event handlers to receive the events from NB2:BLE. To do so, you must declare a class that inherit from INB2Events. Such as following:

class ATL_NO_VTABLE INB2EventsImpl : public NB2::INB2Events
{

STDMETHODIMP raw_NB2StateChanged( NB2::eNB2Status eNewState ) {return S_OK;}

STDMETHODIMP raw_NB2StartStep( IUnknown * pXMLNode ) {return S_OK;}

STDMETHODIMP raw_NBTerminated( VARIANT_BOOL bSuccess ) {return S_OK;}

};

You could then have your main class inherit from this class, and override the one or more of event handlers. You could also create a whole new object to handle the communication to NB2:BLE as well. Choice is up to you.

The Connect() method takes the object which include the event hander as an argument.

Above example is extracted from NBLite, the complete source code for NBLite v1.00 is available here.
 

Home Up

This site was last updated 11/21/2004