AbstractBuddy and AbstractConversation renamed
This commit is contained in:
parent
9200d53702
commit
b5c026470f
16 changed files with 78 additions and 78 deletions
|
@ -36,13 +36,13 @@ typedef enum { BUDDY_NO_FLAG = 0,
|
|||
} BuddyFlag;
|
||||
|
||||
/// Represents one legacy network Buddy.
|
||||
class AbstractBuddy {
|
||||
class Buddy {
|
||||
public:
|
||||
/// Constructor.
|
||||
AbstractBuddy(RosterManager *rosterManager, long id);
|
||||
Buddy(RosterManager *rosterManager, long id);
|
||||
|
||||
/// Destructor
|
||||
virtual ~AbstractBuddy();
|
||||
virtual ~Buddy();
|
||||
|
||||
/// Sets unique ID used to identify this buddy by StorageBackend. This is set
|
||||
/// by RosterStorage class once the buddy is stored into database or when the
|
||||
|
@ -52,7 +52,7 @@ class AbstractBuddy {
|
|||
void setID(long id);
|
||||
|
||||
/// Returns unique ID used to identify this buddy by StorageBackend.
|
||||
/// \see AbstractBuddy::setID(long)
|
||||
/// \see Buddy::setID(long)
|
||||
/// \return ID
|
||||
long getID();
|
||||
|
|
@ -31,13 +31,13 @@ namespace Transport {
|
|||
|
||||
class ConversationManager;
|
||||
|
||||
class AbstractConversation {
|
||||
class Conversation {
|
||||
public:
|
||||
/// Constructor.
|
||||
AbstractConversation(ConversationManager *conversationManager, const std::string &legacyName);
|
||||
Conversation(ConversationManager *conversationManager, const std::string &legacyName);
|
||||
|
||||
/// Destructor
|
||||
virtual ~AbstractConversation();
|
||||
virtual ~Conversation();
|
||||
|
||||
const std::string &getLegacyName() { return m_legacyName; }
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace Transport {
|
||||
|
||||
class AbstractConversation;
|
||||
class Conversation;
|
||||
class User;
|
||||
class Component;
|
||||
|
||||
|
@ -47,9 +47,9 @@ class ConversationManager {
|
|||
|
||||
Component *getComponent() { return m_component; }
|
||||
|
||||
void setConversation(AbstractConversation *conv);
|
||||
void setConversation(Conversation *conv);
|
||||
|
||||
void unsetConversation(AbstractConversation *conv);
|
||||
void unsetConversation(Conversation *conv);
|
||||
|
||||
private:
|
||||
void handleMessageReceived(Swift::Message::ref message);
|
||||
|
@ -57,7 +57,7 @@ class ConversationManager {
|
|||
Component *m_component;
|
||||
User *m_user;
|
||||
|
||||
std::map<std::string, AbstractConversation *> m_convs;
|
||||
std::map<std::string, Conversation *> m_convs;
|
||||
friend class UserManager;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
#include "Swiften/Swiften.h"
|
||||
#include "Swiften/Elements/Message.h"
|
||||
#include "transport/abstractconversation.h"
|
||||
#include "transport/conversation.h"
|
||||
|
||||
namespace Transport {
|
||||
|
||||
class AbstractConversation;
|
||||
class Conversation;
|
||||
class ConversationManager;
|
||||
|
||||
class Factory {
|
||||
public:
|
||||
|
||||
virtual AbstractConversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName) = 0;
|
||||
virtual Conversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class Component;
|
|||
class StorageBackend;
|
||||
class UserRegistration;
|
||||
class RosterManager;
|
||||
class AbstractBuddy;
|
||||
class Buddy;
|
||||
|
||||
/// Basic logging class which logs various data into std::out (standard output).
|
||||
class Logger
|
||||
|
@ -82,8 +82,8 @@ class Logger
|
|||
void handleUserDestroyed(User *user);
|
||||
|
||||
// RosterManager
|
||||
void handleBuddySet(AbstractBuddy *buddy);
|
||||
void handleBuddyUnset(AbstractBuddy *buddy);
|
||||
void handleBuddySet(Buddy *buddy);
|
||||
void handleBuddyUnset(Buddy *buddy);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace Transport {
|
||||
|
||||
class AbstractBuddy;
|
||||
class Buddy;
|
||||
class User;
|
||||
class Component;
|
||||
|
||||
|
@ -47,34 +47,34 @@ class RosterManager {
|
|||
/// and if the buddy is not already in XMPP user's server-side roster, the proper requests
|
||||
/// are sent to XMPP user (subscribe presences, Roster Item Exchange stanza or
|
||||
/// the buddy is added to server-side roster using remote-roster protoXEP).
|
||||
/// \param buddy AbstractBuddy
|
||||
void setBuddy(AbstractBuddy *buddy);
|
||||
/// \param buddy Buddy
|
||||
void setBuddy(Buddy *buddy);
|
||||
|
||||
/// Deassociates the buddy with this roster.
|
||||
/// \param buddy AbstractBuddy.
|
||||
void unsetBuddy(AbstractBuddy *buddy);
|
||||
/// \param buddy Buddy.
|
||||
void unsetBuddy(Buddy *buddy);
|
||||
|
||||
AbstractBuddy *getBuddy(const std::string &name);
|
||||
Buddy *getBuddy(const std::string &name);
|
||||
|
||||
/// Returns user associated with this roster.
|
||||
/// \return User
|
||||
User *getUser() { return m_user; }
|
||||
|
||||
/// Called when new AbstractBuddy is added to this roster.
|
||||
/// \param buddy newly added AbstractBuddy
|
||||
boost::signal<void (AbstractBuddy *buddy)> onBuddySet;
|
||||
/// Called when new Buddy is added to this roster.
|
||||
/// \param buddy newly added Buddy
|
||||
boost::signal<void (Buddy *buddy)> onBuddySet;
|
||||
|
||||
/// Called when AbstractBuddy has been removed from this roster.
|
||||
/// \param buddy removed AbstractBuddy
|
||||
boost::signal<void (AbstractBuddy *buddy)> onBuddyUnset;
|
||||
/// Called when Buddy has been removed from this roster.
|
||||
/// \param buddy removed Buddy
|
||||
boost::signal<void (Buddy *buddy)> onBuddyUnset;
|
||||
|
||||
private:
|
||||
void setBuddyCallback(AbstractBuddy *buddy);
|
||||
void setBuddyCallback(Buddy *buddy);
|
||||
|
||||
void sendBuddyRosterPush(AbstractBuddy *buddy);
|
||||
void sendBuddyRosterPush(Buddy *buddy);
|
||||
void handleBuddyRosterPushResponse(Swift::ErrorPayload::ref error, const std::string &key);
|
||||
|
||||
std::map<std::string, AbstractBuddy *> m_buddies;
|
||||
std::map<std::string, Buddy *> m_buddies;
|
||||
Component *m_component;
|
||||
User *m_user;
|
||||
Swift::Timer::ref m_setBuddyTimer;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "transport/user.h"
|
||||
#include "transport/storagebackend.h"
|
||||
#include "transport/rostermanager.h"
|
||||
#include "transport/abstractconversation.h"
|
||||
#include "transport/conversation.h"
|
||||
#include "spectrumeventloop.h"
|
||||
#include "spectrumbuddy.h"
|
||||
#include "spectrumconversation.h"
|
||||
|
@ -432,9 +432,9 @@ static void handleUserDestroyed(User *user, UserManager *userManager, Config *co
|
|||
|
||||
class SpectrumFactory : public Factory {
|
||||
public:
|
||||
AbstractConversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName) {
|
||||
Conversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName) {
|
||||
PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, (PurpleAccount *) conversationManager->getUser()->getData() , legacyName.c_str());
|
||||
return (AbstractConversation *) conv->ui_data;
|
||||
return (Conversation *) conv->ui_data;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
|
||||
|
||||
SpectrumBuddy::SpectrumBuddy(RosterManager *rosterManager, long id, PurpleBuddy *buddy) : AbstractBuddy(rosterManager, id), m_buddy(buddy) {
|
||||
SpectrumBuddy::SpectrumBuddy(RosterManager *rosterManager, long id, PurpleBuddy *buddy) : Buddy(rosterManager, id), m_buddy(buddy) {
|
||||
}
|
||||
|
||||
SpectrumBuddy::~SpectrumBuddy() {
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
#include "account.h"
|
||||
#include "glib.h"
|
||||
#include <algorithm>
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/rostermanager.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
// Wrapper for PurpleBuddy
|
||||
class SpectrumBuddy : public AbstractBuddy {
|
||||
class SpectrumBuddy : public Buddy {
|
||||
public:
|
||||
SpectrumBuddy(RosterManager *rosterManager, long id, PurpleBuddy *buddy);
|
||||
virtual ~SpectrumBuddy();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
|
||||
|
||||
SpectrumConversation::SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv) : AbstractConversation(conversationManager, legacyName), m_conv(conv) {
|
||||
SpectrumConversation::SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv) : Conversation(conversationManager, legacyName), m_conv(conv) {
|
||||
}
|
||||
|
||||
SpectrumConversation::~SpectrumConversation() {
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
#include "account.h"
|
||||
#include "glib.h"
|
||||
#include <algorithm>
|
||||
#include "transport/abstractconversation.h"
|
||||
#include "transport/conversation.h"
|
||||
#include "transport/conversationmanager.h"
|
||||
#include "transport/user.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
// Wrapper for PurpleBuddy
|
||||
class SpectrumConversation : public AbstractConversation {
|
||||
class SpectrumConversation : public Conversation {
|
||||
public:
|
||||
SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv);
|
||||
virtual ~SpectrumConversation();
|
||||
|
|
|
@ -18,73 +18,73 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
||||
*/
|
||||
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/rostermanager.h"
|
||||
#include "transport/user.h"
|
||||
#include "transport/transport.h"
|
||||
|
||||
namespace Transport {
|
||||
|
||||
AbstractBuddy::AbstractBuddy(RosterManager *rosterManager, long id) : m_id(id), m_online(false), m_subscription("ask"), m_flags(BUDDY_NO_FLAG), m_rosterManager(rosterManager){
|
||||
Buddy::Buddy(RosterManager *rosterManager, long id) : m_id(id), m_online(false), m_subscription("ask"), m_flags(BUDDY_NO_FLAG), m_rosterManager(rosterManager){
|
||||
m_rosterManager->setBuddy(this);
|
||||
}
|
||||
|
||||
AbstractBuddy::~AbstractBuddy() {
|
||||
Buddy::~Buddy() {
|
||||
m_rosterManager->unsetBuddy(this);
|
||||
}
|
||||
|
||||
void AbstractBuddy::generateJID() {
|
||||
void Buddy::generateJID() {
|
||||
m_jid = Swift::JID();
|
||||
m_jid = Swift::JID(getSafeName(), m_rosterManager->getUser()->getComponent()->getJID().toString(), "bot");
|
||||
}
|
||||
|
||||
void AbstractBuddy::setID(long id) {
|
||||
void Buddy::setID(long id) {
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
long AbstractBuddy::getID() {
|
||||
long Buddy::getID() {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void AbstractBuddy::setFlags(BuddyFlag flags) {
|
||||
void Buddy::setFlags(BuddyFlag flags) {
|
||||
m_flags = flags;
|
||||
|
||||
generateJID();
|
||||
}
|
||||
|
||||
BuddyFlag AbstractBuddy::getFlags() {
|
||||
BuddyFlag Buddy::getFlags() {
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
const Swift::JID &AbstractBuddy::getJID() {
|
||||
const Swift::JID &Buddy::getJID() {
|
||||
if (!m_jid.isValid()) {
|
||||
generateJID();
|
||||
}
|
||||
return m_jid;
|
||||
}
|
||||
|
||||
void AbstractBuddy::setOnline() {
|
||||
void Buddy::setOnline() {
|
||||
m_online = true;
|
||||
}
|
||||
|
||||
void AbstractBuddy::setOffline() {
|
||||
void Buddy::setOffline() {
|
||||
m_online = false;
|
||||
m_lastPresence = Swift::Presence::ref();
|
||||
}
|
||||
|
||||
bool AbstractBuddy::isOnline() {
|
||||
bool Buddy::isOnline() {
|
||||
return m_online;
|
||||
}
|
||||
|
||||
void AbstractBuddy::setSubscription(const std::string &subscription) {
|
||||
void Buddy::setSubscription(const std::string &subscription) {
|
||||
m_subscription = subscription;
|
||||
}
|
||||
|
||||
const std::string &AbstractBuddy::getSubscription() {
|
||||
const std::string &Buddy::getSubscription() {
|
||||
return m_subscription;
|
||||
}
|
||||
|
||||
Swift::Presence::ref AbstractBuddy::generatePresenceStanza(int features, bool only_new) {
|
||||
Swift::Presence::ref Buddy::generatePresenceStanza(int features, bool only_new) {
|
||||
std::string alias = getAlias();
|
||||
std::string name = getSafeName();
|
||||
|
||||
|
@ -126,7 +126,7 @@ Swift::Presence::ref AbstractBuddy::generatePresenceStanza(int features, bool on
|
|||
return presence;
|
||||
}
|
||||
|
||||
std::string AbstractBuddy::getSafeName() {
|
||||
std::string Buddy::getSafeName() {
|
||||
if (m_jid.isValid()) {
|
||||
return m_jid.getNode();
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ std::string AbstractBuddy::getSafeName() {
|
|||
return name;
|
||||
}
|
||||
|
||||
void AbstractBuddy::buddyChanged() {
|
||||
void Buddy::buddyChanged() {
|
||||
Swift::Presence::ref presence = generatePresenceStanza(255);
|
||||
if (presence) {
|
||||
m_rosterManager->getUser()->getComponent()->getStanzaChannel()->sendPresence(presence);
|
|
@ -19,27 +19,27 @@
|
|||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "transport/abstractconversation.h"
|
||||
#include "transport/conversation.h"
|
||||
#include "transport/conversationmanager.h"
|
||||
#include "transport/user.h"
|
||||
#include "transport/transport.h"
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/rostermanager.h"
|
||||
|
||||
namespace Transport {
|
||||
|
||||
AbstractConversation::AbstractConversation(ConversationManager *conversationManager, const std::string &legacyName) : m_conversationManager(conversationManager) {
|
||||
Conversation::Conversation(ConversationManager *conversationManager, const std::string &legacyName) : m_conversationManager(conversationManager) {
|
||||
m_legacyName = legacyName;
|
||||
m_conversationManager->setConversation(this);
|
||||
}
|
||||
|
||||
AbstractConversation::~AbstractConversation() {
|
||||
Conversation::~Conversation() {
|
||||
m_conversationManager->unsetConversation(this);
|
||||
}
|
||||
|
||||
void AbstractConversation::handleMessage(boost::shared_ptr<Swift::Message> &message) {
|
||||
void Conversation::handleMessage(boost::shared_ptr<Swift::Message> &message) {
|
||||
message->setTo(m_conversationManager->getUser()->getJID().toBare());
|
||||
AbstractBuddy *buddy = m_conversationManager->getUser()->getRosterManager()->getBuddy(m_legacyName);
|
||||
Buddy *buddy = m_conversationManager->getUser()->getRosterManager()->getBuddy(m_legacyName);
|
||||
if (buddy) {
|
||||
std::cout << m_legacyName << " 222222\n";
|
||||
message->setFrom(buddy->getJID());
|
|
@ -19,9 +19,9 @@
|
|||
*/
|
||||
|
||||
#include "transport/conversationmanager.h"
|
||||
#include "transport/abstractconversation.h"
|
||||
#include "transport/conversation.h"
|
||||
#include "transport/usermanager.h"
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/factory.h"
|
||||
#include "transport/user.h"
|
||||
#include "Swiften/Roster/SetRosterRequest.h"
|
||||
|
@ -38,11 +38,11 @@ ConversationManager::ConversationManager(User *user, Component *component){
|
|||
ConversationManager::~ConversationManager() {
|
||||
}
|
||||
|
||||
void ConversationManager::setConversation(AbstractConversation *conv) {
|
||||
void ConversationManager::setConversation(Conversation *conv) {
|
||||
m_convs[conv->getLegacyName()] = conv;
|
||||
}
|
||||
|
||||
void ConversationManager::unsetConversation(AbstractConversation *conv) {
|
||||
void ConversationManager::unsetConversation(Conversation *conv) {
|
||||
m_convs.erase(conv->getLegacyName());
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "transport/transport.h"
|
||||
#include "transport/storagebackend.h"
|
||||
#include "transport/userregistration.h"
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/rostermanager.h"
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
@ -111,11 +111,11 @@ void Logger::handleUserDestroyed(User *user) {
|
|||
std::cout << "[USERMANAGER] User \"" << user->getJID().toBare().toString() << "\" (UIN: \"" << user->getUserInfo().uin << "\") disconnected and User class is going to be destroyed\n";
|
||||
}
|
||||
|
||||
void Logger::handleBuddySet(AbstractBuddy *buddy) {
|
||||
void Logger::handleBuddySet(Buddy *buddy) {
|
||||
std::cout << "[ROSTERMANAGER] \"" << buddy->getRosterManager()->getUser()->getJID().toBare().toString() << "\": Buddy \"" << buddy->getSafeName() << "\" (ALIAS: \"" << buddy->getAlias() << "\") has been bound with this user's roster.\n";
|
||||
}
|
||||
|
||||
void Logger::handleBuddyUnset(AbstractBuddy *buddy) {
|
||||
void Logger::handleBuddyUnset(Buddy *buddy) {
|
||||
std::cout << "[ROSTERMANAGER] \"" << buddy->getRosterManager()->getUser()->getJID().toBare().toString() << "\": Buddy \"" << buddy->getSafeName() << "\" (ALIAS: \"" << buddy->getAlias() << "\") has been unbound with this user's roster.\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
*/
|
||||
|
||||
#include "transport/rostermanager.h"
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/usermanager.h"
|
||||
#include "transport/abstractbuddy.h"
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/user.h"
|
||||
#include "Swiften/Roster/SetRosterRequest.h"
|
||||
#include "Swiften/Elements/RosterPayload.h"
|
||||
|
@ -38,12 +38,12 @@ RosterManager::RosterManager(User *user, Component *component){
|
|||
RosterManager::~RosterManager() {
|
||||
}
|
||||
|
||||
void RosterManager::setBuddy(AbstractBuddy *buddy) {
|
||||
void RosterManager::setBuddy(Buddy *buddy) {
|
||||
m_setBuddyTimer->onTick.connect(boost::bind(&RosterManager::setBuddyCallback, this, buddy));
|
||||
m_setBuddyTimer->start();
|
||||
}
|
||||
|
||||
void RosterManager::sendBuddyRosterPush(AbstractBuddy *buddy) {
|
||||
void RosterManager::sendBuddyRosterPush(Buddy *buddy) {
|
||||
Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
|
||||
Swift::RosterItemPayload item;
|
||||
item.setJID(buddy->getJID().toBare());
|
||||
|
@ -57,7 +57,7 @@ void RosterManager::sendBuddyRosterPush(AbstractBuddy *buddy) {
|
|||
request->send();
|
||||
}
|
||||
|
||||
void RosterManager::setBuddyCallback(AbstractBuddy *buddy) {
|
||||
void RosterManager::setBuddyCallback(Buddy *buddy) {
|
||||
m_setBuddyTimer->onTick.disconnect(boost::bind(&RosterManager::setBuddyCallback, this, buddy));
|
||||
|
||||
m_buddies[buddy->getName()] = buddy;
|
||||
|
@ -72,7 +72,7 @@ void RosterManager::setBuddyCallback(AbstractBuddy *buddy) {
|
|||
}
|
||||
}
|
||||
|
||||
void RosterManager::unsetBuddy(AbstractBuddy *buddy) {
|
||||
void RosterManager::unsetBuddy(Buddy *buddy) {
|
||||
m_buddies.erase(buddy->getName());
|
||||
onBuddyUnset(buddy);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void RosterManager::handleBuddyRosterPushResponse(Swift::ErrorPayload::ref error
|
|||
}
|
||||
}
|
||||
|
||||
AbstractBuddy *RosterManager::getBuddy(const std::string &name) {
|
||||
Buddy *RosterManager::getBuddy(const std::string &name) {
|
||||
return m_buddies[name];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue