Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarafei Praliaskouski <komzpa@gmail.com>2013-02-22 11:44:07 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:51:24 +0300
commite18fe9f4cc6531cee399377b044862128f9db174 (patch)
tree7a2772ec12a96e4333d44d7613ad16976ea40e65 /platform
parente3397bbc36245bf446d06c41772df3ad8966906c (diff)
linux deployment
Diffstat (limited to 'platform')
-rw-r--r--platform/platform_linux.cpp68
1 files changed, 62 insertions, 6 deletions
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp
index 2b44259284..523463bc8e 100644
--- a/platform/platform_linux.cpp
+++ b/platform/platform_linux.cpp
@@ -4,6 +4,11 @@
#include <stdlib.h>
#include <unistd.h>
+#include "../std/fstream.hpp"
+
+
+#include <sys/stat.h>
+#include <sys/types.h>
/// @return directory where binary resides, including slash at the end
@@ -25,10 +30,52 @@ Platform::Platform()
string path;
CHECK(GetBinaryFolder(path), ("Can't retrieve path to executable"));
- // @TODO implement correct resources and writable directories for public releases
- m_resourcesDir = path + "../../data/";
- m_writableDir = m_resourcesDir;
- m_settingsDir = m_writableDir;
+ string home;
+ home = ::getenv("HOME");
+
+ m_settingsDir = home + "/.config/MapsWithMe/";
+
+ if (!IsFileExistsByFullPath(m_settingsDir + SETTINGS_FILE_NAME))
+ {
+ mkdir((home + "/.config/").c_str(), 0755);
+ mkdir(m_settingsDir.c_str(), 0755);
+ }
+
+ m_writableDir = home + "/.local/share/MapsWithMe/";
+ mkdir((home + "/.local/").c_str(), 0755);
+ mkdir((home + "/.local/share/").c_str(), 0755);
+ mkdir(m_writableDir.c_str(), 0755);
+
+ char * resDir = ::getenv("MWM_RESOURCES_DIR");
+ if (resDir)
+ m_resourcesDir = resDir;
+ else
+ {
+ // installed version
+ if (IsFileExistsByFullPath("/usr/share/MapsWithMe/eula.html"))
+ m_resourcesDir = "/usr/share/MapsWithMe";
+ // developer builds with symlink
+ if (IsFileExistsByFullPath(path + "../../data/eula.html")){
+ m_resourcesDir = path + "../../data";
+ m_writableDir = m_resourcesDir;
+ }
+ // developer builds without symlink
+ if (IsFileExistsByFullPath(path + "../../../omim/data/eula.html"))
+ {
+ m_resourcesDir = path + "../../../omim/data";
+ m_writableDir = m_resourcesDir;
+ }
+ // portable installations
+ else if (IsFileExistsByFullPath(path + "/eula.html"))
+ {
+ m_resourcesDir = path;
+ m_writableDir = m_resourcesDir;
+ m_settingsDir = m_resourcesDir;
+ }
+ }
+ m_resourcesDir += '/';
+ m_settingsDir += '/';
+
char * tmpDir = ::getenv("TMPDIR");
if (tmpDir)
m_tmpDir = tmpDir;
@@ -40,6 +87,7 @@ Platform::Platform()
LOG(LDEBUG, ("Writable directory:", m_writableDir));
LOG(LDEBUG, ("Tmp directory:", m_tmpDir));
LOG(LDEBUG, ("Settings directory:", m_settingsDir));
+ LOG(LDEBUG, ("Client ID:", UniqueClientId()));
}
int Platform::CpuCores() const
@@ -51,8 +99,16 @@ int Platform::CpuCores() const
}
string Platform::UniqueClientId() const
-{
- return "@TODO";
+{
+ string machinefile = "/var/lib/dbus/machine-id";
+ if (IsFileExistsByFullPath("/etc/machine-id"))
+ machinefile = "/etc/machine-id";
+
+ std::ifstream ifs(machinefile.c_str());
+ string content( (std::istreambuf_iterator<char>(ifs) ),
+ (std::istreambuf_iterator<char>() ) );
+
+ return content.substr(0,32);
}
void Platform::RunOnGuiThread(TFunctor const & fn)