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

Side by Side Diff: chrome/browser/chromeos/input_method/ibus_engine_controller.cc

Issue 10109001: Replace all LOGs in input_method/, except two user-facing errors, to DVLOG(1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 "chrome/browser/chromeos/input_method/ibus_engine_controller.h" 5 #include "chrome/browser/chromeos/input_method/ibus_engine_controller.h"
6 6
7 #if defined(HAVE_IBUS) 7 #if defined(HAVE_IBUS)
8 #include <ibus.h> 8 #include <ibus.h>
9 #endif 9 #endif
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (preedit_text_) { 90 if (preedit_text_) {
91 g_object_unref(preedit_text_); 91 g_object_unref(preedit_text_);
92 preedit_text_ = NULL; 92 preedit_text_ = NULL;
93 } 93 }
94 if (ibus_) { 94 if (ibus_) {
95 DisconnectIBusSignals(); 95 DisconnectIBusSignals();
96 g_object_unref(ibus_); 96 g_object_unref(ibus_);
97 } 97 }
98 g_connections_->erase(engine_id_); 98 g_connections_->erase(engine_id_);
99 ClearProperties(); 99 ClearProperties();
100 VLOG(1) << "Removing engine: " << engine_id_; 100 DVLOG(1) << "Removing engine: " << engine_id_;
101 } 101 }
102 102
103 // Initializes the object. Returns true on success. 103 // Initializes the object. Returns true on success.
104 bool Init(const char* engine_id, const char* engine_name, 104 bool Init(const char* engine_id, const char* engine_name,
105 const char* description, const char* language, 105 const char* description, const char* language,
106 const char* layout) { 106 const char* layout) {
107 engine_id_ = engine_id; 107 engine_id_ = engine_id;
108 engine_name_ = engine_name; 108 engine_name_ = engine_name;
109 description_ = description; 109 description_ = description;
110 language_ = language; 110 language_ = language;
111 layout_ = layout; 111 layout_ = layout;
112 112
113 bus_name_ = "org.freedesktop.IBus."; 113 bus_name_ = "org.freedesktop.IBus.";
114 bus_name_ += engine_id; 114 bus_name_ += engine_id;
115 115
116 // engine_id_ must be unique. 116 // engine_id_ must be unique.
117 if (g_connections_->find(engine_id_) != g_connections_->end()) { 117 if (g_connections_->find(engine_id_) != g_connections_->end()) {
118 LOG(ERROR) << "ibus engine name already in use: " << engine_id_; 118 DVLOG(1) << "ibus engine name already in use: " << engine_id_;
119 return false; 119 return false;
120 } 120 }
121 121
122 // Initialize an IBus bus. 122 // Initialize an IBus bus.
123 ibus_init(); 123 ibus_init();
124 ibus_ = ibus_bus_new(); 124 ibus_ = ibus_bus_new();
125 125
126 // Check the IBus connection status. 126 // Check the IBus connection status.
127 if (!ibus_) { 127 if (!ibus_) {
128 LOG(ERROR) << "ibus_bus_new() failed"; 128 DVLOG(1) << "ibus_bus_new() failed";
129 return false; 129 return false;
130 } 130 }
131 131
132 (*g_connections_)[engine_id_] = this; 132 (*g_connections_)[engine_id_] = this;
133 VLOG(1) << "Adding engine: " << engine_id_; 133 DVLOG(1) << "Adding engine: " << engine_id_;
134 134
135 // Check the IBus connection status. 135 // Check the IBus connection status.
136 bool result = true; 136 bool result = true;
137 if (ibus_bus_is_connected(ibus_)) { 137 if (ibus_bus_is_connected(ibus_)) {
138 VLOG(1) << "ibus_bus_is_connected(). IBus connection is ready."; 138 DVLOG(1) << "ibus_bus_is_connected(). IBus connection is ready.";
139 result = MaybeCreateComponent(); 139 result = MaybeCreateComponent();
140 } 140 }
141 141
142 // Start listening the gobject signals regardless of the bus connection 142 // Start listening the gobject signals regardless of the bus connection
143 // status. 143 // status.
144 ConnectIBusSignals(); 144 ConnectIBusSignals();
145 return result; 145 return result;
146 } 146 }
147 147
148 virtual void SetPreeditText(const char* text, int cursor) { 148 virtual void SetPreeditText(const char* text, int cursor) {
149 if (active_engine_) { 149 if (active_engine_) {
150 VLOG(1) << "SetPreeditText"; 150 DVLOG(1) << "SetPreeditText";
151 if (preedit_text_) { 151 if (preedit_text_) {
152 g_object_unref(preedit_text_); 152 g_object_unref(preedit_text_);
153 preedit_text_ = NULL; 153 preedit_text_ = NULL;
154 } 154 }
155 preedit_cursor_ = cursor; 155 preedit_cursor_ = cursor;
156 preedit_text_ = static_cast<IBusText*>( 156 preedit_text_ = static_cast<IBusText*>(
157 g_object_ref_sink(ibus_text_new_from_string(text))); 157 g_object_ref_sink(ibus_text_new_from_string(text)));
158 ibus_engine_update_preedit_text(IBUS_ENGINE(active_engine_), 158 ibus_engine_update_preedit_text(IBUS_ENGINE(active_engine_),
159 preedit_text_, 159 preedit_text_,
160 preedit_cursor_, TRUE); 160 preedit_cursor_, TRUE);
161 } 161 }
162 } 162 }
163 163
164 virtual void SetPreeditUnderline(int start, int end, int type) { 164 virtual void SetPreeditUnderline(int start, int end, int type) {
165 VLOG(1) << "SetPreeditUnderline"; 165 DVLOG(1) << "SetPreeditUnderline";
166 if (active_engine_ && preedit_text_) { 166 if (active_engine_ && preedit_text_) {
167 // Translate the type to ibus's constants. 167 // Translate the type to ibus's constants.
168 int underline_type; 168 int underline_type;
169 switch (type) { 169 switch (type) {
170 case UNDERLINE_NONE: 170 case UNDERLINE_NONE:
171 underline_type = IBUS_ATTR_UNDERLINE_NONE; 171 underline_type = IBUS_ATTR_UNDERLINE_NONE;
172 break; 172 break;
173 173
174 case UNDERLINE_SINGLE: 174 case UNDERLINE_SINGLE:
175 underline_type = IBUS_ATTR_UNDERLINE_SINGLE; 175 underline_type = IBUS_ATTR_UNDERLINE_SINGLE;
(...skipping 18 matching lines...) Expand all
194 ibus_text_append_attribute(preedit_text_, IBUS_ATTR_TYPE_UNDERLINE, 194 ibus_text_append_attribute(preedit_text_, IBUS_ATTR_TYPE_UNDERLINE,
195 underline_type, start, end); 195 underline_type, start, end);
196 ibus_engine_update_preedit_text(IBUS_ENGINE(active_engine_), 196 ibus_engine_update_preedit_text(IBUS_ENGINE(active_engine_),
197 preedit_text_, 197 preedit_text_,
198 preedit_cursor_, TRUE); 198 preedit_cursor_, TRUE);
199 } 199 }
200 } 200 }
201 201
202 virtual void CommitText(const char* text) { 202 virtual void CommitText(const char* text) {
203 if (active_engine_) { 203 if (active_engine_) {
204 VLOG(1) << "CommitText"; 204 DVLOG(1) << "CommitText";
205 // Reset the preedit text when a commit occurs. 205 // Reset the preedit text when a commit occurs.
206 SetPreeditText("", 0); 206 SetPreeditText("", 0);
207 if (preedit_text_) { 207 if (preedit_text_) {
208 g_object_unref(preedit_text_); 208 g_object_unref(preedit_text_);
209 preedit_text_ = NULL; 209 preedit_text_ = NULL;
210 } 210 }
211 IBusText* ibus_text = static_cast<IBusText*>( 211 IBusText* ibus_text = static_cast<IBusText*>(
212 ibus_text_new_from_string(text)); 212 ibus_text_new_from_string(text));
213 ibus_engine_commit_text(IBUS_ENGINE(active_engine_), ibus_text); 213 ibus_engine_commit_text(IBUS_ENGINE(active_engine_), ibus_text);
214 } 214 }
215 } 215 }
216 216
217 virtual void SetTableVisible(bool visible) { 217 virtual void SetTableVisible(bool visible) {
218 table_visible_ = visible; 218 table_visible_ = visible;
219 if (active_engine_) { 219 if (active_engine_) {
220 VLOG(1) << "SetTableVisible"; 220 DVLOG(1) << "SetTableVisible";
221 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 221 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
222 active_engine_->table, 222 active_engine_->table,
223 table_visible_); 223 table_visible_);
224 if (visible) { 224 if (visible) {
225 ibus_engine_show_lookup_table(IBUS_ENGINE(active_engine_)); 225 ibus_engine_show_lookup_table(IBUS_ENGINE(active_engine_));
226 } else { 226 } else {
227 ibus_engine_hide_lookup_table(IBUS_ENGINE(active_engine_)); 227 ibus_engine_hide_lookup_table(IBUS_ENGINE(active_engine_));
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 virtual void SetCursorVisible(bool visible) { 232 virtual void SetCursorVisible(bool visible) {
233 cursor_visible_ = visible; 233 cursor_visible_ = visible;
234 if (active_engine_) { 234 if (active_engine_) {
235 VLOG(1) << "SetCursorVisible"; 235 DVLOG(1) << "SetCursorVisible";
236 ibus_lookup_table_set_cursor_visible(active_engine_->table, visible); 236 ibus_lookup_table_set_cursor_visible(active_engine_->table, visible);
237 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 237 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
238 active_engine_->table, 238 active_engine_->table,
239 table_visible_); 239 table_visible_);
240 } 240 }
241 } 241 }
242 242
243 virtual void SetOrientationVertical(bool vertical) { 243 virtual void SetOrientationVertical(bool vertical) {
244 vertical_ = vertical; 244 vertical_ = vertical;
245 if (active_engine_) { 245 if (active_engine_) {
246 VLOG(1) << "SetOrientationVertical"; 246 DVLOG(1) << "SetOrientationVertical";
247 ibus_lookup_table_set_orientation(active_engine_->table, 247 ibus_lookup_table_set_orientation(active_engine_->table,
248 vertical ? IBUS_ORIENTATION_VERTICAL : 248 vertical ? IBUS_ORIENTATION_VERTICAL :
249 IBUS_ORIENTATION_HORIZONTAL); 249 IBUS_ORIENTATION_HORIZONTAL);
250 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 250 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
251 active_engine_->table, 251 active_engine_->table,
252 table_visible_); 252 table_visible_);
253 } 253 }
254 } 254 }
255 255
256 virtual void SetPageSize(unsigned int size) { 256 virtual void SetPageSize(unsigned int size) {
257 page_size_ = size; 257 page_size_ = size;
258 if (active_engine_) { 258 if (active_engine_) {
259 VLOG(1) << "SetPageSize"; 259 DVLOG(1) << "SetPageSize";
260 ibus_lookup_table_set_page_size(active_engine_->table, size); 260 ibus_lookup_table_set_page_size(active_engine_->table, size);
261 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 261 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
262 active_engine_->table, 262 active_engine_->table,
263 table_visible_); 263 table_visible_);
264 } 264 }
265 } 265 }
266 266
267 virtual void ClearCandidates() { 267 virtual void ClearCandidates() {
268 if (active_engine_) { 268 if (active_engine_) {
269 VLOG(1) << "ClearCandidates"; 269 DVLOG(1) << "ClearCandidates";
270 ibus_lookup_table_clear(active_engine_->table); 270 ibus_lookup_table_clear(active_engine_->table);
271 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 271 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
272 active_engine_->table, 272 active_engine_->table,
273 table_visible_); 273 table_visible_);
274 } 274 }
275 } 275 }
276 276
277 virtual void SetCandidates(std::vector<Candidate> candidates) { 277 virtual void SetCandidates(std::vector<Candidate> candidates) {
278 // Text with this foreground color will be treated as an annotation. 278 // Text with this foreground color will be treated as an annotation.
279 const guint kAnnotationForegroundColor = 0x888888; 279 const guint kAnnotationForegroundColor = 0x888888;
280 if (active_engine_) { 280 if (active_engine_) {
281 VLOG(1) << "SetCandidates"; 281 DVLOG(1) << "SetCandidates";
282 ibus_lookup_table_clear(active_engine_->table); 282 ibus_lookup_table_clear(active_engine_->table);
283 283
284 for (std::vector<Candidate>::iterator ix = candidates.begin(); 284 for (std::vector<Candidate>::iterator ix = candidates.begin();
285 ix != candidates.end(); ++ix ) { 285 ix != candidates.end(); ++ix ) {
286 if (!ix->annotation.empty()) { 286 if (!ix->annotation.empty()) {
287 // If there's an annotation, append it to the value. 287 // If there's an annotation, append it to the value.
288 std::string candidate(ix->value); 288 std::string candidate(ix->value);
289 candidate += " "; 289 candidate += " ";
290 size_t start = g_utf8_strlen(candidate.c_str(), -1); 290 size_t start = g_utf8_strlen(candidate.c_str(), -1);
291 candidate += ix->annotation; 291 candidate += ix->annotation;
(...skipping 26 matching lines...) Expand all
318 } 318 }
319 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 319 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
320 active_engine_->table, 320 active_engine_->table,
321 table_visible_); 321 table_visible_);
322 } 322 }
323 } 323 }
324 324
325 virtual void SetCandidateAuxText(const char* text) { 325 virtual void SetCandidateAuxText(const char* text) {
326 aux_text_ = text; 326 aux_text_ = text;
327 if (active_engine_) { 327 if (active_engine_) {
328 VLOG(1) << "SetCandidateAuxText"; 328 DVLOG(1) << "SetCandidateAuxText";
329 IBusText* ibus_text = static_cast<IBusText*>( 329 IBusText* ibus_text = static_cast<IBusText*>(
330 ibus_text_new_from_string(aux_text_.c_str())); 330 ibus_text_new_from_string(aux_text_.c_str()));
331 ibus_engine_update_auxiliary_text(IBUS_ENGINE(active_engine_), ibus_text, 331 ibus_engine_update_auxiliary_text(IBUS_ENGINE(active_engine_), ibus_text,
332 aux_text_visible_); 332 aux_text_visible_);
333 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 333 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
334 active_engine_->table, 334 active_engine_->table,
335 table_visible_); 335 table_visible_);
336 } 336 }
337 } 337 }
338 338
339 virtual void SetCandidateAuxTextVisible(bool visible) { 339 virtual void SetCandidateAuxTextVisible(bool visible) {
340 aux_text_visible_ = visible; 340 aux_text_visible_ = visible;
341 if (active_engine_) { 341 if (active_engine_) {
342 VLOG(1) << "SetCandidateAuxTextVisible"; 342 DVLOG(1) << "SetCandidateAuxTextVisible";
343 IBusText* ibus_text = static_cast<IBusText*>( 343 IBusText* ibus_text = static_cast<IBusText*>(
344 ibus_text_new_from_string(aux_text_.c_str())); 344 ibus_text_new_from_string(aux_text_.c_str()));
345 ibus_engine_update_auxiliary_text(IBUS_ENGINE(active_engine_), ibus_text, 345 ibus_engine_update_auxiliary_text(IBUS_ENGINE(active_engine_), ibus_text,
346 aux_text_visible_); 346 aux_text_visible_);
347 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 347 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
348 active_engine_->table, 348 active_engine_->table,
349 table_visible_); 349 table_visible_);
350 } 350 }
351 } 351 }
352 352
353 virtual void SetCursorPosition(unsigned int position) { 353 virtual void SetCursorPosition(unsigned int position) {
354 cursor_position_ = position; 354 cursor_position_ = position;
355 if (active_engine_) { 355 if (active_engine_) {
356 VLOG(1) << "SetCursorPosition"; 356 DVLOG(1) << "SetCursorPosition";
357 ibus_lookup_table_set_cursor_pos(active_engine_->table, position); 357 ibus_lookup_table_set_cursor_pos(active_engine_->table, position);
358 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_), 358 ibus_engine_update_lookup_table(IBUS_ENGINE(active_engine_),
359 active_engine_->table, 359 active_engine_->table,
360 table_visible_); 360 table_visible_);
361 } 361 }
362 } 362 }
363 363
364 virtual bool RegisterProperties( 364 virtual bool RegisterProperties(
365 const std::vector<EngineProperty*>& properties) { 365 const std::vector<EngineProperty*>& properties) {
366 VLOG(1) << "RegisterProperties"; 366 DVLOG(1) << "RegisterProperties";
367 ClearProperties(); 367 ClearProperties();
368 CopyProperties(properties, &properties_); 368 CopyProperties(properties, &properties_);
369 369
370 if (active_engine_) { 370 if (active_engine_) {
371 if (!SetProperties()) { 371 if (!SetProperties()) {
372 return false; 372 return false;
373 } 373 }
374 } 374 }
375 return true; 375 return true;
376 } 376 }
377 377
378 void ClearProperties() { 378 void ClearProperties() {
379 STLDeleteContainerPointers(properties_.begin(), properties_.end()); 379 STLDeleteContainerPointers(properties_.begin(), properties_.end());
380 properties_.clear(); 380 properties_.clear();
381 property_map_.clear(); 381 property_map_.clear();
382 } 382 }
383 383
384 virtual bool UpdateProperties( 384 virtual bool UpdateProperties(
385 const std::vector<EngineProperty*>& properties) { 385 const std::vector<EngineProperty*>& properties) {
386 VLOG(1) << "UpdateProperties"; 386 DVLOG(1) << "UpdateProperties";
387 return UpdatePropertyList(properties); 387 return UpdatePropertyList(properties);
388 } 388 }
389 389
390 void CopyProperties(const std::vector<EngineProperty*>& properties, 390 void CopyProperties(const std::vector<EngineProperty*>& properties,
391 std::vector<EngineProperty*>* dest) { 391 std::vector<EngineProperty*>* dest) {
392 for (std::vector<EngineProperty*>::const_iterator property = 392 for (std::vector<EngineProperty*>::const_iterator property =
393 properties.begin(); property != properties.end(); ++property) { 393 properties.begin(); property != properties.end(); ++property) {
394 if (property_map_.find((*property)->key) != property_map_.end()) { 394 if (property_map_.find((*property)->key) != property_map_.end()) {
395 LOG(ERROR) << "Property collision on name: " << (*property)->key; 395 DVLOG(1) << "Property collision on name: " << (*property)->key;
396 return; 396 return;
397 } 397 }
398 398
399 EngineProperty* new_property = new EngineProperty; 399 EngineProperty* new_property = new EngineProperty;
400 dest->push_back(new_property); 400 dest->push_back(new_property);
401 property_map_[(*property)->key] = new_property; 401 property_map_[(*property)->key] = new_property;
402 402
403 new_property->key = (*property)->key; 403 new_property->key = (*property)->key;
404 new_property->label = (*property)->label; 404 new_property->label = (*property)->label;
405 new_property->tooltip = (*property)->tooltip; 405 new_property->tooltip = (*property)->tooltip;
406 new_property->sensitive = (*property)->sensitive; 406 new_property->sensitive = (*property)->sensitive;
407 new_property->visible = (*property)->visible; 407 new_property->visible = (*property)->visible;
408 new_property->type = (*property)->type; 408 new_property->type = (*property)->type;
409 new_property->checked = (*property)->checked; 409 new_property->checked = (*property)->checked;
410 410
411 CopyProperties((*property)->children, &(new_property->children)); 411 CopyProperties((*property)->children, &(new_property->children));
412 } 412 }
413 } 413 }
414 414
415 IBusPropList *MakePropertyList( 415 IBusPropList *MakePropertyList(
416 const std::vector<EngineProperty*>& properties) { 416 const std::vector<EngineProperty*>& properties) {
417 IBusPropList *prop_list = ibus_prop_list_new(); 417 IBusPropList *prop_list = ibus_prop_list_new();
418 for (std::vector<EngineProperty*>::const_iterator property = 418 for (std::vector<EngineProperty*>::const_iterator property =
419 properties.begin(); property != properties.end(); ++property) { 419 properties.begin(); property != properties.end(); ++property) {
420 IBusPropList *children = NULL; 420 IBusPropList *children = NULL;
421 if (!(*property)->children.empty()) { 421 if (!(*property)->children.empty()) {
422 children = MakePropertyList((*property)->children); 422 children = MakePropertyList((*property)->children);
423 } 423 }
424 424
425 IBusPropType type = PROP_TYPE_NORMAL; 425 IBusPropType type = PROP_TYPE_NORMAL;
426 switch ((*property)->type) { 426 switch ((*property)->type) {
427 case PROPERTY_TYPE_NORMAL: 427 case PROPERTY_TYPE_NORMAL:
428 type = PROP_TYPE_NORMAL; 428 type = PROP_TYPE_NORMAL;
429 break; 429 break;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 469
470 bool SetProperties() { 470 bool SetProperties() {
471 IBusPropList *prop_list = MakePropertyList(properties_); 471 IBusPropList *prop_list = MakePropertyList(properties_);
472 ibus_engine_register_properties(IBUS_ENGINE(active_engine_), prop_list); 472 ibus_engine_register_properties(IBUS_ENGINE(active_engine_), prop_list);
473 return true; 473 return true;
474 } 474 }
475 475
476 bool UpdatePropertyList(const std::vector<EngineProperty*>& properties) { 476 bool UpdatePropertyList(const std::vector<EngineProperty*>& properties) {
477 for (std::vector<EngineProperty*>::const_iterator property = 477 for (std::vector<EngineProperty*>::const_iterator property =
478 properties.begin(); property != properties.end(); ++property) { 478 properties.begin(); property != properties.end(); ++property) {
479 std::map<std::string, EngineProperty*>::iterator cur_property = 479 std::map<std::string, EngineProperty*>::iterator cur_property =
480 property_map_.find((*property)->key); 480 property_map_.find((*property)->key);
481 if (cur_property == property_map_.end()) { 481 if (cur_property == property_map_.end()) {
482 LOG(ERROR) << "Missing property: " << (*property)->key; 482 DVLOG(1) << "Missing property: " << (*property)->key;
483 return false; 483 return false;
484 } 484 }
485 485
486 if ((*property)->modified & PROPERTY_MODIFIED_LABEL) { 486 if ((*property)->modified & PROPERTY_MODIFIED_LABEL) {
487 cur_property->second->label = (*property)->label; 487 cur_property->second->label = (*property)->label;
488 } 488 }
489 if ((*property)->modified & PROPERTY_MODIFIED_TOOLTIP) { 489 if ((*property)->modified & PROPERTY_MODIFIED_TOOLTIP) {
490 cur_property->second->tooltip = (*property)->tooltip; 490 cur_property->second->tooltip = (*property)->tooltip;
491 } 491 }
492 if ((*property)->modified & PROPERTY_MODIFIED_SENSITIVE) { 492 if ((*property)->modified & PROPERTY_MODIFIED_SENSITIVE) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 static void InitEngine(IBusChromeOSEngine* engine) { 588 static void InitEngine(IBusChromeOSEngine* engine) {
589 } 589 }
590 590
591 private: 591 private:
592 // Installs gobject signal handlers to |ibus_|. 592 // Installs gobject signal handlers to |ibus_|.
593 void ConnectIBusSignals() { 593 void ConnectIBusSignals() {
594 if (!ibus_) { 594 if (!ibus_) {
595 return; 595 return;
596 } 596 }
597 VLOG(1) << "ConnectIBusSignals"; 597 DVLOG(1) << "ConnectIBusSignals";
598 g_signal_connect(ibus_, 598 g_signal_connect(ibus_,
599 "connected", 599 "connected",
600 G_CALLBACK(IBusBusConnectedCallback), 600 G_CALLBACK(IBusBusConnectedCallback),
601 this); 601 this);
602 g_signal_connect(ibus_, 602 g_signal_connect(ibus_,
603 "disconnected", 603 "disconnected",
604 G_CALLBACK(IBusBusDisconnectedCallback), 604 G_CALLBACK(IBusBusDisconnectedCallback),
605 this); 605 this);
606 } 606 }
607 607
608 // Removes gobject signal handlers from |ibus_|. 608 // Removes gobject signal handlers from |ibus_|.
609 void DisconnectIBusSignals() { 609 void DisconnectIBusSignals() {
610 if (!ibus_) { 610 if (!ibus_) {
611 return; 611 return;
612 } 612 }
613 g_signal_handlers_disconnect_by_func( 613 g_signal_handlers_disconnect_by_func(
614 ibus_, 614 ibus_,
615 reinterpret_cast<gpointer>(G_CALLBACK(IBusBusConnectedCallback)), 615 reinterpret_cast<gpointer>(G_CALLBACK(IBusBusConnectedCallback)),
616 this); 616 this);
617 g_signal_handlers_disconnect_by_func( 617 g_signal_handlers_disconnect_by_func(
618 ibus_, 618 ibus_,
619 reinterpret_cast<gpointer>(G_CALLBACK(IBusBusDisconnectedCallback)), 619 reinterpret_cast<gpointer>(G_CALLBACK(IBusBusDisconnectedCallback)),
620 this); 620 this);
621 } 621 }
622 622
623 // Handles "connected" signal from ibus-daemon. 623 // Handles "connected" signal from ibus-daemon.
624 static void IBusBusConnectedCallback(IBusBus* bus, gpointer user_data) { 624 static void IBusBusConnectedCallback(IBusBus* bus, gpointer user_data) {
625 LOG(WARNING) << "IBus connection is recovered."; 625 DVLOG(1) << "IBus connection is recovered.";
626 g_return_if_fail(user_data); 626 g_return_if_fail(user_data);
627 IBusEngineControllerImpl* self 627 IBusEngineControllerImpl* self
628 = static_cast<IBusEngineControllerImpl*>(user_data); 628 = static_cast<IBusEngineControllerImpl*>(user_data);
629 DCHECK(ibus_bus_is_connected(self->ibus_)); 629 DCHECK(ibus_bus_is_connected(self->ibus_));
630 if (!self->MaybeCreateComponent()) { 630 if (!self->MaybeCreateComponent()) {
631 LOG(ERROR) << "MaybeCreateComponent() failed"; 631 DVLOG(1) << "MaybeCreateComponent() failed";
632 return; 632 return;
633 } 633 }
634 } 634 }
635 635
636 // Handles "disconnected" signal from ibus-daemon. 636 // Handles "disconnected" signal from ibus-daemon.
637 static void IBusBusDisconnectedCallback(IBusBus* bus, gpointer user_data) { 637 static void IBusBusDisconnectedCallback(IBusBus* bus, gpointer user_data) {
638 LOG(WARNING) << "IBus connection is terminated."; 638 DVLOG(1) << "IBus connection is terminated.";
639 if (g_factory_) { 639 if (g_factory_) {
640 g_object_unref(g_factory_); 640 g_object_unref(g_factory_);
641 g_factory_ = NULL; 641 g_factory_ = NULL;
642 } 642 }
643 } 643 }
644 644
645 bool MaybeCreateComponent() { 645 bool MaybeCreateComponent() {
646 if (!ibus_ || !ibus_bus_is_connected(ibus_)) { 646 if (!ibus_ || !ibus_bus_is_connected(ibus_)) {
647 return false; 647 return false;
648 } 648 }
649 649
650 VLOG(1) << "MaybeCreateComponent"; 650 DVLOG(1) << "MaybeCreateComponent";
651 IBusComponent* component = ibus_component_new(bus_name_.c_str(), 651 IBusComponent* component = ibus_component_new(bus_name_.c_str(),
652 description_.c_str(), 652 description_.c_str(),
653 "", 653 "",
654 "", 654 "",
655 engine_name_.c_str(), 655 engine_name_.c_str(),
656 "", 656 "",
657 "", 657 "",
658 ""); 658 "");
659 g_object_ref_sink(component); 659 g_object_ref_sink(component);
660 ibus_component_add_engine(component, 660 ibus_component_add_engine(component,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 interface_name, 709 interface_name,
710 method_name, 710 method_name,
711 parameters, 711 parameters,
712 invocation); 712 invocation);
713 } 713 }
714 } 714 }
715 715
716 static void OnProcessKeyEvent(IBusEngine* ibus_engine, guint keyval, 716 static void OnProcessKeyEvent(IBusEngine* ibus_engine, guint keyval,
717 guint keycode, guint modifiers, 717 guint keycode, guint modifiers,
718 GDBusMethodInvocation* key_data) { 718 GDBusMethodInvocation* key_data) {
719 VLOG(1) << "OnProcessKeyEvent"; 719 DVLOG(1) << "OnProcessKeyEvent";
720 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 720 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
721 if (engine->connection) { 721 if (engine->connection) {
722 engine->connection->observer_->OnKeyEvent( 722 engine->connection->observer_->OnKeyEvent(
723 !(modifiers & IBUS_RELEASE_MASK), 723 !(modifiers & IBUS_RELEASE_MASK),
724 keyval, keycode, 724 keyval, keycode,
725 modifiers & IBUS_MOD1_MASK, 725 modifiers & IBUS_MOD1_MASK,
726 modifiers & IBUS_CONTROL_MASK, 726 modifiers & IBUS_CONTROL_MASK,
727 modifiers & IBUS_SHIFT_MASK, 727 modifiers & IBUS_SHIFT_MASK,
728 reinterpret_cast<KeyEventHandle*>(key_data)); 728 reinterpret_cast<KeyEventHandle*>(key_data));
729 } 729 }
730 } 730 }
731 731
732 static void OnReset(IBusEngine* ibus_engine) { 732 static void OnReset(IBusEngine* ibus_engine) {
733 VLOG(1) << "OnReset"; 733 DVLOG(1) << "OnReset";
734 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 734 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
735 if (engine->connection) { 735 if (engine->connection) {
736 engine->connection->observer_->OnReset(); 736 engine->connection->observer_->OnReset();
737 } 737 }
738 } 738 }
739 739
740 static void OnEnable(IBusEngine* ibus_engine) { 740 static void OnEnable(IBusEngine* ibus_engine) {
741 VLOG(1) << "OnEnable"; 741 DVLOG(1) << "OnEnable";
742 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 742 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
743 if (engine->connection) { 743 if (engine->connection) {
744 engine->connection->active_engine_ = engine; 744 engine->connection->active_engine_ = engine;
745 engine->connection->active_ = true; 745 engine->connection->active_ = true;
746 engine->connection->observer_->OnEnable(); 746 engine->connection->observer_->OnEnable();
747 if (engine->connection->focused_) { 747 if (engine->connection->focused_) {
748 engine->connection->observer_->OnFocusIn(); 748 engine->connection->observer_->OnFocusIn();
749 } 749 }
750 engine->connection->SetProperties(); 750 engine->connection->SetProperties();
751 } 751 }
752 } 752 }
753 753
754 static void OnDisable(IBusEngine* ibus_engine) { 754 static void OnDisable(IBusEngine* ibus_engine) {
755 VLOG(1) << "OnDisable"; 755 DVLOG(1) << "OnDisable";
756 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 756 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
757 if (engine->connection) { 757 if (engine->connection) {
758 engine->connection->active_ = false; 758 engine->connection->active_ = false;
759 engine->connection->observer_->OnDisable(); 759 engine->connection->observer_->OnDisable();
760 if (engine->connection->active_engine_ == engine) { 760 if (engine->connection->active_engine_ == engine) {
761 engine->connection->active_engine_ = NULL; 761 engine->connection->active_engine_ = NULL;
762 } 762 }
763 } 763 }
764 } 764 }
765 765
766 static void OnFocusIn(IBusEngine* ibus_engine) { 766 static void OnFocusIn(IBusEngine* ibus_engine) {
767 VLOG(1) << "OnFocusIn"; 767 DVLOG(1) << "OnFocusIn";
768 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 768 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
769 if (engine->connection) { 769 if (engine->connection) {
770 engine->connection->focused_ = true; 770 engine->connection->focused_ = true;
771 if (engine->connection->active_) { 771 if (engine->connection->active_) {
772 engine->connection->observer_->OnFocusIn(); 772 engine->connection->observer_->OnFocusIn();
773 } 773 }
774 engine->connection->SetProperties(); 774 engine->connection->SetProperties();
775 } 775 }
776 } 776 }
777 777
778 static void OnFocusOut(IBusEngine* ibus_engine) { 778 static void OnFocusOut(IBusEngine* ibus_engine) {
779 VLOG(1) << "OnFocusOut"; 779 DVLOG(1) << "OnFocusOut";
780 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 780 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
781 if (engine->connection) { 781 if (engine->connection) {
782 engine->connection->focused_ = false; 782 engine->connection->focused_ = false;
783 if (engine->connection->active_) { 783 if (engine->connection->active_) {
784 engine->connection->observer_->OnFocusOut(); 784 engine->connection->observer_->OnFocusOut();
785 } 785 }
786 } 786 }
787 } 787 }
788 788
789 static void OnPageUp(IBusEngine* ibus_engine) { 789 static void OnPageUp(IBusEngine* ibus_engine) {
790 // Not implemented 790 // Not implemented
791 } 791 }
792 792
793 static void OnPageDown(IBusEngine* ibus_engine) { 793 static void OnPageDown(IBusEngine* ibus_engine) {
794 // Not implemented 794 // Not implemented
795 } 795 }
796 796
797 static void OnCursorUp(IBusEngine* ibus_engine) { 797 static void OnCursorUp(IBusEngine* ibus_engine) {
798 // Not implemented 798 // Not implemented
799 } 799 }
800 800
801 static void OnCursorDown(IBusEngine* ibus_engine) { 801 static void OnCursorDown(IBusEngine* ibus_engine) {
802 // Not implemented 802 // Not implemented
803 } 803 }
804 804
805 static void OnPropertyActivate(IBusEngine* ibus_engine, 805 static void OnPropertyActivate(IBusEngine* ibus_engine,
806 const gchar *prop_name, guint prop_state) { 806 const gchar *prop_name, guint prop_state) {
807 VLOG(1) << "OnPropertyActivate"; 807 DVLOG(1) << "OnPropertyActivate";
808 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 808 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
809 if (engine->connection) { 809 if (engine->connection) {
810 engine->connection->observer_->OnPropertyActivate(prop_name, prop_state); 810 engine->connection->observer_->OnPropertyActivate(prop_name, prop_state);
811 } 811 }
812 } 812 }
813 813
814 static void OnCandidateClicked(IBusEngine* ibus_engine, guint index, 814 static void OnCandidateClicked(IBusEngine* ibus_engine, guint index,
815 guint button, guint state) { 815 guint button, guint state) {
816 VLOG(1) << "OnCandidateClicked"; 816 DVLOG(1) << "OnCandidateClicked";
817 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine); 817 IBusChromeOSEngine* engine = IBUS_CHROMEOS_ENGINE(ibus_engine);
818 if (engine->connection) { 818 if (engine->connection) {
819 int pressed_button = 0; 819 int pressed_button = 0;
820 if (button & IBUS_BUTTON1_MASK) { 820 if (button & IBUS_BUTTON1_MASK) {
821 pressed_button |= MOUSE_BUTTON_1_MASK; 821 pressed_button |= MOUSE_BUTTON_1_MASK;
822 } 822 }
823 if (button & IBUS_BUTTON2_MASK) { 823 if (button & IBUS_BUTTON2_MASK) {
824 pressed_button |= MOUSE_BUTTON_2_MASK; 824 pressed_button |= MOUSE_BUTTON_2_MASK;
825 } 825 }
826 if (button & IBUS_BUTTON3_MASK) { 826 if (button & IBUS_BUTTON3_MASK) {
827 pressed_button |= MOUSE_BUTTON_3_MASK; 827 pressed_button |= MOUSE_BUTTON_3_MASK;
828 } 828 }
829 engine->connection->observer_->OnCandidateClicked(index, pressed_button, 829 engine->connection->observer_->OnCandidateClicked(index, pressed_button,
830 state); 830 state);
831 } 831 }
832 } 832 }
833 833
834 static GObject* EngineConstructor(GType type, guint n_construct_params, 834 static GObject* EngineConstructor(GType type, guint n_construct_params,
835 GObjectConstructParam *construct_params) { 835 GObjectConstructParam *construct_params) {
836 IBusChromeOSEngine* engine = (IBusChromeOSEngine*) 836 IBusChromeOSEngine* engine = (IBusChromeOSEngine*)
837 G_OBJECT_CLASS(ibus_chromeos_engine_parent_class) 837 G_OBJECT_CLASS(ibus_chromeos_engine_parent_class)
838 ->constructor(type, n_construct_params, construct_params); 838 ->constructor(type, n_construct_params, construct_params);
839 const gchar* name = ibus_engine_get_name((IBusEngine*)engine); 839 const gchar* name = ibus_engine_get_name((IBusEngine*)engine);
840 ConnectionMap::iterator connection = g_connections_->find(name); 840 ConnectionMap::iterator connection = g_connections_->find(name);
841 if (connection == g_connections_->end()) { 841 if (connection == g_connections_->end()) {
842 LOG(ERROR) << "Connection never created: " << name; 842 DVLOG(1) << "Connection never created: " << name;
843 engine->connection = NULL; 843 engine->connection = NULL;
844 engine->table = NULL; 844 engine->table = NULL;
845 return (GObject *) engine; 845 return (GObject *) engine;
846 } 846 }
847 847
848 connection->second->engine_instances_.insert(engine); 848 connection->second->engine_instances_.insert(engine);
849 849
850 if (!connection->second->active_engine_) { 850 if (!connection->second->active_engine_) {
851 connection->second->active_engine_ = engine; 851 connection->second->active_engine_ = engine;
852 } 852 }
(...skipping 15 matching lines...) Expand all
868 868
869 connection->second->SetProperties(); 869 connection->second->SetProperties();
870 870
871 return (GObject *) engine; 871 return (GObject *) engine;
872 } 872 }
873 873
874 static void OnDestroy(IBusChromeOSEngine* chromeos_engine) { 874 static void OnDestroy(IBusChromeOSEngine* chromeos_engine) {
875 const gchar* name = ibus_engine_get_name((IBusEngine*)chromeos_engine); 875 const gchar* name = ibus_engine_get_name((IBusEngine*)chromeos_engine);
876 ConnectionMap::iterator connection = g_connections_->find(name); 876 ConnectionMap::iterator connection = g_connections_->find(name);
877 if (connection == g_connections_->end()) { 877 if (connection == g_connections_->end()) {
878 LOG(ERROR) << "Connection already destroyed, or never created: " << name; 878 DVLOG(1) << "Connection already destroyed, or never created: " << name;
879 } else { 879 } else {
880 connection->second->engine_instances_.erase(chromeos_engine); 880 connection->second->engine_instances_.erase(chromeos_engine);
881 if (connection->second->active_engine_ == chromeos_engine) { 881 if (connection->second->active_engine_ == chromeos_engine) {
882 connection->second->active_engine_ = NULL; 882 connection->second->active_engine_ = NULL;
883 } 883 }
884 } 884 }
885 if (chromeos_engine->table) { 885 if (chromeos_engine->table) {
886 g_object_unref(chromeos_engine->table); 886 g_object_unref(chromeos_engine->table);
887 chromeos_engine->table = NULL; 887 chromeos_engine->table = NULL;
888 } 888 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 IBusEngineController* IBusEngineController::Create(Observer* observer, 941 IBusEngineController* IBusEngineController::Create(Observer* observer,
942 const char* engine_id, 942 const char* engine_id,
943 const char* engine_name, 943 const char* engine_name,
944 const char* description, 944 const char* description,
945 const char* language, 945 const char* language,
946 const char* layout) { 946 const char* layout) {
947 #if defined(HAVE_IBUS) 947 #if defined(HAVE_IBUS)
948 IBusEngineControllerImpl* connection = new IBusEngineControllerImpl(observer); 948 IBusEngineControllerImpl* connection = new IBusEngineControllerImpl(observer);
949 if (!connection->Init(engine_id, engine_name, description, language, 949 if (!connection->Init(engine_id, engine_name, description, language,
950 layout)) { 950 layout)) {
951 LOG(ERROR) << "Failed to Init() IBusEngineControllerImpl. " 951 DVLOG(1) << "Failed to Init() IBusEngineControllerImpl. "
952 << "Returning NULL"; 952 << "Returning NULL";
953 delete connection; 953 delete connection;
954 connection = NULL; 954 connection = NULL;
955 } 955 }
956 return connection; 956 return connection;
957 #else 957 #else
958 return NULL; 958 return NULL;
959 #endif 959 #endif
960 } 960 }
961 961
962 IBusEngineController::~IBusEngineController() { 962 IBusEngineController::~IBusEngineController() {
963 } 963 }
964 964
965 } // namespace input_method 965 } // namespace input_method
966 } // namespace chromeos 966 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698