home *** CD-ROM | disk | FTP | other *** search
-
- //
- // nptree.cpp - CPU Monitor Plug-in
- //
-
- #include "..\inc\stdafx.h"
- #include "nptree.h"
- #include "npwindow.h"
-
-
- //
- // Constructor - Initialize variables. Get the instance pointer for any
- // NPP type calls.
- //
- CCpuMon::CCpuMon (NPP pInstance)
- {
- this->pInstance = pInstance;
-
- bRunningCGIProgram = FALSE;
- }
-
-
- //
- // Destructor
- //
- CCpuMon::~CCpuMon ()
- {
- }
-
-
- //
- // Open - Get ready for data, called from Netscape's NPP_NewStream
- //
- BOOL CCpuMon::Open (NPStream* pStream)
- {
- this->pStream = pStream;
-
- return TRUE;
- }
-
-
- //
- // EndOfStream - Called from NPP_DestroyStream. The stream is done. Our plug-in
- // has all the data.
- //
- BOOL CCpuMon::EndOfStream (void)
- {
- // CPU Monitor is file based, just return.
-
- return TRUE;
- }
-
-
- //
- // GotFileName - Called from NPP_StreamAsFile with a local filename
- //
- BOOL CCpuMon::GotFileName (const char* fname)
- {
- // Open the file in ASCII read only
-
- FILE* fp = fopen (fname, "r");
-
- if (fp)
- {
- if (bRunningCGIProgram)
- {
- // CGI program is running, update the graphic
-
- // pWindow->UpdateChart (fp);
- fclose (fp);
-
- return TRUE;
- }
-
- if (fgets (ProgramURL, sizeof(ProgramURL), fp))
- {
- // The first file starts us. It must contain the URL
- // for the CGI program.
-
- fclose (fp);
-
- char* p = strchr(ProgramURL, '\n'); // Remove newline
-
- if (p)
- *p = NULL;
-
- // Flag the CGI program as running and get the URL
-
- bRunningCGIProgram = TRUE;
-
- NPError rc = NPN_GetURL (pInstance, ProgramURL, NULL);
- }
- }
-
- return TRUE;
- }
-
-
- //
- // RequestUpdate - Called from CPluginWindow::OnUpdate when the update button
- // is clicked.
- //
- BOOL CCpuMon::RequestUpdate (void)
- {
- if (!bRunningCGIProgram)
- return FALSE;
-
- NPError rc = NPN_GetURL (pInstance, ProgramURL, NULL);
-
- if (rc)
- return FALSE;
-
- return TRUE;
- }
-
-
- //
- // Close - Called from NPP_Destroy. This plug-in instance is history. Free
- // all resources.
- //
- BOOL CCpuMon::Close (void)
- {
- return TRUE;
- }
-
-
-