forward vcard set to backend
This commit is contained in:
parent
b37bd6524f
commit
f1e8d12674
4 changed files with 30 additions and 1 deletions
|
@ -80,6 +80,7 @@ class NetworkPluginServer {
|
|||
void handleBuddyRemoved(Buddy *buddy);
|
||||
void handleBuddyAdded(Buddy *buddy, const Swift::RosterItemPayload &item);
|
||||
|
||||
void handleVCardUpdated(User *user, boost::shared_ptr<Swift::VCard> vcard);
|
||||
void handleVCardRequired(User *user, const std::string &name, unsigned int id);
|
||||
|
||||
void send(boost::shared_ptr<Swift::Connection> &, const std::string &data);
|
||||
|
|
|
@ -39,6 +39,7 @@ class VCardResponder : public Swift::Responder<Swift::VCard> {
|
|||
void sendVCard(unsigned int id, boost::shared_ptr<Swift::VCard> vcard);
|
||||
|
||||
boost::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
|
||||
boost::signal<void (User *, boost::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
|
||||
|
||||
private:
|
||||
struct VCardData {
|
||||
|
|
|
@ -125,6 +125,7 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
|
|||
|
||||
m_vcardResponder = new VCardResponder(component->getIQRouter(), userManager);
|
||||
m_vcardResponder->onVCardRequired.connect(boost::bind(&NetworkPluginServer::handleVCardRequired, this, _1, _2, _3));
|
||||
m_vcardResponder->onVCardUpdated.connect(boost::bind(&NetworkPluginServer::handleVCardUpdated, this, _1, _2));
|
||||
m_vcardResponder->start();
|
||||
|
||||
m_rosterResponder = new RosterResponder(component->getIQRouter(), userManager);
|
||||
|
@ -655,8 +656,23 @@ void NetworkPluginServer::handleBuddyAdded(Buddy *buddy, const Swift::RosterItem
|
|||
handleBuddyUpdated(buddy, item);
|
||||
}
|
||||
|
||||
void NetworkPluginServer::handleVCardUpdated(User *user, boost::shared_ptr<Swift::VCard> v) {
|
||||
pbnetwork::VCard vcard;
|
||||
vcard.set_username(user->getJID().toBare());
|
||||
vcard.set_buddyname("");
|
||||
vcard.set_id(0);
|
||||
vcard.set_photo(&v->getPhoto()[0], v->getPhoto().size());
|
||||
|
||||
std::string message;
|
||||
vcard.SerializeToString(&message);
|
||||
|
||||
WRAP(message, pbnetwork::WrapperMessage_Type_TYPE_VCARD);
|
||||
|
||||
Client *c = (Client *) user->getData();
|
||||
send(c->connection, message);
|
||||
}
|
||||
|
||||
void NetworkPluginServer::handleVCardRequired(User *user, const std::string &name, unsigned int id) {
|
||||
std::cout << "VCARD REQUIRED " << name << " " << id << "\n";
|
||||
pbnetwork::VCard vcard;
|
||||
vcard.set_username(user->getJID().toBare());
|
||||
vcard.set_buddyname(name);
|
||||
|
|
|
@ -73,6 +73,17 @@ 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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User *user = m_userManager->getUser(from.toBare().toString());
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
onVCardUpdated(user, payload);
|
||||
|
||||
sendResponse(from, id, boost::shared_ptr<VCard>(new VCard()));
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue