Skip to content

Commit fc064b2

Browse files
committed
Change Group::ContainsUser to take user object
1 parent 6178fdc commit fc064b2

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

binaryninjaapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22463,7 +22463,7 @@ namespace BinaryNinja::Collaboration
2246322463
std::string GetName();
2246422464
void SetName(const std::string& name);
2246522465
void SetUsernames(const std::vector<std::string>& usernames);
22466-
bool ContainsUser(const std::string& username);
22466+
bool ContainsUser(Ref<CollabUser> user);
2246722467

2246822468
};
2246922469

binaryninjacore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8616,7 +8616,7 @@ extern "C"
86168616
BINARYNINJACOREAPI void BNCollaborationGroupSetName(BNCollaborationGroup* group, const char* name);
86178617
BINARYNINJACOREAPI bool BNCollaborationGroupGetUsers(BNCollaborationGroup* group, char*** userIds, char*** usernames, size_t* count);
86188618
BINARYNINJACOREAPI bool BNCollaborationGroupSetUsernames(BNCollaborationGroup* group, const char** names, size_t count);
8619-
BINARYNINJACOREAPI bool BNCollaborationGroupContainsUser(BNCollaborationGroup* group, const char* username);
8619+
BINARYNINJACOREAPI bool BNCollaborationGroupContainsUser(BNCollaborationGroup* group, BNCollaborationUser* user);
86208620

86218621
// CollabUser
86228622
BINARYNINJACOREAPI BNCollaborationUser* BNNewCollaborationUserReference(BNCollaborationUser* user);

collaboration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,9 @@ void CollabGroup::SetUsernames(const std::vector<std::string>& usernames)
10891089
}
10901090

10911091

1092-
bool CollabGroup::ContainsUser(const std::string& username)
1092+
bool CollabGroup::ContainsUser(Ref<CollabUser> user)
10931093
{
1094-
return BNCollaborationGroupContainsUser(m_object, username.c_str());
1094+
return BNCollaborationGroupContainsUser(m_object, user->m_object);
10951095
}
10961096

10971097

python/collaboration/group.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import List, Tuple
33

44
from .. import _binaryninjacore as core
5-
from . import remote, util
5+
from . import remote, user, util
66

77

88
class Group:
@@ -102,11 +102,11 @@ def users(self, usernames: List[str]):
102102
if not core.BNCollaborationGroupSetUsernames(self._handle, array, len(usernames)):
103103
raise RuntimeError(util._last_error())
104104

105-
def contains_user(self, username: str) -> bool:
105+
def contains_user(self, user: user.User) -> bool:
106106
"""
107-
Test if a group has a user with the given username
107+
Test if a group contains a user
108108
109-
:param username: Username of user to check membership
110-
:return: If the user is in the group
109+
:param user: User to check membership of
110+
:return: If the group contains the user
111111
"""
112-
return core.BNCollaborationGroupContainsUser(self._handle, username)
112+
return core.BNCollaborationGroupContainsUser(self._handle, user._handle)

rust/src/collaboration/group.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::Remote;
2+
use crate::collaboration::RemoteUser;
23
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable};
34
use crate::string::{BnString, IntoCStr};
45
use binaryninjacore_sys::*;
@@ -100,10 +101,9 @@ impl RemoteGroup {
100101
success.then_some(()).ok_or(())
101102
}
102103

103-
/// Test if a group has a user with the given username
104-
pub fn contains_user(&self, username: &str) -> bool {
105-
let username = username.to_cstr();
106-
unsafe { BNCollaborationGroupContainsUser(self.handle.as_ptr(), username.as_ptr()) }
104+
/// Test if a group contains a user
105+
pub fn contains_user(&self, user: Ref<RemoteUser>) -> bool {
106+
unsafe { BNCollaborationGroupContainsUser(self.handle.as_ptr(), user.handle.as_ptr()) }
107107
}
108108
}
109109

0 commit comments

Comments
 (0)