Solve compilation problems

Signed-off-by: Dageking <dage007@126.com>
This commit is contained in:
Dageking 2021-12-09 10:38:30 +08:00 committed by gudehe
parent 8cd84d1dee
commit f62d406d38
11 changed files with 72 additions and 37 deletions

View File

@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
config("storage_daemon_config") {
include_dirs = [
"include",
@ -19,10 +21,24 @@ config("storage_daemon_config") {
}
ohos_executable("storage_daemon") {
sources = [ "main.cpp" ]
sources = [
"main.cpp",
configs = [ ":storage_daemon_config" ]
"ipc/src/storage_daemon.cpp",
"ipc/src/storage_daemon_stub.cpp",
"ipc/src/storage_daemon_proxy.cpp",
"user/src/user_manager.cpp",
]
configs = [
":storage_daemon_config"
]
deps = [
"//utils/native/base:utils",
]
external_deps = [
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",

View File

@ -16,10 +16,13 @@
#ifndef OHOS_STORAGE_DAEMON_ISTORAGE_DAEMON_H
#define OHOS_STORAGE_DAEMON_ISTORAGE_DAEMON_H
#include <string>
#include "iremote_broker.h"
namespace OHOS {
namespace StorageDaemon {
using namespace std;
class IStorageDaemon : public IRemoteBroker {
public:
enum {
@ -36,7 +39,7 @@ public:
DESTROY_USER_DIRS,
};
virtual void Shutdown();
virtual int32_t Shutdown();
virtual int32_t Mount(string volId, uint32_t flags);
virtual int32_t UMount(string volId);

View File

@ -17,12 +17,13 @@
#define OHOS_STORAGE_DAEMON_STORAGE_DAEMON_H
#include "ipc/storage_daemon_stub.h"
#include "utils/errno.h"
namespace OHOS {
namespace StorageDaemon {
class StorageDaemon : StorageDaemonStub {
public:
virtual void Shutdown() override;
virtual int32_t Shutdown() override;
virtual int32_t Mount(string volId, uint32_t flags) override;
virtual int32_t UMount(string volId) override;

View File

@ -23,7 +23,8 @@ namespace OHOS {
namespace StorageDaemon {
class StorageDaemonProxy : public IRemoteProxy<IStorageDaemon> {
public:
virtual void Shutdown() override;
StorageDaemonProxy(const sptr<IRemoteObject> &impl);
virtual int32_t Shutdown() override;
virtual int32_t Mount(string volId, uint32_t flags) override;
virtual int32_t UMount(string volId) override;
@ -35,7 +36,7 @@ public:
virtual int32_t PrepareUserDirs(int32_t userId, uint32_t flags) override;
virtual int32_t DestroyUserDirs(int32_t userId, uint32_t flags) override;
private:
static inline BrokerDelegator<StorageServiceProxy> delegator_;
static inline BrokerDelegator<StorageDaemonProxy> delegator_;
};
} // StorageDaemon
} // OHOS

View File

@ -25,9 +25,10 @@ enum UserState {
};
class UserInfo {
private:
int32_t userId;
UserState state;
public:
UserInfo(int32_t id, UserState state)
{
this->userId = id;

View File

@ -16,9 +16,17 @@
#ifndef OHOS_STORAGE_DAEMON_USER_MANAGER_H
#define OHOS_STORAGE_DAEMON_USER_MANAGER_H
#include <unordered_map>
#include "user/user_info.h"
#include "nocopyable.h"
#define DISABLE_COPY_ASSIGN_MOVE(ClassName) \
ClassName(const ClassName &) = delete; \
ClassName(ClassName &&) = delete; \
ClassName& operator=(const ClassName &) = delete; \
ClassName& operator=(ClassName &&) = delete
namespace OHOS {
namespace StorageDaemon {
class UserManager final {
@ -36,7 +44,7 @@ private:
private:
static UserManager* instance;
std::unorded_map<int32_t, UserInfo> users;
std::unordered_map<int32_t, UserInfo> users;
};
} // STORAGE_DAEMON
} // OHOS

View File

@ -22,7 +22,7 @@
#endif
namespace OHOS {
namespace Storage_Daemon {
namespace StorageDaemon {
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_DOMAIN, "StorageDaemon" };
@ -35,7 +35,7 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_DOMAIN,
#define LOGW(fmt, ...) PRINT_LOG(Warn, fmt, ##__VA_ARGS__)
#define LOGE(fmt, ...) PRINT_LOG(Error, fmt, ##__VA_ARGS__)
#define LOGF(fmt, ...) PRINT_LOG(Fatal, fmt, ##__VA_ARGS__)
}
}
} // StorageDaemon
} // OHOS
#endif // STORAGE_DAEMON_UTILS_LOG_H

View File

@ -19,30 +19,30 @@
namespace OHOS {
namespace StorageDaemon {
StorageDaemon::StorageDaemon() {}
// StorageDaemon::StorageDaemon() {}
int32_t Shutdown()
{
return E_OK;
}
int32_t Mount(string volId)
{
return E_OK;
}
int32_t UMount(string volId)
{
return E_OK;
}
int32_t Check(string volId)
{
return E_OK;
}
int32_t Format(string voldId)
{
return E_OK;
}
int32_t AddUser(int32_t userId)

View File

@ -25,38 +25,38 @@ int32_t StorageDaemonProxy::Shutdown()
{
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageServiceCallbackProxy::GetDescriptor())) {
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
return E_IPC_ERROR;
}
return Remote()->SendRequest(SHUTDOWN, data, reply, option);
}
int32_t StorageDaemonProxy::Mount(string volId)
int32_t StorageDaemonProxy::Mount(string volId, uint32_t flags)
{
return E_OK;
}
int32_t StorageDaemonProxy::UMount(string volId)
{
return E_OK;
}
int32_t StorageDaemonProxy::Check(string volId)
{
return E_OK;
}
int32_t StorageDaemonProxy::Format(string voldId)
{
return E_OK;
}
int32_t StorageDaemonProxy::AddUser(int32_t userId)
{
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageServiceCallbackProxy::GetDescriptor())) {
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
return E_IPC_ERROR;
}
@ -74,14 +74,14 @@ int32_t StorageDaemonProxy::RemoveUser(int32_t userId)
{
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageServiceCallbackProxy::GetDescriptor())) {
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
return E_IPC_ERROR;
}
if (!data.WriteInt32(userId)) {
return E_IPC_ERROR;
}
int err = Remote()->SendRequest(REMOVE_USER, data, reply, option);
int err = Remote()->SendRequest(DEL_USER, data, reply, option);
if (err != E_OK) {
return E_IPC_ERROR;
}
@ -92,7 +92,7 @@ int32_t StorageDaemonProxy::PrepareUserDirs(int32_t userId, uint32_t flags)
{
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageServiceCallbackProxy::GetDescriptor())) {
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
return E_IPC_ERROR;
}
@ -113,7 +113,7 @@ int32_t StorageDaemonProxy::DestroyUserDirs(int32_t userId, uint32_t flags)
{
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageServiceCallbackProxy::GetDescriptor())) {
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
return E_IPC_ERROR;
}

View File

@ -15,6 +15,7 @@
#include "ipc/storage_daemon_stub.h"
#include "utils/errno.h"
#include "utils/log.h"
namespace OHOS {
namespace StorageDaemon {
@ -31,12 +32,12 @@ int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
case SHUTDOWN: err = HandleShutdown(); break;
case ADD_USER: err = HandleAddUser(data, reply); break;
case REMOVE_USER: err = HandleRemoveUser(data, reply); break;
case DEL_USER: err = HandleRemoveUser(data, reply); break;
case PREPARE_USER_DIRS: err = HandlePrepareUserDirs(data, reply); break;
case DESTROY_USER_DIRS: err = HandleDestroyUserDirs(data, reply); break;
default: {
LOGI(" use IPCObjectStub default OnRemoteRequest");
errCode = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
err = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
break;
}
}
@ -53,22 +54,22 @@ int32_t StorageDaemonStub::HandleShutdown()
int32_t StorageDaemonStub::HandleMount(MessageParcel &data, MessageParcel &reply)
{
return E_OK;
}
int32_t StorageDaemonStub::HandleUMount(MessageParcel &data, MessageParcel &reply)
{
return E_OK;
}
int32_t StorageDaemonStub::HandleCheck(MessageParcel &data, MessageParcel &reply)
{
return E_OK;
}
int32_t StorageDaemonStub::HandleFormat(MessageParcel &data, MessageParcel &reply)
{
return E_OK;
}
int32_t StorageDaemonStub::HandleAddUser(MessageParcel &data, MessageParcel &reply)

View File

@ -17,6 +17,8 @@
#include "utils/errno.h"
#include "utils/log.h"
namespace OHOS {
namespace StorageDaemon {
UserManager::UserManager()
{}
@ -35,7 +37,7 @@ int32_t UserManager::AddUser(int32_t userId)
return E_EXIST;
}
users.insert({ userInfo, UserInfo(userId, USER_CREAT) };
users.insert({ userId, UserInfo(userId, USER_CREAT) });
return E_OK;
}
@ -48,10 +50,12 @@ int32_t UserManager::RemoveUser(int32_t userId)
int32_t UserManager::PrepareUserDirs(int32_t userId, uint32_t flags)
{
return E_OK;
}
int32_t UserManager::DestroyUserDirs(int32_t userId, uint32_t flags)
{
return E_OK;
}
} // StorageDaemon
} // OHOS