Ejemplo n.º 1
0
/*****************************************************************************
 * FUNCTION
 *  jpim_evtdb_appendEntry
 * DESCRIPTION
 *  This function adds a new entry into the event database.
 *  If the entry is successfully added, values are assigned to the
 *  index and handle fields of the entry.
 * PARAMETERS
 *  entry         [IN/OUT]
 *  db_type       [IN]              jpim_evtdb_db_enum
 * RETURNS
 *  jpim_error_code_enum
 *****************************************************************************/
void jpim_evtdb_adjustEntry(mmi_evtdb_java_entry_struct *entry, kal_uint8 db_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (entry->startTime.nYear == 0 && entry->endTime.nYear!= 0)
    {
        memcpy(&(entry->startTime), &(entry->endTime), sizeof(applib_time_struct));
    }
    else if(entry->startTime.nYear != 0 && entry->endTime.nYear== 0)
    {
        memcpy(&(entry->endTime), &(entry->startTime), sizeof(applib_time_struct));
    }
    else if(entry->startTime.nYear == 0 && entry->endTime.nYear== 0)
    {
        entry->startTime.nYear = 2004;
        entry->startTime.nMonth = 1;
        entry->startTime.nDay = 1;
        entry->endTime.nYear = 2004;
        entry->endTime.nMonth = 1;
        entry->endTime.nDay = 1;
    }

	if(app_ucs2_strlen((kal_int8*)entry->note) == 0)
    {
		app_asc_str_to_ucs2_str((kal_int8*)entry->note, (kal_int8*)"No Content");
	}

#ifndef __COSMOS_MMI_PACKAGE__
    if (db_type == JPIM_EVTDB_REMINDER || db_type == JPIM_EVTDB_MEETING || db_type == JPIM_EVTDB_COURSE ||
		db_type == JPIM_EVTDB_DATE || db_type == JPIM_EVTDB_CALL|| db_type == JPIM_EVTDB_ANNIVERSARY || 
		db_type == JPIM_EVTDB_ALL)
#else
    if (db_type == JPIM_EVTDB_PERSONAL || db_type == JPIM_EVTDB_MEETING || db_type == JPIM_EVTDB_SPECIALDAY ||
		db_type == JPIM_EVTDB_BIRTHDAY || db_type == JPIM_EVTDB_OTHERS || db_type == JPIM_EVTDB_ALL)
#endif
    {
        entry->field_mask |= JPIM_EVTDB_MASK_NOTE;
		entry->field_mask |= JPIM_EVTDB_MASK_START_TIME;
		entry->field_mask |= JPIM_EVTDB_MASK_END_TIME;
        entry->field_mask |= JPIM_EVTDB_MASK_ALARM;
		entry->field_mask |= JPIM_EVTDB_MASK_REPEAT;
#ifdef	JSR_75_PIM_EXTRA_DETAIL
        entry->field_mask |= JPIM_EVTDB_MASK_DETAILS;
#endif
#ifdef  JSR_75_PIM_EXTRA_TODO
        entry->field_mask |= JPIM_EVTDB_MASK_LOCATION;

        //entry->status = MMI_TDL_STATUS_TOTAL;
        //entry->Priority = MMI_TDL_PRIORITY_TOTAL;
		entry->field_mask &= ~JPIM_EVTDB_MASK_STATUS;
		entry->field_mask &= ~JPIM_EVTDB_MASK_COMPLETE_TIME;
		entry->field_mask &= ~JPIM_EVTDB_MASK_PRIORITY;
#endif

        if (applib_dt_compare_time(&(entry->endTime), &(entry->startTime), NULL) == DT_TIME_LESS)
        {
            memcpy(&(entry->endTime), &(entry->startTime), sizeof(applib_time_struct));
        }
    }

    if (db_type == JPIM_EVTDB_TASK)
    {
        entry->field_mask |= JPIM_EVTDB_MASK_NOTE;
		entry->field_mask |= JPIM_EVTDB_MASK_START_TIME;
		entry->field_mask |= JPIM_EVTDB_MASK_END_TIME;
#ifdef  JSR_75_PIM_EXTRA_TODO
		entry->field_mask |= JPIM_EVTDB_MASK_PRIORITY;
		entry->field_mask |= JPIM_EVTDB_MASK_STATUS;
		entry->field_mask |= JPIM_EVTDB_MASK_COMPLETE_TIME;
		entry->field_mask &= ~JPIM_EVTDB_MASK_LOCATION;
#endif
#ifdef	JSR_75_PIM_EXTRA_DETAIL
		entry->field_mask |= JPIM_EVTDB_MASK_DETAILS;
#endif
        //entry->alarm = TODO_LIST_ALARM_TOTAL;
        //entry->repeat = ALM_FREQ_TOTAL;
		entry->field_mask &= ~JPIM_EVTDB_MASK_ALARM;
#ifdef JSR_75_PIM_EXTRA_ALARM_TIME_USER_DEFINE
		entry->field_mask &= ~JPIM_EVTDB_MASK_ALARM_TIME;
#endif
		entry->field_mask &= ~JPIM_EVTDB_MASK_REPEAT;
    }

}
Ejemplo n.º 2
0
/*****************************************************************************
 * FUNCTION
 *  srv_inet_http_send_request_ext
 * DESCRIPTION
 *  this function is to search the context based on application request id
 * CALLS
 * PARAMETERS
 * RETURNS
 *  void
 *****************************************************************************/
S32 srv_inet_http_send_request_ext( U32 session_handle,
								    U32 req_handle,
									const char *content_type,
									const char *req_body,
									U32 req_length,
                                    const U8* req_header,
									srv_inet_http_req_callback http_request_cb)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
	srv_inet_http_req_obj_struct* http_req;
	S8 cntxt_idx;
	S32 error = SRV_INET_OK;
	U32 no_bytes_written = 0;
	char post_file_ascii[64] = {0};
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
	if(http_request_cb == NULL)
		return SRV_INET_ERROR_INVALID_CALLBACK;
	
	/*is session handle valid, if yes, find global session context*/
	cntxt_idx = inet_srv_find_session_cntx_by_handle( session_handle);
	if((int *)cntxt_idx < 0)
	{
		return SRV_INET_ERROR_INVALID_SESSION_HANDLE;
	}

	/*search http request object based on request handle*/
	http_req = inet_srv_session_search_req_handle(session_handle, req_handle);	
	if(http_req == NULL)
	{
		return SRV_INET_ERROR_INVALID_REQUEST_HANDLE;
	}

	/*Is content type NULL*/
	if(content_type !=NULL)
	{
		http_req->content_len = strlen((char*)content_type);

		http_req->content_type = (U8*)INET_SRV_CONTEXT_MEM_ALLOC(cntxt_idx, http_req->content_len + 1);	
		if(http_req->content_type == NULL)
		{
			/*free object memory*/
			return SRV_INET_ERROR_MEM_NOT_AVAILABLE;
		}
		memcpy (http_req->content_type, content_type, http_req->content_len);
		http_req->content_type[http_req->content_len] = '\0';
	}

	/*does user has provided request headers*/
	if( req_header != NULL)
	{
		http_req->request_header_len = strlen((char*)req_header);

		http_req->request_header = (U8*)INET_SRV_CONTEXT_MEM_ALLOC(cntxt_idx, http_req->request_header_len + 1);	
		if(http_req->request_header == NULL)
		{
			/*free object memory*/
			INET_SRV_CONTEXT_MEM_FREE(cntxt_idx, http_req->content_type);
			return SRV_INET_ERROR_MEM_NOT_AVAILABLE;
		}
		memcpy (http_req->request_header, req_header, http_req->request_header_len);
		http_req->request_header[http_req->request_header_len] = '\0';
	}
	

	sprintf(post_file_ascii, "%s%d%s",  INET_SRV_TEMP_WPS_FILE_PREFIX, ++inet_srv_handle, INET_SRV_TEMP_FILE_EXT);

	app_asc_str_to_ucs2_str((kal_int8*)http_req->post_path, (kal_int8*)post_file_ascii);

	http_req->file_handle = FS_Open( http_req->post_path, FS_READ_WRITE | FS_CREATE );	

    if (http_req->file_handle < 0)
	{
		INET_SRV_CONTEXT_MEM_FREE(cntxt_idx, http_req->request_header);
					/*free object memory*/
		INET_SRV_CONTEXT_MEM_FREE(cntxt_idx, http_req->content_type);
		return SRV_INET_ERROR_FILE_ACCESS;
	}
	
	/*register callback function for http response*/
	INET_SRV_CONTEXT_SET_CALLBACK(cntxt_idx) = http_request_cb;

	http_req->wps_req_id			= (++inet_srv_handle) + 100;
	http_req->reply_type			= WPS_DATA_TYPE_BUFFER;
	http_req->reply_segment_len		= INET_SRV_REPLY_SEGMENT_LENGTH;
	http_req->post_type				= WPS_DATA_TYPE_FILE;
	http_req->post_path_len			= strlen(post_file_ascii);
	http_req->more_post				= MMI_FALSE;


	error = inet_srv_session_write_to_file( http_req, req_body,
									        req_length, &no_bytes_written);

	if(error != SRV_INET_OK )
		return SRV_INET_ERROR_FILE_ACCESS;

	http_req->post_total_len		= no_bytes_written;
	
	return error;

}