File indexing completed on 2024-04-14 03:59:56

0001 /***************************************************************************
0002                           cconnection.h  -  handles connections
0003     This file is a part of KMuddy distribution.
0004                              -------------------
0005     begin                : Po Jul 22 2002
0006     copyright            : (C) 2002 by Tomas Mecir
0007     email                : kmuddy@kmuddy.com
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *   This program is free software; you can redistribute it and/or modify  *
0013  *   it under the terms of the GNU General Public License as published by  *
0014  *   the Free Software Foundation; either version 2 of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  ***************************************************************************/
0018 
0019 #ifndef CCONNECTION_H
0020 #define CCONNECTION_H
0021 
0022 #include <qobject.h>
0023 #include <qstringlist.h>
0024 
0025 #include "cactionbase.h"
0026 
0027 struct cConnectionPrivate;
0028 
0029 /**
0030 This class handles connecting, disconnecting, calls load/save
0031 of connection settings and related things.
0032   *@author Tomas Mecir
0033   */
0034 
0035 class cConnection : public QObject, public cActionBase {
0036    Q_OBJECT
0037 public: 
0038   cConnection (int sess);
0039   ~cConnection () override;
0040   void establishConnection (const QString &profileName, bool sendNothing = false);
0041   void establishQuickConnection (const QString &server, int port);
0042   bool isConnected ();
0043   void disconnect ();
0044   void reconnect ();
0045   QString getCaption ();
0046   /** call enable/disable menu items in KMuddy as needed */
0047   void updateMenus ();
0048   void setConnectionClosed (bool canCloseTab);
0049   void unsetConnectionClosed ();
0050   bool connectionClosed ();
0051   
0052   void addCommands (const QStringList &commands);
0053   void addCommand (const QString &command);
0054   void sendCommands ();
0055   int sentCommands ();
0056 
0057   void eventNothingHandler (QString event, int session) override;
0058   void eventStringHandler (QString event, int session, QString &par1, const QString &) override;
0059   QString actionStringHandler (QString action, int session, QString &par1, const QString &) override;
0060   QString actionNothingHandler (QString action, int session) override;
0061 
0062 public slots:
0063   void showConnPrefsDialog ();
0064   bool handleDisconnect ();
0065   /** shows Output Windows dialog box */
0066   void handleWindowsDialog ();
0067   /** enable/disable alias processing */
0068   void switchAliases (bool val);
0069   /** enable/disable trigger processing */
0070   void switchTriggers (bool val);
0071   /** enable/disable timer processing */
0072   void switchTimers (bool val);
0073   /** enable/disable macro key processing */
0074   void switchShortcuts (bool val);
0075   /** used to save settings */
0076   void saveSession ();
0077 protected slots:
0078   /** attached to timeout() of connecting timer*/
0079   void sendLoginAndPassword ();
0080   /** called when user presses Ok or Apply in MUD Settings dialog */
0081   void getSettingsFromDialog ();
0082   /** save settings */
0083   void save ();
0084 protected:
0085   /** puts profile settings to MUD Settings dialog */
0086   void putSettingsToDialog ();
0087 
0088   /** Register the internal lists. */
0089   void registerLists ();
0090 
0091   /** d-pointer for this class */
0092   cConnectionPrivate *d;
0093 };
0094 
0095 #endif