no message
This commit is contained in:
383
windows/src/common/services/FriendManager.cpp
Normal file
383
windows/src/common/services/FriendManager.cpp
Normal file
@@ -0,0 +1,383 @@
|
||||
#include "FriendManager.h"
|
||||
#include <libopenimsdk.h>
|
||||
#include "../NimResult.h"
|
||||
#include "../ZegoDataUtils.h"
|
||||
#include "ConstDefine.h"
|
||||
#include "Listen.h"
|
||||
|
||||
FriendshipManagerService::FriendshipManagerService()
|
||||
{
|
||||
m_serviceName = "friendshipManager";
|
||||
}
|
||||
|
||||
void FriendshipManagerService::onMethodCalled(
|
||||
const std::string &method,
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (method == "setFriendListener")
|
||||
{
|
||||
setFriendListener(arguments, result);
|
||||
}
|
||||
else if (method == "getFriendsInfo")
|
||||
{
|
||||
getFriendsInfo(arguments, result);
|
||||
}
|
||||
else if (method == "addFriend")
|
||||
{
|
||||
addFriend(arguments, result);
|
||||
}
|
||||
else if (method == "getFriendApplicationListAsRecipient")
|
||||
{
|
||||
getFriendApplicationListAsRecipient(arguments, result);
|
||||
}
|
||||
else if (method == "getFriendApplicationListAsApplicant")
|
||||
{
|
||||
getFriendApplicationListAsApplicant(arguments, result);
|
||||
}
|
||||
else if (method == "getFriendList")
|
||||
{
|
||||
getFriendList(arguments, result);
|
||||
}
|
||||
else if (method == "getFriendListPage")
|
||||
{
|
||||
getFriendListPage(arguments, result);
|
||||
}
|
||||
else if (method == "addBlacklist")
|
||||
{
|
||||
addBlacklist(arguments, result);
|
||||
}
|
||||
else if (method == "getBlacklist")
|
||||
{
|
||||
getBlacklist(arguments, result);
|
||||
}
|
||||
else if (method == "removeBlacklist")
|
||||
{
|
||||
removeBlacklist(arguments, result);
|
||||
}
|
||||
else if (method == "checkFriend")
|
||||
{
|
||||
checkFriend(arguments, result);
|
||||
}
|
||||
else if (method == "deleteFriend")
|
||||
{
|
||||
deleteFriend(arguments, result);
|
||||
}
|
||||
else if (method == "acceptFriendApplication")
|
||||
{
|
||||
acceptFriendApplication(arguments, result);
|
||||
}
|
||||
else if (method == "refuseFriendApplication")
|
||||
{
|
||||
refuseFriendApplication(arguments, result);
|
||||
}
|
||||
else if (method == "searchFriends")
|
||||
{
|
||||
searchFriends(arguments, result);
|
||||
}
|
||||
else if (method == "updateFriends")
|
||||
{
|
||||
updateFriends(arguments, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->NotImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::setFriendListener(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
set_friend_listener(NewFriendshipListenCallBack());
|
||||
result->Success(flutter::EncodableValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getFriendsInfo(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
|
||||
auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *userIDList_cs = const_cast<char *>(userIDList.c_str());
|
||||
|
||||
get_specified_friends_info(NewBaseCallBack(result), operationID_cs, userIDList_cs, filterBlack);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::addFriend(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto friendInfo = map_2_json(*arguments);
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *friendInfo_cs = const_cast<char *>(friendInfo.c_str());
|
||||
|
||||
add_friend(NewBaseCallBack(result), operationID_cs, friendInfo_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getFriendApplicationListAsRecipient(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
|
||||
get_friend_application_list_as_recipient(NewBaseCallBack(result), operationID_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getFriendApplicationListAsApplicant(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
|
||||
get_friend_application_list_as_applicant(NewBaseCallBack(result), operationID_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getFriendList(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
|
||||
get_friend_list(NewBaseCallBack(result), operationID_cs, filterBlack);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getFriendListPage(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset")));
|
||||
auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count")));
|
||||
auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
|
||||
get_friend_list_page(NewBaseCallBack(result), operationID_cs, offset, count, filterBlack);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::addBlacklist(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
|
||||
auto ex = zego_value_get_string(arguments->at(flutter::EncodableValue("ex")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *userID_cs = const_cast<char *>(userID.c_str());
|
||||
char *ex_cs = const_cast<char *>(ex.c_str());
|
||||
|
||||
add_black(NewBaseCallBack(result), operationID_cs, userID_cs, ex_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::getBlacklist(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
|
||||
get_black_list(NewBaseCallBack(result), operationID_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::removeBlacklist(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *userID_cs = const_cast<char *>(userID.c_str());
|
||||
|
||||
remove_black(NewBaseCallBack(result), operationID_cs, userID_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::checkFriend(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *userIDList_cs = const_cast<char *>(userIDList.c_str());
|
||||
|
||||
check_friend(NewBaseCallBack(result), operationID_cs, userIDList_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::deleteFriend(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *userID_cs = const_cast<char *>(userID.c_str());
|
||||
|
||||
delete_friend(NewBaseCallBack(result), operationID_cs, userID_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::acceptFriendApplication(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto applicationInfo = map_2_json(*arguments);
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *applicationInfo_cs = const_cast<char *>(applicationInfo.c_str());
|
||||
|
||||
accept_friend_application(NewBaseCallBack(result), operationID_cs, applicationInfo_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::refuseFriendApplication(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto applicationInfo = map_2_json(*arguments);
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *applicationInfo_cs = const_cast<char *>(applicationInfo.c_str());
|
||||
|
||||
refuse_friend_application(NewBaseCallBack(result), operationID_cs, applicationInfo_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::searchFriends(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto searchParam = zego_value_get_string(arguments->at(flutter::EncodableValue("searchParam")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *searchParam_cs = const_cast<char *>(searchParam.c_str());
|
||||
|
||||
search_friends(NewBaseCallBack(result), operationID_cs, searchParam_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
void FriendshipManagerService::updateFriends(
|
||||
const flutter::EncodableMap *arguments,
|
||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||
{
|
||||
if (arguments)
|
||||
{
|
||||
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
|
||||
auto req = zego_value_get_string(arguments->at(flutter::EncodableValue("req")));
|
||||
char *operationID_cs = const_cast<char *>(operationID.c_str());
|
||||
char *req_cs = const_cast<char *>(req.c_str());
|
||||
|
||||
update_friends(NewBaseCallBack(result), operationID_cs, req_cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user