ASP & XML Application
User Sign in and Sign out: This feature is provided to the user to sign in and set up preferences to render the toolbar. The preferences store is an ASP application. The user has to first register with this application to set up the preferences for buttons and links as well as mail server configuration. The preferences are stored in a database. At the time of rendering the toolbar, the toolbar connects to the ASP application at the web server to fetch the users’ preferences. The ASP application returns the preferences in an XML file in the following format.
ImageHot="IDB_LOGO" Text="LoginSoft"
Id="IDS_LOGINSOFT" Render="url"
Address="www.loginsoft.com" Default="TRUE">
ImageHot="IDB_LOGO" Text="Partners"
Id="IDS_PARTNERS" MenuID="IDR_PARTNERS"
MenuItemcount="2" Default="TRUE">
MenuItemAddress="www.inin.com"/>
MenuItemAddress="www.microsoft.com"/>
The XML file is parsed by the toolbar to identify the buttons and the same is rendered on the toolbar.
The toolbar at any point displays only one of the buttons i.e. Sign In or Sign Out. Sign In button appears when there is no session open with the user. Hence no cookie is deployed. The toolbar is constructed with only default elements and the standard section. As long as the session is open, Sign Out button is rendered on the toolbar.
On clicking Sign In, a session is maintained with the server, which deploys a cookie at the clients/user’s end. As long as the cookie exists on the client, the session is maintained. On Sign out, the session gets closed and the cookie is destroyed.
Http Connection
I know you must be wondering how does the toolbar connect to an ASP application running on a web server far away. The answer is to open an Http connection with the server. In this case, we are opening an Internet session with the server with the help of CInternetSession class of “afxinet” library. Through CInterentSession object we obtain CHttpConnection Object
CHttpConnection object manages your connection to an HTTP server. After obtaining the Connection object, OpenRequest method is invoked to get CHttpFile object.
The class CHttpFile provides the functionality to request and read files on an HTTP server. Through this object the toolbar sends the cookie name to the server for validation and retrieves XML file from the HTTP server.
In case of failure in obtaining the Connection with the HTTP server, then the toolbar is rendered using a Config file present at the client’s end.
Understanding the Technology |
The basic procedure adopted for creating Login Soft Toolbar is:
1. Implement the functions needed by the DLL.
2. Implement the required COM interfaces.
3. Implement any desired optional COM interfaces.
4. Register the object's CLSID.
5. Create a child window, sized to fit the band’s display region.
6. Use the child window to display toolbar and interact with the user.
Apart from the above-mentioned points, this section also covers few details regarding different approaches followed and problems faced during the construction of the toolbar.
Implementing DLL Functions
The DLL exposes the following functions. The toolbar implements these functions and makes appropriate method calls.
DllGetClassObject: This is an entry point for all DLL COM servers. This function on invocation returns a class factory to create an object of the tool band type.
DllCanUnloadNow: This determines whether the DLL that implements this function is in use. If not in use, then the caller can safely unload the DLL from the memory.
DllRegisterServer: This function is used while registering the DLL. The Regsvr32 command calls the Windows LoadLibrary ( ) API on the toolbar DLL name; followed by a call to DllRegisterServer ( ). If this function fails, the program reports an error.
DllUnregisterServer: This function is invoked when unregistering the toolbar DLL.
|