Browse Source

LIB-11: group_manager_api - rename funcs, add init()

init used to be in the GroupDriverReplicator constructor. But this caused problems together with statical initialization.
LIB-11
heck 11 months ago
parent
commit
713cdc3887
3 changed files with 47 additions and 15 deletions
  1. +37
    -5
      src/group_manager_api.cc
  2. +7
    -8
      src/group_manager_api.h
  3. +3
    -2
      src/grp_driver_replicator.cc

+ 37
- 5
src/group_manager_api.cc View File

@ -5,14 +5,44 @@
#include "group_manager_api.h"
#include "grp_driver_replicator.hh"
#include "pEpLog.hh"
#include "grp_driver_dummy.hh"
#include "grp_driver_engine.hh"
#ifdef __cplusplus
extern "C" {
#endif
using namespace std;
using namespace pEp;
pEp::Adapter::GroupDriverReplicator adapter_grp_manager{};
Adapter::GroupDriverReplicator adapter_grp_manager{};
shared_ptr<Adapter::GroupDriverDummy> grp_drv_dummy;
shared_ptr<Adapter::GroupDriverEngine> grp_drv_engine;
DYNAMIC_API PEP_STATUS adapter_group_init()
{
PEP_STATUS status;
try {
const string lm_dummy_db_filename = "listman_dummy.db";
#ifdef WIN32
const string lm_dummy_db_path = string(::per_user_directory()) + "\\" + lm_dummy_db_filename;
#else
const string lm_dummy_db_path = string(::per_user_directory()) + "/" + lm_dummy_db_filename;
#endif
grp_drv_dummy = make_shared<Adapter::GroupDriverDummy>(lm_dummy_db_path);
grp_drv_engine = make_shared<Adapter::GroupDriverEngine>();
adapter_grp_manager.set_replication_source(*grp_drv_dummy.get());
adapter_grp_manager.set_replication_destination(*grp_drv_engine.get());
// adapter_grp_manager.logger.set_enabled(true);
} catch (const std::exception &e) {
pEpLog(Utils::nested_exception_to_string(e));
status = PEP_UNKNOWN_ERROR;
} catch (...) {
pEpLog("unknown exception");
status = PEP_UNKNOWN_ERROR;
}
return status;
}
/*************************************************************************************************
* Group management functions
@ -67,7 +97,7 @@ PEP_STATUS adapter_group_remove_member(
/*************************************************************************************************
* Group query functions
*************************************************************************************************/
DYNAMIC_API PEP_STATUS group_query_groups(PEP_SESSION session, identity_list **groups)
DYNAMIC_API PEP_STATUS adapter_group_query_groups(PEP_SESSION session, identity_list **groups)
{
pEpLog("called");
PEP_STATUS status = adapter_grp_manager.group_query_groups(session, groups);
@ -75,15 +105,17 @@ DYNAMIC_API PEP_STATUS group_query_groups(PEP_SESSION session, identity_list **g
}
DYNAMIC_API PEP_STATUS
group_query_manager(PEP_SESSION session, const pEp_identity *const group, pEp_identity **manager)
adapter_group_query_manager(PEP_SESSION session, const pEp_identity *const group, pEp_identity **manager)
{
pEpLog("called");
PEP_STATUS status = adapter_grp_manager.group_query_manager(session, group, manager);
return status;
}
DYNAMIC_API PEP_STATUS
group_query_members(PEP_SESSION session, const pEp_identity *const group, identity_list **members)
DYNAMIC_API PEP_STATUS adapter_group_query_members(
PEP_SESSION session,
const pEp_identity *const group,
identity_list **members)
{
pEpLog("called");
PEP_STATUS status = adapter_grp_manager.group_query_members(session, group, members);


+ 7
- 8
src/group_manager_api.h View File

@ -10,6 +10,7 @@
extern "C" {
#endif
DYNAMIC_API PEP_STATUS adapter_group_init();
/*************************************************************************************************
* Group management functions
@ -139,7 +140,7 @@ PEP_STATUS adapter_group_remove_member(
*************************************************************************************************/
/**
* <!-- group_query_groups() -->
* <!-- adapter_group_query_groups() -->
*
* @brief queries the list manager which groups currently exist.
*
@ -154,10 +155,10 @@ PEP_STATUS adapter_group_remove_member(
*
*/
DYNAMIC_API PEP_STATUS group_query_groups(PEP_SESSION session, identity_list **groups);
DYNAMIC_API PEP_STATUS adapter_group_query_groups(PEP_SESSION session, identity_list **groups);
/**
* <!-- group_query_manager() -->
* <!-- adapter_group_query_manager() -->
*
* @brief queries the list manager for the group manager of a given group.
*
@ -172,11 +173,10 @@ DYNAMIC_API PEP_STATUS group_query_groups(PEP_SESSION session, identity_list **g
*
*/
DYNAMIC_API PEP_STATUS
group_query_manager(PEP_SESSION session, const pEp_identity *const group, pEp_identity **manager);
DYNAMIC_API PEP_STATUS adapter_group_query_manager(PEP_SESSION session, const pEp_identity *const group, pEp_identity **manager);
/**
* <!-- group_query_members() -->
* <!-- adapter_group_query_members() -->
*
* @brief queries the list manager for all members of a given group.
*
@ -191,8 +191,7 @@ group_query_manager(PEP_SESSION session, const pEp_identity *const group, pEp_id
*
*/
DYNAMIC_API PEP_STATUS
group_query_members(PEP_SESSION session, const pEp_identity *const group, identity_list **members);
DYNAMIC_API PEP_STATUS adapter_group_query_members(PEP_SESSION session, const pEp_identity *const group, identity_list **members);
#ifdef __cplusplus


+ 3
- 2
src/grp_driver_replicator.cc View File

@ -12,7 +12,7 @@ namespace pEp {
GroupDriverReplicator::GroupDriverReplicator()
{
pEpLogClass("called");
const string lm_dummy_db_filename = "listman_dummy.db";
/* const string lm_dummy_db_filename = "listman_dummy.db";
#ifdef WIN32
const string lm_dummy_db_path = string(::per_user_directory()) + "\\" +
lm_dummy_db_filename;
@ -25,6 +25,7 @@ namespace pEp {
default_repl_dst = make_shared<GroupDriverEngine>();
set_replication_destination(*default_repl_dst);
*/
}
void GroupDriverReplicator::set_replication_source(GroupManagerInterface &src)
@ -129,7 +130,7 @@ namespace pEp {
// Rollback
PEP_STATUS rb_stat = repl_src->adapter_group_remove_member(
session,
group_member,
group_identity,
group_member);
if (rb_stat != PEP_STATUS_OK) {
//FATAL ERROR ON ROLLBACK


Loading…
Cancel
Save