break;
default:
Assert(false);
+ break;
}
}
} // namespace Unicode
break;
default:
LogError("Error in Access tag - unknown standard.");
+ break;
}
}
ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin,
m_bSubDomainAccess);
- std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
+ //std::pair <ConfigParserData::AccessInfoSet::iterator, bool> ret =
m_data.accessInfoSet.insert(accessInfo);
}
break;
default:
LogError("Error in Access tag - unknown standard.");
+ break;
}
}
explicit BoxSizeParser(
ConfigParserData::LiveboxInfo::BoxContentInfo& data) :
ElementParser(),
+ m_properNamespace(false),
m_data(data)
{}
namespace Jobs {
Job::Job(InstallationType installType) :
+ m_handle(0),
m_installationType(installType),
m_UndoType(false),
m_paused(false)
PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
DPL::TaskDecl<PluginInstallTask>(this),
m_context(inCont),
+ m_pluginHandle(0),
m_dataFromConfigXML(true)
{
AddStep(&PluginInstallTask::stepCheckPluginPath);
default:
LogDebug("Unknown owner type of cert");
certData[i]->owner = UNKNOWN;
+ break;
}
switch (it->type) {
case WrtDB::WidgetCertificateData::ENDENTITY:
default:
LogError("Unknown type of cert");
certData[i]->type = ENDENTITY;
+ break;
}
certData[i]->chain_id = it->chainId;
}
LogDebug("Registerign widget in ace");
- ace_return_t retval = ACE_ACE_UNKNOWN_ERROR;
- retval = ace_register_widget(
+ ace_return_t retval = ace_register_widget(
static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
//clean up - WidgetInfo
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- srand(time(NULL) + tv.tv_usec);
-
m_installerContext.m_quiet = m_jobStruct.m_quiet;
ConfigureResult result = PrePareInstallation(widgetPath);
// TODO : generate name move to wrt-commons
std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
std::ostringstream genName;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ unsigned int seed = time(NULL) + tv.tv_usec;
- genName << "_" << allowedString[rand() % allowedString.length()];
+ genName << "_" << allowedString[rand_r(&seed) % allowedString.length()];
name = DPL::FromUTF8String(genName.str());
LogDebug("name was generated by WRT");
}
LogInfo("Widget model exists. tizen app id: " << tzAppid);
// Check running state
- int retval = APP_MANAGER_ERROR_NONE;
bool isRunning = false;
- retval = app_manager_is_running(DPL::ToUTF8String(
+ int retval = app_manager_is_running(DPL::ToUTF8String(
tzAppid).c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != retval) {
LogError("Fail to get running state");
namespace WidgetInstall {
TaskCertificates::TaskCertificates(InstallerContext& context) :
DPL::TaskDecl<TaskCertificates>(this),
- m_context(context)
+ m_context(context),
+ m_pkgHandle(NULL)
{
AddStep(&TaskCertificates::StepSetCertiInfo);
AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
namespace WidgetInstall {
TaskEncryptResource::TaskEncryptResource(InstallerContext& context) :
DPL::TaskDecl<TaskEncryptResource>(this),
- m_context(context)
+ m_context(context),
+ m_resEnc(NULL)
{
AddStep(&TaskEncryptResource::StepEncryptResource);
}
<< " with error: "
<< strerror(ftsent->fts_errno));
ThrowMsg(Exceptions::InternalError, "Error reading file");
+ break;
}
}
return false;
}
- struct dirent* dEntry = NULL;
+ struct dirent dEntry;
+ struct dirent *dEntryResult;
+ int return_code;
+
do {
struct stat statInfo;
- if ((dEntry = readdir(dir)) != NULL) {
- std::string fileName = dEntry->d_name;
+ return_code = readdir_r(dir, &dEntry, &dEntryResult);
+ if (dEntryResult != NULL && return_code == 0) {
+ std::string fileName = dEntry.d_name;
std::string fullName = source + "/" + fileName;
if (stat(fullName.c_str(), &statInfo) != 0) {
outfile.close();
infile.close();
}
- } while (dEntry);
+ } while (dEntryResult != NULL && return_code == 0);
closedir(dir);
return true;
}
namespace WidgetInstall {
TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
DPL::TaskDecl<TaskFileManipulation>(this),
- m_context(context)
+ m_context(context),
+ m_extHandle(NULL)
{
if (INSTALL_LOCATION_TYPE_EXTERNAL !=
m_context.locationType)
TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
DPL::TaskDecl<TaskManifestFile>(this),
- m_context(inCont)
+ m_context(inCont),
+ writer(NULL)
{
if (false == m_context.existingWidgetInfo.isExist) {
AddStep(&TaskManifestFile::stepCopyIconFiles);
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
- icon++)
+ ++icon)
{
FOREACH(locale, icon->availableLocales)
{
ThrowMsg(Exceptions::InternalError, path);
}
- struct dirent* d_ent;
- do {
- if ((d_ent = readdir(dir))) {
- if (strcmp(d_ent->d_name, ".") == 0 ||
- strcmp(d_ent->d_name, "..") == 0)
- {
- continue;
- }
- std::string file_name = d_ent->d_name;
- list.push_back(file_name);
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ if (strcmp(entry.d_name, ".") == 0 ||
+ strcmp(entry.d_name, "..") == 0)
+ {
+ continue;
}
- } while (d_ent);
+ std::string file_name = entry.d_name;
+ list.push_back(file_name);
+ }
+
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << path << " with error: "
<< DPL::GetErrnoString());
for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator
icon = icons.rbegin();
icon != icons.rend();
- icon++)
+ ++icon)
{
FOREACH(locale, icon->availableLocales)
{
LiveBoxInfo liveBox;
DPL::Optional<WrtDB::ConfigParserData::LiveboxInfo> ConfigInfo = *it;
DPL::String appid = m_context.widgetConfig.tzAppid;
- size_t found;
if (ConfigInfo->m_liveboxId != L"") {
- found = ConfigInfo->m_liveboxId.find_last_of(L".");
+ size_t found = ConfigInfo->m_liveboxId.find_last_of(L".");
if (found != std::string::npos) {
if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) {
liveBox.setLiveboxId(ConfigInfo->m_liveboxId);
/* Find all .so files and store their names in list */
DIR *dir;
- struct dirent *entry;
struct stat st;
LogDebug("Opening plugins directory");
dir = opendir(m_npsource.c_str());
ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory");
}
std::string tempname;
+ struct dirent entry;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
const std::string ext(".so");
/* Listing directory and checking entries found inside */
- while ((entry = readdir(dir)) != NULL) {
- tempname = m_npsource + "/" + entry->d_name;
+ for (return_code = readdir_r(dir, &entry, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &result))
+ {
+ tempname = m_npsource + "/" + entry.d_name;
if (lstat(tempname.c_str(), &st) != 0) {
LogWarning(
"Failed to call \"lstat\" (errno:" << errno
}
/* Directories other than "." and ".." should not be found*/
if (S_ISDIR(st.st_mode)) {
- if (strncmp(entry->d_name, "..", 2) != 0
- && strncmp(entry->d_name, ".", 1) != 0)
+ if (strncmp(entry.d_name, "..", 2) != 0
+ && strncmp(entry.d_name, ".", 1) != 0)
{
LogError("Directory detected instead of plugin file: "
- << entry->d_name);
+ << entry.d_name);
/* Subdirectories inside plugins/ARCH are not supported */
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError(
}
}
- tempname = std::string(entry->d_name);
+ tempname = std::string(entry.d_name);
/* Check whether file extension is ".so" */
if (tempname.compare(tempname.size() - ext.size(), ext.size(),
ext) == 0)
LogWarning("Non-plugin file found: " << tempname);
}
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << m_npsource << " with error: "
<< DPL::GetErrnoString());
/* Copy plugins from widget package into
* .netscape/plugins in widget's target directory */
for (std::list<std::string>::const_iterator it = m_nplugins.begin();
- it != m_nplugins.end(); it++)
+ it != m_nplugins.end(); ++it)
{
LogDebug("Copying plugin file: " << (*it));
source = m_npsource + "/" + (*it);
FILE *temp = fopen(infoPath.str().c_str(), "w+");
if (temp != NULL) {
fputs(m_context.locations->getWidgetSource().c_str(), temp);
- if (-1 == fsync(temp->_fileno)) {
- fclose(temp);
+ int ret = fsync(temp->_fileno);
+ fclose(temp);
+ if (-1 == ret) {
ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery.");
}
- fclose(temp);
m_context.installInfo = infoPath.str();
void TaskUpdateFiles::StepCreateBackupFolder()
{
LogDebug("StepCreateBackupFolder");
- std::ostringstream backDirPath;
std::string srcBuPath = m_context.locations->getBackupSourceDir();
LogDebug("backup resource directory path : " << srcBuPath);
directory");
}
- struct dirent* dirent;
struct stat statInfo;
- do {
- if ((dirent = readdir(pkgDir))) {
- std::string dirName = dirent->d_name;
- std::string absFileName = dirPath + "/" + dirName;
- if (stat(absFileName.c_str(), &statInfo) != 0) {
- ThrowMsg(Exceptions::InternalError, "Error occurs read file");
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(pkgDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(pkgDir, &dirent, &result))
+ {
+ std::string dirName = dirent.d_name;
+ std::string absFileName = dirPath + "/" + dirName;
+ if (stat(absFileName.c_str(), &statInfo) != 0) {
+ ThrowMsg(Exceptions::InternalError, "Error occurs read file");
+ }
- if (S_ISDIR(statInfo.st_mode)) {
- if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name,
- "..") == 0)
- {
- continue;
- }
- ReadDirList(absFileName, list, subLen);
+ if (S_ISDIR(statInfo.st_mode)) {
+ if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
+ "..") == 0)
+ {
+ continue;
}
-
- list.insert(absFileName.substr(subLen));
+ ReadDirList(absFileName, list, subLen);
}
- } while (dirent);
+
+ list.insert(absFileName.substr(subLen));
+ }
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
//closing the directory
if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
LogError("Failed to close dir: " << dirPath << " with error: "
return;
}
- struct dirent* dirent;
+
+
struct stat statStruct;
- do {
- errno = 0;
- if ((dirent = readdir(localeDir))) {
- DPL::String dirName = DPL::FromUTF8String(dirent->d_name);
- std::string absoluteDirName = localePath + "/";
- absoluteDirName += dirent->d_name;
-
- if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
- LogError("stat() failed with " << DPL::GetErrnoString());
- continue;
- }
+ struct dirent dirent;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(localeDir, &dirent, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(localeDir, &dirent, &result))
+ {
+ DPL::String dirName = DPL::FromUTF8String(dirent.d_name);
+ std::string absoluteDirName = localePath + "/";
+ absoluteDirName += dirent.d_name;
- if (S_ISDIR(statStruct.st_mode)) {
- //Yes, we ignore current, parent & hidden directories
- if (dirName[0] != L'.') {
- LogDebug("Adding locale directory \"" << dirName << "\"");
- m_localeFolders.insert(dirName);
- }
+ if (stat(absoluteDirName.c_str(), &statStruct) != 0) {
+ LogError("stat() failed with " << DPL::GetErrnoString());
+ continue;
+ }
+
+ if (S_ISDIR(statStruct.st_mode)) {
+ //Yes, we ignore current, parent & hidden directories
+ if (dirName[0] != L'.') {
+ LogDebug("Adding locale directory \"" << dirName << "\"");
+ m_localeFolders.insert(dirName);
}
}
- } while (dirent);
+ }
- if (errno != 0) {
- LogError("readdir() failed with " << DPL::GetErrnoString());
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
}
if (-1 == TEMP_FAILURE_RETRY(closedir(localeDir))) {
//TODO: rewrite this madness
std::string cfgAbsPath;
DIR* dir = NULL;
- struct dirent* ptr = NULL;
dir = opendir(_currentPath.c_str());
if (dir == NULL) {
return false;
}
bool has_config_xml = false;
+ struct dirent ptr;
+ struct dirent *result;
+ int return_code;
errno = 0;
- while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on
- // its name
- if (ptr->d_type == DT_REG) {
- if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- std::string dName(ptr->d_name);
+
+ //Find configuration file, based on its name
+ for (return_code = readdir_r(dir, &ptr, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &ptr, &result))
+ {
+ if (ptr.d_type == DT_REG) {
+ if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
+ std::string dName(ptr.d_name);
WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
//Parse widget configuration file
}
}
}
+ if (errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << _currentPath << " with error: "
<< DPL::GetErrnoString());
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
- int ret = APP_MANAGER_ERROR_NONE;
bool isRunning = false;
- ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
+ int ret = app_manager_is_running(m_context.tzAppid.c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != ret) {
LogError("Fail to get running state");
ThrowMsg(Exceptions::PlatformAPIFailure,
try {
WrtDB::WidgetDAOReadOnly dao(m_context.widgetConfig.tzAppid);
TizenAppId tzAppid = dao.getTizenAppId();
- const char *devCap = "";
int result = handle_access_control_conf_forWAC(
DPL::ToUTF8String(tzAppid).c_str(),
NULL,
#include <widget_install/task_commons.h>
-WidgetLocation::DirectoryDeletor::DirectoryDeletor()
-{
- m_dirpath = Jobs::WidgetInstall::createTempPath();
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
+ m_dirpath(Jobs::WidgetInstall::createTempPath())
+{}
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
-{
- m_dirpath = tempPath;
-}
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
+ m_dirpath(tempPath)
+{}
WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
{
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
+ m_installPolicy(WRT_WIM_NOT_INSTALLED),
m_packagePath(),
m_handle(-1),
m_initialized(false),
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
-
- errno = 0;
std::list<std::string> pluginsPaths;
-
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
pluginsPaths.push_back(path);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
//set nb of plugins to install
//this value indicate how many callbacks are expected
m_numPluginsToInstall = pluginsPaths.size();
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
" description: " << description);
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
errno = 0;
std::list<std::string> pluginsPaths;
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
plugin_install_progress_cb);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
+ errno = 0;
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
<< DPL::GetErrnoString());
}
EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid,
- const std::string guid)
+ const std::string & guid)
{
try {
LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
WrtDB::WidgetDAOReadOnly dao(widget_guid);
tzAppid = DPL::ToUTF8String(dao.getTzAppId());
return WRT_SUCCESS;
- } catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ } catch (WidgetDAOReadOnly::Exception::WidgetNotExist&) {
LogError("Error package name is not found");
return WRT_ERROR_PKGNAME_NOT_FOUND;
} catch (const DPL::Exception& ex) {
* @return error code
*/
WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid,
- const std::string guid);
+ const std::string &guid);
#ifdef __cplusplus
}
#endif
}
char buffer[1024] = "";
- int ret;
- while ((ret = fread_unlocked(buffer,
- sizeof(char),
- sizeof(buffer)/sizeof(char),
- filehandle)) > 0)
+ while ( fread_unlocked(buffer, sizeof(char),
+ sizeof(buffer)/sizeof(char), filehandle) > 0 )
{
msg += buffer;
}