{"action":"created","comment":{"url":"https://api.github.com/repos/rilmodem/ofono/pulls/comments/42718002","id":42718002,"diff_hunk":"@@ -0,0 +1,471 @@\n+/*\n+ *\n+ *  oFono - Open Source Telephony\n+ *\n+ *  Copyright (C) 2015 Canonical Ltd.\n+ *\n+ *  This program is free software; you can redistribute it and/or modify\n+ *  it under the terms of the GNU General Public License version 2 as\n+ *  published by the Free Software Foundation.\n+ *\n+ *  This program 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 this program; if not, write to the Free Software\n+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n+ *\n+ */\n+\n+#ifdef HAVE_CONFIG_H\n+#include <config.h>\n+#endif\n+\n+#include <glib.h>\n+#include <gdbus.h>\n+#include <ofono.h>\n+\n+#define OFONO_API_SUBJECT_TO_CHANGE\n+#include <ofono/plugin.h>\n+#include <ofono/modem.h>\n+#include <ofono/log.h>\n+#include <ofono/emulator.h>\n+\n+#define DBUS_PROPERTIES_INTERFACE     \"org.freedesktop.DBus.Properties\"\n+#define UPOWER_SERVICE                \"org.freedesktop.UPower\"\n+#define UPOWER_PATH                   \"/org/freedesktop/UPower\"\n+#define UPOWER_INTERFACE              UPOWER_SERVICE\n+#define UPOWER_DEVICE_INTERFACE       UPOWER_SERVICE \".Device\"\n+\n+static guint modem_watch;\n+static guint upower_battery_watch;\n+static guint upower_daemon_watch;\n+static DBusConnection *connection;\n+static GHashTable *modem_hfp_watches;\n+static GList *modems;\n+static int last_battery_level;\n+static char *battery_device_path;\n+\n+static void emulator_battery_cb(struct ofono_atom *atom, void *data)\n+{\n+\tstruct ofono_emulator *em = __ofono_atom_get_data(atom);\n+\tint val = GPOINTER_TO_INT(data);\n+\n+\tDBG(\"calling set_indicator: %d\", val);\n+\tofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_BATTERY, (int) val);\n+}\n+\n+static gboolean update_battery_level(double percentage_val)\n+{\n+\tGList *list;\n+\tint battery_level;\n+\n+\tif (percentage_val <= 1.00) {\n+\t\tbattery_level = 0;\n+\t} else if (percentage_val > 1.00 && percentage_val <= 100.00) {\n+\t\tbattery_level = ((int) percentage_val - 1) / 20 + 1;\n+\t} else {\n+\t\tofono_error(\"%s: Invalid value for battery level: %f\",\n+\t\t\t\t\t\t\t\t__func__,\n+\t\t\t\t\t\t\t\tpercentage_val);\n+\t\treturn FALSE;\n+\t}\n+\n+\tDBG(\"last_battery_level: %d battery_level: %d\", last_battery_level,\n+\t\t\t\t\t\t\tbattery_level);\n+\n+\tif (last_battery_level == battery_level)\n+\t\tgoto done;\n+\telse","path":"plugins/upower.c","position":81,"original_position":81,"commit_id":"25e980e1457a39c2ee7288ce5756f4433ba12d67","original_commit_id":"25e980e1457a39c2ee7288ce5756f4433ba12d67","user":{"login":"alfonsosanchezbeato","id":3833021,"avatar_url":"https://avatars.githubusercontent.com/u/3833021?v=3","gravatar_id":"","url":"https://api.github.com/users/alfonsosanchezbeato","html_url":"https://github.com/alfonsosanchezbeato","followers_url":"https://api.github.com/users/alfonsosanchezbeato/followers","following_url":"https://api.github.com/users/alfonsosanchezbeato/following{/other_user}","gists_url":"https://api.github.com/users/alfonsosanchezbeato/gists{/gist_id}","starred_url":"https://api.github.com/users/alfonsosanchezbeato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfonsosanchezbeato/subscriptions","organizations_url":"https://api.github.com/users/alfonsosanchezbeato/orgs","repos_url":"https://api.github.com/users/alfonsosanchezbeato/repos","events_url":"https://api.github.com/users/alfonsosanchezbeato/events{/privacy}","received_events_url":"https://api.github.com/users/alfonsosanchezbeato/received_events","type":"User","site_admin":false},"body":"This else is not needed.","created_at":"2015-10-22T07:26:15Z","updated_at":"2015-10-22T07:26:15Z","html_url":"https://github.com/rilmodem/ofono/pull/214#discussion_r42718002","pull_request_url":"https://api.github.com/repos/rilmodem/ofono/pulls/214","_links":{"self":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/comments/42718002"},"html":{"href":"https://github.com/rilmodem/ofono/pull/214#discussion_r42718002"},"pull_request":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/214"}}},"pull_request":{"url":"https://api.github.com/repos/rilmodem/ofono/pulls/214","id":48011395,"html_url":"https://github.com/rilmodem/ofono/pull/214","diff_url":"https://github.com/rilmodem/ofono/pull/214.diff","patch_url":"https://github.com/rilmodem/ofono/pull/214.patch","issue_url":"https://api.github.com/repos/rilmodem/ofono/issues/214","number":214,"state":"open","locked":false,"title":"upower: add bluez5 HFP battery indicator support","user":{"login":"tonyespy","id":5264713,"avatar_url":"https://avatars.githubusercontent.com/u/5264713?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyespy","html_url":"https://github.com/tonyespy","followers_url":"https://api.github.com/users/tonyespy/followers","following_url":"https://api.github.com/users/tonyespy/following{/other_user}","gists_url":"https://api.github.com/users/tonyespy/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyespy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyespy/subscriptions","organizations_url":"https://api.github.com/users/tonyespy/orgs","repos_url":"https://api.github.com/users/tonyespy/repos","events_url":"https://api.github.com/users/tonyespy/events{/privacy}","received_events_url":"https://api.github.com/users/tonyespy/received_events","type":"User","site_admin":false},"body":"This new plugin adds support for the HFP battery indicator when running with Bluez5.  It reads battery events from the upower system daemon, and relays them to any HFP emulator instances associated with the modem.  The plugin currently only supports a single SIM, and as such picks the first modem with available voicecall support ( same as the hfp_ag_bluez5 plugin ).\r\n\r\nTo test, you need to use a device that includes Bluez5 kernel support ( eg. mako ), and follow the instructions for Bluez5 testing per:\r\n\r\nhttps://wiki.ubuntu.com/Bluetooth/TouchBluez5Testing\r\n","created_at":"2015-10-18T16:07:08Z","updated_at":"2015-10-22T07:26:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f98d4508a04a8c06f7342c829828bfb967d7ac07","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rilmodem/ofono/pulls/214/commits","review_comments_url":"https://api.github.com/repos/rilmodem/ofono/pulls/214/comments","review_comment_url":"https://api.github.com/repos/rilmodem/ofono/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rilmodem/ofono/issues/214/comments","statuses_url":"https://api.github.com/repos/rilmodem/ofono/statuses/25e980e1457a39c2ee7288ce5756f4433ba12d67","head":{"label":"tonyespy:hfp-add-set-battery-ind","ref":"hfp-add-set-battery-ind","sha":"25e980e1457a39c2ee7288ce5756f4433ba12d67","user":{"login":"tonyespy","id":5264713,"avatar_url":"https://avatars.githubusercontent.com/u/5264713?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyespy","html_url":"https://github.com/tonyespy","followers_url":"https://api.github.com/users/tonyespy/followers","following_url":"https://api.github.com/users/tonyespy/following{/other_user}","gists_url":"https://api.github.com/users/tonyespy/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyespy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyespy/subscriptions","organizations_url":"https://api.github.com/users/tonyespy/orgs","repos_url":"https://api.github.com/users/tonyespy/repos","events_url":"https://api.github.com/users/tonyespy/events{/privacy}","received_events_url":"https://api.github.com/users/tonyespy/received_events","type":"User","site_admin":false},"repo":{"id":12712924,"name":"ofono","full_name":"tonyespy/ofono","owner":{"login":"tonyespy","id":5264713,"avatar_url":"https://avatars.githubusercontent.com/u/5264713?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyespy","html_url":"https://github.com/tonyespy","followers_url":"https://api.github.com/users/tonyespy/followers","following_url":"https://api.github.com/users/tonyespy/following{/other_user}","gists_url":"https://api.github.com/users/tonyespy/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyespy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyespy/subscriptions","organizations_url":"https://api.github.com/users/tonyespy/orgs","repos_url":"https://api.github.com/users/tonyespy/repos","events_url":"https://api.github.com/users/tonyespy/events{/privacy}","received_events_url":"https://api.github.com/users/tonyespy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tonyespy/ofono","description":"","fork":true,"url":"https://api.github.com/repos/tonyespy/ofono","forks_url":"https://api.github.com/repos/tonyespy/ofono/forks","keys_url":"https://api.github.com/repos/tonyespy/ofono/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tonyespy/ofono/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tonyespy/ofono/teams","hooks_url":"https://api.github.com/repos/tonyespy/ofono/hooks","issue_events_url":"https://api.github.com/repos/tonyespy/ofono/issues/events{/number}","events_url":"https://api.github.com/repos/tonyespy/ofono/events","assignees_url":"https://api.github.com/repos/tonyespy/ofono/assignees{/user}","branches_url":"https://api.github.com/repos/tonyespy/ofono/branches{/branch}","tags_url":"https://api.github.com/repos/tonyespy/ofono/tags","blobs_url":"https://api.github.com/repos/tonyespy/ofono/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tonyespy/ofono/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tonyespy/ofono/git/refs{/sha}","trees_url":"https://api.github.com/repos/tonyespy/ofono/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tonyespy/ofono/statuses/{sha}","languages_url":"https://api.github.com/repos/tonyespy/ofono/languages","stargazers_url":"https://api.github.com/repos/tonyespy/ofono/stargazers","contributors_url":"https://api.github.com/repos/tonyespy/ofono/contributors","subscribers_url":"https://api.github.com/repos/tonyespy/ofono/subscribers","subscription_url":"https://api.github.com/repos/tonyespy/ofono/subscription","commits_url":"https://api.github.com/repos/tonyespy/ofono/commits{/sha}","git_commits_url":"https://api.github.com/repos/tonyespy/ofono/git/commits{/sha}","comments_url":"https://api.github.com/repos/tonyespy/ofono/comments{/number}","issue_comment_url":"https://api.github.com/repos/tonyespy/ofono/issues/comments{/number}","contents_url":"https://api.github.com/repos/tonyespy/ofono/contents/{+path}","compare_url":"https://api.github.com/repos/tonyespy/ofono/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tonyespy/ofono/merges","archive_url":"https://api.github.com/repos/tonyespy/ofono/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tonyespy/ofono/downloads","issues_url":"https://api.github.com/repos/tonyespy/ofono/issues{/number}","pulls_url":"https://api.github.com/repos/tonyespy/ofono/pulls{/number}","milestones_url":"https://api.github.com/repos/tonyespy/ofono/milestones{/number}","notifications_url":"https://api.github.com/repos/tonyespy/ofono/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tonyespy/ofono/labels{/name}","releases_url":"https://api.github.com/repos/tonyespy/ofono/releases{/id}","created_at":"2013-09-09T21:13:08Z","updated_at":"2015-04-21T17:25:07Z","pushed_at":"2015-10-21T15:29:39Z","git_url":"git://github.com/tonyespy/ofono.git","ssh_url":"git@github.com:tonyespy/ofono.git","clone_url":"https://github.com/tonyespy/ofono.git","svn_url":"https://github.com/tonyespy/ofono","homepage":null,"size":24514,"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":"rilmodem:master","ref":"master","sha":"1e4a2a08858e8a256ec5843c396b4b1049006672","user":{"login":"rilmodem","id":5394617,"avatar_url":"https://avatars.githubusercontent.com/u/5394617?v=3","gravatar_id":"","url":"https://api.github.com/users/rilmodem","html_url":"https://github.com/rilmodem","followers_url":"https://api.github.com/users/rilmodem/followers","following_url":"https://api.github.com/users/rilmodem/following{/other_user}","gists_url":"https://api.github.com/users/rilmodem/gists{/gist_id}","starred_url":"https://api.github.com/users/rilmodem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilmodem/subscriptions","organizations_url":"https://api.github.com/users/rilmodem/orgs","repos_url":"https://api.github.com/users/rilmodem/repos","events_url":"https://api.github.com/users/rilmodem/events{/privacy}","received_events_url":"https://api.github.com/users/rilmodem/received_events","type":"Organization","site_admin":false},"repo":{"id":12710932,"name":"ofono","full_name":"rilmodem/ofono","owner":{"login":"rilmodem","id":5394617,"avatar_url":"https://avatars.githubusercontent.com/u/5394617?v=3","gravatar_id":"","url":"https://api.github.com/users/rilmodem","html_url":"https://github.com/rilmodem","followers_url":"https://api.github.com/users/rilmodem/followers","following_url":"https://api.github.com/users/rilmodem/following{/other_user}","gists_url":"https://api.github.com/users/rilmodem/gists{/gist_id}","starred_url":"https://api.github.com/users/rilmodem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilmodem/subscriptions","organizations_url":"https://api.github.com/users/rilmodem/orgs","repos_url":"https://api.github.com/users/rilmodem/repos","events_url":"https://api.github.com/users/rilmodem/events{/privacy}","received_events_url":"https://api.github.com/users/rilmodem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rilmodem/ofono","description":"7f3955122af8b0349fb7d3f2db8abd754459d146","fork":false,"url":"https://api.github.com/repos/rilmodem/ofono","forks_url":"https://api.github.com/repos/rilmodem/ofono/forks","keys_url":"https://api.github.com/repos/rilmodem/ofono/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rilmodem/ofono/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rilmodem/ofono/teams","hooks_url":"https://api.github.com/repos/rilmodem/ofono/hooks","issue_events_url":"https://api.github.com/repos/rilmodem/ofono/issues/events{/number}","events_url":"https://api.github.com/repos/rilmodem/ofono/events","assignees_url":"https://api.github.com/repos/rilmodem/ofono/assignees{/user}","branches_url":"https://api.github.com/repos/rilmodem/ofono/branches{/branch}","tags_url":"https://api.github.com/repos/rilmodem/ofono/tags","blobs_url":"https://api.github.com/repos/rilmodem/ofono/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rilmodem/ofono/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rilmodem/ofono/git/refs{/sha}","trees_url":"https://api.github.com/repos/rilmodem/ofono/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rilmodem/ofono/statuses/{sha}","languages_url":"https://api.github.com/repos/rilmodem/ofono/languages","stargazers_url":"https://api.github.com/repos/rilmodem/ofono/stargazers","contributors_url":"https://api.github.com/repos/rilmodem/ofono/contributors","subscribers_url":"https://api.github.com/repos/rilmodem/ofono/subscribers","subscription_url":"https://api.github.com/repos/rilmodem/ofono/subscription","commits_url":"https://api.github.com/repos/rilmodem/ofono/commits{/sha}","git_commits_url":"https://api.github.com/repos/rilmodem/ofono/git/commits{/sha}","comments_url":"https://api.github.com/repos/rilmodem/ofono/comments{/number}","issue_comment_url":"https://api.github.com/repos/rilmodem/ofono/issues/comments{/number}","contents_url":"https://api.github.com/repos/rilmodem/ofono/contents/{+path}","compare_url":"https://api.github.com/repos/rilmodem/ofono/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rilmodem/ofono/merges","archive_url":"https://api.github.com/repos/rilmodem/ofono/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rilmodem/ofono/downloads","issues_url":"https://api.github.com/repos/rilmodem/ofono/issues{/number}","pulls_url":"https://api.github.com/repos/rilmodem/ofono/pulls{/number}","milestones_url":"https://api.github.com/repos/rilmodem/ofono/milestones{/number}","notifications_url":"https://api.github.com/repos/rilmodem/ofono/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rilmodem/ofono/labels{/name}","releases_url":"https://api.github.com/repos/rilmodem/ofono/releases{/id}","created_at":"2013-09-09T19:45:47Z","updated_at":"2015-08-31T08:38:50Z","pushed_at":"2015-10-21T15:29:39Z","git_url":"git://github.com/rilmodem/ofono.git","ssh_url":"git@github.com:rilmodem/ofono.git","clone_url":"https://github.com/rilmodem/ofono.git","svn_url":"https://github.com/rilmodem/ofono","homepage":"","size":25999,"stargazers_count":4,"watchers_count":4,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":13,"forks":14,"open_issues":13,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/214"},"html":{"href":"https://github.com/rilmodem/ofono/pull/214"},"issue":{"href":"https://api.github.com/repos/rilmodem/ofono/issues/214"},"comments":{"href":"https://api.github.com/repos/rilmodem/ofono/issues/214/comments"},"review_comments":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/214/comments"},"review_comment":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rilmodem/ofono/pulls/214/commits"},"statuses":{"href":"https://api.github.com/repos/rilmodem/ofono/statuses/25e980e1457a39c2ee7288ce5756f4433ba12d67"}}}}