OLD | NEW |
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ | 1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ |
2 /* vim:set et sts=4: */ | 2 /* vim:set et sts=4: */ |
3 /* ibus - The Input Bus | 3 /* ibus - The Input Bus |
4 * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com> | 4 * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com> |
5 * Copyright (C) 2015-2017 Takao Fujiwara <takao.fujiwara1@gmail.com> | 5 * Copyright (C) 2015-2018 Takao Fujiwara <takao.fujiwara1@gmail.com> |
6 * Copyright (C) 2008-2016 Red Hat, Inc. | 6 * Copyright (C) 2008-2016 Red Hat, Inc. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2.1 of the License, or (at your option) any later version. | 11 * version 2.1 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 cursor_pos, | 1141 cursor_pos, |
1142 anchor_pos); | 1142 anchor_pos); |
1143 } | 1143 } |
1144 | 1144 |
1145 if (g_object_is_floating (text)) | 1145 if (g_object_is_floating (text)) |
1146 g_object_unref (text); | 1146 g_object_unref (text); |
1147 | 1147 |
1148 g_dbus_method_invocation_return_value (invocation, NULL); | 1148 g_dbus_method_invocation_return_value (invocation, NULL); |
1149 } | 1149 } |
1150 | 1150 |
| 1151 /* |
| 1152 * Since IBusService is inherited by IBusImpl, this method cannot be |
| 1153 * applied to IBusServiceClass.method_call() directly but can be in |
| 1154 * each child class.method_call(). |
| 1155 */ |
| 1156 static gboolean |
| 1157 bus_input_context_service_authorized_method (IBusService *service, |
| 1158 GDBusConnection *connection) |
| 1159 { |
| 1160 if (ibus_service_get_connection (service) == connection) |
| 1161 return TRUE; |
| 1162 return FALSE; |
| 1163 } |
| 1164 |
1151 /** | 1165 /** |
1152 * bus_input_context_service_method_call: | 1166 * bus_input_context_service_method_call: |
1153 * | 1167 * |
1154 * Handle a D-Bus method call whose destination and interface name are both "org
.freedesktop.IBus.InputContext" | 1168 * Handle a D-Bus method call whose destination and interface name are both "org
.freedesktop.IBus.InputContext" |
1155 */ | 1169 */ |
1156 static void | 1170 static void |
1157 bus_input_context_service_method_call (IBusService *service, | 1171 bus_input_context_service_method_call (IBusService *service, |
1158 GDBusConnection *connection, | 1172 GDBusConnection *connection, |
1159 const gchar *sender, | 1173 const gchar *sender, |
1160 const gchar *object_path, | 1174 const gchar *object_path, |
(...skipping 29 matching lines...) Expand all Loading... |
1190 { "FocusOut", _ic_focus_out }, | 1204 { "FocusOut", _ic_focus_out }, |
1191 { "Reset", _ic_reset }, | 1205 { "Reset", _ic_reset }, |
1192 { "SetCapabilities", _ic_set_capabilities }, | 1206 { "SetCapabilities", _ic_set_capabilities }, |
1193 { "PropertyActivate", _ic_property_activate }, | 1207 { "PropertyActivate", _ic_property_activate }, |
1194 { "SetEngine", _ic_set_engine }, | 1208 { "SetEngine", _ic_set_engine }, |
1195 { "GetEngine", _ic_get_engine }, | 1209 { "GetEngine", _ic_get_engine }, |
1196 { "SetSurroundingText", _ic_set_surrounding_text } | 1210 { "SetSurroundingText", _ic_set_surrounding_text } |
1197 }; | 1211 }; |
1198 | 1212 |
1199 gint i; | 1213 gint i; |
| 1214 |
| 1215 if (!bus_input_context_service_authorized_method (service, connection)) |
| 1216 return; |
| 1217 |
1200 for (i = 0; i < G_N_ELEMENTS (methods); i++) { | 1218 for (i = 0; i < G_N_ELEMENTS (methods); i++) { |
1201 if (g_strcmp0 (method_name, methods[i].method_name) == 0) { | 1219 if (g_strcmp0 (method_name, methods[i].method_name) == 0) { |
1202 methods[i].method_callback ((BusInputContext *)service, parameters,
invocation); | 1220 methods[i].method_callback ((BusInputContext *)service, parameters,
invocation); |
1203 return; | 1221 return; |
1204 } | 1222 } |
1205 } | 1223 } |
1206 | 1224 |
1207 g_return_if_reached (); | 1225 g_return_if_reached (); |
1208 } | 1226 } |
1209 | 1227 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 service_set_property (service, | 1281 service_set_property (service, |
1264 connection, | 1282 connection, |
1265 sender, | 1283 sender, |
1266 object_path, | 1284 object_path, |
1267 interface_name, | 1285 interface_name, |
1268 property_name, | 1286 property_name, |
1269 value, | 1287 value, |
1270 error); | 1288 error); |
1271 } | 1289 } |
1272 | 1290 |
| 1291 if (!bus_input_context_service_authorized_method (service, connection)) |
| 1292 return FALSE; |
| 1293 |
1273 if (g_strcmp0 (property_name, "ContentType") == 0) { | 1294 if (g_strcmp0 (property_name, "ContentType") == 0) { |
1274 BusInputContext *context = (BusInputContext *) service; | 1295 BusInputContext *context = (BusInputContext *) service; |
1275 _ic_set_content_type (context, value); | 1296 _ic_set_content_type (context, value); |
1276 return TRUE; | 1297 return TRUE; |
1277 } | 1298 } |
1278 | 1299 |
1279 g_return_val_if_reached (FALSE); | 1300 g_return_val_if_reached (FALSE); |
1280 } | 1301 } |
1281 | 1302 |
| 1303 |
1282 gboolean | 1304 gboolean |
1283 bus_input_context_has_focus (BusInputContext *context) | 1305 bus_input_context_has_focus (BusInputContext *context) |
1284 { | 1306 { |
1285 g_assert (BUS_IS_INPUT_CONTEXT (context)); | 1307 g_assert (BUS_IS_INPUT_CONTEXT (context)); |
1286 | 1308 |
1287 return context->has_focus; | 1309 return context->has_focus; |
1288 } | 1310 } |
1289 | 1311 |
1290 void | 1312 void |
1291 bus_input_context_focus_in (BusInputContext *context) | 1313 bus_input_context_focus_in (BusInputContext *context) |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2595 | 2617 |
2596 if (text == text_empty || text == NULL) | 2618 if (text == text_empty || text == NULL) |
2597 return; | 2619 return; |
2598 | 2620 |
2599 GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)text); | 2621 GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)text); |
2600 bus_input_context_emit_signal (context, | 2622 bus_input_context_emit_signal (context, |
2601 "CommitText", | 2623 "CommitText", |
2602 g_variant_new ("(v)", variant), | 2624 g_variant_new ("(v)", variant), |
2603 NULL); | 2625 NULL); |
2604 } | 2626 } |
OLD | NEW |