gendwnd.cpp

Go to the documentation of this file.
00001 // $Id: gendwnd.cpp 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 
00100 #include "camtypes.h" 
00101 #include "gendwnd.h"
00102 //#include "webster.h"
00103 #include "impexpop.h"
00104 //#include "resimmap.h" //_R(IDS_HTML_DOWNLOADFAILED)
00105 
00106 
00107 DECLARE_SOURCE("$Revision: 751 $");
00108 
00109 CC_IMPLEMENT_DYNCREATE(OpGenericDownload, DownloadOp) 
00110 
00111 #define new CAM_DEBUG_NEW
00112 
00113 
00114 /********************************************************************************************
00115 
00116 >   GenericDownloadParam::GenericDownloadParam()
00117 
00118     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00119     Created:    01/05/97
00120     Inputs:     
00121     Returns:    
00122     Purpose:    Default constructor. Do nothing
00123     Errors:     
00124 
00125 ********************************************************************************************/
00126 
00127 GenericDownloadParam::GenericDownloadParam()
00128 {
00129 
00130 }
00131 
00132 /********************************************************************************************
00133 
00134 >   GenericDownloadParam::~GenericDownloadParam()
00135 
00136     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00137     Created:    01/05/97
00138     Inputs:     
00139     Returns:    
00140     Purpose:    Destructor. Do nothing
00141     Errors:     
00142 
00143 ********************************************************************************************/
00144 
00145 GenericDownloadParam::~GenericDownloadParam()
00146 {
00147 
00148 }
00149 
00150 /********************************************************************************************
00151 
00152 >   BOOL OpGenericDownload::Init()
00153 
00154     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00155     Created:    28/04/97
00156     Inputs:     
00157     Returns:    TRUE if the Init worked ok
00158     Purpose:    
00159     Errors:     
00160 
00161 ********************************************************************************************/
00162 
00163 BOOL OpGenericDownload::Init()
00164 {
00165     return RegisterOpDescriptor(
00166         0,                                  // Tool ID
00167         _R(IDS_OPGENERICDOWNLOAD),                      // String resource ID
00168         CC_RUNTIME_CLASS(OpGenericDownload),    // Runtime class
00169         OPTOKEN_OPGENERICDOWNLOAD,                  // Token string
00170         OpGenericDownload::GetState,            // GetState function
00171         0,                                  // Help ID
00172         0,                                  // Bubble ID
00173         0,                                  // Resource ID
00174         0                                   // Control ID
00175     );
00176 }
00177 
00178 
00179 /********************************************************************************************
00180 
00181 >   OpState OpGenericDownload::GetState(String_256*, OpDescriptor*)
00182 
00183     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00184     Created:    28/04/97
00185     Inputs:     
00186     Returns:    
00187     Purpose:    
00188     Errors:     
00189 
00190 ********************************************************************************************/
00191 
00192 OpState OpGenericDownload::GetState(String_256*, OpDescriptor*)
00193 {
00194     OpState OpSt;
00195     return(OpSt);
00196 }
00197 
00198 
00199 /********************************************************************************************
00200 
00201 >   BOOL OpGenericDownload::OnDocChangingMsg(Document* pChangingDoc, DocChangingMsg::DocState State)
00202 
00203     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00204     Created:    14/05/97
00205     Inputs:     pChangingDoc -
00206                 State -
00207     Returns:    
00208     Purpose:    End (abort) the operation when for instance the current document has been destroyed
00209                 while downloading.
00210     Errors:     
00211 
00212 ********************************************************************************************/
00213 
00214 BOOL OpGenericDownload::OnDocChangingMsg(Document* pChangingDoc, DocChangingMsg::DocState State)
00215 {
00216     GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
00217     Document* pCurDoc = pGenericParam->pDoc;
00218 
00219     if (pParam != NULL)
00220     {
00221         if (State == DocChangingMsg::ABOUTTODIE && pChangingDoc == pCurDoc)
00222         {
00223 //          Document::SetSelectedViewAndSpread(pCurDoc);
00224 //          SelOperation* Op = pGenericParam->m_Op;
00225 //          ((OpMenuImport*)Op)->EndImport();
00226 
00227             // end of the download op
00228             FailAndExecute(); 
00229             End();
00230         }
00231     }
00232 
00233     return TRUE;
00234 }
00235 
00236 
00237 /********************************************************************************************
00238 
00239 >   void OpGenericDownload::OnDownloadSuccess()
00240 
00241     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00242     Created:    28/04/97
00243     Inputs:     
00244     Returns:    
00245     Purpose:    Function called when the download has finished and is success
00246                 
00247     Errors:     
00248 
00249 ********************************************************************************************/
00250 
00251 void OpGenericDownload::OnDownloadSuccess()
00252 {
00253     // get a pointer to the OpParam so that I can retrieve some useful information
00254     GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
00255 
00256     String_256 GenericFile = (pGenericParam->file).GetFileName();
00257     if (IsUserName("Olivier"))
00258         TRACE1("OpGenericDownload::OnDownloadSuccess(), file = %s\n", (TCHAR*)GenericFile);
00259 
00260     Filter* pFilter = pGenericParam->m_pFilter;
00261     PathName Path = pGenericParam->file;
00262     String_256 URL = pGenericParam->strURL;
00263     SelOperation* Op = pGenericParam->m_Op;
00264 
00265     // call the DoImport function from OpMenuImport class
00266     ((OpMenuImport*)Op)->DoImport(Path, pFilter, &URL);
00267 
00268     // remove the temporary file
00269     remove((TCHAR*) (String_256) Path.GetPath());
00270 }
00271 
00272 
00273 /********************************************************************************************
00274 
00275 >   void OpGenericDownload::OnDownloadFail()
00276 
00277     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com> (rewritten by Graham)
00278     Created:    28/04/97
00279     Inputs:     
00280     Returns:    
00281     Purpose:    Function called when the download has failed
00282     Errors:     
00283 
00284 ********************************************************************************************/
00285 
00286 
00287 void OpGenericDownload::OnDownloadFail()
00288 {
00289     //First get a pointer to the parameters
00290     GenericDownloadParam* pGenParam = (GenericDownloadParam*) pParam;
00291 
00292     if (pGenParam==NULL)
00293     {
00294         ERROR2RAW("OpBitmapDownload::OnDownloadFail - no download parameters");
00295         return;
00296     }
00297 
00298     //Get the URL which the user typed
00299     String_256 strURL=pGenParam->strURL;
00300 
00301     //And put it up as a message
00302     String_256 strMessage;
00303     strMessage.MakeMsg(_R(IDS_HTML_DOWNLOADFAILED), &strURL);
00304     Error::SetError(0, strMessage, 0);
00305     InformError();
00306 
00307 }
00308 
00309 
00310 /********************************************************************************************
00311 
00312 >   void OpGenericDownload::OnDownloadAbort()
00313 
00314     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00315     Created:    09/05/97
00316     Inputs:     
00317     Returns:    
00318     Purpose:    Function called when the use abort download 
00319     Errors:     
00320 
00321 ********************************************************************************************/
00322 
00323 void OpGenericDownload::OnDownloadAbort()
00324 {
00325 
00326     // get a pointer to the OpParam so that I can retrieve some useful information
00327     GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
00328 
00329     String_256 GenericFile = pGenericParam->strURL;
00330     if (IsUserName("Olivier"))
00331         TRACE1("OpGenericDownload::OnDownloadAbort(), file = %s\n", (TCHAR*)GenericFile);
00332 
00333     // stop the import op
00334     SelOperation* Op = pGenericParam->m_Op;
00335     ((OpMenuImport*)Op)->EndImport();
00336 }

Generated on Sat Nov 10 03:48:30 2007 for Camelot by  doxygen 1.4.4