defuze.me  Client
remoteevent.hpp
00001 /**************************************************************************
00002 ** defuze.me Epitech Innovative Project
00003 **
00004 ** Copyright 2010-2011
00005 **   Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard
00006 **   Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier
00007 **
00008 ** All rights reserved.
00009 **************************************************************************/
00010 
00011 namespace Network {
00012     class RemoteEvent;
00013 }
00014 
00015 #ifndef REMOTEEVENT_HPP
00016 #define REMOTEEVENT_HPP
00017 
00018 #include <QObject>
00019 #include <QVariantMap>
00020 #include "remotesock.hpp"
00021 
00022 namespace Network
00023 {
00045     class RemoteEvent : public QObject
00046     {
00047         Q_OBJECT
00048         friend class    RemoteSock;
00049         friend class    Doorman;
00050 
00051     public:
00052         enum AutoReplyType {
00053             OK,
00054             NO_CHANGES,
00055             ERROR
00056         };
00057 
00058         unsigned        getUid() const;
00059         bool            isReply() const;
00060         unsigned        getRequestId() const;
00061         RemoteEvent*    getRequest() const;
00062         const QString&  getEvent() const;
00063         RemoteSock*     getRemote() const;
00064         void            setData(const QVariantMap& data);
00065         QVariant&       operator[](const QString& key);
00066         QVariant        operator[](const QString& key) const;
00067         void            send();                                         
00068         void            sendWithReply(const QObject *, const char *);   
00069         QByteArray      toStream() const;                               
00070         RemoteEvent&    newReply(const QString& name) const;            
00071         void            autoReply(AutoReplyType type) const;
00072 
00073     signals:
00074         void            receiveReply(const RemoteEvent&);               
00075 
00076     public slots:
00077 
00078     private:
00079         RemoteEvent(RemoteSock *remote, const QByteArray& packet = ""); 
00080         ~RemoteEvent();
00081 
00082         QString         event;                                          
00083         unsigned        uid;                                            
00084         unsigned        replyTo;                                        
00085         QVariantMap     data;
00086         RemoteSock      *remote;                                        
00087     };
00088 }
00089 
00090 #endif // REMOTEEVENT_HPP