summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/libiris/005_join_muc_with_password.patch
blob: 058825dbcc749bb056a62cfc7d62cf59f3ef1a7d (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Index: iris/include/im.h
===================================================================
--- iris/include/im.h	(révision 498969)
+++ iris/include/im.h	(copie de travail)
@@ -607,6 +607,7 @@
 		FileTransferManager *fileTransferManager() const;
 
 		bool groupChatJoin(const QString &host, const QString &room, const QString &nick);
+		bool groupChatJoin(const QString &host, const QString &room, const QString &nick, const QString &password);
 		void groupChatSetStatus(const QString &host, const QString &room, const Status &);
 		void groupChatChangeNick(const QString &host, const QString &room, const QString &nick, const Status &);
 		void groupChatLeave(const QString &host, const QString &room);
Index: iris/xmpp-im/client.cpp
===================================================================
--- iris/xmpp-im/client.cpp	(révision 498969)
+++ iris/xmpp-im/client.cpp	(copie de travail)
@@ -315,6 +315,35 @@
 	return true;
 }
 
+bool Client::groupChatJoin(const QString &host, const QString &room, const QString &nick, const QString &password)
+{
+	Jid jid(room + "@" + host + "/" + nick);
+	for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end();) {
+		GroupChat &i = *it;
+		if(i.j.compare(jid, false)) {
+			// if this room is shutting down, then free it up
+			if(i.status == GroupChat::Closing)
+				it = d->groupChatList.remove(it);
+			else
+				return false;
+		}
+		else
+			++it;
+	}
+
+	debug(QString("Client: Joined: [%1]\n").arg(jid.full()));
+	GroupChat i;
+	i.j = jid;
+	i.status = GroupChat::Connecting;
+	d->groupChatList += i;
+
+	JT_MucPresence *j = new JT_MucPresence(rootTask());
+	j->pres(jid, Status(), password);
+	j->go(true);
+
+	return true;
+}
+
 void Client::groupChatSetStatus(const QString &host, const QString &room, const Status &_s)
 {
 	Jid jid(room + "@" + host);
Index: iris/xmpp-im/xmpp_tasks.h
===================================================================
--- iris/xmpp-im/xmpp_tasks.h	(révision 498969)
+++ iris/xmpp-im/xmpp_tasks.h	(copie de travail)
@@ -439,6 +439,26 @@
 		class Private;
 		Private *d;
 	};
+
+	class JT_MucPresence : public Task
+	{
+		Q_OBJECT
+	public:
+		JT_MucPresence(Task *parent);
+		~JT_MucPresence();
+
+		void pres(const Status &);
+		void pres(const Jid &, const Status &, const QString &password);
+
+		void onGo();
+
+	private:
+		QDomElement tag;
+		int type;
+
+		class Private;
+		Private *d;
+	};
 }
 
 #endif
Index: iris/xmpp-im/xmpp_tasks.cpp
===================================================================
--- iris/xmpp-im/xmpp_tasks.cpp	(révision 498969)
+++ iris/xmpp-im/xmpp_tasks.cpp	(copie de travail)
@@ -1956,3 +1956,75 @@
 	return true;
 }
 
+//----------------------------------------------------------------------------
+// JT_MucPresence
+//----------------------------------------------------------------------------
+JT_MucPresence::JT_MucPresence(Task *parent)
+:Task(parent)
+{
+	type = -1;
+}
+
+JT_MucPresence::~JT_MucPresence()
+{
+}
+
+void JT_MucPresence::pres(const Status &s)
+{
+	type = 0;
+
+	tag = doc()->createElement("presence");
+	if(!s.isAvailable()) {
+		tag.setAttribute("type", "unavailable");
+		if(!s.status().isEmpty())
+			tag.appendChild(textTag(doc(), "status", s.status()));
+	}
+	else {
+		if(s.isInvisible())
+			tag.setAttribute("type", "invisible");
+
+		if(!s.show().isEmpty())
+			tag.appendChild(textTag(doc(), "show", s.show()));
+		if(!s.status().isEmpty())
+			tag.appendChild(textTag(doc(), "status", s.status()));
+
+		tag.appendChild( textTag(doc(), "priority", QString("%1").arg(s.priority()) ) );
+
+		if(!s.keyID().isEmpty()) {
+			QDomElement x = textTag(doc(), "x", s.keyID());
+			x.setAttribute("xmlns", "http://jabber.org/protocol/e2e");
+			tag.appendChild(x);
+		}
+		if(!s.xsigned().isEmpty()) {
+			QDomElement x = textTag(doc(), "x", s.xsigned());
+			x.setAttribute("xmlns", "jabber:x:signed");
+			tag.appendChild(x);
+		}
+
+		if(!s.capsNode().isEmpty() && !s.capsVersion().isEmpty()) {
+			QDomElement c = doc()->createElement("c");
+			c.setAttribute("xmlns","http://jabber.org/protocol/caps");
+			c.setAttribute("node",s.capsNode());
+			c.setAttribute("ver",s.capsVersion());
+			if (!s.capsExt().isEmpty()) 
+				c.setAttribute("ext",s.capsExt());
+			tag.appendChild(c);
+		}
+	}
+}
+
+void JT_MucPresence::pres(const Jid &to, const Status &s, const QString &password)
+{
+	pres(s);
+	tag.setAttribute("to", to.full());
+	QDomElement x = textTag(doc(), "x", s.xsigned());
+	x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
+	x.appendChild( textTag(doc(), "password", password.latin1()) );
+	tag.appendChild(x);
+}
+
+void JT_MucPresence::onGo()
+{
+	send(tag);
+	setSuccess();
+}