1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_
#define CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "dbus/object_path.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace chromeos {
class IBusComponent;
class IBusInputContextClient;
// A class to make the actual DBus calls for IBusBus service.
// This class only makes calls, result/error handling should be done by
// callbacks.
class CHROMEOS_EXPORT IBusClient {
public:
enum ExitOption {
RESTART_IBUS_DAEMON,
SHUT_DOWN_IBUS_DAEMON
};
typedef base::Callback<void(const dbus::ObjectPath&)>
CreateInputContextCallback;
typedef base::Callback<void()> RegisterComponentCallback;
typedef base::Callback<void()> ErrorCallback;
virtual ~IBusClient();
// Requests the ibus-daemon to create new input context. If succeeded,
// |callback| will be called with an ObjectPath which is used in input context
// handling. If failed, |error_callback| is called instead.
virtual void CreateInputContext(
const std::string& client_name,
const CreateInputContextCallback& callback,
const ErrorCallback& error_callback) = 0;
// Requests the ibus-daemon to register new engine object. If succeeded,
// |callback| will be called. If failed, |error_callback| is called instead.
virtual void RegisterComponent(
const IBusComponent& ibus_component,
const RegisterComponentCallback& callback,
const ErrorCallback& error_callback) = 0;
// Requests the ibus-daemon to set global engine. If failed, |error_callback|
// is called.
virtual void SetGlobalEngine(const std::string& engine_name,
const ErrorCallback& error_callback) = 0;
// Requests the ibus-daemon to exit daemon process. If |option| is
// RESTART_IBUS_DAEMON, ibus-daemon will be relaunched. If |option| is
// SHUT_DOWN_IBUS_DAEMON, ibus-daemon will not be relaunched. The
// |error_callback| is called if an error occurs.
virtual void Exit(ExitOption option, const ErrorCallback& error_callback) = 0;
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static CHROMEOS_EXPORT IBusClient* Create(DBusClientImplementationType type,
dbus::Bus* bus);
protected:
// Create() should be used instead.
IBusClient();
private:
DISALLOW_COPY_AND_ASSIGN(IBusClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_
|