OpAsynchFontInstall Class Reference

This operation will attempt to download and install fonts from a web server to the local machine. More...

#include <inetop.h>

Inheritance diagram for OpAsynchFontInstall:

DownloadOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpAsynchFontInstall ()
virtual ~OpAsynchFontInstall ()

Static Public Member Functions

static BOOL Init ()
 Creates an OpDescriptor for an WebFontInstall operation.

Protected Member Functions

virtual void OnDownloadSuccess ()
 
  • Performs the actual install using the font file just downloaded.


Detailed Description

This operation will attempt to download and install fonts from a web server to the local machine.

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/03/97
See also:
OpAsynchClipartImport

Definition at line 243 of file inetop.h.


Constructor & Destructor Documentation

OpAsynchFontInstall::OpAsynchFontInstall  )  [inline]
 

Definition at line 248 of file inetop.h.

00248 {};

virtual OpAsynchFontInstall::~OpAsynchFontInstall  )  [inline, virtual]
 

Definition at line 249 of file inetop.h.

00249 {}; 


Member Function Documentation

BOOL OpAsynchFontInstall::Init void   )  [static]
 

Creates an OpDescriptor for an WebFontInstall operation.

> BOOL OpAsynchFontInstall::Init()

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/04/97
Returns:
FALSE if it fails (due to lack of memory)
See also:

Reimplemented from DownloadOp.

Definition at line 2114 of file inetop.cpp.

02115 {  
02116     return RegisterOpDescriptor(
02117         0,                              // Tool ID
02118         _R(IDS_OPASYNCHFONTINSTALL),                // String resource ID
02119         CC_RUNTIME_CLASS(OpAsynchFontInstall),  // Runtime class
02120         OPTOKEN_OPASYNCHFONTINSTALL,            // Token string
02121         DownloadOp::GetState,           // GetState function
02122         0,                              // Help ID
02123         0,                              // Bubble ID
02124         0,                              // Resource ID
02125         0                               // Control ID
02126     );
02127 }   

void OpAsynchFontInstall::OnDownloadSuccess  )  [protected, virtual]
 

  • Performs the actual install using the font file just downloaded.

Author:
Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/01/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Reimplemented from DownloadOp.

Definition at line 2143 of file inetop.cpp.

02144 {
02145     // Verify that the pointer is valid & the right type
02146     WebFontInstallParam* pInstallParam =  (WebFontInstallParam*) pParam;
02147     if (!pInstallParam->pGallery || !pInstallParam->pGallery->IsKindOf(CC_RUNTIME_CLASS(FontsSGallery)))
02148     {
02149         ERROR3("Invalid gallery pointer");
02150         return;
02151     }
02152 
02153     // if we have just downloaded a "pfb" file we need to download the
02154     // corresponding .pfm file
02155     String_256 FileExt((String_256)pInstallParam->file.GetType());
02156     FileExt.toLower();
02157     if (FileExt == String_256("pfb"))
02158     {
02159         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpAsynchFontInstall));
02160         if (pOpDesc != NULL)
02161         {
02162             BOOL ok = TRUE;
02163             WebFontInstallParam* Param = new WebFontInstallParam;
02164             ERROR3IF(!Param, "Memory allocation error");
02165             if (!Param)
02166                 return;
02167 
02168             // Set up the parameters which we need to download and install the font
02169             Param->type = TYPE_FONT;
02170             Param->priority = AsynchDownload::PRIORITY_HIGH;
02171             Param->pGallery = pInstallParam->pGallery;
02172             PathName FileName(pInstallParam->file);
02173             FileName.SetType("pfm");
02174             Param->file = FileName;
02175             Param->strDescription = pInstallParam->strDescription;
02176             Param->strAltDescription = pInstallParam->strAltDescription;
02177 
02178             // get the url address of the font
02179             String_256 URL;
02180             UINT32 Count = pInstallParam->strURL.Length() - FileName.GetFileName().Length();
02181             pInstallParam->strURL.Left(&Param->strURL, Count);
02182 
02183             // add the file name
02184             String_256 FName = FileName.GetFileName();
02185             FName.toLower();
02186             Param->strURL += FName;
02187             Param->bIsTemp = FALSE;
02188             Param->Output = &ok;
02189 
02190             // Invoke the operation
02191             pOpDesc->Invoke((OpParam*) Param);
02192             return;
02193         }
02194         else
02195         {
02196             ERROR3("Can't find Op descriptor");
02197         }
02198             return;
02199     }
02200     else if (FileExt == String_256("pfm"))
02201         pInstallParam->file.SetType(String_256("pfb"));
02202     
02203     FontsSGallery* pFontsGallery = (FontsSGallery*) pInstallParam->pGallery; // the cast should be safe at this point
02204     String_64 SlowJob;
02205     SlowJob.MakeMsg(_R(IDS_FONTS_INSTALLING), (TCHAR*) pInstallParam->strAltDescription);
02206     BeginSlowJob(-1, FALSE, &SlowJob);
02207     FontsSGallery::DontUpdate = TRUE;
02208     BOOL ok = pFontsGallery->InstallFont(&pInstallParam->file, &pInstallParam->strDescription, pInstallParam->bIsTemp);
02209     FontsSGallery::DontUpdate = FALSE;
02210     EndSlowJob();
02211     if (!ok)
02212     {
02213         // Problems installing a specified font
02214         String_256 ErrMsg;
02215         ErrMsg.MakeMsg(_R(IDS_PROBLEMS_INSTALLING), (TCHAR *) pInstallParam->strAltDescription);
02216         Error::SetError(0, ErrMsg, 0);
02217         InformError();
02218         Error::ClearError();
02219     }
02220     else
02221     {
02222         // Warn everyone that the fonts have changed - and update our gallery
02223         SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
02224     }
02225     // remove the temporary font file
02226     DownloadCache::RemoveFile((String_256) pInstallParam->file.GetPath());
02227     pFontsGallery->SelectionHasChanged();
02228 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:57:30 2007 for Camelot by  doxygen 1.4.4