summaryrefslogtreecommitdiffstats
path: root/src/jabber_whiteboard/session-file-player.h
blob: aa2e2b4c12fed8bad981bb0b0a2b9005379a60b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
 * Whiteboard session file playback mechanism
 *
 * Authors:
 * David Yip <yipdw@rose-hulman.edu>
 *
 * Copyright (c) 2005 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#ifndef __WHITEBOARD_SESSION_FILE_PLAYER_H__
#define __WHITEBOARD_SESSION_FILE_PLAYER_H__

#include <list>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <gtkmm/textbuffer.h>
#include <sigc++/sigc++.h>

struct SPDesktop;

namespace Inkscape {
    namespace UI {
       namespace Dialog {
           class SessionPlaybackDialogImpl;
       }
    }
    namespace Whiteboard {

class SessionFile;
class SessionManager;

class SessionFilePlayer {
friend class UI::Dialog::SessionPlaybackDialogImpl;

public:
	SessionFilePlayer(unsigned int bufsz, SessionManager* sm);
	~SessionFilePlayer();

	void load(SessionFile* sm);
	SessionFile* unload();

	Glib::ustring const& filename();
	Glib::ustring const& curmsg();

	void start();
	void stop();
	void setDelay(unsigned int delay);
	void setMessageOutputWidget(Glib::RefPtr<Gtk::TextBuffer> const& widgetptr);

	static unsigned short const BACKWARD = 0;
	static unsigned short const FORWARD = 1;

private:
	bool step(unsigned short dir);
	void _outputMessageToWidget();

	SessionManager* _sm;
	SessionFile* _sf;

	// Output widget refptr
	Glib::RefPtr<Gtk::TextBuffer> _outputwidget;

	// Playback signal
	sigc::connection _playback_dispatcher;

	// trackers
	unsigned int _delay;
	unsigned short _curdir;
	bool _playing;
	Glib::ustring _curmsg;

	// (position, msgsize)
	std::list< std::pair< gint64, gint64 > > _visited;
	gint64 _current;
	gint64 _next;

	// noncopyable, nonassignable
	SessionFilePlayer(SessionFilePlayer const&);
	void operator=(SessionFilePlayer const&);
};

}

}

#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :