| 1 |
/* main.c generated by valac 0.56.19, the Vala compiler |
| 2 |
* generated from main.vala, do not modify */ |
| 3 |
|
| 4 |
/* vim:set et sts=4 sw=4: |
| 5 |
* |
| 6 |
* ibus - The Input Bus |
| 7 |
* |
| 8 |
* Copyright (c) 2011-2013 Peng Huang <[email protected]> |
| 9 |
* Copyright (c) 2015-2025 Takao Fujiwara <[email protected]> |
| 10 |
* |
| 11 |
* This library is free software; you can redistribute it and/or |
| 12 |
* modify it under the terms of the GNU Lesser General Public |
| 13 |
* License as published by the Free Software Foundation; either |
| 14 |
* version 2.1 of the License, or (at your option) any later version. |
| 15 |
* |
| 16 |
* This library is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 |
* Lesser General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU Lesser General Public |
| 22 |
* License along with this library; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 24 |
* USA |
| 25 |
*/ |
| 26 |
|
| 27 |
#include <ibus.h> |
| 28 |
#include <glib-object.h> |
| 29 |
#include <stdlib.h> |
| 30 |
#include <string.h> |
| 31 |
#include <glib.h> |
| 32 |
#include <locale.h> |
| 33 |
#include <gio/gio.h> |
| 34 |
#include <glib/gstdio.h> |
| 35 |
|
| 36 |
#if !defined(VALA_STRICT_C) |
| 37 |
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14) |
| 38 |
#pragma GCC diagnostic warning "-Wincompatible-pointer-types" |
| 39 |
#elif defined(__clang__) && (__clang_major__ >= 16) |
| 40 |
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types" |
| 41 |
#pragma clang diagnostic ignored "-Wincompatible-pointer-types" |
| 42 |
#endif |
| 43 |
#endif |
| 44 |
#if !defined(VALA_EXTERN) |
| 45 |
#if defined(_MSC_VER) |
| 46 |
#define VALA_EXTERN __declspec(dllexport) extern |
| 47 |
#elif __GNUC__ >= 4 |
| 48 |
#define VALA_EXTERN __attribute__((visibility("default"))) extern |
| 49 |
#else |
| 50 |
#define VALA_EXTERN extern |
| 51 |
#endif |
| 52 |
#endif |
| 53 |
|
| 54 |
#define TYPE_DUMMY_ENGINE (dummy_engine_get_type ()) |
| 55 |
#define DUMMY_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DUMMY_ENGINE, DummyEngine)) |
| 56 |
#define DUMMY_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DUMMY_ENGINE, DummyEngineClass)) |
| 57 |
#define IS_DUMMY_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DUMMY_ENGINE)) |
| 58 |
#define IS_DUMMY_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DUMMY_ENGINE)) |
| 59 |
#define DUMMY_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DUMMY_ENGINE, DummyEngineClass)) |
| 60 |
|
| 61 |
typedef struct _DummyEngine DummyEngine; |
| 62 |
typedef struct _DummyEngineClass DummyEngineClass; |
| 63 |
typedef struct _DummyEnginePrivate DummyEnginePrivate; |
| 64 |
enum { |
| 65 |
DUMMY_ENGINE_0_PROPERTY, |
| 66 |
DUMMY_ENGINE_NUM_PROPERTIES |
| 67 |
}; |
| 68 |
static GParamSpec* dummy_engine_properties[DUMMY_ENGINE_NUM_PROPERTIES]; |
| 69 |
typedef struct _Block1Data Block1Data; |
| 70 |
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) |
| 71 |
#define _g_free0(var) (var = (g_free (var), NULL)) |
| 72 |
|
| 73 |
struct _DummyEngine { |
| 74 |
IBusEngineSimple parent_instance; |
| 75 |
DummyEnginePrivate * priv; |
| 76 |
}; |
| 77 |
|
| 78 |
struct _DummyEngineClass { |
| 79 |
IBusEngineSimpleClass parent_class; |
| 80 |
}; |
| 81 |
|
| 82 |
struct _Block1Data { |
| 83 |
int _ref_count_; |
| 84 |
IBusBus* bus; |
| 85 |
gint id; |
| 86 |
}; |
| 87 |
|
| 88 |
VALA_EXTERN IBusEngineSimple* m_simple; |
| 89 |
IBusEngineSimple* m_simple = NULL; |
| 90 |
static gpointer dummy_engine_parent_class = NULL; |
| 91 |
|
| 92 |
VALA_EXTERN GType dummy_engine_get_type (void) G_GNUC_CONST ; |
| 93 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DummyEngine, g_object_unref) |
| 94 |
VALA_EXTERN DummyEngine* dummy_engine_new (void); |
| 95 |
VALA_EXTERN DummyEngine* dummy_engine_construct (GType object_type); |
| 96 |
static GType dummy_engine_get_type_once (void); |
| 97 |
static gint _vala_main (gchar** args, |
| 98 |
gint args_length1); |
| 99 |
static Block1Data* block1_data_ref (Block1Data* _data1_); |
| 100 |
static void block1_data_unref (void * _userdata_); |
| 101 |
static void __lambda4_ (IBusBus* bus); |
| 102 |
static void ___lambda4__ibus_bus_disconnected (IBusBus* _sender, |
| 103 |
gpointer self); |
| 104 |
static IBusEngine* __lambda5_ (Block1Data* _data1_, |
| 105 |
IBusFactory* factory, |
| 106 |
const gchar* name); |
| 107 |
static gboolean __lambda6_ (void); |
| 108 |
static gboolean ___lambda6__gsource_func (gpointer self); |
| 109 |
static IBusEngine* ___lambda5__ibus_factory_create_engine (IBusFactory* _sender, |
| 110 |
const gchar* engine_name, |
| 111 |
gpointer self); |
| 112 |
|
| 113 |
DummyEngine* |
| 114 |
dummy_engine_construct (GType object_type) |
| 115 |
{ |
| 116 |
DummyEngine * self = NULL; |
| 117 |
self = (DummyEngine*) g_object_new (object_type, NULL); |
| 118 |
return self; |
| 119 |
} |
| 120 |
|
| 121 |
DummyEngine* |
| 122 |
dummy_engine_new (void) |
| 123 |
{ |
| 124 |
return dummy_engine_construct (TYPE_DUMMY_ENGINE); |
| 125 |
} |
| 126 |
|
| 127 |
static void |
| 128 |
dummy_engine_class_init (DummyEngineClass * klass, |
| 129 |
gpointer klass_data) |
| 130 |
{ |
| 131 |
dummy_engine_parent_class = g_type_class_peek_parent (klass); |
| 132 |
} |
| 133 |
|
| 134 |
static void |
| 135 |
dummy_engine_instance_init (DummyEngine * self, |
| 136 |
gpointer klass) |
| 137 |
{ |
| 138 |
} |
| 139 |
|
| 140 |
static GType |
| 141 |
dummy_engine_get_type_once (void) |
| 142 |
{ |
| 143 |
static const GTypeInfo g_define_type_info = { sizeof (DummyEngineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dummy_engine_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DummyEngine), 0, (GInstanceInitFunc) dummy_engine_instance_init, NULL }; |
| 144 |
GType dummy_engine_type_id; |
| 145 |
dummy_engine_type_id = g_type_register_static (ibus_engine_simple_get_type (), "DummyEngine", &g_define_type_info, 0); |
| 146 |
return dummy_engine_type_id; |
| 147 |
} |
| 148 |
|
| 149 |
GType |
| 150 |
dummy_engine_get_type (void) |
| 151 |
{ |
| 152 |
static volatile gsize dummy_engine_type_id__once = 0; |
| 153 |
if (g_once_init_enter (&dummy_engine_type_id__once)) { |
| 154 |
GType dummy_engine_type_id; |
| 155 |
dummy_engine_type_id = dummy_engine_get_type_once (); |
| 156 |
g_once_init_leave (&dummy_engine_type_id__once, dummy_engine_type_id); |
| 157 |
} |
| 158 |
return dummy_engine_type_id__once; |
| 159 |
} |
| 160 |
|
| 161 |
static Block1Data* |
| 162 |
block1_data_ref (Block1Data* _data1_) |
| 163 |
{ |
| 164 |
g_atomic_int_inc (&_data1_->_ref_count_); |
| 165 |
return _data1_; |
| 166 |
} |
| 167 |
|
| 168 |
static void |
| 169 |
block1_data_unref (void * _userdata_) |
| 170 |
{ |
| 171 |
Block1Data* _data1_; |
| 172 |
_data1_ = (Block1Data*) _userdata_; |
| 173 |
if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) { |
| 174 |
_g_object_unref0 (_data1_->bus); |
| 175 |
g_slice_free (Block1Data, _data1_); |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
static void |
| 180 |
__lambda4_ (IBusBus* bus) |
| 181 |
{ |
| 182 |
g_return_if_fail (bus != NULL); |
| 183 |
g_debug ("main.vala:42: bus disconnected"); |
| 184 |
ibus_quit (); |
| 185 |
} |
| 186 |
|
| 187 |
static void |
| 188 |
___lambda4__ibus_bus_disconnected (IBusBus* _sender, |
| 189 |
gpointer self) |
| 190 |
{ |
| 191 |
__lambda4_ (_sender); |
| 192 |
} |
| 193 |
|
| 194 |
static gpointer |
| 195 |
_g_object_ref0 (gpointer self) |
| 196 |
{ |
| 197 |
return self ? g_object_ref (self) : NULL; |
| 198 |
} |
| 199 |
|
| 200 |
static gboolean |
| 201 |
__lambda6_ (void) |
| 202 |
{ |
| 203 |
IBusEngineSimple* _tmp0_; |
| 204 |
gchar* user_file = NULL; |
| 205 |
gchar* home = NULL; |
| 206 |
const gchar* _tmp1_; |
| 207 |
gchar* _tmp2_; |
| 208 |
const gchar* _tmp3_; |
| 209 |
const gchar* _tmp9_; |
| 210 |
gchar* _tmp10_; |
| 211 |
const gchar* _tmp11_; |
| 212 |
gboolean result; |
| 213 |
_tmp0_ = m_simple; |
| 214 |
ibus_engine_simple_add_table_by_locale (_tmp0_, NULL); |
| 215 |
user_file = NULL; |
| 216 |
_tmp1_ = g_get_home_dir (); |
| 217 |
_tmp2_ = g_strdup (_tmp1_); |
| 218 |
home = _tmp2_; |
| 219 |
_tmp3_ = home; |
| 220 |
if (_tmp3_ != NULL) { |
| 221 |
const gchar* _tmp4_; |
| 222 |
gchar* _tmp5_; |
| 223 |
const gchar* _tmp6_; |
| 224 |
_tmp4_ = home; |
| 225 |
_tmp5_ = g_strconcat (_tmp4_, "/.XCompose", NULL); |
| 226 |
_g_free0 (user_file); |
| 227 |
user_file = _tmp5_; |
| 228 |
_tmp6_ = user_file; |
| 229 |
if (g_file_test (_tmp6_, G_FILE_TEST_EXISTS)) { |
| 230 |
IBusEngineSimple* _tmp7_; |
| 231 |
const gchar* _tmp8_; |
| 232 |
_tmp7_ = m_simple; |
| 233 |
_tmp8_ = user_file; |
| 234 |
ibus_engine_simple_add_compose_file (_tmp7_, _tmp8_); |
| 235 |
} |
| 236 |
} |
| 237 |
_tmp9_ = g_getenv ("XCOMPOSEFILE"); |
| 238 |
_tmp10_ = g_strdup (_tmp9_); |
| 239 |
_g_free0 (user_file); |
| 240 |
user_file = _tmp10_; |
| 241 |
_tmp11_ = user_file; |
| 242 |
if (_tmp11_ != NULL) { |
| 243 |
const gchar* _tmp12_; |
| 244 |
_tmp12_ = user_file; |
| 245 |
if (g_file_test (_tmp12_, G_FILE_TEST_EXISTS)) { |
| 246 |
IBusEngineSimple* _tmp13_; |
| 247 |
const gchar* _tmp14_; |
| 248 |
_tmp13_ = m_simple; |
| 249 |
_tmp14_ = user_file; |
| 250 |
ibus_engine_simple_add_compose_file (_tmp13_, _tmp14_); |
| 251 |
} |
| 252 |
} |
| 253 |
result = FALSE; |
| 254 |
_g_free0 (home); |
| 255 |
_g_free0 (user_file); |
| 256 |
return result; |
| 257 |
} |
| 258 |
|
| 259 |
static gboolean |
| 260 |
___lambda6__gsource_func (gpointer self) |
| 261 |
{ |
| 262 |
gboolean result; |
| 263 |
result = __lambda6_ (); |
| 264 |
return result; |
| 265 |
} |
| 266 |
|
| 267 |
static IBusEngine* |
| 268 |
__lambda5_ (Block1Data* _data1_, |
| 269 |
IBusFactory* factory, |
| 270 |
const gchar* name) |
| 271 |
{ |
| 272 |
static const char path[] = "/org/freedesktop/IBus/engine/simple/%d"; |
| 273 |
IBusEngine* engine = NULL; |
| 274 |
const gchar* _tmp0_; |
| 275 |
gint _tmp1_; |
| 276 |
gchar* _tmp2_; |
| 277 |
gchar* _tmp3_; |
| 278 |
IBusBus* _tmp4_; |
| 279 |
GDBusConnection* _tmp5_; |
| 280 |
IBusEngine* _tmp6_; |
| 281 |
IBusEngine* _tmp7_; |
| 282 |
IBusEngine* _tmp8_; |
| 283 |
IBusEngineSimple* _tmp9_; |
| 284 |
IBusEngineSimple* _tmp10_; |
| 285 |
IBusEngine* result; |
| 286 |
g_return_val_if_fail (factory != NULL, NULL); |
| 287 |
g_return_val_if_fail (name != NULL, NULL); |
| 288 |
if (!g_str_has_prefix (name, "xkb:")) { |
| 289 |
result = NULL; |
| 290 |
return result; |
| 291 |
} |
| 292 |
_tmp0_ = name; |
| 293 |
_data1_->id = _data1_->id + 1; |
| 294 |
_tmp1_ = _data1_->id; |
| 295 |
_tmp2_ = g_strdup_printf (path, _tmp1_); |
| 296 |
_tmp3_ = _tmp2_; |
| 297 |
_tmp4_ = _data1_->bus; |
| 298 |
_tmp5_ = ibus_bus_get_connection (_tmp4_); |
| 299 |
_tmp6_ = ibus_engine_new_with_type (ibus_engine_simple_get_type (), _tmp0_, _tmp3_, _tmp5_); |
| 300 |
g_object_ref_sink (_tmp6_); |
| 301 |
_tmp7_ = _tmp6_; |
| 302 |
_g_free0 (_tmp3_); |
| 303 |
engine = _tmp7_; |
| 304 |
_tmp8_ = engine; |
| 305 |
_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, ibus_engine_simple_get_type (), IBusEngineSimple)); |
| 306 |
_g_object_unref0 (m_simple); |
| 307 |
m_simple = _tmp9_; |
| 308 |
_tmp10_ = m_simple; |
| 309 |
g_object_unref ((GObject*) _tmp10_); |
| 310 |
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda6__gsource_func, NULL, NULL); |
| 311 |
result = engine; |
| 312 |
return result; |
| 313 |
} |
| 314 |
|
| 315 |
static IBusEngine* |
| 316 |
___lambda5__ibus_factory_create_engine (IBusFactory* _sender, |
| 317 |
const gchar* engine_name, |
| 318 |
gpointer self) |
| 319 |
{ |
| 320 |
IBusEngine* result; |
| 321 |
result = __lambda5_ (self, _sender, engine_name); |
| 322 |
return result; |
| 323 |
} |
| 324 |
|
| 325 |
static gint |
| 326 |
_vala_main (gchar** args, |
| 327 |
gint args_length1) |
| 328 |
{ |
| 329 |
Block1Data* _data1_; |
| 330 |
IBusBus* _tmp0_; |
| 331 |
IBusBus* _tmp1_; |
| 332 |
IBusBus* _tmp2_; |
| 333 |
IBusFactory* factory = NULL; |
| 334 |
IBusBus* _tmp3_; |
| 335 |
GDBusConnection* _tmp4_; |
| 336 |
IBusFactory* _tmp5_; |
| 337 |
IBusFactory* _tmp6_; |
| 338 |
guint flags = 0U; |
| 339 |
guint retval = 0U; |
| 340 |
IBusBus* _tmp7_; |
| 341 |
gint result; |
| 342 |
_data1_ = g_slice_new0 (Block1Data); |
| 343 |
_data1_->_ref_count_ = 1; |
| 344 |
setlocale (LC_ALL, ""); |
| 345 |
ibus_init (); |
| 346 |
_tmp0_ = ibus_bus_new (); |
| 347 |
g_object_ref_sink (_tmp0_); |
| 348 |
_data1_->bus = _tmp0_; |
| 349 |
_tmp1_ = _data1_->bus; |
| 350 |
if (!ibus_bus_is_connected (_tmp1_)) { |
| 351 |
g_warning ("main.vala:37: ibus-daemon does not exist."); |
| 352 |
result = 1; |
| 353 |
block1_data_unref (_data1_); |
| 354 |
_data1_ = NULL; |
| 355 |
return result; |
| 356 |
} |
| 357 |
_tmp2_ = _data1_->bus; |
| 358 |
g_signal_connect (_tmp2_, "disconnected", (GCallback) ___lambda4__ibus_bus_disconnected, NULL); |
| 359 |
_tmp3_ = _data1_->bus; |
| 360 |
_tmp4_ = ibus_bus_get_connection (_tmp3_); |
| 361 |
_tmp5_ = ibus_factory_new (_tmp4_); |
| 362 |
g_object_ref_sink (_tmp5_); |
| 363 |
factory = _tmp5_; |
| 364 |
_data1_->id = 0; |
| 365 |
_tmp6_ = factory; |
| 366 |
g_signal_connect_data (_tmp6_, "create-engine", (GCallback) ___lambda5__ibus_factory_create_engine, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); |
| 367 |
flags = (guint) (IBUS_BUS_NAME_FLAG_REPLACE_EXISTING | IBUS_BUS_NAME_FLAG_ALLOW_REPLACEMENT); |
| 368 |
_tmp7_ = _data1_->bus; |
| 369 |
retval = (guint) ibus_bus_request_name (_tmp7_, "org.freedesktop.IBus.Simple", (guint32) flags); |
| 370 |
if (retval == ((guint) 0)) { |
| 371 |
g_warning ("main.vala:104: Registry bus name org.freedesktop.IBus.Simple failed!"); |
| 372 |
result = 1; |
| 373 |
_g_object_unref0 (factory); |
| 374 |
block1_data_unref (_data1_); |
| 375 |
_data1_ = NULL; |
| 376 |
return result; |
| 377 |
} |
| 378 |
ibus_main (); |
| 379 |
_g_object_unref0 (m_simple); |
| 380 |
m_simple = NULL; |
| 381 |
result = 0; |
| 382 |
_g_object_unref0 (factory); |
| 383 |
block1_data_unref (_data1_); |
| 384 |
_data1_ = NULL; |
| 385 |
return result; |
| 386 |
} |
| 387 |
|
| 388 |
int |
| 389 |
main (int argc, |
| 390 |
char ** argv) |
| 391 |
{ |
| 392 |
return _vala_main (argv, argc); |
| 393 |
} |
| 394 |
|