{"action":"created","comment":{"url":"https://api.github.com/repos/guh/guh/pulls/comments/25360840","id":25360840,"diff_hunk":"@@ -0,0 +1,149 @@\n+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n+ *                                                                         *\n+ *  This file is part of guh.                                              *\n+ *                                                                         *\n+ *  Guh is free software: you can redistribute it and/or modify            *\n+ *  it under the terms of the GNU General Public License as published by   *\n+ *  the Free Software Foundation, version 2 of the License.                *\n+ *                                                                         *\n+ *  Guh is distributed in the hope that it will be useful,                 *\n+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *\n+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *\n+ *  GNU General Public License for more details.                           *\n+ *                                                                         *\n+ *  You should have received a copy of the GNU General Public License      *\n+ *  along with guh. If not, see <http://www.gnu.org/licenses/>.            *\n+ *                                                                         *\n+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n+\n+#include \"guhsettings.h\"\n+\n+GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent):\n+    QObject(parent),\n+    m_role(role)\n+{\n+    QString settingsFile;\n+    QString settingsPrefix = QCoreApplication::instance()->organizationName();\n+    bool runningAsDaemon = isRunningAsDaemon();\n+\n+    switch (role) {\n+    case SettingsRoleNone:\n+        break;\n+    case SettingsRoleDevices:\n+        if (runningAsDaemon) {\n+            settingsFile = \"/etc/\" + settingsPrefix + \"/devices.conf\";\n+            m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);\n+        } else {\n+            settingsFile = settingsPrefix + \"/devices\";\n+            m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);\n+        }\n+        break;\n+    case SettingsRoleRules:\n+        if (runningAsDaemon) {\n+            settingsFile = \"/etc/\" + settingsPrefix + \"/rules.conf\";\n+            m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);\n+        } else {\n+            settingsFile = settingsPrefix + \"/rules\";\n+            m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);\n+        }\n+        break;\n+    case SettingsRolePlugins:\n+        if (runningAsDaemon) {\n+            settingsFile = \"/etc/\" + settingsPrefix + \"/plugins.conf\";\n+            m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);\n+        } else {\n+            settingsFile = settingsPrefix + \"/plugins\";\n+            m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);\n+        }\n+        break;\n+    case SettingsRoleGlobal:\n+        settingsFile = \"/etc/guh/guhd.conf\";\n+        m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);\n+        break;\n+    default:\n+        break;\n+    }\n+}\n+\n+GuhSettings::~GuhSettings()\n+{\n+    m_settings->sync();\n+    delete m_settings;\n+}\n+\n+GuhSettings::SettingsRole GuhSettings::settingsRole() const\n+{\n+    return m_role;\n+}\n+\n+QStringList GuhSettings::allKeys() const\n+{\n+    return m_settings->allKeys();\n+}\n+\n+void GuhSettings::beginGroup(const QString &prefix)\n+{\n+    m_settings->beginGroup(prefix);\n+}\n+\n+QStringList GuhSettings::childGroups() const\n+{\n+    return m_settings->childGroups();\n+}\n+\n+QStringList GuhSettings::childKeys() const\n+{\n+    return m_settings->childKeys();\n+}\n+\n+void GuhSettings::clear()\n+{\n+    m_settings->clear();\n+}\n+\n+bool GuhSettings::contains(const QString &key) const\n+{\n+    return m_settings->contains(key);\n+}\n+\n+void GuhSettings::endGroup()\n+{\n+    m_settings->endGroup();\n+}\n+\n+QString GuhSettings::group() const\n+{\n+    return m_settings->group();\n+}\n+\n+QString GuhSettings::fileName() const\n+{\n+    return m_settings->fileName();\n+}\n+\n+bool GuhSettings::isWritable() const\n+{\n+    return m_settings->isWritable();\n+}\n+\n+void GuhSettings::remove(const QString &key)\n+{\n+    m_settings->remove(key);\n+}\n+\n+void GuhSettings::setValue(const QString &key, const QVariant &value)\n+{\n+    m_settings->setValue(key, value);\n+}\n+\n+QVariant GuhSettings::value(const QString &key, const QVariant &defaultValue) const\n+{\n+    return m_settings->value(key, defaultValue);\n+}\n+\n+bool GuhSettings::isRunningAsDaemon()\n+{\n+    // FIXME: once this class is in the server, use guhcore::runningMode()\n+    QString user = qgetenv(\"USER\");","path":"libguh/guhsettings.cpp","position":147,"original_position":147,"commit_id":"80ddbe9fa3d521459c9be322960d4f7eac440774","original_commit_id":"80ddbe9fa3d521459c9be322960d4f7eac440774","user":{"login":"t-mon","id":6507449,"avatar_url":"https://avatars.githubusercontent.com/u/6507449?v=3","gravatar_id":"","url":"https://api.github.com/users/t-mon","html_url":"https://github.com/t-mon","followers_url":"https://api.github.com/users/t-mon/followers","following_url":"https://api.github.com/users/t-mon/following{/other_user}","gists_url":"https://api.github.com/users/t-mon/gists{/gist_id}","starred_url":"https://api.github.com/users/t-mon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t-mon/subscriptions","organizations_url":"https://api.github.com/users/t-mon/orgs","repos_url":"https://api.github.com/users/t-mon/repos","events_url":"https://api.github.com/users/t-mon/events{/privacy}","received_events_url":"https://api.github.com/users/t-mon/received_events","type":"User","site_admin":false},"body":"@mzanetti I don't know why, but in jenkins this step always fails! ","created_at":"2015-02-25T17:42:55Z","updated_at":"2015-02-25T17:42:55Z","html_url":"https://github.com/guh/guh/pull/106#discussion_r25360840","pull_request_url":"https://api.github.com/repos/guh/guh/pulls/106","_links":{"self":{"href":"https://api.github.com/repos/guh/guh/pulls/comments/25360840"},"html":{"href":"https://github.com/guh/guh/pull/106#discussion_r25360840"},"pull_request":{"href":"https://api.github.com/repos/guh/guh/pulls/106"}}},"pull_request":{"url":"https://api.github.com/repos/guh/guh/pulls/106","id":29271249,"html_url":"https://github.com/guh/guh/pull/106","diff_url":"https://github.com/guh/guh/pull/106.diff","patch_url":"https://github.com/guh/guh/pull/106.patch","issue_url":"https://api.github.com/repos/guh/guh/issues/106","number":106,"state":"open","locked":false,"title":"add guhd.conf and settings improvement","user":{"login":"t-mon","id":6507449,"avatar_url":"https://avatars.githubusercontent.com/u/6507449?v=3","gravatar_id":"","url":"https://api.github.com/users/t-mon","html_url":"https://github.com/t-mon","followers_url":"https://api.github.com/users/t-mon/followers","following_url":"https://api.github.com/users/t-mon/following{/other_user}","gists_url":"https://api.github.com/users/t-mon/gists{/gist_id}","starred_url":"https://api.github.com/users/t-mon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t-mon/subscriptions","organizations_url":"https://api.github.com/users/t-mon/orgs","repos_url":"https://api.github.com/users/t-mon/repos","events_url":"https://api.github.com/users/t-mon/events{/privacy}","received_events_url":"https://api.github.com/users/t-mon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-13T15:10:47Z","updated_at":"2015-02-25T17:42:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"312bcc0d7acbb58f0c1e3b4aa06fd38034e13ce7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guh/guh/pulls/106/commits","review_comments_url":"https://api.github.com/repos/guh/guh/pulls/106/comments","review_comment_url":"https://api.github.com/repos/guh/guh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guh/guh/issues/106/comments","statuses_url":"https://api.github.com/repos/guh/guh/statuses/80ddbe9fa3d521459c9be322960d4f7eac440774","head":{"label":"t-mon:fix-config","ref":"fix-config","sha":"80ddbe9fa3d521459c9be322960d4f7eac440774","user":{"login":"t-mon","id":6507449,"avatar_url":"https://avatars.githubusercontent.com/u/6507449?v=3","gravatar_id":"","url":"https://api.github.com/users/t-mon","html_url":"https://github.com/t-mon","followers_url":"https://api.github.com/users/t-mon/followers","following_url":"https://api.github.com/users/t-mon/following{/other_user}","gists_url":"https://api.github.com/users/t-mon/gists{/gist_id}","starred_url":"https://api.github.com/users/t-mon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t-mon/subscriptions","organizations_url":"https://api.github.com/users/t-mon/orgs","repos_url":"https://api.github.com/users/t-mon/repos","events_url":"https://api.github.com/users/t-mon/events{/privacy}","received_events_url":"https://api.github.com/users/t-mon/received_events","type":"User","site_admin":false},"repo":{"id":22575681,"name":"guh","full_name":"t-mon/guh","owner":{"login":"t-mon","id":6507449,"avatar_url":"https://avatars.githubusercontent.com/u/6507449?v=3","gravatar_id":"","url":"https://api.github.com/users/t-mon","html_url":"https://github.com/t-mon","followers_url":"https://api.github.com/users/t-mon/followers","following_url":"https://api.github.com/users/t-mon/following{/other_user}","gists_url":"https://api.github.com/users/t-mon/gists{/gist_id}","starred_url":"https://api.github.com/users/t-mon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t-mon/subscriptions","organizations_url":"https://api.github.com/users/t-mon/orgs","repos_url":"https://api.github.com/users/t-mon/repos","events_url":"https://api.github.com/users/t-mon/events{/privacy}","received_events_url":"https://api.github.com/users/t-mon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/t-mon/guh","description":"","fork":true,"url":"https://api.github.com/repos/t-mon/guh","forks_url":"https://api.github.com/repos/t-mon/guh/forks","keys_url":"https://api.github.com/repos/t-mon/guh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/t-mon/guh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/t-mon/guh/teams","hooks_url":"https://api.github.com/repos/t-mon/guh/hooks","issue_events_url":"https://api.github.com/repos/t-mon/guh/issues/events{/number}","events_url":"https://api.github.com/repos/t-mon/guh/events","assignees_url":"https://api.github.com/repos/t-mon/guh/assignees{/user}","branches_url":"https://api.github.com/repos/t-mon/guh/branches{/branch}","tags_url":"https://api.github.com/repos/t-mon/guh/tags","blobs_url":"https://api.github.com/repos/t-mon/guh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/t-mon/guh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/t-mon/guh/git/refs{/sha}","trees_url":"https://api.github.com/repos/t-mon/guh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/t-mon/guh/statuses/{sha}","languages_url":"https://api.github.com/repos/t-mon/guh/languages","stargazers_url":"https://api.github.com/repos/t-mon/guh/stargazers","contributors_url":"https://api.github.com/repos/t-mon/guh/contributors","subscribers_url":"https://api.github.com/repos/t-mon/guh/subscribers","subscription_url":"https://api.github.com/repos/t-mon/guh/subscription","commits_url":"https://api.github.com/repos/t-mon/guh/commits{/sha}","git_commits_url":"https://api.github.com/repos/t-mon/guh/git/commits{/sha}","comments_url":"https://api.github.com/repos/t-mon/guh/comments{/number}","issue_comment_url":"https://api.github.com/repos/t-mon/guh/issues/comments{/number}","contents_url":"https://api.github.com/repos/t-mon/guh/contents/{+path}","compare_url":"https://api.github.com/repos/t-mon/guh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/t-mon/guh/merges","archive_url":"https://api.github.com/repos/t-mon/guh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/t-mon/guh/downloads","issues_url":"https://api.github.com/repos/t-mon/guh/issues{/number}","pulls_url":"https://api.github.com/repos/t-mon/guh/pulls{/number}","milestones_url":"https://api.github.com/repos/t-mon/guh/milestones{/number}","notifications_url":"https://api.github.com/repos/t-mon/guh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/t-mon/guh/labels{/name}","releases_url":"https://api.github.com/repos/t-mon/guh/releases{/id}","created_at":"2014-08-03T13:46:26Z","updated_at":"2015-02-24T08:04:16Z","pushed_at":"2015-02-25T15:48:26Z","git_url":"git://github.com/t-mon/guh.git","ssh_url":"git@github.com:t-mon/guh.git","clone_url":"https://github.com/t-mon/guh.git","svn_url":"https://github.com/t-mon/guh","homepage":null,"size":4643,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"guh:master","ref":"master","sha":"6802ab548d49788aa7cee609b3814c06c63f6446","user":{"login":"guh","id":5237262,"avatar_url":"https://avatars.githubusercontent.com/u/5237262?v=3","gravatar_id":"","url":"https://api.github.com/users/guh","html_url":"https://github.com/guh","followers_url":"https://api.github.com/users/guh/followers","following_url":"https://api.github.com/users/guh/following{/other_user}","gists_url":"https://api.github.com/users/guh/gists{/gist_id}","starred_url":"https://api.github.com/users/guh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guh/subscriptions","organizations_url":"https://api.github.com/users/guh/orgs","repos_url":"https://api.github.com/users/guh/repos","events_url":"https://api.github.com/users/guh/events{/privacy}","received_events_url":"https://api.github.com/users/guh/received_events","type":"Organization","site_admin":false},"repo":{"id":12134385,"name":"guh","full_name":"guh/guh","owner":{"login":"guh","id":5237262,"avatar_url":"https://avatars.githubusercontent.com/u/5237262?v=3","gravatar_id":"","url":"https://api.github.com/users/guh","html_url":"https://github.com/guh","followers_url":"https://api.github.com/users/guh/followers","following_url":"https://api.github.com/users/guh/following{/other_user}","gists_url":"https://api.github.com/users/guh/gists{/gist_id}","starred_url":"https://api.github.com/users/guh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guh/subscriptions","organizations_url":"https://api.github.com/users/guh/orgs","repos_url":"https://api.github.com/users/guh/repos","events_url":"https://api.github.com/users/guh/events{/privacy}","received_events_url":"https://api.github.com/users/guh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guh/guh","description":"","fork":false,"url":"https://api.github.com/repos/guh/guh","forks_url":"https://api.github.com/repos/guh/guh/forks","keys_url":"https://api.github.com/repos/guh/guh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guh/guh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guh/guh/teams","hooks_url":"https://api.github.com/repos/guh/guh/hooks","issue_events_url":"https://api.github.com/repos/guh/guh/issues/events{/number}","events_url":"https://api.github.com/repos/guh/guh/events","assignees_url":"https://api.github.com/repos/guh/guh/assignees{/user}","branches_url":"https://api.github.com/repos/guh/guh/branches{/branch}","tags_url":"https://api.github.com/repos/guh/guh/tags","blobs_url":"https://api.github.com/repos/guh/guh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guh/guh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guh/guh/git/refs{/sha}","trees_url":"https://api.github.com/repos/guh/guh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guh/guh/statuses/{sha}","languages_url":"https://api.github.com/repos/guh/guh/languages","stargazers_url":"https://api.github.com/repos/guh/guh/stargazers","contributors_url":"https://api.github.com/repos/guh/guh/contributors","subscribers_url":"https://api.github.com/repos/guh/guh/subscribers","subscription_url":"https://api.github.com/repos/guh/guh/subscription","commits_url":"https://api.github.com/repos/guh/guh/commits{/sha}","git_commits_url":"https://api.github.com/repos/guh/guh/git/commits{/sha}","comments_url":"https://api.github.com/repos/guh/guh/comments{/number}","issue_comment_url":"https://api.github.com/repos/guh/guh/issues/comments{/number}","contents_url":"https://api.github.com/repos/guh/guh/contents/{+path}","compare_url":"https://api.github.com/repos/guh/guh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guh/guh/merges","archive_url":"https://api.github.com/repos/guh/guh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guh/guh/downloads","issues_url":"https://api.github.com/repos/guh/guh/issues{/number}","pulls_url":"https://api.github.com/repos/guh/guh/pulls{/number}","milestones_url":"https://api.github.com/repos/guh/guh/milestones{/number}","notifications_url":"https://api.github.com/repos/guh/guh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guh/guh/labels{/name}","releases_url":"https://api.github.com/repos/guh/guh/releases{/id}","created_at":"2013-08-15T12:58:58Z","updated_at":"2015-02-24T17:25:37Z","pushed_at":"2015-02-24T17:25:37Z","git_url":"git://github.com/guh/guh.git","ssh_url":"git@github.com:guh/guh.git","clone_url":"https://github.com/guh/guh.git","svn_url":"https://github.com/guh/guh","homepage":"dev.guh.guru","size":7161,"stargazers_count":11,"watchers_count":11,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":18,"forks":3,"open_issues":18,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guh/guh/pulls/106"},"html":{"href":"https://github.com/guh/guh/pull/106"},"issue":{"href":"https://api.github.com/repos/guh/guh/issues/106"},"comments":{"href":"https://api.github.com/repos/guh/guh/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/guh/guh/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/guh/guh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guh/guh/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/guh/guh/statuses/80ddbe9fa3d521459c9be322960d4f7eac440774"}}}}