GetWebPage.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 15:34:53 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/IOKitComponent/trunk/include/GetWebPage.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licensed under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MX_GETWEBPAGE_H__
00061 #define __MX_GETWEBPAGE_H__
00062 
00063 
00064 
00065 #define MX_GETWEBPAGE_ID "GetWebPage"
00066 
00067 
00068 
00069 #include <interfaces/IGetWebPage.h>
00070 #include <interfaces/IComponent.h>
00071 #include <interfaces/IComponentInvoker.h>
00072 #include <interfaces/IHTTPGetStreamSource.h>
00073 #include <interfaces/IKeyChain.h>
00074 #include <interfaces/IAuthenticationDialog.h>
00075 
00076 #include <Framework/Framework.h>
00077 
00078 #include <mxm/core/mxmIPAddress.h>
00079 #include <mxm/core/mxmPerlStyleHash.h>
00080 
00081 #include <QObject>
00082 #include <QTimer>
00083 
00084 
00085 
00086 namespace mx {
00087    
00089 
00097    class GetWebPage : public QObject,
00098                       public mxmObject,
00099                       public virtual IComponent,
00100                       public virtual IGetWebPage {
00101       
00102       Q_OBJECT
00103       
00104       // These static methods provide interface and capability ids for
00105       // registration with the framework (for both the component and its
00106       // invoker).
00107     private:
00108       static mxm::smart<mxmStringList> _enumerateInterfaces() {
00109          return(new mxmStringList((mxmString(MX_GETWEBPAGE_ID),
00110                                    MX_ICOMPONENT_ID,
00111                                    MX_IGETWEBPAGE_ID,
00112                                    MX_IASYNCACTION_ID,
00113                                    MX_ISUPPORTSHOSTSPECIFICATION_ID,
00114                                    MX_ISUPPORTSPROXYSPECIFICATION_ID,
00115                                    MX_ISUPPORTSWEBPAGESPECIFICATION_ID,
00116                                    MX_ICANUSEKEYCHAIN_ID,
00117                                    MX_ICANUSEDIALOGS_ID,
00118                                    MX_ICANUSETIMEOUTS_ID)));
00119       }
00120       static mxm::smart<mxmStringList> _enumerateCapabilities(
00121                                           const mxmString &interface) {
00122          if(interface == mx::Framework::IdHintKey)
00123           return(new mxmStringList(MX_GETWEBPAGE_ID));
00124          else
00125           return(new mxmStringList());
00126       }
00127       
00128     private:
00129       class Invoker : public mxmObject, public virtual IComponentInvoker {
00130        public:
00131          mxm::smart<mxmStringList> enumerateInterfaces() {
00132             return(_enumerateInterfaces());
00133          }
00134          mxm::smart<mxmStringList> enumerateCapabilities(
00135                                      const mxmString &interface) {
00136             return(_enumerateCapabilities(interface));
00137          }
00138          IComponent *newComponent() {
00139             return(new GetWebPage());
00140          }
00141       };
00142     public:
00143       static IComponentInvoker *newInvoker() {
00144          return(new Invoker());
00145       }
00146       
00147     private:
00148       mxmIPAddress Host,
00149                    Proxy;
00150       mxmStringList WebPages;
00151       mxm::smart<IKeyChain> KeyChain;
00152     protected:
00153       mxm::smart<IAuthenticationDialog> AuthenticationDialog;
00154       mxm::smart<QTimer> TimeoutTimer;
00155       int TimeoutInterval_ms;
00156     private:
00157       mxmPerlStyleHash ChainKeys;
00158       bool DialogsEnabled;
00159       
00160     protected:
00161       bool Executing;
00162       
00163       mxm::smart<IHTTPGetStreamSource> StreamSource;
00164       mxmStringList LineBuffer;
00165       mxmString CurrentLine;
00166       
00167     public:
00168       GetWebPage();
00169       
00170     signals:
00172       void signalActionExecuted(bool);
00173       
00174     public:
00176       mxm::smart<mxmStringList> enumerateInterfaces() {
00177          return(_enumerateInterfaces());
00178       }
00180       mxm::smart<mxmStringList> enumerateCapabilities(
00181                                    const mxmString &interface) {
00182          return(_enumerateCapabilities(interface));
00183       }
00184       
00186       void setHost(const mxmIPAddress &host);
00188       void setProxy(const mxmIPAddress &proxy);
00190       void setWebPages(const mxmStringList &web_pages);
00191       
00193       void useKeyChain(const mxmPerlStyleHash &chain_keys);
00195       void useDialogs(bool enable);
00196       
00198       void useTimeouts(int interval_ms);
00199       
00201       const mxmStringList &webPageBuffer();
00202       
00204       void executeAction();
00206       void abortAction();
00208       mxmQtSignal actionExecutedSignal();
00210       bool actionExecuting();
00211       
00212     private slots:
00213       void slotIncoming();
00214       virtual void cleanUpAfterDownload();
00215       void slotTimeout();
00216    };
00217 };
00218 
00219 
00220 
00221 #endif   // __MX_GETWEBPAGE_H__
00222 

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6