{"action":"created","comment":{"url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/comments/83600487","pull_request_review_id":4432824,"id":83600487,"diff_hunk":"@@ -0,0 +1,141 @@\n+Promise = require 'bluebird'\n+DBus = require './dbus-promise'\n+\n+dbus = new DBus()\n+\n+bus = dbus.getBus('system')\n+\n+systemd = require './systemd'\n+\n+SERVICE = 'org.freedesktop.NetworkManager'\n+WHITE_LIST = ['resin-vpn', 'eth0']\n+\n+exports.start = ->\n+\tsystemd.start('NetworkManager.service')\n+\n+exports.stop = ->\n+\tsystemd.stop('NetworkManager.service')\n+\n+exports.isSetup = ->\n+\tgetConnections()\n+\t.then (connections) ->\n+\t\tbuffer = []\n+\t\tfor connection in connections\n+\t\t\tbuffer.push(validateConnection(connection))\n+\n+\t\tPromise.all(buffer)\n+\t\t.then (results) ->\n+\t\t\treturn true in results\n+\n+exports.setCredentials = (ssid, passphrase) ->\n+\tbus.getInterfaceAsync(SERVICE, '/org/freedesktop/NetworkManager/Settings', 'org.freedesktop.NetworkManager.Settings')\n+\t.then (manager) ->\n+\t\tconnection = {\n+\t\t\t'802-11-wireless': {\n+\t\t\t\tssid: unpack(ssid)\n+\t\t\t},\n+\t\t\tconnection: {\n+\t\t\t\tid: ssid,\n+\t\t\t\ttype: '802-11-wireless',\n+\t\t\t},\n+\t\t\t'802-11-wireless-security': {\n+\t\t\t\t'auth-alg': 'open',\n+\t\t\t\t'key-mgmt': 'wpa-psk',\n+\t\t\t\t'psk': passphrase,\n+\t\t\t}\n+\t\t}\n+\n+\t\tmanager.AddConnectionAsync(connection)\n+\n+exports.clearCredentials = ->\n+\tgetConnections()\n+\t.then (connections) ->\n+\t\tbuffer = []\n+\t\tfor connection in connections\n+\t\t\tbuffer.push(deleteConnection(connection))\n+\n+\t\tPromise.all(buffer)\n+\n+exports.connect  = (timeout) ->\n+\tgetDevices()\n+\t.then (devices) ->\n+\t\tbuffer = []\n+\t\tfor device in devices\n+\t\t\tbuffer.push(validateDevice(device, 2))\n+\n+\t\t_manager = null\n+\t\tPromise.all(buffer)\n+\t\t.then (result) ->\n+\t\t\tbus.getInterfaceAsync(SERVICE, '/org/freedesktop/NetworkManager', 'org.freedesktop.NetworkManager')\n+\t\t\t.then (manager) ->\n+\t\t\t\t_manager = manager\n+\t\t\t\t_manager.ActivateConnectionAsync('/', devices[result.indexOf(true)], '/')\n+\t\t\t.then ->\n+\t\t\t\tnew Promise (resolve, reject, onCancel) ->\n+\t\t\t\t\thandler = (value) ->\n+\t\t\t\t\t\tif value == 70\n+\t\t\t\t\t\t\t_manager.removeListener('StateChanged', handler)\n+\t\t\t\t\t\t\tresolve()\n+\n+\t\t\t\t\t_manager.on('StateChanged', handler)\n+\n+\t\t\t\t\t_manager.CheckConnectivityAsync()\n+\t\t\t\t\t.then (state) ->\n+\t\t\t\t\t\tif state == 5\n+\t\t\t\t\t\t\t_manager.removeListener('StateChanged', handler)\n+\t\t\t\t\t\t\tresolve()\n+\n+\t\t\t\t\tsetTimeout ->\n+\t\t\t\t\t\t_manager.removeListener('StateChanged', handler)\n+\t\t\t\t\t\treject()\n+\t\t\t\t\t, timeout\n+\n+getConnections = ->\n+\tbus.getInterfaceAsync(SERVICE, '/org/freedesktop/NetworkManager/Settings', 'org.freedesktop.NetworkManager.Settings')\n+\t.then (settings) ->","path":"src/networkManager.coffee","position":95,"original_position":95,"commit_id":"5278876076c55d548a28eec4a8991d02988b69f4","original_commit_id":"5278876076c55d548a28eec4a8991d02988b69f4","user":{"login":"josephroberts","id":1107385,"avatar_url":"https://avatars.githubusercontent.com/u/1107385?v=3","gravatar_id":"","url":"https://api.github.com/users/josephroberts","html_url":"https://github.com/josephroberts","followers_url":"https://api.github.com/users/josephroberts/followers","following_url":"https://api.github.com/users/josephroberts/following{/other_user}","gists_url":"https://api.github.com/users/josephroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/josephroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephroberts/subscriptions","organizations_url":"https://api.github.com/users/josephroberts/orgs","repos_url":"https://api.github.com/users/josephroberts/repos","events_url":"https://api.github.com/users/josephroberts/events{/privacy}","received_events_url":"https://api.github.com/users/josephroberts/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2016-10-17T08:54:42Z","updated_at":"2016-10-17T08:54:42Z","html_url":"https://github.com/resin-io/resin-wifi-connect/pull/49#discussion_r83600487","pull_request_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/comments/83600487"},"html":{"href":"https://github.com/resin-io/resin-wifi-connect/pull/49#discussion_r83600487"},"pull_request":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49","id":88290993,"html_url":"https://github.com/resin-io/resin-wifi-connect/pull/49","diff_url":"https://github.com/resin-io/resin-wifi-connect/pull/49.diff","patch_url":"https://github.com/resin-io/resin-wifi-connect/pull/49.patch","issue_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/49","number":49,"state":"open","locked":false,"title":"Network manager support","user":{"login":"josephroberts","id":1107385,"avatar_url":"https://avatars.githubusercontent.com/u/1107385?v=3","gravatar_id":"","url":"https://api.github.com/users/josephroberts","html_url":"https://github.com/josephroberts","followers_url":"https://api.github.com/users/josephroberts/followers","following_url":"https://api.github.com/users/josephroberts/following{/other_user}","gists_url":"https://api.github.com/users/josephroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/josephroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephroberts/subscriptions","organizations_url":"https://api.github.com/users/josephroberts/orgs","repos_url":"https://api.github.com/users/josephroberts/repos","events_url":"https://api.github.com/users/josephroberts/events{/privacy}","received_events_url":"https://api.github.com/users/josephroberts/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-06T15:57:25Z","updated_at":"2016-10-17T08:54:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7e55d008e92c91d4e8b3d19b293815cbb7cdd15","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49/commits","review_comments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49/comments","review_comment_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/49/comments","statuses_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/statuses/5278876076c55d548a28eec4a8991d02988b69f4","head":{"label":"resin-io:network-manager-support","ref":"network-manager-support","sha":"5278876076c55d548a28eec4a8991d02988b69f4","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":37727198,"name":"resin-wifi-connect","full_name":"resin-io/resin-wifi-connect","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/resin-wifi-connect","description":null,"fork":false,"url":"https://api.github.com/repos/resin-io/resin-wifi-connect","forks_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/forks","keys_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/teams","hooks_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/hooks","issue_events_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/events","assignees_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/tags","blobs_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/languages","stargazers_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/stargazers","contributors_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/contributors","subscribers_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/subscribers","subscription_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/subscription","commits_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/merges","archive_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/downloads","issues_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/deployments","created_at":"2015-06-19T14:45:09Z","updated_at":"2016-10-12T18:48:17Z","pushed_at":"2016-10-14T14:55:40Z","git_url":"git://github.com/resin-io/resin-wifi-connect.git","ssh_url":"git@github.com:resin-io/resin-wifi-connect.git","clone_url":"https://github.com/resin-io/resin-wifi-connect.git","svn_url":"https://github.com/resin-io/resin-wifi-connect","homepage":null,"size":1028,"stargazers_count":25,"watchers_count":25,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":7,"forks":28,"open_issues":7,"watchers":25,"default_branch":"master"}},"base":{"label":"resin-io:master","ref":"master","sha":"27791820436526d6f1299c640ba259ac4c01f4de","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":37727198,"name":"resin-wifi-connect","full_name":"resin-io/resin-wifi-connect","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/resin-wifi-connect","description":null,"fork":false,"url":"https://api.github.com/repos/resin-io/resin-wifi-connect","forks_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/forks","keys_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/teams","hooks_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/hooks","issue_events_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/events","assignees_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/tags","blobs_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/languages","stargazers_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/stargazers","contributors_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/contributors","subscribers_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/subscribers","subscription_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/subscription","commits_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/merges","archive_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/downloads","issues_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/resin-wifi-connect/deployments","created_at":"2015-06-19T14:45:09Z","updated_at":"2016-10-12T18:48:17Z","pushed_at":"2016-10-14T14:55:40Z","git_url":"git://github.com/resin-io/resin-wifi-connect.git","ssh_url":"git@github.com:resin-io/resin-wifi-connect.git","clone_url":"https://github.com/resin-io/resin-wifi-connect.git","svn_url":"https://github.com/resin-io/resin-wifi-connect","homepage":null,"size":1028,"stargazers_count":25,"watchers_count":25,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":7,"forks":28,"open_issues":7,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49"},"html":{"href":"https://github.com/resin-io/resin-wifi-connect/pull/49"},"issue":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/49"},"comments":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/resin-io/resin-wifi-connect/statuses/5278876076c55d548a28eec4a8991d02988b69f4"}}}}
{"actor":{"display_login":"josephroberts"}}