File indexing completed on 2024-04-21 15:08:08

0001 //
0002 // C++ Interface: cmxpmanager
0003 //
0004 // Description: 
0005 //
0006 /*
0007 Copyright 2004-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef CMXPMANAGER_H
0024 #define CMXPMANAGER_H
0025 
0026 #include <qobject.h>
0027 #include <qcolor.h>
0028 #include <qfont.h>
0029 
0030 #include <config-mxp.h>
0031 
0032 #include "cactionbase.h"
0033 
0034 #ifdef HAVE_MXP
0035 #include <libmxp/libmxp.h>
0036 #endif //HAVE_MXP
0037 
0038 /**
0039 This class interfaces with the MXP library and provides information about received text and tags, as sent by the MXP library.
0040 
0041 @author Tomas Mecir
0042 */
0043 
0044 class cMXPManager : public QObject, public cActionBase
0045 {
0046 Q_OBJECT
0047 public:
0048   /** constructor */
0049   cMXPManager (int sess);
0050   /** destructor */
0051   ~cMXPManager () override;
0052   
0053 #ifdef HAVE_MXP
0054   virtual void eventNothingHandler (QString event, int session) override;
0055   virtual QString actionIntHandler (QString action, int session, int par1, int par2 = 0) override;
0056   virtual QString actionNothingHandler (QString action, int session) override;
0057   
0058   bool isMXPActive () { return mxpactive; };
0059   void setMXPActive (bool active);
0060 
0061   /** is the server actually sending us MXP sequences? */
0062   bool isMXPInUse () { return mxpinuse; };
0063     
0064   /** process text coming from the server */
0065   void processText (const QString &text);
0066 
0067   void switchToOpenMode ();
0068   void setDefaultFont (QFont font, QColor fg, QColor bg);
0069 #endif //HAVE_MXP
0070 
0071 //some signals... these must not be #defined out, or MOC would complain...
0072 signals:
0073   void gotNewText (const QString &text);
0074   void gotFgColor (QColor color);
0075   void gotBgColor (QColor color);
0076   void gotAttrib (int a);
0077   void gotALink (const QString &name, const QString &url, const QString &text,
0078       const QString &hint);
0079   void gotSENDLink (const QString &name, const QString &command, const QString &text,
0080       const QString &hint, bool toprompt, bool ismenu);
0081   void gotExpire (const QString &name);
0082   void gotNewLine ();
0083   
0084 //same holds for slots...
0085 public slots:
0086   void reset ();
0087 
0088 #ifdef HAVE_MXP
0089 
0090 protected:
0091   void processResult (mxpResult *res);
0092   QColor toColor (RGB mxpColor);
0093   void sendDefaultFont ();
0094   void initLibrary ();
0095   bool mxpactive, havehandler;
0096   bool mxpinuse;
0097   
0098   QFont deffont;
0099   QColor deffg, defbg;
0100   int curattrib;
0101     
0102   MXPHANDLER h;
0103 #endif //HAVE_MXP
0104 
0105 };
0106 
0107 #endif