Libtransport: Fix crash in avatar handling code when storage backend is not set. Add extended_test for avatars using libpurple backend
This commit is contained in:
parent
321215840b
commit
ddee629fe4
3 changed files with 16 additions and 9 deletions
|
@ -62,6 +62,7 @@ User::User(const Swift::JID &jid, UserInfo &userInfo, Component *component, User
|
|||
m_resources = 0;
|
||||
m_reconnectCounter = 0;
|
||||
m_reconnectLimit = 3;
|
||||
m_storageBackend = NULL;
|
||||
|
||||
m_reconnectTimer = m_component->getNetworkFactories()->getTimerFactory()->createTimer(5000);
|
||||
m_reconnectTimer->onTick.connect(boost::bind(&User::onConnectingTimeout, this));
|
||||
|
@ -173,17 +174,19 @@ void User::leaveRoom(const std::string &room) {
|
|||
void User::handlePresence(Swift::Presence::ref presence, bool forceJoin) {
|
||||
LOG4CXX_INFO(logger, "PRESENCE " << presence->getFrom().toString() << " " << presence->getTo().toString());
|
||||
|
||||
if (m_storageBackend) {
|
||||
boost::shared_ptr<Swift::VCardUpdate> vcardUpdate = presence->getPayload<Swift::VCardUpdate>();
|
||||
if (vcardUpdate) {
|
||||
std::string value = "";
|
||||
int type = (int) TYPE_STRING;
|
||||
boost::shared_ptr<Swift::VCardUpdate> vcardUpdate = presence->getPayload<Swift::VCardUpdate>();
|
||||
if (vcardUpdate) {
|
||||
std::string value = "";
|
||||
int type = (int) TYPE_STRING;
|
||||
if (m_storageBackend) {
|
||||
m_storageBackend->getUserSetting(m_userInfo.id, "photohash", type, value);
|
||||
if (value != vcardUpdate->getPhotoHash()) {
|
||||
LOG4CXX_INFO(logger, m_jid.toString() << ": Requesting VCard")
|
||||
}
|
||||
if (value != vcardUpdate->getPhotoHash()) {
|
||||
LOG4CXX_INFO(logger, m_jid.toString() << ": Requesting VCard")
|
||||
if (m_storageBackend) {
|
||||
m_storageBackend->updateUserSetting(m_userInfo.id, "photohash", vcardUpdate->getPhotoHash());
|
||||
requestVCard();
|
||||
}
|
||||
requestVCard();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ bool VCardResponder::handleGetRequest(const Swift::JID& from, const Swift::JID&
|
|||
}
|
||||
|
||||
bool VCardResponder::handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::VCard> payload) {
|
||||
if (!to.getNode().empty()) {
|
||||
if (!to.getNode().empty() && from.toBare().toString() != to.toBare().toString()) {
|
||||
LOG4CXX_WARN(logger, from.toBare().toString() << ": Tried to set VCard of somebody else");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ class BaseTest:
|
|||
responder.register_plugin('xep_0030') # Service Discovery
|
||||
responder.register_plugin('xep_0045') # Multi-User Chat
|
||||
responder.register_plugin('xep_0199') # XMPP Ping
|
||||
responder.register_plugin('xep_0153')
|
||||
responder.register_plugin('xep_0054')
|
||||
responder['feature_mechanisms'].unencrypted_plain = True
|
||||
|
||||
to = ("127.0.0.1", 5223)
|
||||
|
@ -63,6 +65,8 @@ class BaseTest:
|
|||
client.register_plugin('xep_0030') # Service Discovery
|
||||
client.register_plugin('xep_0045') # Multi-User Chat
|
||||
client.register_plugin('xep_0199') # XMPP Ping
|
||||
client.register_plugin('xep_0153')
|
||||
client.register_plugin('xep_0054')
|
||||
client['feature_mechanisms'].unencrypted_plain = True
|
||||
|
||||
time.sleep(2)
|
||||
|
|
Loading…
Add table
Reference in a new issue