CloudSrvGprot.h 18 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
#ifndef __BACKUP_RESTORE_SRV_GPROT_H__
#define __BACKUP_RESTORE_SRV_GPROT_H__

#include "MMIDataType.h"
#include "kal_general_types.h"
#include "DtcntSrvGprot.h"
#include "CloudPlugin.h"

/* Event ID */
typedef enum
{
    SRV_CLD_STATUS_IND = 0, /* Status indication. */
    SRV_CLD_DATA_IND,       /* Data is arriving. */
} srv_backup_restore_event_enum;

/* Error code */
#define SRV_CLD_SUCCESS     (0)
#define SRV_CLD_ERROR       (-1)
#define SRV_CLD_WOULDBLOCK  (-2)

/* Error code */
typedef enum
{
    SRV_CLD_NODATA          = (-3),
    SRV_CLD_NO_MEMORY       = (-4),
    SRV_CLD_FS_ERROR        = (-5),
    SRV_CLD_NWK_ERROR       = (-6),
    SRV_CLD_GET_UID_ERROR   = (-7),
    SRV_CLD_BUSY            = (-8),
    SRV_CLD_LOGOUT          = (-9),
    SRV_CLD_NO_NEED_SYNC    = (-10),
    SRV_CLD_ACCT_ERROR      = (-11),
    SRV_CLD_NO_STORAGE      = (-12),
    SRV_CLD_DISK_FULL       = (-13)
}srv_cloud_error_type_enum;

#define SRV_CLD_URL_LEN     (256)

#define SRV_CLD_UID_LEN     (50)
#define SRV_CLD_ETAG_LEN    (20)
#define SRV_CLD_CTAG_LEN    (40)
#define SRV_CLOUD_ASM_SIZE  (100*1024)
#define SRV_CLOUD_INVALID_INDEX  (0xEEEE)

#define SRV_CLD_SMS_UID_LEN     SRV_CLD_UID_LEN

typedef struct
{
    CHAR id[SRV_CLD_UID_LEN + 1];
    CHAR tag[SRV_CLD_ETAG_LEN + 1];
} srv_cloud_uid_struct;

typedef struct
{
    U32 imap_uid;
    CHAR sms_uid[SRV_CLD_SMS_UID_LEN + 1];
} srv_cloud_sms_imap_uid_struct;

typedef enum
{
    SRV_CLD_UID_NOT_EXIST = 0,
    SRV_CLD_UID_EXIST_CHANGE,
    SRV_CLD_UID_EXIST_NOT_CHANGE
} srv_cloud_uid_exist_enum;

typedef enum
{
    SRV_CLD_TYPE_VCARD = 0, /* vCard */
    SRV_CLD_TYPE_SMS,       /* SMS */
    SRV_CLD_TYPE_TOTAL
} srv_cloud_type_enum;

typedef enum
{
    SRV_CLD_OPT_ACCT_INFO,  /* Set account info, srv_cloud_set_opt_acct_info_struct */
    SRV_CLD_OPT_DTYPE,      /* Set data type (VCard only), srv_cloud_dtype_enum */
    SRV_CLD_OPT_PROXY,      /* Set proxy (VCard only), proxy address and port. */
    SRV_CLD_OPT_TOTAL
} srv_cloud_opt_enum;

typedef enum
{
    SRV_CLD_OP_BACKUP = 0,  /* Backup. */
    SRV_CLD_OP_RESTORE,     /* Restore. */
    SRV_CLD_OP_TOTAL
} srv_cloud_op_enum;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
typedef enum
{
    SRV_CLD_DT_RECORD = 0,  /* Record data. */  /* use buffer */
    SRV_CLD_DT_URI,         /* Hypertext link. */ /* use file */
    SRV_CLD_DT_TOTAL
} srv_cloud_dtype_enum;

typedef enum
{
    SRV_CLD_ACTION_ADD,
    SRV_CLD_ACTION_DEL,
    SRV_CLD_ACTION_UPDATE,
    SRV_CLD_ACTION_TOTAL
}srv_cloud_set_store_enum;

typedef struct
{
    U32 provider;
    U8  account_id;
} srv_cloud_set_opt_acct_info_struct;

typedef S32 (*srv_cloud_uid_query_callback_ptr)(srv_cloud_uid_struct *uid, srv_cloud_uid_exist_enum *exist, void *userdata);

typedef struct
{
    srv_cloud_op_enum op_type;
} srv_cloud_op_struct;

typedef struct
{
    U16 port;
    srv_dtcnt_prof_px_srv_enum  service;
    //U8 address[SRV_DTCNT_PROF_MAX_IP_ADDR_LEN];
    U8 address[SRV_DTCNT_PROF_MAX_PROXY_ADDR_LEN+1]; //URL Proxy
    U8 username[SRV_DTCNT_PROF_MAX_PX_AUTH_ID_LEN + 1];
    U8 passwd[SRV_DTCNT_PROF_MAX_PX_AUTH_PW_LEN + 1];
}srv_cloud_px_info_struct;

typedef void * ( *srv_cloud_mem_alloc)(U32 len);
typedef void ( *srv_cloud_mem_free)(void* ptr);

typedef void (*srv_cloud_set_opt_cb_t)(S32 result);

typedef struct
{
        srv_cloud_set_opt_acct_info_struct acct;    /* for SRV_CLD_OPT_ACCT_INFO */
        srv_cloud_dtype_enum data_type;             /* for SRV_CLD_OPT_DTYPE */
        srv_cloud_px_info_struct proxy;             /* for SRV_CLD_OPT_PROXY */
        srv_cloud_mem_alloc  mem_alloc;
        srv_cloud_mem_free   mem_free; 
        srv_cloud_set_opt_cb_t cb_func;             /* for asynchronous to set option */
} srv_cloud_opt_struct;

/* Vcard data structure. */
typedef struct
{
    U8 *url;
    U8 *tag;        // version
    U8 *data;       // vcard data
    U32 length;     // data buffer length
} srv_cloud_card_struct;

#define NUMBER_SEPERATOR_CHAR  ';'

/* SMS data structure. */
typedef struct
{
    U32 date;
    void *number;           // CHAR eg. "120;999;119", seperator is NUMBER_SEPERATOR_CHAR
    U32   number_buf_len;
    void *content;          // WCHAR
    U32   content_buf_len;
    void *sms_data;         // buffer
    U32    sms_data_len;
    /* TODO: need SMS owner to fill this struct */
} srv_cloud_sms_struct;



/**************************************************** 
*  struct of EVT_ID_SRV_CLD_ERROR_IND;
*
*  In both backup and restore process
*  After app call srv_cloud_operate(), it should handle this event;
*  This event indicate the error information; 
*
*  type: application type
*  error_type: root cause of fail
*
*****************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    srv_cloud_type_enum type;
    srv_cloud_error_type_enum error_type;
}srv_cloud_error_evt_struct;

/*********************************************************
* struct of EVT_ID_SRV_CLD_ASYNC_UID_DONE_IND;
*
* In both backup and restore process
* After app call srv_cloud_async_set_store_uid(), it should handle this event;
* When async add done, service post this event to app
*
* type: application type
*
************************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    srv_cloud_type_enum type;

}srv_cloud_post_async_done_evt_struct;


/****************************************************
* struct of EVT_ID_SRV_CLD_BACKUP_BEGIN_IND
*
* In backup process
* After app call srv_cloud_operate(), it should handle this event;
* This event notify application to begin backup.
*
* type: application type
*
*****************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    srv_cloud_type_enum type;

}srv_cloud_post_backup_begin_evt_struct;


/***********************************************************
* struct of EVT_ID_SRV_CLD_PUT_DATA_RES_IND
*
* In backup process
* After app call srv_cloud_put_data(), it should handle this event;
* This event return the result of put_data.
*
* result: 0, success
*
************************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    U8 result;
    srv_cloud_type_enum type;
}srv_cloud_put_data_result_evt_struct;


/***************************************************************
* struct of EVT_ID_SRV_CLD_CLOSE_DONE_IND
*
* In both backup and restore process
* After app call srv_cloud_close(), it should handle this event;
* This event notify application service is closed done.
*
* type: application type
*
****************************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    srv_cloud_type_enum type;
}srv_cloud_post_close_done_struct;


/**********************************************************
* struct of EVT_ID_SRV_CLD_GET_DATA_IND
*
* In restore process
* After app call srv_cloud_operate(), it should handle this event;
* This event means application should get data from service.
*
* type: application type
* over_flag: FALSE, app should get data; 
*               TRUE, there is no data anymore;
*
************************************************************/
typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;             /* MMI_EVENT_ID */
    U16 size;               /* EVENT SIZE */
    void *user_data;        /* Piggyback user data */
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    U16 index;
    MMI_BOOL over_flag;
    srv_cloud_type_enum type;
    U8 is_add;
}srv_cloud_get_data_ind_evt_struct;



typedef struct
{
#ifdef __BUILD_DOM__
    U16 evt_id;     
    U16 size;           
    void *user_data;   
#endif
    /* DOM-NOT_FOR_SDK-BEGIN */
    MMI_EVT_PARAM_HEADER    /* MMI_EVENT_COMMON_HEADER */
    /* DOM-NOT_FOR_SDK-END */
    U32 count;
    srv_cloud_type_enum type;
}srv_cloud_progress_ind_evt_struct;



/******************************************************************************
 * FUNCTION
 *     srv_cloud_create
 * DESCRIPTION
 *     Create a service descriptor for the later synchronization or backup and allocate the related resource.
 *     This is the first function to call when the application wants to synchronize or backup with the server.
 *     Only support single instance, before application call this API, should call last instance's srv_cloud_close(). 
 * PARAMETERS
 *    type   : [IN] could service type
 * RETURNS
 *    On success, return the service handle; otherwise return the error code that is less than 0.
 ******************************************************************************/
extern S32 srv_cloud_create(srv_cloud_type_enum type);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_close
 * DESCRIPTION
 *    Close the service descriptor, release the related resource and free the memory occupied. 
 *    The application should call the function after it has finished the synchronize or backup.
 * PARAMETERS
 *    hdl   : [IN] service handle
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_close(S32 hdl);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_setopt
 * DESCRIPTION
 *    Set the user option.
 * PARAMETERS
 *    hdl   : [IN] service handle
 *    opt   : [IN] set option type
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_setopt(S32 hdl, const srv_cloud_opt_struct *opt);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_operate
 * DESCRIPTION
 *    Begin an operation, such as restore, backup, synchronization etc.
 * PARAMETERS
 *    hdl   : [IN] service handle
 *    op    : [IN] operation struct pointer
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_operate(S32 hdl, const srv_cloud_op_struct *op);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_abort
 * DESCRIPTION
 *    Abort the current operation
 * PARAMETERS
 *    hdl   : [IN] service handle
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_abort(S32 hdl);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_get_data
 * DESCRIPTION
 *    Get the data from the server. It indicates there is not more data if it returns SRV_CLD_NODATA.
 * PARAMETERS
 *    hdl   : [IN]  service handle
 *    buf   : [OUT] data struct pointer
 *    num   : [OUT] record number
 *    len   : [OUT] written length
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_get_data(S32 hdl, void *buf, U32 *num, U32 *len);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_put_data
 * DESCRIPTION
 *    Put  the data to the service.
 *    if len = 0, buf is the file name; if len >0, buf is record data; if buf = NULL and len = 0, there is no more data.
 * PARAMETERS
 *    hdl   : [IN] service handle
 *    buf   : [IN] data struct pointer or file path pointer
 *    num   : [IN] index of a SMS or vCard
 *    len   : [IN] buffer length
 * RETURNS
 *    On success, return SRV_CLD_SUCCESS; otherwise return error code.
 ******************************************************************************/
extern S32 srv_cloud_put_data(S32 hdl, const void *buf, U32 num, U32 len);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_put_data_commit
 * DESCRIPTION
 *    Notify service put data done
 * PARAMETERS
 *    hdl   : [IN] service handle
 * RETURNS
 *    void
 ******************************************************************************/
extern void srv_cloud_put_data_commit(S32 hdl);

/******************************************************************************
 * FUNCTION
 *     srv_cloud_backup_uid_check
 * DESCRIPTION
 *    Check whether this index need to backup
 * PARAMETERS
 *    index   : [IN] index of item
 *    type   : [IN] SMS or vCard
 * RETURNS
 *    If exist, return 1, otherwise return 0. For errors, return value < 0
 ******************************************************************************/
MMI_BOOL srv_cloud_backup_uid_check( U16 index, srv_cloud_type_enum type);


/******************************************************************************
*Fucntion
*  srv_cloud_sync_set_store_uid
*DESCRIPTION
*  Sync pdata uid list in the database
*  When app add/delete/update a record, App call this API to update the UID store in service 
*PARAMETERS
*  index : [IN] id of a vCard or SMS
*  uid :    [IN] new uid, if application doesn't store UID, please pass NULL
*  type:   [IN] SMS or vCard
*  action: [IN] add or delete or update
*RETURNS
*  if success return SRV_CLD_SUCCESS; otherwise return error code.
******************************************************************************/
extern S32 srv_cloud_sync_set_store_uid(U16 index, 
                                 srv_cloud_uid_struct *uid, 
                                 srv_cloud_type_enum type, 
                                 srv_cloud_set_store_enum action);

/**********************************************************************************
*Fucntion
*  srv_cloud_async_get_store_uid
*DESCRIPTION
*  Get UID from NVRAM 
*PARAMETERS
*  index : [IN] id of a vCard or SMS
*  uid :    [OUT] UID in the NVRAM
*  type:   [IN] SMS or vCard
*RETURNS
*  if success return SRV_CLD_SUCCESS; otherwise return error code.
************************************************************************************/
extern S32 srv_cloud_sync_get_store_uid(U16 index, 
                               srv_cloud_uid_struct *uid, 
                               srv_cloud_type_enum type);

/**********************************************************************************
*Fucntion
*  srv_cloud_async_set_store_uid
*DESCRIPTION
*  Async updata uid list store in the database 
*PARAMETERS
*  buf :    [IN]  app use this buf to store the index set
*  num :   [IN]  num of index in buf
*  type:   [IN]  SMS or vCard
*  action: [IN]  only support ADD now
*RETURNS
*  if success return SRV_CLD_SUCCESS; otherwise return error code.
************************************************************************************/

extern S32 srv_cloud_async_set_store_uid(U16 * buf, U16 num, 
                                        srv_cloud_type_enum type,
                                        srv_cloud_set_store_enum action);


/**********************************************************************************
*Fucntion
*  srv_cloud_is_support_backup_restore
*DESCRIPTION
*  Check the provider whether support backup restore feature 
*PARAMETERS
*  type:   [IN]  SMS or vCard
*  id:       [IN]  provider id
*RETURNS
*  if support return MMI_TRUE; otherwise return MMI_FALSE.
************************************************************************************/

extern MMI_BOOL srv_cloud_is_support_backup_restore(srv_cloud_type_enum type, U32 id);

/**********************************************************************************
*Fucntion
*  srv_cloud_support_backup_restore_list
*DESCRIPTION
*  Check the provider list that support backup restore feature 
*PARAMETERS
*  type:   [IN]  SMS or vCard
*  id:       [OUT]  provider id list
* num:     [OUT] list num
*RETURNS
*  NULL
************************************************************************************/

extern void srv_cloud_support_backup_restore_list(srv_cloud_type_enum type, U32* id, U8 * num);


/**********************************************************************************
*Fucntion
*  srv_cloud_query_provider_info
*DESCRIPTION
*  get provider info 
*PARAMETERS
*  id:       [IN]      provider id
*  info:    [OUT]   provider info
*RETURNS
*  if find the provider info, return MMI_TRUE; otherwise return MMI_FALSE.
************************************************************************************/

extern MMI_BOOL srv_cloud_query_provider_info( U32 id, cloud_plugin_provider_struct * info);

extern MMI_BOOL srv_cloud_query_server_info(U32 id, U32 feature, cloud_plugin_server_info_struct *info);

extern S32 srv_cloud_retry(S32 hdl, srv_cloud_set_opt_acct_info_struct *acct);
extern MMI_BOOL srv_cloud_add_real_time(srv_cloud_type_enum type);


#endif /* */