handleBuddyRemovedRequest
This commit is contained in:
parent
f7a46da7b0
commit
ed6b548f48
3 changed files with 29 additions and 2 deletions
|
@ -65,6 +65,7 @@ class NetworkPlugin {
|
|||
virtual void handleJoinRoomRequest(const std::string &/*user*/, const std::string &/*room*/, const std::string &/*nickname*/, const std::string &/*pasword*/) {}
|
||||
virtual void handleLeaveRoomRequest(const std::string &/*user*/, const std::string &/*room*/) {}
|
||||
virtual void handleBuddyUpdatedRequest(const std::string &/*user*/, const std::string &/*buddyName*/, const std::string &/*alias*/, const std::string &/*groups*/) {}
|
||||
virtual void handleBuddyRemovedRequest(const std::string &/*user*/, const std::string &/*buddyName*/, const std::string &/*groups*/) {}
|
||||
|
||||
|
||||
private:
|
||||
|
@ -76,6 +77,7 @@ class NetworkPlugin {
|
|||
void handleLeaveRoomPayload(const std::string &payload);
|
||||
void handleVCardPayload(const std::string &payload);
|
||||
void handleBuddyChangedPayload(const std::string &payload);
|
||||
void handleBuddyRemovedPayload(const std::string &payload);
|
||||
void handleDataRead(const Swift::SafeByteArray&);
|
||||
void _handleConnected(bool error);
|
||||
void handleDisconnected();
|
||||
|
|
|
@ -275,6 +275,16 @@ void NetworkPlugin::handleBuddyChangedPayload(const std::string &data) {
|
|||
handleBuddyUpdatedRequest(payload.username(), payload.buddyname(), payload.alias(), payload.groups());
|
||||
}
|
||||
|
||||
void NetworkPlugin::handleBuddyRemovedPayload(const std::string &data) {
|
||||
pbnetwork::Buddy payload;
|
||||
if (payload.ParseFromString(data) == false) {
|
||||
// TODO: ERROR
|
||||
return;
|
||||
}
|
||||
|
||||
handleBuddyRemovedRequest(payload.username(), payload.buddyname(), payload.groups());
|
||||
}
|
||||
|
||||
void NetworkPlugin::handleDataRead(const Swift::SafeByteArray &data) {
|
||||
m_data.insert(m_data.end(), data.begin(), data.end());
|
||||
|
||||
|
|
|
@ -520,8 +520,23 @@ void NetworkPluginServer::handleMessageReceived(NetworkConversation *conv, boost
|
|||
send(c->connection, message);
|
||||
}
|
||||
|
||||
void NetworkPluginServer::handleBuddyRemoved(Buddy *buddy) {
|
||||
|
||||
void NetworkPluginServer::handleBuddyRemoved(Buddy *b) {
|
||||
User *user = b->getRosterManager()->getUser();
|
||||
|
||||
pbnetwork::Buddy buddy;
|
||||
buddy.set_username(user->getJID().toBare());
|
||||
buddy.set_buddyname(b->getName());
|
||||
buddy.set_alias(b->getAlias());
|
||||
buddy.set_groups(b->getGroups().size() == 0 ? "" : b->getGroups()[0]);
|
||||
buddy.set_status(Swift::StatusShow::None);
|
||||
|
||||
std::string message;
|
||||
buddy.SerializeToString(&message);
|
||||
|
||||
WRAP(message, pbnetwork::WrapperMessage_Type_TYPE_BUDDY_REMOVED);
|
||||
|
||||
Client *c = (Client *) user->getData();
|
||||
send(c->connection, message);
|
||||
}
|
||||
|
||||
void NetworkPluginServer::handleBuddyUpdated(Buddy *b, const Swift::RosterItemPayload &item) {
|
||||
|
|
Loading…
Add table
Reference in a new issue