PPInstance.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Filename: PPInstance.h
  2. // Created by: atrestman (14Sept09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #pragma once
  15. #include <string>
  16. #include <vector>
  17. #include <math.h>
  18. #include "afxmt.h"
  19. #include "p3d_plugin.h"
  20. #include "PPDownloadCallback.h"
  21. #include "PPLogger.h"
  22. #include "fileSpec.h"
  23. #include "load_plugin.h"
  24. #define WM_PY_LAUNCHED (WM_USER + 1)
  25. #define WM_PROGRESS (WM_USER + 2)
  26. #define WM_PANDA_NOTIFICATION (WM_USER + 3)
  27. class CP3DActiveXCtrl;
  28. class PPInstance
  29. {
  30. public:
  31. PPInstance( CP3DActiveXCtrl& parentCtrl );
  32. virtual ~PPInstance( );
  33. int DownloadP3DComponents( std::string& p3dDllFilename );
  34. int LoadPlugin( const std::string& dllFilename );
  35. int UnloadPlugin( void );
  36. static void ref_plugin();
  37. static void unref_plugin();
  38. int Start( const std::string& p3dFileName );
  39. int Stop( );
  40. std::string GetHostUrl( );
  41. std::string GetP3DFilename( );
  42. static void HandleRequestLoop();
  43. inline bool IsInit() { return m_isInit; }
  44. HWND m_parentWnd;
  45. CEvent m_eventStop;
  46. CEvent m_eventDownloadStopped;
  47. P3D_object* m_p3dObject;
  48. protected:
  49. PPInstance( );
  50. PPInstance( const PPInstance& );
  51. int DownloadFile( const std::string& from, const std::string& to );
  52. int CopyFile( const std::string& from, const std::string& to );
  53. bool read_contents_file(const std::string &contents_filename);
  54. void find_host(TiXmlElement *xcontents);
  55. void read_xhost(TiXmlElement *xhost);
  56. void add_mirror(std::string mirror_url);
  57. void choose_random_mirrors(std::vector<std::string> &result, int num_mirrors);
  58. void HandleRequest( P3D_request *request );
  59. static void HandleRequestGetUrl( void *data );
  60. void set_failed();
  61. P3D_instance* m_p3dInstance;
  62. CP3DActiveXCtrl& m_parentCtrl;
  63. PPLogger m_logger;
  64. bool m_handleRequestOnUIThread;
  65. bool m_isInit;
  66. bool m_pluginLoaded;
  67. std::string _download_url_prefix;
  68. typedef std::vector<std::string> Mirrors;
  69. Mirrors _mirrors;
  70. FileSpec _core_api_dll;
  71. bool _failed;
  72. std::string m_rootDir;
  73. };