Files
@ af6c160261c2
Branch filter:
Location: libtransport.git/include/transport/Conversation.h - annotation
af6c160261c2
5.6 KiB
text/plain
Web interface: support service.base_location=/something/ to override default '/' root location used by the web interface
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 78e71f9345c7 76c678dd6f1d fe47e0979be9 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d d39705842a2a b5c026470f07 76c678dd6f1d 1af263f488e8 1af263f488e8 1af263f488e8 1af263f488e8 1af263f488e8 1af263f488e8 1af263f488e8 58fbe0d388c6 58fbe0d388c6 1af263f488e8 1af263f488e8 1055c577d2d3 1af263f488e8 1055c577d2d3 1055c577d2d3 1055c577d2d3 1055c577d2d3 d39705842a2a 76c678dd6f1d d39705842a2a d39705842a2a d39705842a2a d39705842a2a d39705842a2a d39705842a2a b5c026470f07 76c678dd6f1d d39705842a2a d39705842a2a d39705842a2a 76c678dd6f1d 76c678dd6f1d d39705842a2a d39705842a2a d39705842a2a d39705842a2a 2add374fbd61 d39705842a2a 4f9457bdd83a e5aab1415d9e 4f9457bdd83a d39705842a2a d39705842a2a d39705842a2a d39705842a2a d39705842a2a d39705842a2a d39705842a2a 1af263f488e8 d39705842a2a d39705842a2a d39705842a2a d39705842a2a 70cf46773b85 76c678dd6f1d ff3adaa3f33f ff3adaa3f33f ff3adaa3f33f ff3adaa3f33f 5b89dae8ca9a 5b89dae8ca9a 5b89dae8ca9a 5b89dae8ca9a 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b 7e9ea5150d9c 7e9ea5150d9c 7e9ea5150d9c 7e9ea5150d9c 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b 88607aff3c0b d39705842a2a d39705842a2a d39705842a2a 76c678dd6f1d 76c678dd6f1d d39705842a2a d39705842a2a d39705842a2a b62274f1ddda b62274f1ddda b62274f1ddda b62274f1ddda d39705842a2a d39705842a2a d39705842a2a 943dc1925b7c 943dc1925b7c 943dc1925b7c 943dc1925b7c d39705842a2a d39705842a2a d39705842a2a d39705842a2a 8c529dbabbbc 943dc1925b7c d39705842a2a d39705842a2a d39705842a2a 943dc1925b7c 943dc1925b7c 943dc1925b7c 943dc1925b7c 4717bd007185 4717bd007185 24d902983a17 1055c577d2d3 1055c577d2d3 8761e976aeca 7e9ea5150d9c 1055c577d2d3 1055c577d2d3 c0687aba7478 1055c577d2d3 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d 0a33a3100eb9 943dc1925b7c 943dc1925b7c 5b89dae8ca9a 88607aff3c0b 8b6973539f23 70cf46773b85 e5aab1415d9e e5aab1415d9e e5aab1415d9e e5aab1415d9e e5aab1415d9e e5aab1415d9e e5aab1415d9e 7e9ea5150d9c e5aab1415d9e 76c678dd6f1d 76c678dd6f1d 76c678dd6f1d | /**
* XMPP - libpurple transport
*
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#pragma once
#include <string>
#include <algorithm>
#include <list>
#include "Swiften/Elements/Message.h"
#include "Swiften/Elements/Presence.h"
namespace Transport {
class ConversationManager;
/// Represents one XMPP-Legacy network conversation.
class Conversation {
public:
typedef enum {
PARTICIPANT_FLAG_NONE = 0,
PARTICIPANT_FLAG_MODERATOR = 1,
PARTICIPANT_FLAG_CONFLICT = 2,
PARTICIPANT_FLAG_BANNED = 4,
PARTICIPANT_FLAG_NOT_AUTHORIZED = 8,
PARTICIPANT_FLAG_ME = 16,
PARTICIPANT_FLAG_KICKED = 32,
PARTICIPANT_FLAG_ROOM_NOT_FOUD = 64
} ParticipantFlag;
typedef struct _Participant {
ParticipantFlag flag;
int status;
std::string statusMessage;
} Participant;
/// Creates new conversation.
/// \param conversationManager ConversationManager associated with this Conversation.
/// \param legacyName Legacy network name of recipient.
/// \param muc True if this conversation is Multi-user chat.
Conversation(ConversationManager *conversationManager, const std::string &legacyName, bool muc = false);
/// Destructor.
virtual ~Conversation();
/// Returns legacy network name of this conversation.
/// \return legacy network name of this conversation.
const std::string &getLegacyName() { return m_legacyName; }
/// Handles new message from Legacy network and forwards it to XMPP.
/// \param message Message received from legacy network.
/// \param nickname For MUC conversation this is nickname of room participant who sent this message.
void handleMessage(boost::shared_ptr<Swift::Message> &message, const std::string &nickname = "");
void handleRawMessage(boost::shared_ptr<Swift::Message> &message);
void handleRawPresence(Swift::Presence::ref presence);
/// Handles participant change in MUC.
/// \param nickname Nickname of participant which changed.
/// \param flag ParticipantFlag.
/// \param status Current status of this participant.
/// \param statusMessage Current status message of this participant.
/// \param newname If participant was renamed, this variable contains his new name.
void handleParticipantChanged(const std::string &nickname, ParticipantFlag flag, int status = Swift::StatusShow::None, const std::string &statusMessage = "", const std::string &newname = "");
/// Sets XMPP user nickname in MUC rooms.
/// \param nickname XMPP user nickname in MUC rooms.
void setNickname(const std::string &nickname);
const std::string &getNickname() {
return m_nickname;
}
void setJID(const Swift::JID &jid) {
m_jid = jid;
}
void addJID(const Swift::JID &jid) {
m_jids.push_back(jid);
}
void clearJIDs() {
m_jids.clear();
}
void removeJID(const Swift::JID &jid) {
m_jids.remove(jid);
}
const std::list<Swift::JID> &getJIDs() {
return m_jids;
}
/// Sends message to Legacy network.
/// \param message Message.
virtual void sendMessage(boost::shared_ptr<Swift::Message> &message) = 0;
/// Returns ConversationManager associated with this Conversation.
/// \return ConversationManager associated with this Conversation.
ConversationManager *getConversationManager() {
return m_conversationManager;
}
/// Returns True if this conversation is MUC room.
/// \return True if this conversation is MUC room.
bool isMUC() {
return m_muc;
}
/// Sets room name associated with this Conversation.
/// This is used to detect Private messages associated with particular room.
/// \param room room name associated with this Conversation.
void setRoom(const std::string &room);
/// Returns room name associated with this Conversation.
/// \return room name associated with this Conversation.
const std::string &getRoom() {
return m_room;
}
void destroyRoom();
std::string getParticipants();
void sendParticipants(const Swift::JID &to);
void sendCachedMessages(const Swift::JID &to = Swift::JID());
private:
Swift::Presence::ref generatePresence(const std::string &nick, int flag, int status, const std::string &statusMessage, const std::string &newname = "");
void cacheMessage(boost::shared_ptr<Swift::Message> &message);
private:
ConversationManager *m_conversationManager;
std::string m_legacyName;
std::string m_nickname;
std::string m_room;
bool m_muc;
Swift::JID m_jid;
std::list<Swift::JID> m_jids;
bool m_sentInitialPresence;
bool m_nicknameChanged;
// TODO: Move this to some extra class to cache the most used
// rooms across different accounts. Just now if we have 10 users
// connected to single room, we store all those things 10 times.
// It would be also great to store last 100 messages per room
// every time, so we can get history messages for IRC for example.
boost::shared_ptr<Swift::Message> m_subject;
std::list<boost::shared_ptr<Swift::Message> > m_cachedMessages;
std::map<std::string, Swift::Presence::ref> m_participants;
};
}
|