ej_simple_tts.c
23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
#ifndef _ej_SIMPLE_TTS_C_
#define _ej_SIMPLE_TTS_C_
#include "MMI_features.h"
#include "MMI_include.h"
#include "ProfilesSrvGprot.h"
#include "IdleAppResDef.h"
#include "MMIDataType.h"
#include "GlobalResDef.h"
#include "ej_api_base.h"
#include "ej_nvram.h"
#include "ej_simple_tts.h"
#include "mdi_datatype.h"
#include "mmi_rp_app_simpletts_def.h"
#include "mmi_rp_srv_spof_def.h"
#include "mmi_rp_cui_dialer_def.h"
#include "UcmSrvGprot.h"
#ifdef __SIMPLETTS_RES_WAV__
#include "AmrVoice.hxx"
#else
#include "ej_keynum_wav.hxx"
#endif
static T_Simpletts_Info GSimplettsInfo;
P_Simpletts_Info MyGetSimplettsInfo(void)
{
return &GSimplettsInfo;
}
void MySimplettsNvramDefault(void)
{
P_Simpletts_Info SimplettsInfo = MyGetSimplettsInfo();
ej_s32 size = 0;
SimplettsInfo->vol = SIMPLETTS_VOL_DEFAULT;
SimplettsInfo->PlayTone = SIMPLETTS_PLAYTONE_DEFAULT;
SimplettsInfo->PlayTime = SIMPLETTS_PLAYTIME_DEFAULT;
SimplettsInfo->PlayIncomming = SIMPLETTS_PLAYINCOM_DEFAULT;
SimplettsInfo->PlayMenu = SIMPLETTS_PLAYMENU_DEFAULT;
SimplettsInfo->MagicVoice = SIMPLETTS_MV_DEFAULT;
size = sizeof(T_Simpletts_Info);
ej_write_nvram((void*)SimplettsInfo, size);
}
void EjSimplettsInit(void)
{
P_Simpletts_Info SimplettsInfo = MyGetSimplettsInfo();
ej_s32 size = 0;
ej_check_nvram();
size = sizeof(T_Simpletts_Info);
ej_read_nvram((void*)SimplettsInfo, size);
//sk_MAIN_INIT();
//sk_app_init();
ej_simpletts_printf("SimplettsInfo->PlayTone = %d, SimplettsInfo->PlayTime =%d, SimplettsInfo->PlayIncomming = %d", SimplettsInfo->PlayTone, SimplettsInfo->PlayTime, SimplettsInfo->PlayIncomming);
}
void ej_save_simpletts_nvram(SKY_SIMPLETTS_TYPE type, ej_u8 value)
{
P_Simpletts_Info SimplettsInfo = MyGetSimplettsInfo();
ej_s32 size = 0;
switch(type)
{
case SIMPLE_TTS_PLAY_VOL :
SimplettsInfo->vol = value;
break;
case SIMPLE_TTS_PLAY_TONE :
SimplettsInfo->PlayTone= value;
break;
case SIMPLE_TTS_PLAY_INCOMING :
SimplettsInfo->PlayIncomming = value;
break;
case SIMPLE_TTS_PLAY_TIME :
SimplettsInfo->PlayTime = value;
break;
case SIMPLE_TTS_PLAY_MENU :
SimplettsInfo->PlayMenu = value;
break;
case SIMPLE_TTS_MAGICVOICE :
SimplettsInfo->MagicVoice = value;
break;
default:
break;
}
size = sizeof(T_Simpletts_Info);
ej_write_nvram((void*)SimplettsInfo, size);
}
ej_u8 ej_get_simpletts_opt(SKY_SIMPLETTS_TYPE type)
{
ej_u8 value = 0;
P_Simpletts_Info SimplettsInfo = MyGetSimplettsInfo();
switch(type)
{
case SIMPLE_TTS_PLAY_VOL :
value = SimplettsInfo->vol;
break;
case SIMPLE_TTS_PLAY_TONE :
value = SimplettsInfo->PlayTone;
break;
case SIMPLE_TTS_PLAY_INCOMING :
value = SimplettsInfo->PlayIncomming;
break;
case SIMPLE_TTS_PLAY_TIME :
value = SimplettsInfo->PlayTime;
break;
case SIMPLE_TTS_PLAY_MENU :
value = SimplettsInfo->PlayMenu;
break;
case SIMPLE_TTS_MAGICVOICE :
value = SimplettsInfo->MagicVoice;
break;
default:
break;
}
return value;
}
static ej_u16 ej_group_id = 0;
static mmi_ret ej_app_group_proc(mmi_event_struct* param)
{
if (param->evt_id == EVT_ID_GROUP_ACTIVE)
{
}
else if (param->evt_id == EVT_ID_GROUP_INACTIVE)
{
}
else if (param->evt_id == EVT_ID_GROUP_GOBACK_IN_END_KEY || param->evt_id == EVT_ID_GROUP_DELETE_REQ_IN_END_KEY)
{
}
return MMI_RET_OK;
}
void ej_app_enter_new_screen(U16 newscrnID, FuncPtr newExitHandler, FuncPtr newEntryHandler, mmi_frm_scrn_type_enum flag)
{
if (!mmi_frm_group_is_present(ej_group_id))
{
ej_group_id = mmi_frm_group_create(GRP_ID_ROOT, GRP_ID_AUTO_GEN, ej_app_group_proc, NULL);
mmi_frm_group_enter(ej_group_id, MMI_FRM_NODE_SMART_CLOSE_FLAG);
}
mmi_frm_scrn_enter(ej_group_id, newscrnID, newExitHandler, newEntryHandler, flag);
}
void ej_tts_volume_set_done(void)
{
ej_s8 index = 0;
ej_s8 vol = 0;
vol = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_VOL);
index = (ej_s8)GetHighlightedItem();
if(vol != (ej_u8)index)
{
ej_save_simpletts_nvram(SIMPLE_TTS_PLAY_VOL, index);
DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_OK, 1, 1000, SAVE_TONE);
return;
}
GoBackHistory();
}
void ej_simpletts_volume_setting_enter(void)
{
ej_u8 *str_list[7];
ej_u16 index = 0;
for(index = 0; index < 7; index ++)
{
str_list[index] = (ej_u8*)GetString(STR_ID_EJ_VOLUME_1 + index);
}
ej_app_enter_new_screen(SCR_ID_EJ_VOL_SETTING, 0, ej_simpletts_volume_setting_enter, 1);
index = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_VOL);
gui_lock_double_buffer();
ShowCategory36Screen(STR_GLOBAL_OK, 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 7, str_list, index, 0);
ChangeTitleString((U8*)GetString(STR_ID_EJ_VOLUME));
draw_title();
SetLeftSoftkeyFunction(ej_tts_volume_set_done, KEY_EVENT_UP);
SetKeyHandler(ej_tts_volume_set_done, KEY_ENTER, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_tts_volume_set_done, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
gui_unlock_double_buffer();
ej_BLT_ALL;
}
static void ej_simpletts_playtone_select_done(void)
{
ej_s8 index = 0;
ej_u8 value = 0;
index = (ej_s8)GetHighlightedItem();
value = index ? 0 : 1;
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TONE) != value)
{
ej_save_simpletts_nvram(SIMPLE_TTS_PLAY_TONE, value);
DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_OK, 1, 1000, SAVE_TONE);
return;
}
GoBackHistory();
}
void ej_simpletts_playtone_setting_enter(void)
{
ej_u8 *str_list[2];
ej_u16 index = 0;
str_list[0] = (ej_u8*)GetString(STR_ID_EJ_IS_OPEN);
str_list[1] = (ej_u8*)GetString(STR_ID_EJ_IS_CLOSE);
gui_lock_double_buffer();
ej_app_enter_new_screen(SCR_ID_EJ_PLAY_TONE, 0, ej_simpletts_playtone_setting_enter, 1);
index = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TONE)? 0 : 1;
ShowCategory36Screen(STR_GLOBAL_OK, 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 2, str_list, index, 0);
ChangeTitleString((U8*)GetString(STR_ID_EJ_PLAY_TONE));
draw_title();
gui_unlock_double_buffer();
ej_BLT_ALL;
SetLeftSoftkeyFunction(ej_simpletts_playtone_select_done, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_simpletts_playtone_select_done, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetKeyHandler(ej_simpletts_playtone_select_done, KEY_ENTER, KEY_EVENT_UP);
}
static void ej_simpletts_playtime_select_done(void)
{
ej_s8 index = 0;
ej_u8 value = 0;
index = (ej_s8)GetHighlightedItem();
value = index ? 0 : 1;
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TIME) != value)
{
ej_save_simpletts_nvram(SIMPLE_TTS_PLAY_TIME, value);
DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_OK, 1, 1000, SAVE_TONE);
return;
}
GoBackHistory();
}
void ej_simpletts_playtime_setting_enter(void)
{
ej_u8 *str_list[2];
ej_u16 index = 0;
str_list[0] = (ej_u8*)GetString(STR_ID_EJ_IS_OPEN);
str_list[1] = (ej_u8*)GetString(STR_ID_EJ_IS_CLOSE);
gui_lock_double_buffer();
ej_app_enter_new_screen(SCR_ID_EJ_PLAY_TIME, 0, ej_simpletts_playtime_setting_enter, 1);
index = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TIME) ? 0 : 1;
ShowCategory36Screen(STR_GLOBAL_OK, 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 2, str_list, index, 0);
ChangeTitleString((U8*)GetString(STR_ID_EJ_PLAY_TIME));
draw_title();
gui_unlock_double_buffer();
ej_BLT_ALL;
SetLeftSoftkeyFunction(ej_simpletts_playtime_select_done, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_simpletts_playtime_select_done, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetKeyHandler(ej_simpletts_playtime_select_done, KEY_ENTER, KEY_EVENT_UP);
}
static void ej_simpletts_playincoming_select_done(void)
{
ej_s8 index = 0;
ej_u8 value = 0;
index = (ej_s8)GetHighlightedItem();
value = index ? 0 : 1;
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_INCOMING) != value)
{
ej_save_simpletts_nvram(SIMPLE_TTS_PLAY_INCOMING, value);
DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_OK, 1, 1000, SAVE_TONE);
return;
}
GoBackHistory();
}
void ej_simpletts_playincoming_setting_enter(void)
{
ej_u8 *str_list[2];
ej_u16 index = 0;
str_list[0] = (ej_u8*)GetString(STR_ID_EJ_IS_OPEN);
str_list[1] = (ej_u8*)GetString(STR_ID_EJ_IS_CLOSE);
gui_lock_double_buffer();
ej_app_enter_new_screen(SCR_ID_EJ_PLAY_INCOMING, 0, ej_simpletts_playincoming_setting_enter, 1);
index = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_INCOMING)? 0 : 1;
ShowCategory36Screen(STR_GLOBAL_OK, 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 2, str_list, index, 0);
ChangeTitleString((U8*)GetString(STR_ID_EJ_IMCOMING_CALL));
draw_title();
gui_unlock_double_buffer();
ej_BLT_ALL;
SetLeftSoftkeyFunction(ej_simpletts_playincoming_select_done, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_simpletts_playincoming_select_done, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetKeyHandler(ej_simpletts_playincoming_select_done, KEY_ENTER, KEY_EVENT_UP);
}
static void ej_simpletts_playmenu_select_done(void)
{
ej_s8 index = 0;
ej_u8 value = 0;
index = (ej_s8)GetHighlightedItem();
value = index ? 0 : 1;
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_MENU) != value)
{
ej_save_simpletts_nvram(SIMPLE_TTS_PLAY_MENU, value);
DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_OK, 1, 1000, SAVE_TONE);
return;
}
GoBackHistory();
}
void ej_simpletts_playmenu_setting_enter(void)
{
ej_u8 *str_list[2];
ej_u16 index = 0;
str_list[0] = (ej_u8*)GetString(STR_ID_EJ_IS_OPEN);
str_list[1] = (ej_u8*)GetString(STR_ID_EJ_IS_CLOSE);
gui_lock_double_buffer();
ej_app_enter_new_screen(SCR_ID_EJ_PLAY_MENU, 0, ej_simpletts_playmenu_setting_enter, 1);
index = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_MENU)? 0 : 1;
ShowCategory36Screen(STR_GLOBAL_OK, 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, 2, str_list, index, 0);
ChangeTitleString((U8*)GetString(STR_ID_EJ_IMCOMING_CALL));
draw_title();
gui_unlock_double_buffer();
ej_BLT_ALL;
SetLeftSoftkeyFunction(ej_simpletts_playmenu_select_done, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_simpletts_playmenu_select_done, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetKeyHandler(ej_simpletts_playmenu_select_done, KEY_ENTER, KEY_EVENT_UP);
}
void ej_mv_setting_enter(void)
{
}
void ej_simple_tts_enter(void)
{
ej_u8 * gui_buffer = 0;
ej_u16 * WPopString = 0;
ej_app_enter_new_screen(SCR_ID_EJ_SIMPLE_TTS, MyFuncAndStringDeinit, ej_simple_tts_enter, 1);
gui_buffer = mmi_frm_scrn_get_active_gui_buf();
MyFuncAndStringInit();
MyFuncAndStringAddItem(ej_simpletts_volume_setting_enter, (ej_u16*)GetString(STR_ID_EJ_VOLUME), 0);
#ifdef __EJ_SIMPLETTS_PLAYTONE_SUPPORT__
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TONE))
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_OPEN);
else
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_CLOSE);
MyFuncAndStringAddItem(ej_simpletts_playtone_setting_enter,(ej_u16*)GetString(STR_ID_EJ_PLAY_TONE), WPopString);
#endif
#ifdef __EJ_SIMPLETTS_PLAYTIME_SUPPORT__
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TIME) )
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_OPEN);
else
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_CLOSE);
MyFuncAndStringAddItem(ej_simpletts_playtime_setting_enter, (ej_u16*)GetString(STR_ID_EJ_PLAY_TIME), WPopString);
#endif
#ifdef __EJ_SIMPLETTS_PLAYINCOMING_SUPPORT__
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_INCOMING))
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_OPEN);
else
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_CLOSE);
MyFuncAndStringAddItem(ej_simpletts_playincoming_setting_enter, (ej_u16*)GetString(STR_ID_EJ_IMCOMING_CALL), WPopString);
#endif
#ifdef __EJ_SIMPLETTS_PLAYMENU_SUPPORT__
if(ej_get_simpletts_opt(SIMPLE_TTS_PLAY_MENU))
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_OPEN);
else
WPopString = (ej_u16*)GetString(STR_ID_EJ_IS_CLOSE);
MyFuncAndStringAddItem(ej_simpletts_playincoming_setting_enter, (ej_u16*)GetString(STR_ID_EJ_IMCOMING_CALL), WPopString);
#endif
//MyFuncAndStringAddItem(ej_mv_setting_enter, (ej_u16*)GetString(OPENSTR_MAGICE_VOICE), 0);
ShowCategory353Screen((U8*)GetString(STR_ID_EJ_SIMPLETTS), 0, STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK, MyFuncAndStringGetTotal(), (U8**)MyFuncAndStringGetStrList(),
(U16*)MyFuncAndStringGetIconList(), (U8**)MyFuncAndStringGetPopStrList(), 0, 0, gui_buffer);
SetLeftSoftkeyFunction(MyFuncAndStringLskHdl, KEY_EVENT_UP);
SetCenterSoftkeyFunction(MyFuncAndStringLskHdl, KEY_EVENT_UP);
SetKeyHandler(MyFuncAndStringLskHdl, KEY_ENTER, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
}
void sky_simple_tts_hilite(void)
{
SetLeftSoftkeyFunction(ej_simple_tts_enter, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
SetCenterSoftkeyFunction(ej_simple_tts_enter, KEY_EVENT_UP);
SetKeyHandler(ej_simple_tts_enter, KEY_ENTER, KEY_EVENT_UP);
}
#ifdef __SIMPLETTS_RES_AMR__
static const T_KeyToneInfo ChMapPtr[] = {
{'0', sizeof(ej_0_amr_res), ej_0_amr_res},
{'1', sizeof(ej_1_amr_res), ej_1_amr_res},
{'2', sizeof(ej_2_amr_res), ej_2_amr_res},
{'3', sizeof(ej_3_amr_res), ej_3_amr_res},
{'4', sizeof(ej_4_amr_res), ej_4_amr_res},
{'5', sizeof(ej_5_amr_res), ej_5_amr_res},
{'6', sizeof(ej_6_amr_res), ej_6_amr_res},
{'7', sizeof(ej_7_amr_res), ej_7_amr_res},
{'8', sizeof(ej_8_amr_res), ej_8_amr_res},
{'9', sizeof(ej_9_amr_res), ej_9_amr_res},
{'*', sizeof(ej_start_amr_res), ej_start_amr_res},
{'#', sizeof(ej_pound_amr_res), ej_pound_amr_res},
{'p', sizeof(ej_p_amr_res), ej_p_amr_res},
{'w', sizeof(ej_w_amr_res), ej_w_amr_res},
{'+', sizeof(ej_add_amr_res), ej_add_amr_res},
{'T', sizeof(ej_tts_time_res), ej_tts_time_res},
{'D', sizeof(ej_tts_dain_amr_res), ej_tts_dain_amr_res},
{'F', sizeof(ej_tts_fen_amr_res), ej_tts_fen_amr_res},
{'Z', sizeof(ej_tts_zheng_amr_res), ej_tts_zheng_amr_res},
{'S', sizeof(ej_shi_amr_res), ej_shi_amr_res}, //
{'L', sizeof(ej_Incoming_amr_res), ej_Incoming_amr_res},
};
#else
static const T_KeyToneInfo ChMapPtr[] = {
{'0', ej_0_wav_size, ej_0_wav_res},
{'1', ej_1_wav_size, ej_1_wav_res},
{'2', ej_2_wav_size, ej_2_wav_res},
{'3', ej_3_wav_size, ej_3_wav_res},
{'4', ej_4_wav_size, ej_4_wav_res},
{'5', ej_5_wav_size, ej_5_wav_res},
{'6', ej_6_wav_size, ej_6_wav_res},
{'7', ej_0_wav_size, ej_7_wav_res},
{'8', ej_8_wav_size, ej_8_wav_res},
{'9', ej_0_wav_size, ej_9_wav_res},
{'*', ej_star_wav_size, ej_star_wav_res},
{'#', ej_pound_wav_size, ej_pound_wav_res},
};
#endif
int MyGetNumVoiceFormat(void )
{
#ifdef __SIMPLETTS_RES_AMR__
return MDI_FORMAT_AMR;
#else
return MDI_FORMAT_WAV;
#endif
}
void MyGetNumVoicePtrAndSize(ej_s8 num, ej_s32* size, ej_s8** VoicePtr)
{
ej_s32 i = 0;
ej_s32 total = 0;
total = sizeof(ChMapPtr)/sizeof(ChMapPtr[0]);
for(i = 0; i < total; i++)
{
if(ChMapPtr[i].ch == num)
{
*size = ChMapPtr[i].len;
*VoicePtr = (ej_s8*)ChMapPtr[i].ptr;
return;
}
}
}
static void ej_audio_play_ptr(ej_s8* ptr, ej_s32 size, ej_u8 format, mdi_ext_callback cb)
{
ej_u8 path;
ej_s32 result;
ej_u8 vol = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_VOL);
if(srv_prof_is_profile_activated(SRV_PROF_SILENT_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED
|| srv_prof_is_profile_activated(SRV_PROF_MEETING_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED)
return;
#ifdef __MMI_BACKGROUND_CALL__
if (srv_ucm_is_background_call())
return ;
#endif /* __MMI_BACKGROUND_CALL__ */
#ifdef __MMI_FM_RADIO__
if(mmi_fmrdo_is_power_on() )
return ;
#endif
#ifdef MDI_AUDIO_LOCK
MDI_AUDIO_LOCK;
#endif
path = MDI_DEVICE_SPEAKER_BOTH;
if(srv_earphone_is_plug_in())
{
path = MDI_DEVICE_SPEAKER2;
}
#ifdef __MMI_BT_SUPPORT__
if(mmi_bt_is_receiving())
{
path = MDI_DEVICE_BT_HEADSET;
}
#endif
result = mdi_audio_play_string_with_vol_path_non_block((void *)ptr,(U32) size,(U8)format, MDI_AUDIO_PLAY_ONCE, cb, NULL,vol,path);
if(result != MDI_AUDIO_SUCCESS)
{
//if(cb)
//cb(result, NULL);
}
#ifdef MDI_AUDIO_UNLOCK
MDI_AUDIO_UNLOCK;
#endif
}
ej_s32 ej_play_ch(ej_u16 ch, ej_s32 format, mdi_ext_callback cb)
{
ej_s32 flag = 0;
do{
ej_s8* ptr = 0;
ej_s32 size = 0;
MyGetNumVoicePtrAndSize(ch, &size, &ptr);
if(!ptr || size == 0)
break;
ej_audio_play_ptr(ptr, size, format, cb);
flag = 1;
}while(0);
return flag;
}
void ej_play_tone(ej_s8 ch)
{
do{
ej_u16 scr = GetActiveScreenId();
if( scr != SCR_ID_CUI_DIALER_MAIN)
break;
if(!ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TONE))
break;
ej_play_ch(ch, MyGetNumVoiceFormat(), 0);
}while(0);
}
#ifdef __SIMPLETTS_RES_AMR__
static ej_s8* SimpttsBuffer = 0;
#define MAX_SIMPTTS_BUFF_SIZE 150 * 1024
void InitSimpTtsBuffer(void)
{
SimpttsBuffer = ej_med_malloc(MAX_SIMPTTS_BUFF_SIZE);
if(SimpttsBuffer)
ej_memset(SimpttsBuffer , 0, MAX_SIMPTTS_BUFF_SIZE);
}
void DeinitSimpTtsBuffer(void)
{
if(SimpttsBuffer)
{
ej_med_free(&SimpttsBuffer);
}
}
void MySimpTTsAmrResSplit(ej_s8* NumStr, ej_s8** ResBuf, ej_s32* ResBufLen)
{
ej_s32 i = 0;
ej_s32 len = 0;//
ej_s32 nTmp = 0;
if(!NumStr)
return;
len = ej_strlen((const ej_s8 * )NumStr);
if(len == 0)
return;
for(i=0; i < len; i++)
{
int size = 0;
char* ptr = 0;
MyGetNumVoicePtrAndSize(NumStr[i], &size, &ptr);
nTmp = size;
if(i == 0 )
{
ej_memcpy(*ResBuf + *ResBufLen, ptr, nTmp );
}
else
{
nTmp -= 6 ;
ej_memcpy(*ResBuf + *ResBufLen, ptr+6, nTmp);
}
*ResBufLen += nTmp ;
}
}
ej_s32 MySimpTTsPlayAmrStr(ej_u8* str, ej_s32 format, mdi_ext_callback cb)
{
ej_u8 *pData ;
ej_s32 size = 0;
InitSimpTtsBuffer();
if(!SimpttsBuffer)
return 0;
pData = SimpttsBuffer;
MySimpTTsAmrResSplit((char*)str, &pData, &size);
ej_audio_play_ptr(pData, size, format, cb);
return 1;
}
#endif
static ej_s8 G_StopPlayIncoming = 0;
typedef struct{
ej_u8 NumUrlIndex;
ej_u8 NumUrlLen;
ej_u8 Flag;
ej_u8 num_uri[SRV_UCM_MAX_NUM_URI_LEN + 1];
}T_PlayTtsInfo, *P_PlayTtsInfo;
static T_PlayTtsInfo G_PlayTTs;
P_PlayTtsInfo MyGetIncomingCallInfo(void)
{
return &G_PlayTTs;
}
void MySimplettsPlayIncomNumCb(mdi_result result, void* user_data)
{
P_PlayTtsInfo PlayTtsInfo = MyGetIncomingCallInfo();
#ifdef __SIMPLETTS_RES_AMR__
DeinitSimpTtsBuffer();
if(PlayTtsInfo->Flag == 0)
mmi_ucm_play_incoming_tone();
#else
if(PlayTtsInfo->Flag)
return;
else if(PlayTtsInfo->NumUrlIndex >= PlayTtsInfo->NumUrlLen)
mmi_ucm_play_incoming_tone();
else
ej_play_ch(PlayTtsInfo->num_uri[PlayTtsInfo->NumUrlIndex++], MyGetNumVoiceFormat(), MySimplettsPlayIncomNumCb);
#endif
}
ej_s32 EjSimplettsPlayIncomNum(ej_u8* NumUrl)
{
#ifdef __EJ_SIMPLETTS_PLAYINCOMING_SUPPORT__
ej_s8 flag = 0;
do{
ej_u8 opt = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_INCOMING);
ej_s32 result = 0;
P_PlayTtsInfo PlayTtsInfo = MyGetIncomingCallInfo();
if(0 == opt)
break;
if(0 == NumUrl)
break;
if(srv_prof_is_profile_activated(SRV_PROF_SILENT_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED
|| srv_prof_is_profile_activated(SRV_PROF_MEETING_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED)
break;
ej_memset(PlayTtsInfo, 0, sizeof(T_PlayTtsInfo));
PlayTtsInfo->NumUrlLen = ej_strlen(NumUrl);
ej_memcpy(PlayTtsInfo->num_uri, NumUrl, PlayTtsInfo->NumUrlLen);
#ifdef __SIMPLETTS_RES_AMR__
ej_strcat(PlayTtsInfo->num_uri, "L");
result = MySimpTTsPlayAmrStr(PlayTtsInfo->num_uri, MySimplettsPlayIncomNumCb);
#else
result = ej_play_ch(PlayTtsInfo->num_uri[PlayTtsInfo->NumUrlIndex++], MyGetNumVoiceFormat(), MySimplettsPlayIncomNumCb);
#endif
if(result)
flag = 1;
}while(0) ;
return flag;
#else
return 0;
#endif
}
void ej_simpletts_stop(void);
void EjStopPlayIncomingCall(void)
{
P_PlayTtsInfo PlayTtsInfo = MyGetIncomingCallInfo();
PlayTtsInfo->Flag = 1;
ej_simpletts_stop();
}
#ifdef __SIMPLETTS_RES_AMR__
void MySimpTTsPlayTimeCb(mdi_result result, void* user_data)
{
DeinitSimpTtsBuffer();
}
void MySimpTtsPlayTime(void)
{
#ifdef __EJ_SIMPLETTS_PLAYTIME_SUPPORT__
MyTime CurTime;
ej_s8 TimeBuf[52] = {0};
ej_s8 TempBuf[16] = {0};
ej_u8 opt = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_TIME) ;
if(!opt)
return ;
if(srv_prof_is_profile_activated(SRV_PROF_SILENT_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED
|| srv_prof_is_profile_activated(SRV_PROF_MEETING_MODE)== SRV_PROF_RET_PROFILE_ACTIVATED)
return ;
ej_get_time(&CurTime);
ej_strcpy((ej_s8*)TimeBuf, (const ej_s8 * )"T");
if(CurTime.nHour >= 10)
{
ej_s32 num = 0;
num = CurTime.nHour/10;
if(num == 1)
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"S");
if(num == 2)
{
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"2");
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"S");
}
num = CurTime.nHour%10;
if(num !=0)
{
ej_itoa_ext(num, TempBuf, 10);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )TempBuf);
}
if((CurTime.nHour/10 == 0) && (CurTime.nHour%10 == 0))
{
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"0");
}
else if((CurTime.nHour/10 == 2) && (CurTime.nHour%10 == 4))
{
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"0");
}
}
else
{
ej_itoa_ext(CurTime.nHour, TempBuf, 10);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )TempBuf);
}
ej_strcat((ej_s8*)TimeBuf, (const ej_s8*)"D");
if(CurTime.nMin == 0)
{
ej_strcat((ej_s8*)TimeBuf, (const ej_s8*)"Z");
}
else
{
if(CurTime.nMin < 10)
{
ej_strcat((ej_s8*)TimeBuf, (const ej_s8*)"0");
ej_memset(TempBuf, 0, 16);
ej_itoa_ext(CurTime.nMin, TempBuf, 10);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )TempBuf);
}
else
{
ej_s32 num = 0;
num = CurTime.nMin/10;
if(num == 1)
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"S");
else
{
ej_memset(TempBuf, 0, 16);
ej_itoa_ext(num, TempBuf, 10);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )TempBuf);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )"S");
}
num = CurTime.nMin%10;
if(num !=0)
{
ej_itoa_ext(num, TempBuf, 10);
ej_strcat((ej_s8 * )TimeBuf, (const ej_s8 * )TempBuf);
}
}
ej_strcat((ej_s8*)TimeBuf, (const ej_s8*)"F");
}
MySimpTTsPlayAmrStr(TimeBuf, MySimpTTsPlayTimeCb);
return ;
#endif
}
#endif
#ifdef __EJ_SIMPLETTS_PLAYMENU_SUPPORT__
#include "ej_menu_wav.hxx"
typedef struct{
const ej_u16* string;
ej_s32 size;
const ej_u8* ptr;
}T_MenuResInfo, *P_MenuResInfo;
/*工具箱*/
static const ej_u16 OrganzerStr[] = {0x5de5, 0x5177, 0x7bb1, 0x0009, 0x0000 };
/*多媒体*/
static const ej_u16 MediaStr[] = {0x591a, 0x5a92, 0x4f53, 0x0009, 0x0000};
/*设置*/
static const ej_u16 SettingStr[] = {0x6a21, 0x5f0f, 0x8bbe, 0x7f6e, 0x0000};
/*信息*/
static const ej_u16 SmsStr[] = {0x4fe1, 0x606f, 0x0000};
/*娱乐游戏*/
static const ej_u16 GameStr[] = {0x5a31, 0x4e50, 0x6e38, 0x620f, 0x0000};
/*电话簿*/
static const ej_u16 PhbStr[] = {0x7535, 0x8bdd, 0x7c3f, 0x0000 };
static const T_MenuResInfo MenuRes[] =
{
{OrganzerStr, ej_organzer_wav_size, ej_organzer_wav_res},
{MediaStr, ej_media_wav_size, ej_media_wav_res},
{SettingStr,ej_setting_wav_size, ej_setting_wav_res },
{GameStr, ej_game_wav_size, ej_game_wav_res},
{SmsStr, ej_sms_wav_size, ej_sms_wav_res}
};
/*通过菜单字符串获取资源和大小*/
void ej_get_menu_res_ptr_size(ej_u16* str, ej_s32* size, ej_s8** ptr)
{
ej_s8 total = sizeof(MenuRes)/sizeof(MenuRes[0]);
ej_s8 i = 0;
for(i = 0; i< total; i++)
{
if(ej_ucs2_strcmp((const ej_u16 * )MenuRes[i].string, (const ej_u16 * )str) == 0)
{
*ptr = (char*)MenuRes[i].ptr;
*size = MenuRes[i].size;
break;
}
}
if(i == total)
{
*ptr = 0;
*size = 0;
}
}
#endif
void ej_play_menu(ej_u16* str)
{
#ifdef __EJ_SIMPLETTS_PLAYMENU_SUPPORT__
do{
ej_u8 opt = 0;
ej_s8* ptr = 0;
ej_s32 size = 0;
if(!str)
break;
opt = ej_get_simpletts_opt(SIMPLE_TTS_PLAY_MENU);
if(!opt)
break;
ej_get_menu_res_ptr_size(str, &size, &ptr);
if(size == 0 || ptr == 0)
break;
ej_audio_play_ptr(ptr, size, MDI_FORMAT_WAV, 0);
}while(0);
#endif
}
void ej_simpletts_stop(void)
{
mdi_audio_stop_string();
#ifdef __SIMPLETTS_RES_AMR__
DeinitSimpTtsBuffer();
#endif
}
#endif