#include "external-encryption.h"
-#define EXTERNAL_PATH "/opt/media/SDCardA1"
-#define EXTERNAL_STATE_VCONF_KEY VCONFKEY_SDE_CRYPTO_STATE
-#define EXTERNAL_OPTION_ONLY_NEW_FILE_VCONF_KEY VCONFKEY_SDE_ENCRYPT_NEWFILE
-#define EXTERNAL_OPTION_EXCEPT_FOR_MEDIA_FILE_VCONF_KEY VCONFKEY_SDE_EXCLUDE_MEDIAFILE
-
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
namespace ode {
bool isBootCompleted = false;
+const char *EXTERNAL_PATH = "/media/SDCardA1";
+const char *PRIVILEGE_PLATFORM = "http://tizen.org/privilege/internal/default/platform";
+
+void spawnUI()
+{
+ INFO(SINK, "Launching SD card password popup.");
+ try {
+ AppBundle bundle;
+ bundle.add("viewtype", "SD_CARD_PASSWORD");
+
+ Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ launchpad.launch("org.tizen.ode", bundle);
+ } catch (runtime::Exception &e) {
+ ERROR(SINK, "Failed to launch SD card password popup: " + std::string(e.what()));
+ }
+}
+
void externalCallback(dbus::Variant parameters)
{
int intparams[6];
char* strparams[7];
parameters.get("(issssssisibii)",
- &intparams[0], // block type: 0 - scsi, 1 : mmc, 2 : mapper
+ &intparams[0], // block type: 0 - scsi, 1 : mmc
&strparams[0], // devnode
&strparams[1], // syspath
&strparams[2], // usage
&intparams[2], // state: 0 - unmount, 1 - mount
&intparams[3], // primary: 0 - flase, 1 - true
&intparams[4], // flags: 1 - unmounted 2 - broken filesystem 4 - no filesystem 8 - not supported 16 - readonly
- &intparams[5]); // strage id
+ &intparams[5]); // storage id
if (intparams[0] != 1 || (std::string(strparams[3]) != "vfat" &&
std::string(strparams[3]) != "ext4")) {
INFO(SINK, "SD card not mounted, ignoring.");
} else {
INFO(SINK, "SD card mounted.");
- char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
+ char *value = ::vconf_get_str(VCONFKEY_SDE_CRYPTO_STATE);
if (value != NULL) {
std::string valueStr(value);
free(value);
if (valueStr == "encrypted" && isBootCompleted) {
- try {
- INFO(SINK, "Launching SD card password popup.");
- AppBundle bundle;
- bundle.add("viewtype", "SD_CARD_PASSWORD");
-
- Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
- launchpad.launch("org.tizen.ode", bundle);
- } catch (runtime::Exception &e) {
- ERROR(SINK, "Failed to launch SD card password popup: " + std::string(e.what()));
- }
+ spawnUI();
}
}
}
INFO(SINK, "Boot completed.");
- char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
+ char *value = ::vconf_get_str(VCONFKEY_SDE_CRYPTO_STATE);
if (value != NULL) {
std::string valueStr(value);
free(value);
if (valueStr == "encrypted") {
- try {
- INFO(SINK, "Launching SD card password popup.");
- AppBundle bundle;
- bundle.add("viewtype", "SD_CARD_PASSWORD");
- Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
- launchpad.launch("org.tizen.ode", bundle);
- } catch (runtime::Exception &e) {
- ERROR(SINK, "Failed to launch SD card password popup: " + std::string(e.what()));
- }
+ spawnUI();
}
}
isBootCompleted = true;
int value;
value = 0;
- ::vconf_get_bool(EXTERNAL_OPTION_EXCEPT_FOR_MEDIA_FILE_VCONF_KEY, &value);
+ ::vconf_get_bool(VCONFKEY_SDE_EXCLUDE_MEDIAFILE, &value);
if (value) {
result |= ExternalEncryption::Option::OnlyNewFile;
}
value = 0;
- ::vconf_get_bool(EXTERNAL_OPTION_ONLY_NEW_FILE_VCONF_KEY, &value);
+ ::vconf_get_bool(VCONFKEY_SDE_ENCRYPT_NEWFILE, &value);
if (value) {
result |= ExternalEncryption::Option::ExceptForMediaFile;
}
} else {
value = false;
}
- ::vconf_set_bool(EXTERNAL_OPTION_EXCEPT_FOR_MEDIA_FILE_VCONF_KEY, value);
+ ::vconf_set_bool(VCONFKEY_SDE_EXCLUDE_MEDIAFILE, value);
if (options & ExternalEncryption::Option::ExceptForMediaFile) {
value = true;
} else {
value = false;
}
- ::vconf_set_bool(EXTERNAL_OPTION_ONLY_NEW_FILE_VCONF_KEY, value);
+ ::vconf_set_bool(VCONFKEY_SDE_ENCRYPT_NEWFILE, value);
}
} // namsepace
setOptions(options & getSupportedOptions());
INFO(SINK, "Encryption completed.");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
+ ::vconf_set_str(VCONFKEY_SDE_CRYPTO_STATE, "encrypted");
server.notify("ExternalEncryptionServer::mount");
INFO(SINK, "Syncing disk.");
sync();
} catch (runtime::Exception &e) {
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ ::vconf_set_str(VCONFKEY_SDE_CRYPTO_STATE, "error_partially_encrypted");
ERROR(SINK, "Encryption failed: " + std::string(e.what()));
}
};
}
INFO(SINK, "Decryption started.");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ ::vconf_set_str(VCONFKEY_SDE_CRYPTO_STATE, "error_partially_encrypted");
engine->decrypt(MasterKey, getOptions());
INFO(SINK, "Decryption completed.");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "unencrypted");
+ ::vconf_set_str(VCONFKEY_SDE_CRYPTO_STATE, "unencrypted");
INFO(SINK, "Syncing disk.");
sync();
}
engine->clearKeyMeta();
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "unencrypted");
+ ::vconf_set_str(VCONFKEY_SDE_CRYPTO_STATE, "unencrypted");
return 0;
}
int ExternalEncryptionServer::getState()
{
- char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
+ char *value = ::vconf_get_str(VCONFKEY_SDE_CRYPTO_STATE);
if (value == NULL) {
throw runtime::Exception("Failed to get vconf value.");
}