RemoteSync.hpp   RemoteSync.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef REMOTESYNC_HPP_ #ifndef REMOTESYNC_HPP_
#define REMOTESYNC_HPP_ #define REMOTESYNC_HPP_
#include "StelModule.hpp"
#include "SyncClient.hpp"
#include "SyncServer.hpp"
#include <QFont> #include <QFont>
#include <QKeyEvent> #include <QKeyEvent>
#include <QLoggingCategory>
#include "StelModule.hpp" #include <QTimer>
class RemoteSyncDialog; class RemoteSyncDialog;
class SyncServer;
class SyncClient; Q_DECLARE_LOGGING_CATEGORY(remoteSync)
//! Main class of the RemoteSync plug-in. //! Main class of the RemoteSync plug-in.
//! Provides a synchronization mechanism for multiple Stellarium instances in a network. //! Provides a synchronization mechanism for multiple Stellarium instances in a network.
//! This plugin has been developed during ESA SoCiS 2015. //! This plugin has been developed during ESA SoCiS 2015/2016.
class RemoteSync : public StelModule class RemoteSync : public StelModule
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(SyncState) Q_ENUMS(SyncState ClientBehaviour)
public: public:
enum SyncState enum SyncState
{ {
IDLE, //Plugin is disabled IDLE, //Plugin is disabled
SERVER, //Plugin is running as server SERVER, //Plugin is running as server
CLIENT, //Plugin is connected as a client to a server CLIENT, //Plugin is connected as a client to a server
CLIENT_CONNECTING //Plugin is currently trying to connect to CLIENT_CONNECTING, //Plugin is currently trying to connect t
a server o a server
CLIENT_CLOSING, //Plugin is disconnecting from the server
CLIENT_WAIT_RECONNECT //Plugin is waiting to try reconnectin
g again
};
//! Defines behavior when client connection is lost/server quits
enum ClientBehavior
{
NONE, //do nothing
RECONNECT, //automatically try to reconnect
QUIT //quit the client
}; };
RemoteSync(); RemoteSync();
virtual ~RemoteSync(); virtual ~RemoteSync();
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods defined in the StelModule class // Methods defined in the StelModule class
virtual void init() Q_DECL_OVERRIDE; virtual void init() Q_DECL_OVERRIDE;
virtual void update(double deltaTime) Q_DECL_OVERRIDE; virtual void update(double deltaTime) Q_DECL_OVERRIDE;
virtual double getCallOrder(StelModuleActionName actionName) const Q _DECL_OVERRIDE; virtual double getCallOrder(StelModuleActionName actionName) const Q _DECL_OVERRIDE;
virtual bool configureGui(bool show=true) Q_DECL_OVERRIDE; virtual bool configureGui(bool show=true) Q_DECL_OVERRIDE;
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
QString getClientServerHost() const { return clientServerHost; } QString getClientServerHost() const { return clientServerHost; }
int getClientServerPort() const { return clientServerPort; } int getClientServerPort() const { return clientServerPort; }
int getServerPort() const { return serverPort; } int getServerPort() const { return serverPort; }
SyncClient::SyncOptions getClientSyncOptions() const { return syncOp
tions; }
QStringList getStelPropFilter() const { return stelPropFilter; }
ClientBehavior getConnectionLostBehavior() const { return connection
LostBehavior; }
ClientBehavior getQuitBehavior() const { return quitBehavior; }
SyncState getState() const { return state; } SyncState getState() const { return state; }
public slots: public slots:
void setClientServerHost(const QString& clientServerHost); void setClientServerHost(const QString& clientServerHost);
void setClientServerPort(const int port); void setClientServerPort(const int port);
void setServerPort(const int port); void setServerPort(const int port);
void setClientSyncOptions(SyncClient::SyncOptions options);
void setStelPropFilter(const QStringList& stelPropFilter);
void setConnectionLostBehavior(const ClientBehavior bh);
void setQuitBehavior(const ClientBehavior bh);
//! Starts the plugin in server mode, on the port specified by the s erverPort property. //! Starts the plugin in server mode, on the port specified by the s erverPort property.
//! If currently in a state other than IDLE, this call has no effect . //! If currently in a state other than IDLE, this call has no effect .
void startServer(); void startServer();
//! Tries to disconnect all current clients and stops the server, re turning to the IDLE state. //! Tries to disconnect all current clients and stops the server, re turning to the IDLE state.
//! Only has an effect in the SERVER state. //! Only has an effect in the SERVER state.
void stopServer(); void stopServer();
//! Connects the plugin to the server specified by the clientServerH ost and clientServerPort properties. //! Connects the plugin to the server specified by the clientServerH ost and clientServerPort properties.
//! If currently in a state other than IDLE, this call has no effect . //! If currently in a state other than IDLE or CLIENT_WAIT_RECONNECT , this call has no effect.
void connectToServer(); void connectToServer();
//! Disconnects from the server and returns to the IDLE state. //! Disconnects from the server and returns to the IDLE state.
//! Only has an effect in the CLIENT state. //! Only has an effect in the CLIENT state.
void disconnectFromServer(); void disconnectFromServer();
//! Load the plug-in's settings from the configuration file. //! Load the plug-in's settings from the configuration file.
//! Settings are kept in the "RemoteSync" section in Stellarium's //! Settings are kept in the "RemoteSync" section in Stellarium's
//! configuration file. If no such section exists, it will load defa ult //! configuration file. If no such section exists, it will load defa ult
//! values. //! values.
skipping to change at line 106 skipping to change at line 129
//! @see loadSettings(), restoreSettings() //! @see loadSettings(), restoreSettings()
void saveSettings(); void saveSettings();
//! Restore the plug-in's settings to the default state. //! Restore the plug-in's settings to the default state.
//! Replace the plug-in's settings in Stellarium's configuration fil e //! Replace the plug-in's settings in Stellarium's configuration fil e
//! with the default values and re-load them. //! with the default values and re-load them.
//! Uses internally loadSettings() and saveSettings(). //! Uses internally loadSettings() and saveSettings().
void restoreDefaultSettings(); void restoreDefaultSettings();
signals: signals:
void errorOccurred(const QString errorString); void errorOccurred(const QString& errorString);
void clientServerHostChanged(const QString clientServerHost); void clientServerHostChanged(const QString& clientServerHost);
void clientServerPortChanged(const int port); void clientServerPortChanged(const int port);
void serverPortChanged(const int port); void serverPortChanged(const int port);
void clientSyncOptionsChanged(const SyncClient::SyncOptions options)
;
void stelPropFilterChanged(const QStringList& stelPropFilter);
void connectionLostBehaviorChanged(const ClientBehavior bh);
void quitBehaviorChanged(const ClientBehavior bh);
void stateChanged(RemoteSync::SyncState state); void stateChanged(RemoteSync::SyncState state);
private slots: private slots:
void clientDisconnected(); void clientDisconnected(bool clean);
void clientConnected(); void clientConnected();
void clientConnectionFailed();
private: private:
void setState(RemoteSync::SyncState state); void setState(RemoteSync::SyncState state);
void setError(const QString& errorString); void setError(const QString& errorString);
SyncState applyClientBehavior(ClientBehavior bh);
static QString packStringList(const QStringList props);
static QStringList unpackStringList(const QString packedProps);
//The host string/IP addr to connect to //The host string/IP addr to connect to
QString clientServerHost; QString clientServerHost;
//The host port to connect to //The host port to connect to
int clientServerPort; int clientServerPort;
//the port used in server mode //the port used in server mode
int serverPort; int serverPort;
SyncState state; SyncClient::SyncOptions syncOptions;
QStringList stelPropFilter;
ClientBehavior connectionLostBehavior;
ClientBehavior quitBehavior;
QTimer reconnectTimer;
SyncState state;
SyncServer* server; SyncServer* server;
SyncClient* client; SyncClient* client;
// the last error that occurred // the last error that occurred
QString errorString; QString errorString;
QSettings* conf; QSettings* conf;
// GUI // GUI
RemoteSyncDialog* configDialog; RemoteSyncDialog* configDialog;
skipping to change at line 156 skipping to change at line 194
//! This class is used by Qt to manage a plug-in interface //! This class is used by Qt to manage a plug-in interface
class RemoteSyncStelPluginInterface : public QObject, public StelPluginInte rface class RemoteSyncStelPluginInterface : public QObject, public StelPluginInte rface
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID StelPluginInterface_iid) Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
Q_INTERFACES(StelPluginInterface) Q_INTERFACES(StelPluginInterface)
public: public:
virtual StelModule* getStelModule() const; virtual StelModule* getStelModule() const;
virtual StelPluginInfo getPluginInfo() const; virtual StelPluginInfo getPluginInfo() const;
virtual QObjectList getExtensionList() const { return QObjectList(); }
}; };
#endif /*REMOTESYNC_HPP_*/ #endif /*REMOTESYNC_HPP_*/
 End of changes. 17 change blocks. 
14 lines changed or deleted 57 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/