OpURLImport Class Reference

#include <dbgthumb.h>

Inheritance diagram for OpURLImport:

OpMenuImport OpMenuImport SelOperation SelOperation UndoableOperation UndoableOperation Operation Operation MessageHandler MessageHandler ListItem ListItem CCObject CCObject SimpleCCObject SimpleCCObject List of all members.

Public Member Functions

 OpURLImport ()
 Default constructor.
void Do (OpDescriptor *)
 Imports a URL into the current document.
 OpURLImport ()
void Do (OpDescriptor *)
 Imports a file into the current document.

Static Public Member Functions

static BOOL Init ()
 Declares the OpDescriptor.
static OpState GetState (String_256 *, OpDescriptor *)
 This item is always available, so long as a document is visible.
static BOOL Init ()
 Declares op descriptors for Acorn Draw file reading.
static OpState GetState (String_256 *, OpDescriptor *)
 This item is always available, so long as a document is visible.

Protected Member Functions

BOOL ImportURL (WebAddress urlToGet)
 Imports the URL given.
FilterGetAllFilter ()
 Gets a pointer to the All filter.
BOOL ImportURL (WebAddress urlToGet)
FilterGetAllFilter ()

Detailed Description

Definition at line 123 of file dbgthumb.h.


Constructor & Destructor Documentation

OpURLImport::OpURLImport  ) 
 

Default constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/97

Definition at line 219 of file dbgthumb.cpp.

00220 {
00221     OpFlags.HasOwnTimeIndicator = TRUE; // The OpURLImport op has its own time indicator
00222 }

OpURLImport::OpURLImport  ) 
 


Member Function Documentation

void OpURLImport::Do OpDescriptor  )  [virtual]
 

Imports a file into the current document.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/02/94
Returns:
Errors: Various. Get reported to the user.

Reimplemented from OpMenuImport.

void OpURLImport::Do OpDescriptor  )  [virtual]
 

Imports a URL into the current document.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/97
Returns:
Errors: -

Reimplemented from OpMenuImport.

Definition at line 164 of file dbgthumb.cpp.

00165 {
00166     //First display our Import from URL dialog and get a filename from it
00167     WebAddress urlToGet;
00168     
00169     BOOL ok=URLImportDlg::OpenAndGetURL(&urlToGet);
00170 
00171     //And if the user clicked OK
00172     if (ok)
00173     {
00174 
00175         //So, is the URL we've got back a local filename?
00176         if (urlToGet.IsLocalFile())
00177         {
00178             //Yes. So get it as a pathname
00179             PathName pthToGet=urlToGet.GetPathName();
00180 
00181             //And first get a pointer to the All filter
00182             Filter* pAllFilter=GetAllFilter();
00183 
00184             //And if we found it
00185             if (pAllFilter)
00186             {
00187                 //Then import the pathname
00188                 String_256 strToGet=pthToGet.GetPath();
00189 
00190                 DoImport(pthToGet, pAllFilter, &strToGet);
00191             }
00192 
00193         }
00194         else
00195         {
00196             //No, it's a URL.
00197 
00198             //So download it
00199             ImportURL(urlToGet);
00200         }
00201     }
00202 
00203 
00204 
00205 
00206 
00207 }

Filter* OpURLImport::GetAllFilter  )  [protected]
 

Filter * OpURLImport::GetAllFilter  )  [protected]
 

Gets a pointer to the All filter.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/6/97
Parameters:
- [INPUTS]

Definition at line 347 of file dbgthumb.cpp.

00348 {
00349     //So get a pointer to the All filter
00350     FilterManager* pFilterManager=Camelot.GetFilterManager();
00351 
00352     ERROR2IF(pFilterManager==NULL, FALSE, "OpURLImport::ImportURL - FilterManager does not exist");
00353 
00354     return pFilterManager->FindFilterFromID(FILTERID_GENERIC);
00355         
00356 }

static OpState OpURLImport::GetState String_256 ,
OpDescriptor
[static]
 

This item is always available, so long as a document is visible.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/02/94

Reimplemented from OpMenuImport.

OpState OpURLImport::GetState String_256 ,
OpDescriptor
[static]
 

This item is always available, so long as a document is visible.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/97

Reimplemented from OpMenuImport.

Definition at line 234 of file dbgthumb.cpp.

00235 {
00236     OpState OpSt;
00237 
00238     return OpSt;
00239 }

BOOL OpURLImport::ImportURL WebAddress  urlToGet  )  [protected]
 

BOOL OpURLImport::ImportURL WebAddress  urlToGet  )  [protected]
 

Imports the URL given.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/97
Parameters:
urlToGet The URL to import [INPUTS]
GTODO: Handle local files GTODO: HMOve this function somewhere useful

Definition at line 261 of file dbgthumb.cpp.

00262 {
00263     //First, set up some variables. We must do this now because I'm 
00264     //going to use a goto in a moment
00265     GenericDownloadParam* Param;
00266     OpDescriptor* pOpDesc;
00267     PathName pthTemp;
00268 
00269     //We want to import urlToGet using the best available filter
00270 
00271     //To get the best available filter, we simply download to the "All" filter
00272     //So get a pointer to the All filter
00273     Filter* pAllFilter=GetAllFilter();
00274 
00275     //Check we found it
00276     if (pAllFilter==NULL)
00277         goto ReturnError;
00278 
00279     //Now, get ready to download the file. This is rather complex.
00280 
00281     //First create a new set of download parameters
00282     //This object will be deleted when the download finishes
00283     Param = new GenericDownloadParam;
00284     
00285     //Now find the generic download OpDescriptor
00286     pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_OPGENERICDOWNLOAD);
00287 
00288     //And check we found it
00289     if (pOpDesc==NULL)
00290         goto ReturnError;
00291   
00292     //Now, create a temporary file to download to
00293     pthTemp=FileUtil::GetTemporaryPathName();
00294 
00295 
00296 
00297     /*            GTODO: Take all this out
00298                 TCHAR TempDir[MAX_PATH];
00299                 FileUtil::GetTemporaryPath(MAX_PATH,TempDir);
00300                 // get temp file name
00301                 TCHAR TempFileName[256];
00302                 TCHAR Prefix[] = "TMP"; // the first three letters of the new file name
00303                 FileUtil::GetTemporaryFileName(TempDir,Prefix,0,TempFileName);
00304                 */
00305 
00306     //And now fill in our parameters
00307     Param->type = TYPE_GENERIC;
00308     Param->priority = AsynchDownload::PRIORITY_NORMAL;
00309     Param->strDescription = String_256(_R(IDS_HTMLIMPORT_FILEDOWNLOAD));
00310     Param->uCaptionID = _R(IDS_GENERICPROGRESSDLGCAPTION);
00311     Param->uErrorMsgID = _R(IDS_GENERICDOWNLOADFAILED);
00312     Param->file = pthTemp.GetPath();
00313 
00314     Param->strURL = urlToGet.GetWebAddress();
00315                 
00316     Param->Output = NULL;
00317 
00318     Param->m_pFilter = pAllFilter;
00319     Param->m_Op = this;                     
00320     Param->pDoc = Document::GetCurrent();
00321 
00322     //And, finally, start the download going, if we've got a URL to download
00323     if (!Param->strURL.IsEmpty())
00324         pOpDesc->Invoke((OpParam*) Param);
00325     
00326     //And return TRUE
00327     return TRUE;
00328 
00329 ReturnError:
00330     if (Param)
00331         delete Param;
00332 
00333     return FALSE;
00334 }

static BOOL OpURLImport::Init void   )  [static]
 

Declares op descriptors for Acorn Draw file reading.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/02/94
Returns:
TRUE if worked, FALSE if failed (out of memory)

Errors: Returns FALSE on failure.

Reimplemented from OpMenuImport.

BOOL OpURLImport::Init void   )  [static]
 

Declares the OpDescriptor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/97
Returns:
TRUE if worked, FALSE if failed (out of memory)

Errors: -

Reimplemented from OpMenuImport.

Definition at line 131 of file dbgthumb.cpp.

00132 {
00133     return RegisterOpDescriptor(
00134                                     0,                          // Tool ID
00135                                     _R(IDS_URLIMPORT),                  // String resource ID
00136                                     CC_RUNTIME_CLASS(OpURLImport),  // Runtime class
00137                                     OPTOKEN_URLIMPORT,          // Token string
00138                                     GetState,                   // GetState function
00139                                     0,                          // help ID GTODO: Is this needed?
00140                                     _R(IDBBL_URLIMPORT),            // bubble help
00141                                     _R(IDD_BARCONTROLSTORE),        // resource ID
00142                                     _R(IDC_FILEURLIMPORT),              // control ID
00143                                     SYSTEMBAR_FILE,             // Bar ID
00144                                     TRUE,                       // Receive system messages
00145                                     FALSE,                      // Smart duplicate operation
00146                                     TRUE,                       // Clean operation
00147                                     0,      // String for one copy only error
00148                                     (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags
00149                                 );
00150     
00151 }


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