blob: 54e6717e7543f4d7b2bba485a593d90db4076f26 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2016
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS (""MEDIATEK SOFTWARE"")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN ""AS-IS"" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35/*************************************************************
36*
37* This Software is the property of VIA Telecom, Inc. and may only be used pursuant to a license from VIA Telecom, Inc.
38*
39* Any unauthorized use inconsistent with the terms of such license is strictly prohibited.
40*
41* Copyright (c) 2006-2010 VIA Telecom, Inc. All rights reserved.
42*
43*************************************************************/
44
45/*****************************************************************************
46
47 FILE NAME: valphbapi.h
48
49 DESCRIPTION:
50
51This file contains all api of val phone book for upper layer
52
53*****************************************************************************/
54#ifndef VAL_PHB_API_H
55#define VAL_PHB_API_H
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60/*===========================================================================
61
62 INCLUDE FILES FOR MODULE
63
64===========================================================================*/
65#include "sysdefs.h"
66#include "valapi.h"
67
68/*===========================================================================
69
70 MARCO DEFINES
71
72===========================================================================*/
73
74/*remote uicc,needn't access phonebook */
75#if defined(SYS_OPTION_REMOTE_UICC) && !defined(MTK_DEV_C2K_IRAT)
76#define VAL_PHB_MAX_REC_NUMBER 1
77#define VAL_PHB_MAX_FLASH_REC_NUMBER 1
78#define VAL_PHB_MAX_UIM_REC_NUMBER 1
79#else
80
81#ifdef MTK_CBP
82#define VAL_PHB_MAX_FLASH_REC_NUMBER 5
83#define VAL_PHB_MAX_UIM_REC_NUMBER 300
84#define VAL_PHB_MAX_UIM_FDN_REC_NUMBER 40
85#define VAL_PHB_MAX_UIM_FLASH_REC_NUMBER (VAL_PHB_MAX_FLASH_REC_NUMBER + VAL_PHB_MAX_UIM_REC_NUMBER)
86#define VAL_PHB_MAX_REC_NUMBER (VAL_PHB_MAX_FLASH_REC_NUMBER + VAL_PHB_MAX_UIM_REC_NUMBER + VAL_PHB_MAX_UIM_FDN_REC_NUMBER)
87#else
88#define VAL_PHB_MAX_REC_NUMBER 450
89#define VAL_PHB_MAX_FLASH_REC_NUMBER 200
90#define VAL_PHB_MAX_UIM_REC_NUMBER 250
91#endif
92#endif
93
94#define EOL 0xFFFF /* stands for End Of List */
95
96/* Field struct data length defined */
97#define PHB_FIELD_ID_LEN FIELD_SIZE(ValPhbFieldT,FieldId)
98#define PHB_FIELD_TYPE_LEN FIELD_SIZE(ValPhbFieldT,FieldType)
99#define PHB_FIELD_DATALEN_LEN FIELD_SIZE(ValPhbFieldT,DataLength)
100#define PHB_FIELD_HEADER_LEN FIELD_OFFSET(ValPhbFieldT,Data)
101
102
103#define VAL_PHB_DEV_NONE 0x00
104#define VAL_PHB_MAX_REGISTERED_IDS 5 /*!< Max registered app */
105#define VAL_PHB_TELESRVID_COUNT 20 /*!< Max registered teleservice id */
106
107#define VAL_PHB_GROUP_STATE 0xF0 /* the start value of group id for record state */
108
109#define VAL_PHB_MAX_REC_BUFFER_CNT 4
110
111//don't modify following Macro, brew has referred to it
112#define VAL_PHB_MAX_FLASH_REC_CNT 500 /* Phb Flash Record counts */
113
114//don't modify following Macro, brew has referred to it
115#ifdef FEATURE_ADVANCED_CONTACT
116#define VAL_PHB_MAX_REC_SIZE 1312 /* max contact size in bytes */
117
118#define VAL_PHB_MAX_ALPHA_LENGTH 65
119#define VAL_PHB_MAX_PHONE_LENGTH 66 /* string type */
120#else
121#define VAL_PHB_MAX_REC_SIZE 196 /* max contact size in bytes */
122
123#ifdef MTK_CBP
124#define VAL_PHB_MAX_ALPHA_LENGTH 40
125#else
126#define VAL_PHB_MAX_ALPHA_LENGTH 33
127#endif
128#define VAL_PHB_MAX_PHONE_LENGTH 33 /* string type */
129#endif
130
131#ifdef MTK_CBP
132#define PHB_MAX_ALPHA_LENGTH 40
133#else
134#define PHB_MAX_ALPHA_LENGTH 15
135#endif
136
137#ifdef MTK_CBP
138#define PHB_MAX_PHONE_LENGTH 41 /*string type*/
139#define PHB_MAX_PHONE_ADN_LENGTH 21 /*string type*/
140#else
141#define PHB_MAX_PHONE_LENGTH 21 /*string type*/
142#endif
143
144#define PHB_MAX_UIM_UPDATE_RETRY_NUMBER 2
145/* It is external PHB contact structure,
146 it is used to interface with UI task or other tasks,
147 It's PhoneNumber is string type
148 */
149typedef struct
150{
151 kal_uint8 Ton;
152 kal_uint8 Npi;
153 kal_uint8 AlphaIdentifier[PHB_MAX_ALPHA_LENGTH+1]; /*Alpha Identifier*/
154 kal_uint8 PhoneNumber[PHB_MAX_PHONE_LENGTH+1]; /*Dialing Number/SSC String*/
155 kal_uint16 RecID; /*Record ID*/
156 kal_bool HasExtension;
157 kal_uint8 spdial_index; /* speed dial index, 0 if nothing */
158 kal_uint8 category; /* personal or business */
159 kal_uint8 telcategory; /* category of this phone # */
160 kal_uint8 restricted; /* is it restricted */
161 kal_uint8 Secret;
162 kal_uint32 offset; /* phone extension offset */
163} ValPhbContactFullT;
164
165/* buffer state */
166typedef enum
167{
168 VAL_PHB_BUF_FREE = 0x00,
169 VAL_PHB_BUF_USED,
170 VAL_PHB_BUF_MODIFIED,
171 VAL_PHB_BUF_MAX_STATE
172}ValPhbBufferStateT;
173
174typedef struct
175{
176 kal_uint8 BufState; /* The buffer state*/
177 kal_uint8 DeviceId; /* The device id for buffer contact */
178 kal_uint16 RecId; /* The record id for the contact in val db */
179 kal_uint16 DataLen; /* The actual length of the contact data segment */
180 kal_uint8 Data; /* The buffer for data */
181}ValPhbRecordBufferT;
182
183/* Val phb error */
184typedef enum
185{
186 VAL_PHB_ERR_NONE = 0, /* Operating success */
187 VAL_PHB_ERR_PARMETER = 1, /* Inputting invalid parameter */
188 VAL_PHB_ERR_NOT_PARA_INIT, /* val phb parameters not init(ValPhbInit has not been called) */
189
190 VAL_PHB_ERR_DEV_UNSUPPORT, /* unsupport phb device,error device id */
191 VAL_PHB_ERR_DEV_REG, /* phb device register error, register device is full */
192 VAL_PHB_ERR_DEV_ALREADY_REG, /* phb device already register */
193 VAL_PHB_ERR_DEV_NOT_REG, /* phb device not register */
194 VAL_PHB_ERR_DEV_NOT_OPEN, /* phb device not open */
195 VAL_PHB_ERR_DEV_ALREADY_OPEN, /* phb device already open */
196 VAL_PHB_ERR_DEV_OPEN, /* error when open phb device open */
197 VAL_PHB_ERR_DEV_CLOSE, /* error when close phb device failure */
198 VAL_PHB_ERR_DEV_INIT_BUSY, /* phb device initial busy */
199
200 VAL_PHB_ERR_REC_EMPTY, /* empty record of phb device */
201 VAL_PHB_ERR_REC_READ, /* read record of phb device failure */
202 VAL_PHB_ERR_REC_WRITE, /* write record of phb device failure */
203 VAL_PHB_ERR_REC_DELETE, /* delete record of phb device failure */
204
205 VAL_PHB_ERR_NO_VAL_MEMORY, /* val malloc failure */
206 VAL_PHB_ERR_NO_MEMORY, /* no memory for new phb record */
207 VAL_PHB_ERR_NO_ENOUGH_MEMORY, /* no enough memory for new phb record */
208 VAL_PHB_ERR_NO_BUFFER, /* no record buffer for field operating */
209
210 VAL_PHB_ERR_MAX_REC_SIZE, /* no more space of the record for this field */
211 VAL_PHB_ERR_FIELD_NONEXISTENCE /* no such phb field */
212
213}ValPhbResultT;
214
215typedef enum /* Return values */
216{
217 CONTACT_SUCCESS, /* success */
218 CONTACT_FULL, /* contact phonebook or item is full */
219 CONTACT_FAIL, /* fail in the PHONE file */
220 CONTACT_EXTEN_FAIL, /* fail in the EXTEN file */
221 CONTACT_SUCCESS_AND_COMPRESS, /* contact EXTEN file request to compress and success. */
222 CONTACT_EXTEN_RECOVER /* contact EXTEN file request to recover */
223} ContactResultT;
224
225
226typedef struct
227{
228 kal_uint16 PhbUimRecNum;
229 kal_uint16 PhbFlashRecNum;
230 kal_uint16 PhbUimFreeNum;
231#ifdef MTK_CBP
232 kal_uint8 FdnRecNum;
233 kal_uint8 FdnFreeNum;
234#endif
235} ValPhbCountT;
236
237//don't modify following Enum, brew has referred to it
238/* Val phb field type */
239typedef enum
240{
241 VAL_PHB_FIELD_TYPE_NAME_INTER= 0x00,
242 VAL_PHB_FIELD_TYPE_NUMBER_INTER= 0x01,
243 VAL_PHB_FIELD_TYPE_GROUP_INTER = 0x03,
244 VAL_PHB_FIELD_TYPE_MAX_INTER
245}ValPhbFieldTypeInterT;
246
247typedef struct
248{
249 kal_uint8 ValPhbAlphaLength; /* max name length */
250 kal_uint8 ValPhbPhoneLength; /* max string type phone number length */
251 kal_uint8 ValPhbMaxDevCount; /* max phb storage device count */
252 kal_uint16 ValPhbMaxRecSize; /* max record size */
253 kal_uint16 ValPhbMaxRecCount; /* max record count */
254 kal_uint16 ValPhbMaxRecBufCount; /* max record buffer count */
255 kal_uint16 ValPhbMaxPhoneNumberCnt; /* max count of phone number in phone */
256 kal_uint16 ValPhbMaxFieldType; /* max record field type */
257 kal_uint16 ValPhbMaxFieldId; /* max record field id */
258
259 kal_uint16 ValPhbRecBufSize; /* size of ValPhbRecordBufferCustT */
260
261 void* ValPhbRecBufAddress;/* record buffer address */
262}ValPhbCustParaT;
263
264/* init state */
265typedef enum
266{
267 VAL_PHB_INIT_INVALID = 0x00, /* the phb dev initial invalid */
268 VAL_PHB_INIT_VALID, /* the phb dev initial valid */
269 VAL_PHB_INIT_NOT_COMPLETE, /* the phb init not complete */
270 VAL_PHB_INIT_COMPLETE /* the phb init complete */
271}ValPhbInitStateT;
272
273
274//don't modify following Enum, brew has referred to it
275/* Val phb device type */
276/* DON'T add item value to 0, it has been define to VAL_PHB_DEV_NONE in valphbapi.c */
277typedef enum
278{
279 VAL_PHB_DEV_UIM = 0x01,
280 VAL_PHB_DEV_FLASH = 0x02,
281 VAL_PHB_DEV_MAX
282} ValPhbDeviceT;
283
284typedef struct buff_struct
285{
286 kal_uint8 unicodehead;
287 kal_uint8 str[PHB_MAX_ALPHA_LENGTH - 1 + 2];
288} buff;
289
290typedef union search_name_union
291{
292 buff buf;
293 kal_uint8 data[PHB_MAX_ALPHA_LENGTH + 2];
294} searchname_str;
295
296#ifdef MTK_CBP
297#define PHB_MAX_VAL_PHONE_LENGTH 20
298#else
299#define PHB_MAX_VAL_PHONE_LENGTH 10
300#endif
301
302//don't modify following Enum, brew has referred to it
303/* Val phb field type */
304typedef enum
305{
306 VAL_PHB_FIELD_TYPE_NAME = VAL_PHB_FIELD_TYPE_NAME_INTER,
307 VAL_PHB_FIELD_TYPE_NUMBER = VAL_PHB_FIELD_TYPE_NUMBER_INTER,
308 VAL_PHB_FIELD_TYPE_GROUP = VAL_PHB_FIELD_TYPE_GROUP_INTER,
309 VAL_PHB_FIELD_TYPE_NUMBER_INFO,
310 VAL_PHB_FIELD_TYPE_MAX = 0xF0
311}ValPhbFieldTypeT;
312
313typedef struct
314{
315 kal_uint8 Ton;
316 kal_uint8 Npi;
317 kal_uint8 AlphaIdentifier[PHB_MAX_ALPHA_LENGTH+1]; /*Alpha Identifier*/
318 kal_uint8 PhoneNumber[PHB_MAX_VAL_PHONE_LENGTH+1]; /*Dialing Number/SSC String*/
319 kal_uint16 RecID; /*Record ID*/
320 kal_bool HasExtension; /*if have extension info*/
321} ValPhbContactSummaryT;
322
323//don't modify following Enum, brew has referred to it
324/* Val phb field id */
325typedef enum
326{
327 VAL_PHB_FIELD_ID_PRIMARY_NAME = 0x00,
328 VAL_PHB_FIELD_ID_PRIMARY_NUMBER = 0x01,
329 VAL_PHB_FIELD_ID_PRIMARY_NUMBER_INFO = 0x10,
330 VAL_PHB_FIELD_ID_MAX = 0xF0
331}ValPhbFieldIdT;
332
333typedef enum
334{
335 PHB_NODE_CLEAN = 0x00,
336 PHB_NODE_USED = 0x01,
337 PHB_NODE_WRITING = 0x02,
338 PHB_NODE_WAITING_FOR_WRITE = 0x03,
339 PHB_NODE_DELETING = 0x04,
340 PHB_NODE_WAITING_FOR_DELETE = 0x05,
341 PHB_NODE_STATUS_NUM
342} ValNodeStatus;
343/* for customer */
344typedef struct
345{
346 kal_uint8 BufState; /* The buffer state*/
347 kal_uint8 DeviceId; /* The device id for buffer contact */
348 kal_uint16 RecId; /* The record id for the contact in val db */
349 kal_uint16 DataLen; /* The actual length of the contact data segment */
350 kal_uint8 Data[VAL_PHB_MAX_REC_SIZE]; /* The buffer for data */
351}ValPhbRecordBufferCustT;
352
353typedef struct
354{
355 kal_uint16 NextAddress;
356 ValNodeStatus NodeState;
357 ValPhbContactSummaryT ValPhbContact;
358} ValPhbNodeType;
359
360typedef struct
361{
362 kal_uint16 index; // id of the contact
363 kal_uint16 size; // size of the record data
364} ValContactExtenRecHeaderT;
365
366#ifdef MTK_CBP
367#define VAL_PHB_FDN_NUMBER_LEN 40
368
369typedef struct
370{
371 kal_uint8 Ton;
372 kal_uint8 Npi;
373 kal_uint8 AlphaIdentifier[PHB_MAX_ALPHA_LENGTH+1]; /*Alpha Identifier*/
374 kal_uint8 PhoneNumber[VAL_PHB_FDN_NUMBER_LEN+1]; /*Dialing Number/SSC String*/
375 kal_uint8 RecID; /*Record ID*/
376}ValFdnContactInfoT;
377
378typedef struct
379{
380 kal_bool FdnInitOk;
381 kal_bool FdnEnabled;
382 kal_uint8 FdnRecCount;
383 kal_uint8 FdnRecSize;
384}ValFdnContextT;
385#endif
386
387/* marco define for link list */
388#define VAL_PHB_EOL 0xFFFF /* end of link list */
389
390
391typedef kal_uint32 ValPhbEventIdT;
392typedef void (*ValPhbEventFunc) ( RegIdT RegId, kal_uint32 Event, void *MsgP );
393
394
395/*! Contact Event register table structure */
396typedef struct
397{
398 kal_bool IsUse; /*!< if this entry is in use */
399 kal_uint8 NumTeleSrvId; /*!< Teleservice Id count */
400 kal_uint16 TeleSrvId[VAL_PHB_TELESRVID_COUNT]; /*!< Teleservice id */
401 ValPhbEventFunc CallBack; /*!< Function to call back */
402} ValPhbRegTableT;
403
404//don't modify following Struct, brew has referred to it
405/* VAL phb filed type */
406typedef struct
407{
408 kal_uint8 FieldId;
409 kal_uint8 FieldType;
410 kal_uint16 DataLength;
411 void * Data;
412} ValPhbFieldT;
413
414/* val phb device init msg */
415typedef struct
416{
417 ValPhbInitStateT PhbInitState;
418
419} ValPhbInitStateMsgT;
420
421void ValPhbInit(void);
422void ValPhbUnInit(void);
423RegIdT ValPhbRegister(ValPhbEventFunc CallBack);
424ValPhbResultT ValPhbUnRegister(RegIdT RegId);
425kal_bool IsPhbUimInitOk(void);
426kal_bool IsPhbFlashInitOk(void);
427#ifdef SYS_OPTION_NO_UI
428kal_bool ValPhbProcessMsg( kal_uint32 MsgId, void* MsgBufP, kal_uint32 MsgLen );
429#endif
430/*flash*/
431kal_uint32 ValPhbOpenFlashFile(void);
432kal_uint32 ValPhbCloseFlashFile(void);
433kal_bool ValPhbDeleteFlashData(void);
434kal_uint32 ValPhbDbFlush(void);
435
436ValPhbResultT ValPhbGetFlashRecord(kal_uint16 RecId, void *BufferP, kal_uint32 *LengthP);
437ValPhbResultT ValPhbEraseFlashRecord(kal_uint16 RecId);
438ValPhbResultT ValPhbUpdateFlashRecord(kal_uint16 RecId, void *BufferP, kal_uint32 Length);
439/*Field */
440ValPhbResultT ValPhbSetField(kal_uint16 DevId, kal_uint16 RecId, ValPhbFieldT Field);
441ValPhbResultT ValPhbGetField(kal_uint8 DeviceId, kal_uint16 RecordId,ValPhbFieldT *FieldP);
442ValPhbResultT ValPhbClearField(kal_uint8 DeviceId, kal_uint16 RecordId,kal_uint8 FieldId);
443ValPhbResultT ValPhbFlushRecord(kal_uint8 DeviceId, kal_uint16 RecordId);
444
445/*Uim*/
446ValPhbResultT ValPhbGetUimRecParams(void);
447ValPhbResultT ValPhbGetUimRecord(kal_uint16 RecId);
448ValPhbResultT ValPhbEraseUimRecord(kal_uint16 RecId);
449ValPhbResultT ValPhbUpdateUimRecord(kal_uint16 RecId, kal_uint8 * NameP, kal_uint8 * PhNumP, kal_uint8 TON, kal_uint8 NPI);
450
451#ifdef MTK_CBP
452kal_uint8 ValGetPhbAlphaLen(kal_uint8 *pAlpha);
453kal_uint8 PhbGetAlphaIdLenByAddress(kal_uint16 nAddress);
454#endif
455
456/*-------------------------------------*/
457
458void ValPhbInitAllContact( void );
459
460
461/*****************************************************************************
462
463 FUNCTION NAME: ValPhbFindContactByNumber
464
465 DESCRIPTION:
466 update a phone book contact info
467
468 PARAMETERS:
469 pPhbContact: A pointer to a phone book Contact.
470
471 RETURNED VALUES:
472 KAL_TRUE is success, and KAL_FALSE is error
473
474*****************************************************************************/
475kal_bool ValPhbFindContactByNumber( ValPhbContactFullT* pPhbContact,
476 kal_uint8* pNumber );
477#ifdef MTK_CBP
478extern kal_bool ValGetFdnStatus(void);
479#endif
480
481#ifdef __cplusplus
482
483}
484#endif /* __cplusplus */
485#endif
486
487
488
489