DoodleSession.h 1.89 KB
#ifndef _DOODLE_SESSION_H__
#define _DOODLE_SESSION_H__

#include <QtCore>
#include "../mainapp.h"
#include "avatar/zos/zos_type.h"
#include "lemon/service/rcs/mtc_doodle.h"
#include "DoodlePage.h"

namespace JusDoodle {
class DoodleWindow;

class DoodleSession : public QObject
{
    Q_OBJECT

public:
    DoodleSession(int sessId, QObject *parent = 0);
    virtual ~DoodleSession();

    // Initialization
    // The session can process data received.
    bool init();

    // Start doodle, show doodle window.
    // When start for the first time, 
    // EN_MTC_DOODLE_ACTION_START action will be sent as well.
    bool start(int pageCount);

    // Stop doodle, hide doodle window.
    void stop();

    // Set background images.
    void setBackgroundImages(const QStringList &imagePaths);

    // Process data received.
    void recvData(const QString &name, const QString &data);

    // Process file received.
    void recvFile(const QString &name, const QString &path, int pageId);

    // Initialize doodle window
    void initWindow(int pageCount);

public Q_SLOTS:
    // Format EN_MTC_DOODLE_ACTION_SELECT_PAGE action and send to peer.
    void onNotifyPageChanged(int pageId);

    // Format EN_MTC_DOODLE_ACTION_CLEAN action and send to peer.
    void onNotifyClean(int pageId);

    // Format EN_MTC_DOODLE_ACTION_DRAW action and send to peer.
    void onNotifyDrawPath(int pageId, const Path &path,
        const QColor &color, double width);

    // Format EN_MTC_DOODLE_ACTION_ERASE action and send to peer.
    void onNotifyErasePath(int pageId, const Path &path,
        double width);

private:
    // Read path information from action.
    void readPath(MTC_ACT action, Path &path);

    // Do action.
    void procAction(MTC_ACT action);

public:
    DoodleWindow *_doodleWindow;
private:
    MTC_SESS _doodleSess;
    int _sessId;
    bool _isCall;
};

} // namespace JusDoodle

#endif /* _DOODLE_SESSION_H__ */