Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <cstdlib> |
| 6 | #include <string> |
| 7 | |
| 8 | #include <base/at_exit.h> |
| 9 | #include <base/command_line.h> |
| 10 | #include <base/logging.h> |
| 11 | #include <chromeos/syslog_logging.h> |
| 12 | #include <dbus-c++/eventloop-integration.h> |
| 13 | |
Darin Petkov | 728faa9 | 2012-10-12 11:25:47 +0200 | [diff] [blame] | 14 | #include "shill/rpc_task.h" |
Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 15 | #include "shill/shims/environment.h" |
| 16 | #include "shill/shims/task_proxy.h" |
| 17 | |
| 18 | using shill::shims::Environment; |
Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 19 | using std::map; |
| 20 | using std::string; |
| 21 | |
| 22 | int main(int argc, char **argv) { |
| 23 | base::AtExitManager exit_manager; |
| 24 | CommandLine::Init(argc, argv); |
| 25 | chromeos::InitLog(chromeos::kLogToSyslog | chromeos::kLogHeader); |
| 26 | |
| 27 | Environment *environment = Environment::GetInstance(); |
| 28 | string service, path, reason; |
Darin Petkov | 728faa9 | 2012-10-12 11:25:47 +0200 | [diff] [blame] | 29 | if (!environment->GetVariable(shill::kRPCTaskServiceVariable, &service) || |
| 30 | !environment->GetVariable(shill::kRPCTaskPathVariable, &path) || |
Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 31 | !environment->GetVariable("script_type", &reason)) { |
| 32 | LOG(ERROR) << "Environment variables not available."; |
| 33 | return EXIT_FAILURE; |
| 34 | } |
| 35 | |
| 36 | DBus::BusDispatcher dispatcher; |
| 37 | DBus::default_dispatcher = &dispatcher; |
| 38 | DBus::Connection connection(DBus::Connection::SystemBus()); |
Darin Petkov | 728faa9 | 2012-10-12 11:25:47 +0200 | [diff] [blame] | 39 | shill::shims::TaskProxy proxy(&connection, path, service); |
Darin Petkov | 804e8d0 | 2012-10-10 16:44:36 +0200 | [diff] [blame] | 40 | map<string, string> env = environment->AsMap(); |
| 41 | proxy.Notify(reason, env); |
| 42 | return EXIT_SUCCESS; |
| 43 | } |