00001 /*************************************************************************** 00002 * Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #ifndef GUI_ONLINEDOCUMENTATION_H 00025 #define GUI_ONLINEDOCUMENTATION_H 00026 00027 #include <QObject> 00028 #include <QTcpServer> 00029 #include "Command.h" 00030 00031 00032 namespace Gui { 00033 00035 bool GuiExport OpenURLInBrowser(const char * URL); 00036 00042 class OnlineDocumentation : public QObject 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 OnlineDocumentation(); 00048 ~OnlineDocumentation(); 00049 00050 QByteArray loadResource(const QString& filename) const; 00051 00052 private: 00053 QStringList files; 00054 }; 00055 00061 class PythonOnlineHelp : public QObject 00062 { 00063 Q_OBJECT 00064 00065 public: 00066 PythonOnlineHelp(); 00067 ~PythonOnlineHelp(); 00068 00069 QByteArray loadResource(const QString& filename) const; 00070 QByteArray fileNotFound() const; 00071 }; 00072 00076 class HttpServer : public QTcpServer 00077 { 00078 Q_OBJECT 00079 00080 public: 00081 HttpServer(QObject* parent = 0); 00082 00083 void incomingConnection(int socket); 00084 void pause(); 00085 void resume(); 00086 00087 private slots: 00088 void readClient(); 00089 void discardClient(); 00090 00091 private: 00092 PythonOnlineHelp help; 00093 bool disabled; 00094 }; 00095 00096 // -------------------------------------------------------------------- 00097 00098 class StdCmdPythonHelp : public Command 00099 { 00100 public: 00101 StdCmdPythonHelp(); 00102 ~StdCmdPythonHelp(); 00103 const char* className() const 00104 { return "Gui::StdCmdPythonHelp"; } 00105 00106 protected: 00107 void activated(int iMsg); 00108 00109 private: 00110 HttpServer* server; 00111 }; 00112 00113 // -------------------------------------------------------------------- 00114 00115 00116 00117 } 00118 00119 #endif // GUI_ONLINEDOCUMENTATION_H