00001 // $Id: plugmngr.h 1282 2006-06-09 09:46: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 // This is the header file for the main plug-in manager code. 00101 00102 #ifndef INC_PLUGINMANAGER 00103 #define INC_PLUGINMANAGER 00104 00105 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "listitem.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 #include "plugin.h" 00108 #include "plugop.h" 00109 00110 class Progress; 00111 class MenuItem; 00112 00113 #define OPTOKEN_PLUGINS_MENU _T("PlugInsMenu") 00114 #define OPTOKEN_PLUGINS_MANAGER _T("PlugInsManager") 00115 #define OPTOKEN_PLUGINS_PARSING _T("PlugInsParsing") 00116 #define OPTOKEN_PLUGINS_PLUGINSMNGR _T("PlugInsPluginManager") 00117 00118 #define PLUGIN_UNDO_SIG "UNDO:" 00119 #define OPTOKEN_PLUGINS_UNDO_MENU _T("PlugInsUndoMenu") 00120 00121 class PlugInManager; 00122 class MenuItem; 00123 00124 /************************************************************************************** 00125 00126 > class PlugInHandler : public ListItem 00127 00128 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00129 Created: 9/12/96 00130 Purpose: Provides specific characteristics of a type of plug-in. This includes 00131 the type of file which the plug-in in usually stored in. This provides 00132 the basis of which a handler is derived from. 00133 00134 **************************************************************************************/ 00135 00136 class PlugInHandler : public ListItem 00137 { 00138 // Declare the class for memory tracking 00139 CC_DECLARE_DYNAMIC(PlugInHandler); 00140 00141 public: 00142 PlugInHandler(); 00143 ~PlugInHandler(); 00144 00145 virtual BOOL Init() = 0; 00146 00147 public: 00148 // Useful helper functions 00149 virtual BOOL AddFixedPlugIns(); 00150 00151 // Add a plug-in to the list in the plug-in manager 00152 virtual BOOL AddPlugIn(PlugInItem * pPlugIn, CCRuntimeClass* pClass = CC_RUNTIME_CLASS(PlugInOp), 00153 pfnGetState gs = PlugInOp::GetState); 00154 00155 // go and parse the specified plug-in 00156 virtual BOOL ParsePlugIn(const PathName& Path, const INT32 PathID) = 0; 00157 00158 // go and add in the any main menu items that this handler requires 00159 virtual BOOL CreateMainMenuItems(PlugInManager * pManager, MenuItem * pRootMenu, 00160 BOOL AddSeparator = FALSE); 00161 // a handler is asked whether it is going to add menu items so that the manager 00162 // can decide whether to ask the previous handler to add a separator to the end 00163 // of its added menus 00164 // Need to override this if the above function is overriden 00165 virtual BOOL GoingToAddMainMenuItems() { return FALSE; } 00166 00167 public: 00168 // define this handler's unique characteristics 00169 00170 // return a string describing a unique identifier for the plug-ins this handler is interested in 00171 virtual String_32 GetUniqueID() const = 0; 00172 // return a unique type for this kind of plug-in 00173 virtual TypeOfPlugIn GetTypeOfPlugIn() const = 0; 00174 // return a string describing what filetypes the plug-in handler is interested in 00175 virtual String_32 GetFileTypes() const = 0; 00176 00177 }; 00178 00179 /************************************************************************************** 00180 00181 > class PlugInManager : public CCObject 00182 00183 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00184 Created: 9/12/96 00185 Purpose: Provide general handling facilities for plug-ins in Camelot. 00186 00187 **************************************************************************************/ 00188 00189 class PlugInManager : public CCObject 00190 { 00191 // Declare the class for memory tracking 00192 CC_DECLARE_DYNAMIC(PlugInManager); 00193 00194 public: 00195 PlugInManager(); 00196 ~PlugInManager(); 00197 00198 BOOL Init(); 00199 00200 // Allow access to the parse at start up switch 00201 BOOL GetParseAtStartUp() { return m_ParseAtStartUp; } 00202 void SetParseAtStartUp( BOOL NewState ) { m_ParseAtStartUp = NewState; } 00203 00204 // Request a pathname using the plug-in browser form of common file dialog box 00205 BOOL GetPlugInPath( PathName* NewSearchPath ); 00206 00207 // Add a plug-in to the list in the plug-in manager 00208 BOOL AddPlugIn(PlugInItem * pPlugIn); 00209 00210 // Remove a plug-in from the list in the plug-in manager 00211 BOOL RemovePlugIn(PlugInItem * pPlugIn); 00212 00213 PlugInItem * GetFirstPlugIn(); 00214 PlugInItem * GetNextPlugIn(PlugInItem * pPlugIn); 00215 00216 BOOL AddPlugInPath( const PathName& NewSearchPath ); 00217 BOOL DeletePlugInPath( const PathName& SearchPath ); 00218 00219 PlugInPath * GetFirstPathName(); 00220 PlugInPath * GetNextPathName(PlugInPath * pPath); 00221 PlugInItem * GetPreviousPlugIn(PlugInItem * pPlugIn); 00222 00223 // Convert an id stored in a plug-in details record into the real pathname 00224 BOOL GetPlugInPathname(INT32 PathNameID, String_256 * pPathName); 00225 00226 public: 00227 // Useful routines for setting up and destroying the plug-ins list 00228 // This is the one used during start up which only searches for plug-ins 00229 // if this is what the user has requested. 00230 BOOL SearchForPlugIns(); 00231 // This should be called by UI items before they try and put up say a menu 00232 // of available plug-ins. If the user has requested parsing at this point 00233 // then this is where it will happen. 00234 BOOL CheckHaveDetailsOnPlugIns(); 00235 BOOL SearchedPathsYet() { return m_SearchedPaths; } 00236 00237 // Routines to load and save out the list of pathnames to a preferences file 00238 BOOL ReadPathNameList(); 00239 BOOL WritePathNameList(); 00240 00241 // Function to remove all the current plug-ins settings 00242 static BOOL WipePlugInsSettings(); 00243 00244 // Use with care. 00245 BOOL DestroyPlugInsList(); 00246 // This always searches the paths 00247 BOOL ParseAllPaths(); 00248 00249 // Finds the main plug-ins menu item 00250 MenuItem * FindPlugInMainMenuItem(MenuItem * pMainMenu = NULL); 00251 00252 protected: 00253 // This parses a particular pathname for plug-ins 00254 BOOL ParsePathName( const PathName& SearchPath, const INT32 PathID, INT32 * FilesCount, 00255 const Progress& PathsProgress ); 00256 // This parses a pathname for directories 00257 BOOL ParsePathNameForDirectories( const PathName& SearchPath, INT32 * FilesCount ); 00258 00259 private: 00260 // Code for sorting plug-ins into alphabetical order 00261 BOOL SortPlugInsAlphabetically(); 00262 static INT32 __cdecl SortComparator(const void *Item1, const void *Item2); 00263 00264 // Code for deleting all the main plug-in menu items associated with individual plug-ins 00265 BOOL DeleteMainMenuItems(); 00266 // Code for creating the main plug-in menu items associated with the individual plug-ins 00267 BOOL CreateMainMenuItems(); 00268 00269 private: 00270 // List of the paths the user has set which we should look in for plug-ins 00271 PlugInPathList m_Paths; 00272 00273 // The list of plug-in hanlders that Camelot understands. 00274 List m_HandlersList; 00275 00276 // The list of plug-in items 00277 List m_PlugInsList; 00278 00279 // Have we been initialised yet 00280 BOOL m_Initialised; 00281 // Have we searched the paths for plug-ins 00282 BOOL m_SearchedPaths; 00283 // Should we search the specified paths at start up for plug-ins? 00284 static BOOL m_ParseAtStartUp; 00285 }; 00286 00287 #endif // INC_PLUGINMANAGER 00288 00289