37
37
WbManager::WbManager(XMPP::Client* client, PsiAccount* pa, SxeManager* sxemanager) {
39
sxemanager_ = sxemanager;
41
client->addExtension("whiteboard", Features(WBNS));
43
connect(sxemanager_, SIGNAL(sessionNegotiated(SxeSession*)), SLOT(createWbDlg(SxeSession*)));
44
sxemanager_->addInvitationCallback(WbManager::checkInvitation);
39
sxemanager_ = sxemanager;
41
client->addExtension("whiteboard", Features(WBNS));
43
connect(sxemanager_, SIGNAL(sessionNegotiated(SxeSession*)), SLOT(createWbDlg(SxeSession*)));
44
sxemanager_->addInvitationCallback(WbManager::checkInvitation);
47
WbManager::~WbManager()
47
52
void WbManager::openWhiteboard(const Jid &target, const Jid &ownJid, bool groupChat, bool promptInitialDoc) {
49
// check that the target supports whiteboarding via SXE
50
QList<QString> features;
52
if(!sxemanager_->checkSupport(target, features)) {
53
QMessageBox::information(NULL, tr("Unsupported"), tr("The contact does not support whiteboarding."));
54
// check that the target supports whiteboarding via SXE
55
QList<QString> features;
57
if(!sxemanager_->checkSupport(target, features)) {
58
QMessageBox::information(NULL, tr("Unsupported"), tr("The contact does not support whiteboarding."));
58
63
// See if we have a session for the JID
59
64
WbDlg* w = findWbDlg(target);
61
// else negotiate a new session and return null
65
if(promptInitialDoc) {
66
bool openExisting = (QMessageBox::Yes == QMessageBox::question(NULL,
67
tr("Open Existing SVG?"),
68
tr("Would you like to open an existing SVG document in the whitebaord?"),
69
QMessageBox::Yes | QMessageBox::No,
73
// prompt for an existing file
74
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Initial SVG Document for the Whiteboard"),
76
tr("Scalable Vector Graphics (*.svg)"));
79
if(file.open(QIODevice::ReadOnly)) {
80
doc.setContent(file.readAll(), true);
86
if(doc.documentElement().nodeName() != "svg") {
88
// initialize with an empty whiteboarding document
90
doc.setContent(QString(EMPTYWB), true);
95
// negotiate the session
66
// else negotiate a new session and return null
70
if(promptInitialDoc) {
71
bool openExisting = (QMessageBox::Yes == QMessageBox::question(NULL,
72
tr("Open Existing SVG?"),
73
tr("Would you like to open an existing SVG document in the whitebaord?"),
74
QMessageBox::Yes | QMessageBox::No,
78
// prompt for an existing file
79
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Initial SVG Document for the Whiteboard"),
81
tr("Scalable Vector Graphics (*.svg)"));
84
if(file.open(QIODevice::ReadOnly)) {
85
doc.setContent(file.readAll(), true);
91
if(doc.documentElement().nodeName() != "svg") {
93
// initialize with an empty whiteboarding document
95
doc.setContent(QString(EMPTYWB), true);
100
// negotiate the session
96
101
sxemanager_->startNewSession(target, ownJid, groupChat, doc, features);
118
124
void WbManager::createWbDlg(SxeSession* session) {
119
// check if the session is a whiteboarding session
120
bool whiteboarding = false;
121
foreach(QString feature, session->features()) {
123
whiteboarding = true;
128
WbDlg* w = new WbDlg(session, pa_);
130
// connect the signals
131
connect(w, SIGNAL(sessionEnded(WbDlg*)), SLOT(removeDialog(WbDlg*)));
132
connect(session, SIGNAL(peerLeftSession(Jid)), w, SLOT(peerLeftSession(Jid)));
125
// check if the session is a whiteboarding session
126
bool whiteboarding = false;
127
foreach(QString feature, session->features()) {
129
whiteboarding = true;
134
WbDlg* w = new WbDlg(session, pa_);
136
// connect the signals
137
connect(w, SIGNAL(sessionEnded(WbDlg*)), SLOT(removeDialog(WbDlg*)));
138
connect(session, SIGNAL(peerLeftSession(Jid)), w, SLOT(peerLeftSession(Jid)));
140
146
bool WbManager::checkInvitation(const Jid &peer, const QList<QString> &features) {
141
if(!features.contains(WBNS))
147
if(!features.contains(WBNS))
144
return (QMessageBox::Yes == QMessageBox::question(NULL,
145
tr("Whiteboarding Invitation?"),
146
tr("%1 has invited you to a whiteboarding session. Would you like to join?").arg(peer.full()),
147
QMessageBox::Yes | QMessageBox::No,
150
return (QMessageBox::Yes == QMessageBox::question(NULL,
151
tr("Whiteboarding Invitation?"),
152
tr("%1 has invited you to a whiteboarding session. Would you like to join?").arg(peer.full()),
153
QMessageBox::Yes | QMessageBox::No,