blob: 92580ff9b4f69a355e47ce3ebfdb5f5e67491755 (
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
|
/*
* Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <Swift/QtUI/ui_QtJoinMUCWindow.h>
#include <string>
#include <QValidator>
#include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h>
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
class UIEventStream;
class NickValidator : public QValidator {
Q_OBJECT
public:
NickValidator(QObject* parent) : QValidator(parent) {
}
virtual QValidator::State validate(QString& input, int& /*pos*/) const {
if (input.isEmpty()) {
return QValidator::Intermediate;
}
JID test("alice", "wonderland.lit", Q2PSTRING(input));
return test.isValid() ? QValidator::Acceptable : QValidator::Invalid;
}
};
class RoomJIDValidator : public QValidator {
Q_OBJECT
public:
RoomJIDValidator(QObject* parent) : QValidator(parent) {
}
virtual QValidator::State validate(QString& input, int& /*pos*/) const {
if (input.isEmpty()) {
return QValidator::Intermediate;
}
JID roomJID(Q2PSTRING(input));
if (roomJID.getNode().empty() || roomJID.getDomain().empty()) {
return QValidator::Intermediate;
}
return (roomJID.getResource().empty() && !roomJID.getNode().empty() && !roomJID.getDomain().empty() && roomJID.isValid()) ? QValidator::Acceptable : QValidator::Invalid;
}
};
class QtJoinMUCWindow : public QWidget, public JoinMUCWindow {
Q_OBJECT
public:
QtJoinMUCWindow(UIEventStream* uiEventStream);
virtual void setNick(const std::string& nick);
virtual void setMUC(const std::string& nick);
virtual void show();
private slots:
void handleJoin();
void handleSearch();
private:
Ui::QtJoinMUCWindow ui;
std::string lastSetNick;
UIEventStream* uiEventStream;
};
}
|