Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: monitor_network.cc

Issue 652187: Added ConnectToNetwork (Closed)
Patch Set: merge in new changes Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « load.cc ('k') | monitor_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <dlfcn.h> 5 #include <dlfcn.h>
6 #include <glib-object.h> 6 #include <glib-object.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include <base/logging.h> 9 #include <base/logging.h>
10 10
11 #include "chromeos_cros_api.h" // NOLINT 11 #include "chromeos_cros_api.h" // NOLINT
12 #include "chromeos_network.h" // NOLINT 12 #include "chromeos_network.h" // NOLINT
13 #include "chromeos/glib/object.h" // NOLINT 13 #include "chromeos/glib/object.h" // NOLINT
14 #include "monitor_utils.h" //NOLINT 14 #include "monitor_utils.h" //NOLINT
15 15
16 // Dumps the contents of a single service to the logs. 16 // Dumps the contents of a single service to the logs.
17 void DumpService(const chromeos::ServiceInfo& info) { 17 void DumpService(const chromeos::ServiceInfo& info) {
18 LOG(INFO) << " " << info.ssid << 18 LOG(INFO) << " " << info.name <<
19 ", Type=" << info.type <<
20 ", Mode=" << info.mode <<
21 ", Security=" << info.security <<
19 ", State=" << info.state << 22 ", State=" << info.state <<
20 ", Type=" <<info.type << 23 ", Error=" << info.error <<
24 ", PassphraseRequired=" << info.passphrase_required <<
25 ", Passphrase=" << info.passphrase <<
26 ", Strength=" << info.strength <<
27 ", Favorite=" << info.favorite <<
28 ", AutoConnect=" << info.auto_connect <<
21 ", Device=" << info.device_path << 29 ", Device=" << info.device_path <<
22 ", Encryption=" << info.encryption << 30 ", Service=" << info.service_path;
23 ", Signal=" << info.signal_strength <<
24 ", Password=" << info.needs_passphrase;
25 } 31 }
26 32
27 // Dumps the contents of ServiceStatus to the log. 33 // Dumps the contents of ServiceStatus to the log.
28 void DumpServices(const chromeos::ServiceStatus *status) { 34 void DumpServices(const chromeos::ServiceStatus *status) {
29 if (status == NULL) 35 if (status == NULL)
30 return; 36 return;
31 37
32 LOG(INFO) << "Network status:"; 38 LOG(INFO) << "Network status:";
33 for (int i = 0; i < status->size; i++) { 39 for (int i = 0; i < status->size; i++) {
34 DumpService(status->services[i]); 40 DumpService(status->services[i]);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ::g_type_init(); 77 ::g_type_init();
72 GMainLoop* loop = ::g_main_loop_new(NULL, false); 78 GMainLoop* loop = ::g_main_loop_new(NULL, false);
73 79
74 DCHECK(LoadCrosLibrary(argv)) << "Failed to load cros .so"; 80 DCHECK(LoadCrosLibrary(argv)) << "Failed to load cros .so";
75 81
76 LOG(INFO) << "Enabled network devices:"; 82 LOG(INFO) << "Enabled network devices:";
77 int devices = chromeos::GetEnabledNetworkDevices(); 83 int devices = chromeos::GetEnabledNetworkDevices();
78 if (devices == -1) { 84 if (devices == -1) {
79 LOG(INFO) << " offline mode"; 85 LOG(INFO) << " offline mode";
80 } else { 86 } else {
81 if (devices & chromeos::TYPE_ETHERNET) 87 if (devices & (1 << chromeos::TYPE_ETHERNET))
82 LOG(INFO) << " ethernet"; 88 LOG(INFO) << " ethernet";
83 if (devices & chromeos::TYPE_WIFI) 89 if (devices & (1 << chromeos::TYPE_WIFI))
84 LOG(INFO) << " wifi"; 90 LOG(INFO) << " wifi";
85 if (devices & chromeos::TYPE_WIMAX) 91 if (devices & (1 << chromeos::TYPE_WIMAX))
86 LOG(INFO) << " wimax"; 92 LOG(INFO) << " wimax";
87 if (devices & chromeos::TYPE_BLUETOOTH) 93 if (devices & (1 << chromeos::TYPE_BLUETOOTH))
88 LOG(INFO) << " bluetooth"; 94 LOG(INFO) << " bluetooth";
89 if (devices & chromeos::TYPE_CELLULAR) 95 if (devices & (1 << chromeos::TYPE_CELLULAR))
90 LOG(INFO) << " cellular"; 96 LOG(INFO) << " cellular";
91 } 97 }
92 98
93 chromeos::ServiceStatus* status = chromeos::GetAvailableNetworks(); 99 chromeos::ServiceStatus* status = chromeos::GetAvailableNetworks();
94 DCHECK(status) << "Unable to scan for networks"; 100 DCHECK(status) << "Unable to scan for networks";
95 DumpServices(status); 101 DumpServices(status);
96 chromeos::FreeServiceStatus(status); 102 chromeos::FreeServiceStatus(status);
97 103
98 Callback callback(loop); 104 Callback callback(loop);
99 chromeos::NetworkStatusConnection connection = 105 chromeos::NetworkStatusConnection connection =
100 chromeos::MonitorNetworkStatus(&Callback::Run, &callback); 106 chromeos::MonitorNetworkStatus(&Callback::Run, &callback);
101 ::g_main_loop_run(loop); 107 ::g_main_loop_run(loop);
102 chromeos::DisconnectNetworkStatus(connection); 108 chromeos::DisconnectNetworkStatus(connection);
103 return 0; 109 return 0;
104 } 110 }
OLDNEW
« no previous file with comments | « load.cc ('k') | monitor_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698