00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __SCIM_SERVER_H
00038 #define __SCIM_SERVER_H
00039
00040 namespace scim {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class ServerError: public Exception
00054 {
00055 public:
00056 ServerError (const String& what_arg)
00057 : Exception (String("scim::Server: ") + what_arg) { }
00058 };
00059
00060 class ServerFactoryBase;
00061 class ServerInstanceBase;
00062
00063
00064
00065
00066
00067
00068 typedef Pointer <ServerFactoryBase> ServerFactoryPointer;
00069
00070
00071
00072
00073
00074
00075 typedef Pointer <ServerInstanceBase> ServerInstancePointer;
00076
00077 typedef Slot1<void, ServerInstanceBase*>
00078 ServerSlotVoid;
00079
00080 typedef Slot2<void, ServerInstanceBase*,int>
00081 ServerSlotInt;
00082
00083 typedef Slot2<void, ServerInstanceBase*,bool>
00084 ServerSlotBool;
00085
00086 typedef Slot2<void, ServerInstanceBase*,const WideString&>
00087 ServerSlotWideString;
00088
00089 typedef Slot2<void, ServerInstanceBase*,const KeyEvent&>
00090 ServerSlotKeyEvent;
00091
00092 typedef Slot2<void, ServerInstanceBase*,const LookupTable&>
00093 ServerSlotLookupTable;
00094
00095 typedef Slot3<void, ServerInstanceBase*,const WideString&,const AttributeList&>
00096 ServerSlotWideStringAttributeList;
00097
00098
00099 typedef Signal1<void, ServerInstanceBase*>
00100 ServerSignalVoid;
00101
00102 typedef Signal2<void, ServerInstanceBase*,int>
00103 ServerSignalInt;
00104
00105 typedef Signal2<void, ServerInstanceBase*,bool>
00106 ServerSignalBool;
00107
00108 typedef Signal2<void, ServerInstanceBase*,const WideString&>
00109 ServerSignalWideString;
00110
00111 typedef Signal2<void, ServerInstanceBase*,const KeyEvent&>
00112 ServerSignalKeyEvent;
00113
00114 typedef Signal2<void, ServerInstanceBase*,const LookupTable&>
00115 ServerSignalLookupTable;
00116
00117 typedef Signal3<void, ServerInstanceBase*,const WideString&,const AttributeList&>
00118 ServerSignalWideStringAttributeList;
00119
00120
00121
00122
00123
00124
00125
00126 class ServerFactoryBase : public ReferencedObject
00127 {
00128 std::vector<String> m_encoding_list;
00129 std::vector<String> m_locale_list;
00130
00131 public:
00132
00133
00134
00135 virtual ~ServerFactoryBase ();
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 virtual WideString get_name () const = 0;
00153
00154
00155
00156
00157
00158
00159
00160
00161 virtual WideString get_authors () const = 0;
00162
00163
00164
00165
00166
00167
00168
00169
00170 virtual WideString get_credits () const = 0;
00171
00172
00173
00174
00175
00176
00177
00178
00179 virtual WideString get_help () const = 0;
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 virtual String get_uuid () const = 0;
00192
00193
00194
00195
00196
00197
00198 virtual String get_icon_file () const = 0;
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 virtual ServerInstancePointer create_server_instance (const String& encoding, int id = -1) = 0;
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 virtual bool validate_encoding (const String& encoding) const;
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 virtual bool validate_locale (const String& locale) const;
00239
00240
00241
00242
00243
00244
00245 String get_encodings () const;
00246
00247
00248
00249
00250
00251
00252 String get_locales () const;
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 String get_default_encoding () const;
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 String get_default_locale () const;
00273
00274 protected:
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 void set_locales (const String &locales);
00285 };
00286
00287
00288
00289
00290
00291
00292
00293 class ServerInstanceBase : public ReferencedObject
00294 {
00295 ServerFactoryPointer m_factory;
00296 String m_encoding;
00297
00298 ServerSignalVoid m_signal_show_preedit_string;
00299 ServerSignalVoid m_signal_show_status_string;
00300 ServerSignalVoid m_signal_show_aux_string;
00301 ServerSignalVoid m_signal_show_lookup_table;
00302
00303 ServerSignalVoid m_signal_hide_preedit_string;
00304 ServerSignalVoid m_signal_hide_status_string;
00305 ServerSignalVoid m_signal_hide_aux_string;
00306 ServerSignalVoid m_signal_hide_lookup_table;
00307
00308 ServerSignalInt m_signal_update_preedit_caret;
00309 ServerSignalWideStringAttributeList m_signal_update_preedit_string;
00310 ServerSignalWideStringAttributeList m_signal_update_status_string;
00311 ServerSignalWideStringAttributeList m_signal_update_aux_string;
00312 ServerSignalWideString m_signal_commit_string;
00313 ServerSignalLookupTable m_signal_update_lookup_table;
00314 ServerSignalBool m_signal_update_full_width_punctuation;
00315 ServerSignalBool m_signal_update_full_width_letter;
00316
00317 ServerSignalKeyEvent m_signal_forward_keyevent;
00318
00319 int m_id;
00320
00321 public:
00322
00323
00324
00325
00326
00327
00328
00329 ServerInstanceBase (ServerFactoryBase *factory,
00330 const String &encoding,
00331 int id = -1);
00332
00333
00334
00335
00336 virtual ~ServerInstanceBase ();
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346 bool set_encoding (const String& encoding);
00347
00348
00349
00350
00351
00352
00353 String get_encoding () const;
00354
00355
00356
00357
00358
00359
00360 int get_id () const;
00361
00362
00363
00364
00365
00366
00367 String get_factory_uuid () const;
00368
00369 public:
00370
00371
00372
00373
00374
00375
00376
00377
00378 Connection signal_connect_show_preedit_string (ServerSlotVoid *slot);
00379 Connection signal_connect_show_status_string (ServerSlotVoid *slot);
00380 Connection signal_connect_show_aux_string (ServerSlotVoid *slot);
00381 Connection signal_connect_show_lookup_table (ServerSlotVoid *slot);
00382 Connection signal_connect_hide_preedit_string (ServerSlotVoid *slot);
00383 Connection signal_connect_hide_status_string (ServerSlotVoid *slot);
00384 Connection signal_connect_hide_aux_string (ServerSlotVoid *slot);
00385 Connection signal_connect_hide_lookup_table (ServerSlotVoid *slot);
00386 Connection signal_connect_update_preedit_caret (ServerSlotInt *slot);
00387 Connection signal_connect_update_preedit_string (ServerSlotWideStringAttributeList *slot);
00388 Connection signal_connect_update_status_string (ServerSlotWideStringAttributeList *slot);
00389 Connection signal_connect_update_aux_string (ServerSlotWideStringAttributeList *slot);
00390 Connection signal_connect_update_lookup_table (ServerSlotLookupTable *slot);
00391 Connection signal_connect_commit_string (ServerSlotWideString *slot);
00392 Connection signal_connect_forward_keyevent (ServerSlotKeyEvent *slot);
00393 Connection signal_connect_update_full_width_punctuation (ServerSlotBool *slot);
00394 Connection signal_connect_update_full_width_letter (ServerSlotBool *slot);
00395
00396
00397 public:
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414 virtual bool process_key_event (const KeyEvent& key) = 0;
00415
00416
00417
00418
00419
00420
00421 virtual void move_preedit_caret (unsigned int pos) = 0;
00422
00423
00424
00425
00426
00427
00428 virtual void select_lookup_table (unsigned int item) = 0;
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438 virtual void update_lookup_table_page_size (unsigned int page_size) = 0;
00439
00440
00441
00442
00443
00444
00445
00446 virtual void reset () = 0;
00447
00448
00449
00450
00451
00452
00453
00454
00455 virtual void focus_in () = 0;
00456
00457
00458
00459
00460 virtual void focus_out () = 0;
00461
00462
00463
00464
00465 virtual void toggle_full_width_punctuation () = 0;
00466
00467
00468
00469
00470 virtual void toggle_full_width_letter () = 0;
00471
00472
00473
00474
00475
00476
00477
00478
00479 virtual void toggle_input_status () = 0;
00480
00481
00482
00483 protected:
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 void show_preedit_string () {
00501 m_signal_show_preedit_string (this);
00502 }
00503
00504
00505
00506
00507
00508
00509
00510 void show_status_string () {
00511 m_signal_show_status_string (this);
00512 }
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 void show_aux_string () {
00524 m_signal_show_aux_string (this);
00525 }
00526
00527
00528
00529
00530
00531
00532
00533 void show_lookup_table () {
00534 m_signal_show_lookup_table (this);
00535 }
00536
00537
00538
00539
00540 void hide_preedit_string () {
00541 m_signal_hide_preedit_string (this);
00542 }
00543
00544
00545
00546
00547 void hide_status_string () {
00548 m_signal_hide_status_string (this);
00549 }
00550
00551
00552
00553
00554 void hide_aux_string () {
00555 m_signal_hide_aux_string (this);
00556 }
00557
00558
00559
00560
00561 void hide_lookup_table () {
00562 m_signal_hide_lookup_table (this);
00563 }
00564
00565
00566
00567
00568
00569
00570 void update_preedit_caret (int caret) {
00571 m_signal_update_preedit_caret (this,caret);
00572 }
00573
00574
00575
00576
00577
00578
00579
00580 void update_preedit_string (const WideString& str,
00581 const AttributeList& attrs = AttributeList ()) {
00582 m_signal_update_preedit_string (this,str,attrs);
00583 }
00584
00585
00586
00587
00588
00589
00590
00591 void update_status_string (const WideString& str,
00592 const AttributeList& attrs = AttributeList ()) {
00593 m_signal_update_status_string (this,str,attrs);
00594 }
00595
00596
00597
00598
00599
00600
00601
00602 void update_aux_string (const WideString& str,
00603 const AttributeList& attrs = AttributeList ()) {
00604 m_signal_update_aux_string (this,str,attrs);
00605 }
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617 void update_lookup_table (const LookupTable& table) {
00618 m_signal_update_lookup_table (this,table);
00619 }
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 void commit_string (const WideString& str) {
00631 m_signal_commit_string (this,str);
00632 }
00633
00634
00635
00636
00637
00638
00639 void forward_keyevent (const KeyEvent& key) {
00640 m_signal_forward_keyevent (this,key);
00641 }
00642
00643
00644
00645
00646
00647
00648 void update_full_width_punctuation (bool full) {
00649 m_signal_update_full_width_punctuation (this,full);
00650 }
00651
00652
00653
00654
00655
00656
00657 void update_full_width_letter (bool full) {
00658 m_signal_update_full_width_letter (this,full);
00659 }
00660
00661
00662 };
00663
00664 class DummyServerFactory : public ServerFactoryBase
00665 {
00666 public:
00667 DummyServerFactory ();
00668 virtual ~DummyServerFactory ();
00669
00670 virtual WideString get_name () const;
00671 virtual WideString get_authors () const;
00672 virtual WideString get_credits () const;
00673 virtual WideString get_help () const;
00674
00675 virtual String get_uuid () const;
00676
00677 virtual String get_icon_file () const;
00678
00679 virtual bool validate_encoding (const String& encoding) const;
00680 virtual bool validate_locale (const String& locale) const;
00681
00682 virtual ServerInstancePointer create_server_instance (const String& encoding, int id = -1);
00683 };
00684
00685 class DummyServerInstance : public ServerInstanceBase
00686 {
00687 public:
00688 DummyServerInstance (DummyServerFactory *factory,
00689 const String& encoding,
00690 int id = -1);
00691
00692 virtual ~DummyServerInstance ();
00693
00694 virtual bool process_key_event (const KeyEvent& key);
00695 virtual void move_preedit_caret (unsigned int pos);
00696 virtual void select_lookup_table (unsigned int item);
00697 virtual void update_lookup_table_page_size (unsigned int page_size);
00698 virtual void reset ();
00699 virtual void focus_in ();
00700 virtual void focus_out ();
00701 virtual void toggle_full_width_punctuation ();
00702 virtual void toggle_full_width_letter ();
00703 virtual void toggle_input_status ();
00704 };
00705
00706
00707
00708 }
00709
00710 #endif //__SCIM_SERVER_H
00711
00712
00713
00714
00715