blob: 3fbb5e15f57a454f4c6eeb4607d87df40f15797e [file] [log] [blame]
Darin Petkov804e8d02012-10-10 16:44:36 +02001// 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 Petkov728faa92012-10-12 11:25:47 +020014#include "shill/rpc_task.h"
Darin Petkov804e8d02012-10-10 16:44:36 +020015#include "shill/shims/environment.h"
16#include "shill/shims/task_proxy.h"
17
18using shill::shims::Environment;
Darin Petkov804e8d02012-10-10 16:44:36 +020019using std::map;
20using std::string;
21
22int 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 Petkov728faa92012-10-12 11:25:47 +020029 if (!environment->GetVariable(shill::kRPCTaskServiceVariable, &service) ||
30 !environment->GetVariable(shill::kRPCTaskPathVariable, &path) ||
Darin Petkov804e8d02012-10-10 16:44:36 +020031 !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 Petkov728faa92012-10-12 11:25:47 +020039 shill::shims::TaskProxy proxy(&connection, path, service);
Darin Petkov804e8d02012-10-10 16:44:36 +020040 map<string, string> env = environment->AsMap();
41 proxy.Notify(reason, env);
42 return EXIT_SUCCESS;
43}