1 /*
2  * Copyright RIME Developers
3  * Distributed under the BSD License
4  *
5  * 2013-10-21  GONG Chen <chen.sst@gmail.com>
6  */
7 #ifndef RIME_LEVERS_API_H_
8 #define RIME_LEVERS_API_H_
9 
10 #include "rime_api.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef struct { char placeholder; } RimeCustomSettings;
17 
18 typedef struct { char placeholder; } RimeSwitcherSettings;
19 
20 typedef struct { char placeholder; } RimeSchemaInfo;
21 
22 typedef struct {
23   void* ptr;
24   size_t i;
25 } RimeUserDictIterator;
26 
27 typedef struct rime_levers_api_t {
28   int data_size;
29 
30   RimeCustomSettings* (*custom_settings_init)(const char* config_id,
31                                               const char* generator_id);
32   void (*custom_settings_destroy)(RimeCustomSettings* settings);
33   Bool (*load_settings)(RimeCustomSettings* settings);
34   Bool (*save_settings)(RimeCustomSettings* settings);
35   Bool (*customize_bool)(RimeCustomSettings* settings, const char* key, Bool value);
36   Bool (*customize_int)(RimeCustomSettings* settings, const char* key, int value);
37   Bool (*customize_double)(RimeCustomSettings* settings, const char* key, double value);
38   Bool (*customize_string)(RimeCustomSettings* settings, const char* key, const char* value);
39   Bool (*is_first_run)(RimeCustomSettings* settings);
40   Bool (*settings_is_modified)(RimeCustomSettings* settings);
41   Bool (*settings_get_config)(RimeCustomSettings* settings, RimeConfig* config);
42 
43   RimeSwitcherSettings* (*switcher_settings_init)();
44   Bool (*get_available_schema_list)(RimeSwitcherSettings* settings,
45                                     RimeSchemaList* list);
46   Bool (*get_selected_schema_list)(RimeSwitcherSettings* settings,
47                                    RimeSchemaList* list);
48   void (*schema_list_destroy)(RimeSchemaList* list);
49   const char* (*get_schema_id)(RimeSchemaInfo* info);
50   const char* (*get_schema_name)(RimeSchemaInfo* info);
51   const char* (*get_schema_version)(RimeSchemaInfo* info);
52   const char* (*get_schema_author)(RimeSchemaInfo* info);
53   const char* (*get_schema_description)(RimeSchemaInfo* info);
54   const char* (*get_schema_file_path)(RimeSchemaInfo* info);
55   Bool (*select_schemas)(RimeSwitcherSettings* settings,
56                          const char* schema_id_list[],
57                          int count);
58   const char* (*get_hotkeys)(RimeSwitcherSettings* settings);
59   Bool (*set_hotkeys)(RimeSwitcherSettings* settings, const char* hotkeys);
60 
61   Bool (*user_dict_iterator_init)(RimeUserDictIterator* iter);
62   void (*user_dict_iterator_destroy)(RimeUserDictIterator* iter);
63   const char* (*next_user_dict)(RimeUserDictIterator* iter);
64   Bool (*backup_user_dict)(const char* dict_name);
65   Bool (*restore_user_dict)(const char* snapshot_file);
66   int (*export_user_dict)(const char* dict_name, const char* text_file);
67   int (*import_user_dict)(const char* dict_name, const char* text_file);
68 
69   // patch a list or a map
70   Bool (*customize_item)(RimeCustomSettings* settings,
71                          const char* key, RimeConfig* value);
72 
73 } RimeLeversApi;
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif  // RIME_LEVERS_API_H_
80