Panda3D
|
00001 // Filename: virtualFileMountHTTP.h 00002 // Created by: drose (30Oct08) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef VIRTUALFILEMOUNTHTTP_H 00016 #define VIRTUALFILEMOUNTHTTP_H 00017 00018 #include "pandabase.h" 00019 00020 #ifdef HAVE_OPENSSL 00021 00022 #include "virtualFileMount.h" 00023 #include "httpClient.h" 00024 #include "httpChannel.h" 00025 #include "urlSpec.h" 00026 #include "pointerTo.h" 00027 #include "mutexImpl.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : VirtualFileMountHTTP 00031 // Description : Maps a web page (URL root) into the 00032 // VirtualFileSystem. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS VirtualFileMountHTTP : public VirtualFileMount { 00035 PUBLISHED: 00036 VirtualFileMountHTTP(const URLSpec &root, HTTPClient *http = HTTPClient::get_global_ptr()); 00037 virtual ~VirtualFileMountHTTP(); 00038 00039 INLINE HTTPClient *get_http_client() const; 00040 INLINE const URLSpec &get_root() const; 00041 00042 static void reload_vfs_mount_url(); 00043 00044 public: 00045 virtual PT(VirtualFile) make_virtual_file(const Filename &local_filename, 00046 const Filename &original_filename, 00047 bool implicit_pz_file, 00048 int open_flags); 00049 00050 virtual bool has_file(const Filename &file) const; 00051 virtual bool is_directory(const Filename &file) const; 00052 virtual bool is_regular_file(const Filename &file) const; 00053 00054 virtual istream *open_read_file(const Filename &file) const; 00055 virtual off_t get_file_size(const Filename &file, istream *stream) const; 00056 virtual off_t get_file_size(const Filename &file) const; 00057 virtual time_t get_timestamp(const Filename &file) const; 00058 00059 virtual bool scan_directory(vector_string &contents, 00060 const Filename &dir) const; 00061 00062 virtual void output(ostream &out) const; 00063 00064 PT(HTTPChannel) get_channel(); 00065 void recycle_channel(HTTPChannel *channel); 00066 00067 private: 00068 PT(HTTPClient) _http; 00069 URLSpec _root; 00070 00071 MutexImpl _channels_lock; 00072 typedef pvector< PT(HTTPChannel) > Channels; 00073 Channels _channels; 00074 00075 public: 00076 virtual TypeHandle get_type() const { 00077 return get_class_type(); 00078 } 00079 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00080 static TypeHandle get_class_type() { 00081 return _type_handle; 00082 } 00083 static void init_type() { 00084 VirtualFileMount::init_type(); 00085 register_type(_type_handle, "VirtualFileMountHTTP", 00086 VirtualFileMount::get_class_type()); 00087 } 00088 00089 private: 00090 static TypeHandle _type_handle; 00091 }; 00092 00093 #include "virtualFileMountHTTP.I" 00094 00095 #endif // HAVE_OPENSSL 00096 00097 #endif