static void ui_vdoplayer_update_load_media_time(u32 second)
{
    u16 *p_unistr;
    u16 uni_str1[100+1];
    u16 uni_str2[10+1];
    u8  asc_str[10+1];

    memset(uni_str1, 0, sizeof(uni_str1));
    memset(uni_str2, 0, sizeof(uni_str2));
    memset(asc_str, 0, sizeof(asc_str));

    if (second <= 5)
    {
        p_unistr = (u16 *)gui_get_string_addr(IDS_HAVE_LOADED);
        uni_strcpy(uni_str1, p_unistr);
    }
    else
    {
        p_unistr = (u16 *)gui_get_string_addr(IDS_TRY_LOADING_HAVE_LOADED);
        uni_strcpy(uni_str1, p_unistr);
    }

    sprintf(asc_str, " %ld ", second);
    str_asc2uni(asc_str, uni_str2);
    uni_strcat(uni_str1, uni_str2, 100);

    p_unistr = (u16 *)gui_get_string_addr(IDS_SECOND);
    uni_strcat(uni_str1, p_unistr, 100);

    text_set_content_by_unistr(g_pVdoPlayer->hLoadMediaTime, uni_str1);
}
Exemplo n.º 2
0
EC_API EC_OBJ EcMakeUString( const Uchar *ustring, EcInt len , EcBool duplicate )
{
	EC_OBJ obj;
	EcInt l;

	obj = EcMakeUser( tc_ustring, NULL );
	if (EC_ERRORP(obj)) return obj;

	if (len > 0) l = len;
	else l = ustring ? uni_strlen( ustring ) : 0;

	EC_USTRLEN(obj) = 0;

	if (duplicate) {
		EC_USTRDATA(obj) = ec_malloc((l + 1) * sizeof(Uchar));
		if (! EC_USTRDATA(obj)) return Ec_ERROR;
		uni_strcpy(EC_USTRDATA(obj), ustring);
	} else {
		EC_USTRDATA(obj) = ustring;
	}

	EC_USTRLEN(obj) = l;

	return obj;
}
Exemplo n.º 3
0
OP_STATUS
WindowsOpFolderLister::Construct(const uni_char* path, const uni_char* pattern)
{
	m_find_handle = INVALID_HANDLE_VALUE;

	RETURN_IF_ERROR(m_path_pattern.Set(path));
	if (!m_path_pattern.Length() || m_path_pattern[m_path_pattern.Length() - 1] != '\\')
	{
		RETURN_IF_ERROR(m_path_pattern.Append("\\"));
	}

	m_path = OP_NEWA(uni_char, m_path_pattern.Length() + MAX_PATH + 1);
	if (m_path == NULL) return OpStatus::ERR_NO_MEMORY;
	m_path_length = m_path_pattern.Length();
	uni_strcpy(m_path, m_path_pattern.CStr());
	RETURN_IF_ERROR(m_path_pattern.Append(pattern));

	if (!m_path_pattern.Compare(UNI_L("\\*")))
	{
		if ((m_drives = GetLogicalDrives()) == 0)
			return OpStatus::ERR;
	}
	else if (m_path_pattern[0] == '\\' && m_path_pattern[1] != '\\') // remove \ before drive name if present but not from network paths
	{
		m_path_pattern.Delete(0, 1);
	}

	return OpStatus::OK;

}
Exemplo n.º 4
0
u32 file_list_get_partition(partition_t **pp_partition)
{
  file_list_priv_t *p_priv = NULL;
  partition_t *p_partition = NULL;
  u16 partition_letter[10] = {0};
  u8 partition_cnt = 0;
  u8 loopi = 0;
  vfs_dev_info_t dev_info = {0};

  p_priv = class_get_handle_by_id(FILE_LIST_CLASS_ID);
  if (pp_partition)
  {
    *pp_partition = p_priv->partition;
  }

  partition_cnt = vfs_get_partitions(partition_letter, 10);

  for (loopi = 0; loopi < partition_cnt; loopi ++)
  {
    p_partition = &p_priv->partition[loopi];
    vfs_get_dev_info(partition_letter[loopi], &dev_info);
    uni_strcpy(p_partition->name, dev_info.parttion_name);
    p_partition->letter[0] = partition_letter[loopi];
    p_partition->letter[1] = 0x3a/*':'*/;
    p_partition->letter[2] = 0/*'\0'*/;
    p_partition->toatl_size = dev_info.total_size;
    p_partition->free_size = dev_info.free_size;
  }

  return partition_cnt;
}
Exemplo n.º 5
0
static BOOL is_filter_nodir(u16 *p_filter)
{
  u16 *p_ch = NULL;
  u16 tip[8] = {0};
  u16 filter[MAX_FILE_PATH] = {0};
  u16 nodir[8] = {0};

  uni_strncpy(filter, p_filter, MAX_FILE_PATH);
  str_asc2uni(".nodir", nodir);
  uni_strcpy(tip, nodir);
  while (1)
  {
    p_ch = uni_strrchr(filter, 0x7c/*'|'*/);
    if (p_ch == NULL)
    {
      return FALSE;
    }
    p_ch[0] = 0x2e/*'.'*/;
    if (uni_strcmp(p_ch, tip) == 0)
    {
      return TRUE;
    }
    p_ch[0] = 0/*'\0'*/;
  }

  //return FALSE;
}
Exemplo n.º 6
0
/*!
 * Save plug-in subtitle with the same name of current playing file
 */
static void _ui_video_m_save_subt_lang(u16 *p_path)
{
    u8   i          = 0;
    u8   j          = 0;
    u8   cnt        = 0;
    u16 *p_temp     = NULL;
    u16 *p_name     = NULL;
    u16 *p_subt_tmp = NULL;   

    if(NULL == p_path)
    {
        UI_VIDEO_PRINF("[%s]: ##ERR## file name null\n", __FUNCTION__);
        return;
    }

    cnt = (u8)MIN(g_video_m.subt_list.file_count, V_SUB_CNT_MAX);

    p_name = _ui_video_m_get_name_without_path(p_path);

    p_temp = mtos_malloc(sizeof(u16) * (uni_strlen(p_name) + 1));

    uni_strcpy(p_temp, p_name);

    _ui_video_m_get_name_without_ext(p_temp);

    p_subt_tmp = mtos_malloc(sizeof(u16) * MAX_FILE_PATH);

    for(i = 0; i < cnt; i++)
    {
        uni_strncpy(p_subt_tmp, g_video_m.subt_list.p_file[i].p_name, MAX_FILE_PATH - 1);

        if(0 == uni_strncmp(p_subt_tmp, p_temp, uni_strlen(p_temp)))
        {
            /*!
             * Ignore ext, Eg "test.chg.ssa->test.chg" or "test123.ssa" -> "test123"
             */
            _ui_video_m_get_name_without_ext(p_subt_tmp);

            /*!
             * If string is "test.chg", only save "chg"
             */
            _ui_video_m_get_ext_without_name(p_subt_tmp);

            uni_strncpy(g_video_m.subt[j].subt_lang, p_subt_tmp, V_SUB_LANG_LEN - 1);

            /*!
             * Save the index for finding name
             */
            g_video_m.subt[j++].idx = i;
        }
    }

    mtos_free(p_temp);
    mtos_free(p_subt_tmp);

    g_video_m.subt_cnt = j;

    UI_VIDEO_PRINF("[%s]: total cnt:%d name:%s sub cnt:%d\n", __FUNCTION__, cnt, p_name, j);
}
Exemplo n.º 7
0
OP_STATUS
OpScopeCookieManager::DoGetCookie(const GetCookieArg &in, CookieList &out)
{
	OpString in_domain;
	RETURN_IF_ERROR(in_domain.Set(in.GetDomain()));

	RETURN_IF_ERROR(Cookie_Manager::CheckLocalNetworkAndAppendDomain(in_domain));

	// we need non-const strings for the URL API
	OpAutoArray<uni_char> domain_copy( OP_NEWA(uni_char, in_domain.Length() + 1) );
	RETURN_OOM_IF_NULL(domain_copy.get());
	uni_strcpy(domain_copy.get(), in_domain.CStr());
	uni_char *domain = domain_copy.get();
	uni_char *path = NULL;

	OpAutoArray<uni_char> path_copy( in.HasPath() ? OP_NEWA(uni_char, in.GetPath().Length() + 1) : NULL );
	if (in.HasPath())
	{
		RETURN_OOM_IF_NULL(path_copy.get());
		uni_strcpy(path_copy.get(), in.GetPath().CStr());
		path = path_copy.get();
	}

	OpAutoArray< ::Cookie * > cookies( OP_NEWA(::Cookie *, urlManager->GetMaxCookiesInDomain()) );
	RETURN_OOM_IF_NULL(cookies.get());
	int cookie_size = 0;
	OP_STATUS status = g_url_api->BuildCookieList(cookies.get(), &cookie_size, domain, path, TRUE);
	if (OpStatus::IsError(status))
		return SetCommandError(OpScopeTPHeader::BadRequest, UNI_L("Could not get cookies for specified domain and path"));

	for (int i = 0; i < cookie_size; ++i)
	{
		Cookie *cookie_out = out.AppendNewCookieList();
		RETURN_OOM_IF_NULL(cookie_out);

		::Cookie *cookie = cookies[i];
		if (!cookie || !(cookie->Received_Domain().CStr() || (cookie->GetDomain() && cookie->GetDomain()->GetFullDomain())))
		{
			OP_ASSERT(cookie && cookie->GetDomain() && cookie->GetDomain()->GetFullDomain());
			return OpStatus::ERR_NULL_POINTER;
		}

		RETURN_IF_ERROR(SetCookieValue(*cookie_out, *cookie));
	}
	return OpStatus::OK;
}
Exemplo n.º 8
0
void * flist_add_fav_by_name(u16 *p_name, void **pp_media_fav, media_fav_type_t type)
{
  media_fav_t *p_fav_next = *(media_fav_t **)pp_media_fav;
  u32 next_len = 0;
  u16 *p_tip = NULL;

  CHECK_FAIL_RET_NULL(p_name != NULL);

  if (type == RECORD_FAV)
  {
    next_len = sizeof(rec_fav_t);
  }
  else
  {
    next_len = sizeof(media_fav_t);
  }
  
  while (p_fav_next)
  {
    if (!uni_strcmp(p_name, p_fav_next->path))
    {
      OS_PRINTF("\n##debug: flist_add_fav_by_name [%s] exist!!\n", p_name);
      return p_fav_next;
    }

    if (p_fav_next->p_next == NULL)
    {
      break;
    }
    p_fav_next = p_fav_next->p_next;
  }

  if (p_fav_next)
  {
    p_fav_next->p_next = mtos_malloc(next_len);
    CHECK_FAIL_RET_NULL(p_fav_next->p_next != NULL);
    p_fav_next = p_fav_next->p_next;
  }
  else
  {
    p_fav_next = mtos_malloc(next_len);
    CHECK_FAIL_RET_NULL(p_fav_next != NULL);
    *pp_media_fav = p_fav_next;
  }

  p_fav_next->p_next = NULL;
  memset(p_fav_next, 0, next_len);
  uni_strcpy(p_fav_next->path, p_name);

  if(type != RECORD_FAV)
  {
    p_tip = uni_strrchr(p_fav_next->path, 0x5c/*'\'*/);
    p_fav_next->p_filename = ++ p_tip;
  }
  return p_fav_next;
}
void ebox_set_keyboard_content_by_unistr(control_t *p_ctrl, u16 *p_unistr)
{
  ctrl_ebox_t *p_ebox = NULL;

  MT_ASSERT(p_ctrl != NULL);
  p_ebox = (ctrl_ebox_t *)p_ctrl;
  
  ebox_set_content_by_unistr(p_ctrl, p_unistr);
  if ((p_ctrl->priv_attr & EBOX_ARABIC_MASK) && (p_ebox->str_arabic != 0))
  {
    uni_strcpy((u16 *) p_ebox->str_arabic, p_unistr);
  }
}
Exemplo n.º 10
0
OP_STATUS TempBuffer::EnsureConstructed( size_t capacity )
{
	OP_ASSERT(capacity > 0);

	if (storage && allocated >= capacity)
		return OpStatus::OK;

	if (GetExpansionPolicy() == AGGRESSIVE)
		capacity = MAX( capacity, allocated*2 );

	size_t nallocated = (capacity + (alignment-1)) & ~(alignment-1);
	uni_char *nstorage = OP_NEWA( uni_char, nallocated );
	CHECK_ALLOCATION( nstorage );

#ifdef _DEBUG
	// In debug mode, fill up the new space with the pattern "BUG!BUG!..." to
	// make printing of uninitialized memory easy to detect

	const uni_char *const bug = UNI_L("BUG!");

	for (size_t i = 0; i < nallocated; ++i)
		nstorage[i] = bug[i % 4];

#ifdef VALGRIND
	// Even though the buffer has been "initialized" to "BUG!BUG!...", we still
	// want Valgrind to treat it as undefined
	op_valgrind_set_undefined(nstorage, sizeof(uni_char) * nallocated);
#endif // VALGRIND

#endif // _DEBUG

	if (storage)
	{
		OP_ASSERT(uni_strlen(storage) >= Length());
		OP_ASSERT(uni_strlen(storage) < allocated);
		uni_strcpy( nstorage, storage );
		OP_DELETEA(storage);
	}
	else
		nstorage[0] = 0;
	storage = nstorage;
	allocated = nallocated;

	// As a precaution, write a null terminator to the end of the newly
	// allocated memory. This could save us from running off the end in case
	// buggy code forgets to null-terminate the buffer.
	storage[nallocated - 1] = 0;

	CHECK_INVARIANTS();
	return OpStatus::OK;
}
Exemplo n.º 11
0
/* virtual */
const uni_char *
ES_TimeoutThread::GetInfoString()
{
	char delay_string[32]; // ARRAY OK 2011-11-07 sof
	OpDoubleFormat::ToString(delay_string, GetTimerEvent()->GetDelay());

	uni_char *buffer = (uni_char *) g_memory_manager->GetTempBuf();

	uni_strcpy(buffer, UNI_L("Timeout thread: delay "));
	make_doublebyte_in_buffer(delay_string, op_strlen(delay_string), buffer + uni_strlen(buffer), op_strlen(delay_string) + 1);
	uni_strcat(buffer, UNI_L(" ms"));

	return buffer;
}
Exemplo n.º 12
0
OP_STATUS
OpScopeCookieManager::DoRemoveCookie(const RemoveCookieArg &in)
{
	OpString in_domain;
	RETURN_IF_ERROR(in_domain.Set(in.GetDomain()));
	RETURN_IF_ERROR(Cookie_Manager::CheckLocalNetworkAndAppendDomain(in_domain));

	// we need non-const strings for the URL API
	uni_char *domain = NULL;
	OpAutoArray<uni_char> domain_copy( OP_NEWA(uni_char, in_domain.Length() + 1) );
	{
		RETURN_OOM_IF_NULL(domain_copy.get());
		uni_strcpy(domain_copy.get(), in_domain.CStr());
		domain = domain_copy.get();
	}
	uni_char *path = NULL;
	OpAutoArray<uni_char> path_copy( in.HasPath() ? OP_NEWA(uni_char, in.GetPath().Length() + 1) : NULL );
	if (in.HasPath())
	{
		RETURN_OOM_IF_NULL(path_copy.get());
		uni_strcpy(path_copy.get(), in.GetPath().CStr());
		path = path_copy.get();
	}
	uni_char *name = NULL;
	OpAutoArray<uni_char> name_copy( in.HasName() ? OP_NEWA(uni_char, in.GetName().Length() + 1) : NULL );
	if (in.HasName())
	{
		RETURN_OOM_IF_NULL(name_copy.get());
		uni_strcpy(name_copy.get(), in.GetName().CStr());
		name = name_copy.get();
	}

	OP_STATUS status = g_url_api->RemoveCookieList(domain, path, name);
	if (OpStatus::IsError(status))
		return SetCommandError(OpScopeTPHeader::BadRequest, UNI_L("Failure while removing cookies for specified domain, path and name"));
	return OpStatus::OK;
}
Exemplo n.º 13
0
/*!
 * Get ext of file, WARNING: p_name is input param, it is also output param
 */
static void _ui_video_m_get_ext_without_name(u16 *p_name)
{
    u8   i     = 0;
    u16 *p_ext = NULL;

    for(i = 0; i < (uni_strlen(p_name) - 1); i++)
    {
        if('.' == p_name[i])
        {
            p_ext = &p_name[i] + 1;
            uni_strcpy(p_name, p_ext);
            break;
        }
    }
}
Exemplo n.º 14
0
/*!
 * is enter directory
 */
BOOL ui_video_file_is_enter_dir(void)
{
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};
  u16 cur_path[255] = {0};

  if(g_video_m.flist_dir != NULL && g_video_m.file_list.file_count != 0)
  {
    uni_strcpy(cur_path, g_video_m.file_list.p_file[0].name);

    p_temp = uni_strrchr(cur_path, 0x5c/*'\\'*/);

    if (p_temp != NULL)
    {
      //parent dir
      str_asc2uni("..", parent);
      str_asc2uni(".", curn);
      if (uni_strlen(p_temp) >= 3 && uni_strcmp(p_temp + 1, parent/*".."*/) == 0)
      {
        p_temp[0] = 0/*'\0'*/;
        p_temp = uni_strrchr(cur_path, 0x5c/*'\\'*/);
        if (p_temp != NULL)
        {
          p_temp[0] = 0/*'\0'*/;
        }
      }
      //cur dir
      else if (uni_strlen(p_temp) >= 2 && uni_strcmp(p_temp + 1, curn/*"."*/) == 0)
      {
        p_temp[0] = 0/*'\0'*/;
      }
      else
      {
        return FALSE;
      }
    }
    else
    {
      return FALSE;
    }
  }
  else
  {
    return FALSE;
  }
  return TRUE;
}
Exemplo n.º 15
0
int
MakeRomanStr(int number, uni_char* buf, int buf_len, BOOL upper_case)
{
	if (number <= 0)
		return MakeDecimalStr(number, buf, buf_len);

	OP_ASSERT(buf_len >= 5);

	if (buf_len < 6)
		return 0;

	int str_len = 0;

	if (number >= 4000)
	{
		uni_strcpy(buf, UNI_L("...."));
		return 4;
	}

	*buf = '\0';
	int n = number;

	while (n > 0)
		for (int j=0; j<ROMAN_SIZE; j++)
			if (n >= RomanInt[j])
			{
				int len = uni_strlen(RomanStr[j]);

				if (len < buf_len)
				{
					uni_strcat(buf + str_len, RomanStr[j]);
					n -= RomanInt[j];
					str_len += len;
					buf_len -= len;
					break;
				}
				else
					return str_len;
			}

	if (!upper_case)
		uni_strlwr(buf);

	return str_len;
}
Exemplo n.º 16
0
void SpellUIData::OnMisspellingFound(OpSpellCheckerSession *session, OpSpellCheckerWordIterator *word, const uni_char **replacements)
{
	m_is_valid = TRUE;
	m_word_iterator = word;
	m_is_correct = FALSE;
	int buf_ofs = 0;
	int i;
	for (i = 0; i < SPC_MAX_REPLACEMENTS && replacements[i]; i++)
	{
		int len = uni_strlen(replacements[i]) + 1;
		if (buf_ofs + len > REPLACEMENT_CHAR_BUF_SIZE)
			break;
		m_replacements[i] = m_replacement_char_buf + buf_ofs;
		uni_strcpy(m_replacements[i], replacements[i]);
		buf_ofs += len;
	}
	m_replacement_count = i;
}
Exemplo n.º 17
0
OP_STATUS BookmarkAttribute::SetValue(BookmarkAttribute *attr)
{
	packed.m_attr_type = attr->packed.m_attr_type;

	if (packed.m_owns_text_val)
		OP_DELETEA(m_text_value);
	if (attr->m_text_value)
	{
		m_text_value = OP_NEWA(uni_char, uni_strlen(attr->m_text_value)+1);
		if (!m_text_value)
			return OpStatus::ERR_NO_MEMORY;
		uni_strcpy(m_text_value, attr->m_text_value);
		packed.m_owns_text_val = 1;
	}
	else
		m_text_value = attr->m_text_value;
	m_int_value = attr->m_int_value;
	return OpStatus::OK;
}
Exemplo n.º 18
0
void text_set_content_by_unistr(control_t *p_ctrl, u16 *p_unistr)
{
  u16 **p_temp = NULL;

  MT_ASSERT(p_ctrl != NULL);

  p_temp = (u16 **)_text_get_content_addr(p_ctrl, TEXT_STRTYPE_UNICODE);
  if(p_temp == NULL)
  {
    return;
  }

  *p_temp =
    (u16 *)ctrl_unistr_realloc((void *)(*p_temp), uni_strlen(p_unistr));
  if(*p_temp == NULL)
  {
    return;
  }
  uni_strcpy((u16 *)(*p_temp), p_unistr);
}
Exemplo n.º 19
0
BOOL sbox_set_content_by_unistr(control_t *p_ctrl, u16 item_idx, u16 *p_unistr)
{
  u32 *p_temp = NULL;

  MT_ASSERT(p_ctrl != NULL);

  p_temp = _sbox_get_str_buf(p_ctrl, item_idx, SBOX_STRTYPE_UNICODE);
  if(p_temp == NULL)
  {
    return FALSE;
  }

  *p_temp = (u32)ctrl_unistr_realloc((void *)*p_temp, uni_strlen(p_unistr));
  if((*p_temp) == 0)
  {
    return FALSE;
  }
  uni_strcpy((u16 *)(*p_temp), p_unistr);

  return TRUE;
}
Exemplo n.º 20
0
static RET_CODE on_rename_confirm(control_t *p_cont, u16 msg, u32 para1,
                            u32 para2)
{
  RET_CODE ret = SUCCESS;
  control_t *p_ctrl;
  u16 *unistr;  

  p_ctrl = ctrl_get_child_by_id(p_cont, IDC_RENAME_EBOX);
  unistr = ui_comm_t9edit_get_content(p_ctrl);
  if(uni_strlen(unistr) != 0)
  {
    uni_strcpy(new_name, unistr);

    if(SUCCESS == fw_notify_parent(
      ROOT_ID_RENAME, NOTIFY_T_MSG, TRUE, 
      MSG_RENAME_CHECK, (u32)new_name, 0))//check to invalidation of the new string.
    {
      if (uni_strcmp(new_name, rename_param.uni_str))
      {
        //rename_param.cb(new_name);
        fw_notify_parent(ROOT_ID_RENAME, NOTIFY_T_MSG, FALSE,
          MSG_RENAME_UPDATE, (u32)new_name, 0);
      }
      ret = manage_close_menu(ROOT_ID_RENAME, 0, 0);
    }
    else
    {
      ui_comm_cfmdlg_open(NULL, IDS_MSG_INVALID_NAME, NULL, 0);
    }
  }
  else
  {
    ui_comm_cfmdlg_open(NULL, IDS_MSG_INVALID_NAME, NULL, 0);
  }

  return ret;
}
static void ui_playhist_update_vdo_num(control_t* p_ctrl, u16 vdo_idx, u16 total_vdo)
{
    u16 *p_unistr;
    u16 vdo_num;
    u16 uni_str1[25+1];
    u16 uni_str2[15+1];
    u8  asc_str[15+1];

    OS_PRINTF("@@@ui_playhist_update_vdo_num\n");
    vdo_num = (total_vdo > 0) ? (vdo_idx + 1) : 0;

    memset(uni_str1, 0, sizeof(uni_str1));
    memset(uni_str2, 0, sizeof(uni_str2));
    memset(asc_str, 0, sizeof(asc_str));

    p_unistr = (u16 *)gui_get_string_addr(IDS_HD_RSC_NUM);
    uni_strcpy(uni_str1, p_unistr);

    sprintf(asc_str, ": %d / %d", vdo_num, total_vdo);
    str_asc2uni(asc_str, uni_str2);
    uni_strcat(uni_str1, uni_str2, 25);

    text_set_content_by_unistr(p_ctrl, uni_str1);
}
Exemplo n.º 22
0
static u32 get_new_file(file_list_dir_t *p_flist_dir, media_file_t *p_file)
{
  RET_CODE ret = 0;
  vfs_dir_info_t file_info;
  u32 file_cnt = 0;
  u32 fname_len = 0, fpath_len = 0;
  u16 uni_str[8] = {0};

  file_cnt = 0;
  while (file_cnt < p_flist_dir->unit_cnt)
  {
    ret = vfs_readdir (p_flist_dir->cur_dir, &file_info);

    if (ret != SUCCESS)
     //|| file_info.fname[0] == 0)
    {
      OS_PRINTF("\n##debug: ufs_readdir end!\n");
      break;
    }

    fpath_len = uni_strlen(p_flist_dir->cur_path);
    fname_len = uni_strlen(file_info.fname);

    if(fpath_len + fname_len + 1 <  MAX_FILE_PATH)
    {
      memset(p_file[file_cnt].name, 0, MAX_FILE_PATH * sizeof(u16));
      uni_strcpy(p_file[file_cnt].name, p_flist_dir->cur_path);

      if (p_file[file_cnt].name[uni_strlen(p_file[file_cnt].name) - 1] != 0x5c/*'\\'*/)
      {
        uni_str[0] = 0x5c;
        uni_str[1] = 0;
        uni_strcat(p_file[file_cnt].name, uni_str, MAX_FILE_PATH);
      }

      if ((file_info.fattrib & VFS_DIR) && !is_filter_nodir(p_flist_dir->filter))
      {
        uni_str[0] = 0x2e;
        uni_str[1] = 0;
        if (uni_strcmp(file_info.fname, uni_str))
        {
          uni_strcat(p_file[file_cnt].name, file_info.fname, MAX_FILE_PATH);
          p_file[file_cnt].p_name = uni_strrchr(p_file[file_cnt].name, 0x5c/*'\\'*/) + 1;

          p_file[file_cnt].type = DIRECTORY;
          p_file[file_cnt].size = file_info.fsize;
          p_file[file_cnt].default_order = file_cnt;
          file_cnt ++;
          if (file_cnt >= 2)
          {
            check_dir_order(p_file, file_cnt);
          }
        }
      }
      else if (p_flist_dir->filter[0] == 0/*'\0'*/
        || is_filter_file(p_flist_dir->filter, file_info.fname))
      {
        uni_strcat(p_file[file_cnt].name, file_info.fname, MAX_FILE_PATH);
        p_file[file_cnt].p_name = uni_strrchr(p_file[file_cnt].name, 0x5c/*'\\'*/) + 1;
        p_file[file_cnt].type = NOT_DIR_FILE;
        p_file[file_cnt].size = file_info.fsize;
        p_file[file_cnt].default_order = file_cnt;
        file_cnt ++;
      }
    }
  }

  /*for(c**t = 0;  c**t < (file_cnt + 1); c**t ++)
  {
     p_file[c**t].default_order = c**t;
  }*/

  return file_cnt;
}
Exemplo n.º 23
0
void
WindowsOpFolderLister::UpdateFullPath()
{
	uni_strcpy(m_path + m_path_length, m_find_data.cFileName);
}
Exemplo n.º 24
0
flist_dir_t flist_open_dir(u16 *p_filter, u16 *p_path, u32 *p_total_cnt)
{
  file_list_priv_t *p_priv = NULL;
  flist_dir_priv_t *p_dir_priv = NULL;
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};

  CHECK_FAIL_RET_NULL(p_path != NULL);

  p_priv = class_get_handle_by_id(FILE_LIST_CLASS_ID);
  
  if (p_priv->p_opened_dir)
  {
    OS_PRINTF("\n\n\n##waring:please close/leave dir[0x%x] first!\n", p_priv->p_opened_dir);
  }
  p_dir_priv = mtos_malloc(sizeof(flist_dir_priv_t));
  CHECK_FAIL_RET_NULL(p_dir_priv != NULL);
  memset(p_dir_priv, 0, sizeof(flist_dir_priv_t));

  p_dir_priv->p_flist = NULL;
  p_dir_priv->start_idx = 0;
  p_dir_priv->total_cnt = 0;
  
  uni_strcpy(p_dir_priv->cur_path, p_path);

  if (p_filter != NULL)
  {
    uni_strncpy(p_dir_priv->filter, p_filter, MAX_FILE_PATH);
  }

  p_temp = uni_strrchr(p_dir_priv->cur_path, 0x5c/*'\\'*/);

  if (p_temp != NULL)
  {
    //parent dir
    str_asc2uni("..", parent);
    str_asc2uni(".", curn);
    if (uni_strlen(p_temp) >= 3 && uni_strcmp(p_temp + 1, parent/*".."*/) == 0)
    {
      p_temp[0] = 0/*'\0'*/;
      p_temp = uni_strrchr(p_dir_priv->cur_path, 0x5c/*'\\'*/);
      if (p_temp != NULL)
      {
        p_temp[0] = 0/*'\0'*/;
      }
    }
    //cur dir
    else if (uni_strlen(p_temp) >= 2 && uni_strcmp(p_temp + 1, curn/*"."*/) == 0)
    {
      p_temp[0] = 0/*'\0'*/;
    }
  }

  p_dir_priv->vfs_dir = vfs_opendir (p_dir_priv->cur_path, p_priv->max_support_cnt);
  if (p_dir_priv->vfs_dir == NULL)
  {
    mtos_free(p_dir_priv);
    p_dir_priv = NULL;
    return NULL;
  }
  OS_PRINTF("\n##flist read dir please wait...\n");

  flist_reload_dir(p_dir_priv);
  if (p_total_cnt)
  {
    *p_total_cnt = p_dir_priv->total_cnt;
  }
  p_priv->p_opened_dir = p_dir_priv;
  return (flist_dir_t)p_dir_priv;
}
Exemplo n.º 25
0
static u32 flist_read_dir_one(flist_dir_priv_t *p_flist_dir, media_file_t *p_file)
{
  RET_CODE ret = 0;
  vfs_dir_info_t file_info;
  u32 file_cnt = 0;
  u32 fname_len = 0, fpath_len = 0;
  u16 uni_str[8] = {0};

  while (file_cnt < 1)
  {
    ret = vfs_readdir (p_flist_dir->vfs_dir, &file_info);

    if (ret != SUCCESS)
    {
      OS_PRINTF("\n##debug: ufs_readdir end!\n");
      break;
    }

    fpath_len = uni_strlen(p_flist_dir->cur_path);
    fname_len = uni_strlen(file_info.fname);

    if (fpath_len + fname_len + 1 <  MAX_FILE_PATH)
    {
      if (p_file)
      {
        memset(p_file->name, 0, MAX_FILE_PATH * sizeof(u16));
        uni_strcpy(p_file->name, p_flist_dir->cur_path);

        if (p_file->name[uni_strlen(p_file->name) - 1] != 0x5c/*'\\'*/)
        {
          uni_str[0] = 0x5c;
          uni_str[1] = 0;
          uni_strcat(p_file->name, uni_str, MAX_FILE_PATH);
        }
      }
      
      if ((file_info.fattrib & VFS_DIR) && !is_filter_nodir(p_flist_dir->filter))
      {
        uni_str[0] = 0x2e;
        uni_str[1] = 0;
        if (uni_strcmp(file_info.fname, uni_str))
        {
          if (p_file)
          {
            uni_strcat(p_file->name, file_info.fname, MAX_FILE_PATH);
            p_file->p_name = uni_strrchr(p_file->name, 0x5c/*'\\'*/) + 1;

            p_file->type = DIRECTORY;
            p_file->size = file_info.fsize;
          }
          file_cnt ++;
          break;
        }
      }
      else if ((p_flist_dir->filter[0] == 0 || is_filter_file(p_flist_dir->filter, file_info.fname)))
      {
        if (p_file)
        {
          uni_strcat(p_file->name, file_info.fname, MAX_FILE_PATH);
          p_file->p_name = uni_strrchr(p_file->name, 0x5c/*'\\'*/) + 1;
          p_file->type = NOT_DIR_FILE;
          p_file->size = file_info.fsize;
        }
        file_cnt ++;
        break;
      }
    }
  }

  return file_cnt;
}
Exemplo n.º 26
0
flist_dir_t file_list_enter_dir(u16 *p_filter, u16 unit_cnt, u16 *p_path)
{
  file_list_priv_t *p_priv = NULL;
  file_list_dir_t *p_flist_dir = NULL;
  u16 *p_temp = NULL;
  u16 parent[4] = {0};
  u16 curn[4] = {0};

  CHECK_FAIL_RET_NULL(p_path != NULL);

  if (unit_cnt == 0)
  {
    return NULL;
  }

  p_priv = class_get_handle_by_id(FILE_LIST_CLASS_ID);

  if (p_priv->p_opened_dir)
  {
    OS_PRINTF("\n\n\n##waring:please close/leave dir[0x%x] first!\n", p_priv->p_opened_dir);
  }
  p_flist_dir = mtos_malloc(sizeof(file_list_dir_t));
  CHECK_FAIL_RET_NULL(p_flist_dir != NULL);
  memset(p_flist_dir, 0, sizeof(file_list_dir_t));

  uni_strcpy(p_flist_dir->cur_path, p_path);

  if (p_filter != NULL)
  {
    uni_strncpy(p_flist_dir->filter, p_filter, MAX_FILE_PATH);
  }

  p_flist_dir->unit_cnt = unit_cnt;

  p_temp = uni_strrchr(p_flist_dir->cur_path, 0x5c/*'\\'*/);

  if (p_temp != NULL)
  {
    //parent dir
    str_asc2uni("..", parent);
    str_asc2uni(".", curn);
    if (uni_strlen(p_temp) >= 3 && uni_strcmp(p_temp + 1, parent/*".."*/) == 0)
    {
      p_temp[0] = 0/*'\0'*/;
      p_temp = uni_strrchr(p_flist_dir->cur_path, 0x5c/*'\\'*/);
      if (p_temp != NULL)
      {
        p_temp[0] = 0/*'\0'*/;
      }
    }
    //cur dir
    else if (uni_strlen(p_temp) >= 2 && uni_strcmp(p_temp + 1, curn/*"."*/) == 0)
    {
      p_temp[0] = 0/*'\0'*/;
    }
  }

  p_flist_dir->cur_dir = vfs_opendir (p_flist_dir->cur_path, unit_cnt);
  if (p_flist_dir->cur_dir == NULL)
  {
    mtos_free(p_flist_dir);
    p_flist_dir = NULL;
  }
  p_priv->p_opened_dir = p_flist_dir;
  return (flist_dir_t)p_flist_dir;
}
Exemplo n.º 27
0
OP_STATUS HTMLify_DoEscape(uni_char *&target, const uni_char *content, int len, BOOL no_link, BOOL use_xml, int flowed_mail, BOOL smileys) //flowed_mail: 0:Not flowed, 1:Flowed, 2:Flowed,DelSp=Yes
{
    target = NULL;
    int target_capacity = 0;
    int target_used = 0;
    RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, 0, max(10,(int)(len*1.1))));

    const char *tag;
    int taglen = 0;

    uni_char temp0;
    const uni_char *urlstart = content;
    uni_char* content_ptr = (uni_char*)content;

    int quote_depth = 0;
    while (quote_depth<len && *(content_ptr+quote_depth)=='>') quote_depth++;

    while(len > 0)
    {
//		BOOL next_first_on_line = FALSE;
        temp0 = *content_ptr;

        if(!no_link && temp0 == ':')
        {
            *((uni_char *)content_ptr) = '\0';
            int scheme_len = uni_strlen(urlstart);
            URLType url_type = urlManager->MapUrlType(urlstart);
            *((uni_char *)content_ptr) = ':';

            uni_char* start_of_url = (uni_char*)(content_ptr+1);
            if ((flowed_mail>=1 && *start_of_url==' ' && (*(start_of_url+1)=='\r' || *(start_of_url+1)=='\n')) ||
                    (flowed_mail>=2 && *start_of_url==' ' && *(start_of_url+1)==' ' && (*(start_of_url+2)=='\r' || *(start_of_url+2)=='\n')))
            {
                while (*start_of_url==' ') start_of_url++;
                if (*start_of_url=='\r') start_of_url++;
                if (*start_of_url=='\n') start_of_url++;
                while (*start_of_url=='>')
                {
                    start_of_url++;
                    if (*start_of_url==' ') start_of_url++;
                }
            }

            if (url_type != URL_UNKNOWN && *start_of_url!=' ' && *start_of_url!='\r' && *start_of_url!='\n')
            {
                BOOL in_rfc1738_url = FALSE;
                BOOL has_left_paranthese = FALSE;

                //Do we have a <URL: http:// >-link, as defined in Appendix in RFC1738?
                uni_char* temp = (uni_char*)urlstart;
                while (temp>content && (*(temp-1)==' ' || ((flowed_mail>=1 && *(temp-1)=='\r') || *(temp-1)=='\n'))) temp--;
                if ((temp-5)>=content && uni_strnicmp(temp-5, UNI_L("<URL:"), 5)==0)
                    in_rfc1738_url = TRUE;

                target[target_used-scheme_len] = 0; //Remove already appended scheme
                target_used -= scheme_len;

                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, (use_xml ? 14 : 9) + scheme_len));
                uni_strcpy(target+target_used, (use_xml ? UNI_L("<html:a href=\""): UNI_L("<a href=\"")));
                target_used += (use_xml ? 14 : 9);
                uni_strncpy(target+target_used, urlstart, scheme_len); // NULL-termination OK
                target_used += scheme_len;

                //while (len>0 && !isspace(*content_ptr) &&
                while (len>0 && !(((unsigned int) *content_ptr) < 256 && uni_isspace(*content_ptr)) &&
                        *content_ptr != '"' && *content_ptr != '>')
                {
                    if(*content_ptr == '<')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&lt;"));
                        target_used += 4;
                    }
                    else if(*content_ptr == '&')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 5));
                        uni_strcpy(target+target_used, UNI_L("&amp;"));
                        target_used += 5;
                    }
                    else if(*content_ptr == '"')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 6));
                        uni_strcpy(target+target_used, UNI_L("&quot;"));
                        target_used += 6;
                    }
                    else if(((unsigned int) *content_ptr) < 256 && uni_iscntrl(*content_ptr) && (!uni_isspace(*content_ptr)  || *content_ptr == 0x0c || *content_ptr == 0x0b))
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
                        target[target_used++] = '%';
                        target[target_used++] = UriEscape::EscapeFirst((char)(*content_ptr));
                        target[target_used++] = UriEscape::EscapeLast((char)(*content_ptr));
                    }
                    else
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *content_ptr;
                    }
                    if (*content_ptr == '(')
                        has_left_paranthese = TRUE;

                    content_ptr++;
                    len--;

                    if ( (in_rfc1738_url && (*content_ptr=='\r' || *content_ptr=='\n')) ||
                            (flowed_mail>=1 && *content_ptr==' ' && len>1 && (*(content_ptr+1)=='\r' || *(content_ptr+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        const uni_char* tmp_linebreak = content_ptr;
                        int tmp_len = len;
                        int tmp_quote_depth = 0;

                        if (*content_ptr==' ' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\r' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\n' && len>0) {
                            content_ptr++;
                            len--;
                        }
                        while (*content_ptr=='>' && len>0) {
                            content_ptr++;
                            len--;
                            tmp_quote_depth++;
                        }
                        if (tmp_quote_depth == quote_depth)
                        {
                            if ((tmp_quote_depth>0 || flowed_mail>=1) && *content_ptr==' ' && len>0) {
                                content_ptr++;    //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                                len--;
                            }
                        }
                        else //New quote-depth. Link should not go across linebreak. Restore values
                        {
                            len = tmp_len;
                            content_ptr = (uni_char*)tmp_linebreak;
                        }
                    }
                }

                if (!in_rfc1738_url)
                {
                    //Remove ".,?!" from end of URL, it is probably part of text content
                    uni_char url_end_hack;
                    while ((url_end_hack=*(content_ptr-1))=='.' ||
                            url_end_hack==',' ||
                            url_end_hack=='?' ||
                            url_end_hack=='!' ||
                            (url_end_hack==')' && !has_left_paranthese))
                    {
                        content_ptr--;
                        len++;
                        target[target_used--] = 0;
                    }
                }

                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 2));
                uni_strcpy(target+target_used, UNI_L("\">"));
                target_used += 2;

                uni_char* linebreak = NULL; //Points to last linebreak in a multiline URL
                while (urlstart < content_ptr)
                {
                    if(*urlstart == '<')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&lt;"));
                        target_used += 4;
                    }
                    else if(*urlstart == '&')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 5));
                        uni_strcpy(target+target_used, UNI_L("&amp;"));
                        target_used += 5;
                    }
                    else if(*urlstart == '"')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 6));
                        uni_strcpy(target+target_used, UNI_L("&quot;"));
                        target_used += 6;
                    }
                    else if(((unsigned int) *urlstart) < 256 && ((uni_iscntrl(*urlstart) && !!uni_isspace(*urlstart)) || !op_isprint(*urlstart) || *urlstart == 0x0c || *urlstart == 0x0b))
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
                        target[target_used++] = '%';
                        target[target_used++] = UriEscape::EscapeFirst((char)(*urlstart));
                        target[target_used++] = UriEscape::EscapeLast((char)(*urlstart));
                    }
                    else
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *urlstart;
                    }

                    urlstart++;

                    if ( (in_rfc1738_url && (*urlstart=='\r' || *urlstart=='\n')) ||
                            (flowed_mail>=1 && *urlstart==' ' && (*(urlstart+1)=='\r' || *(urlstart+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        int tmp_quote_depth = 0;
                        if (!(flowed_mail>=1 && *urlstart==' ')) //Linebreaks in flowed content should not be counted
                            linebreak = (uni_char*)urlstart;

                        if (*urlstart==' ' && urlstart<content_ptr) urlstart++;
                        if (*urlstart=='\r' && urlstart<content_ptr) urlstart++;
                        if (*urlstart=='\n' && urlstart<content_ptr) urlstart++;
                        while (*urlstart=='>' && urlstart<content_ptr) {
                            urlstart++;
                            tmp_quote_depth++;
                        }
                        if ((tmp_quote_depth>0 || flowed_mail>=1) && *urlstart==' ' && urlstart<content_ptr) urlstart++;
                    }
                }
                RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, use_xml ? 9 : 4));
                uni_strcpy(target+target_used, (use_xml ? UNI_L("</html:a>") : UNI_L("</a>")));
                target_used += (use_xml ? 9 : 4);

                if (in_rfc1738_url)
                {
                    BOOL has_linebreak = FALSE;
                    if (*content_ptr=='\r' && len>0) {
                        linebreak = content_ptr++;
                        len--;
                        has_linebreak=TRUE;
                    }
                    if (*content_ptr=='\n' && len>0) {
                        linebreak = content_ptr++;
                        len--;
                        has_linebreak=TRUE;
                    }
                    while (*content_ptr==' ' && len>0)
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *(content_ptr++);
                        len--;
                    }

                    if (has_linebreak && *content_ptr=='>' && len>3)
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&gt;"));
                        target_used += 4;
                        OP_ASSERT(0); //len -= 4 ?
                        len-=4;
                        content_ptr++;
                    }

                    if ( (*content_ptr=='\r' || *content_ptr=='\n') ||
                            (flowed_mail>=1 && *content_ptr==' ' && (*(content_ptr+1)=='\r' || *(content_ptr+1)=='\n')) ) //Two spaces and DelSp=yes (flowed_mail==2) should not be handled here
                    {
                        int tmp_quote_depth = 0;
                        linebreak = (uni_char*)content_ptr;
                        if (*content_ptr==' ') {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\r') {
                            content_ptr++;
                            len--;
                        }
                        if (*content_ptr=='\n') {
                            content_ptr++;
                            len--;
                        }
                        while (*content_ptr=='>') {
                            content_ptr++;
                            len--;
                            tmp_quote_depth++;
                        }
                        if ((tmp_quote_depth>0 || flowed_mail>=1) && *content_ptr==' ') {
                            content_ptr++;
                            len--;
                        }
                    }
                }

                if (linebreak) //We had a linebreak in the URL. Insert linebreak after link-tag
                {
                    int tmp_quote_depth = 0;

                    if (*linebreak==' ') linebreak++;
                    RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 2));
                    if (*linebreak=='\r') *(target+(target_used++)) = *(linebreak++);
                    if (*linebreak=='\n') *(target+(target_used++)) = *(linebreak++);

                    while (*linebreak=='>')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 4));
                        uni_strcpy(target+target_used, UNI_L("&gt;"));
                        target_used += 4;
                        linebreak++;
                        tmp_quote_depth++;
                    }
                    if ((tmp_quote_depth>0 || flowed_mail>=1) && *linebreak==' ')
                    {
                        RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
                        target[target_used++] = *(linebreak++);
                    }
                }

                urlstart = content_ptr;
                continue;
            }
        }
        tag = NULL;

#ifdef SMILEY_SUPPORT
        OpString8 smiley_tag;
#endif // SMILEY_SUPPORT

        switch(*content_ptr)
        {
        case '"' :
            tag = "&quot;";
            taglen = 6;
            break;
        case '&' :
            tag = "&amp;";
            taglen = 5;
            break;
        case '<' :
            tag = "&lt;";
            taglen = 4;
            break;
        case '>' :
            tag = "&gt;";
            taglen = 4;
            break;
        default:
#ifdef SMILEY_SUPPORT
            if (smileys)
            {
                INT32 smiley_len = GetSmiley(content_ptr, smiley_tag, taglen, content, len, use_xml);

                if (smiley_len)
                {
                    smiley_len--;
                    content_ptr += smiley_len;
                    len -= smiley_len;
                    tag = smiley_tag.CStr();
                }
            }
#endif // SMILEY_SUPPORT
            break;
        }

        if(tag)
        {
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, taglen));
            uni_char *copy_dest = target+target_used;
            target_used += taglen;
            for (int i=taglen; i; i--)
            {
                *copy_dest++ = *tag++;
            }
        }
        else if(*content_ptr < 128 &&
                (!uni_isspace(*content_ptr) || *content_ptr == 0x0c || *content_ptr == 0x0b) && (uni_iscntrl(*content_ptr)   || !op_isprint(*content_ptr)) )
        {
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 3));
            target[target_used++] = '%';
            target[target_used++] = UriEscape::EscapeFirst((char)(*content_ptr));
            target[target_used++] = UriEscape::EscapeLast((char)(*content_ptr));
        }
        else
        {
            if (*content_ptr=='\r' || *content_ptr=='\n')
            {
                quote_depth = 1; //For optimization, add one extra here, and remove it again after loop
                while (quote_depth<len && content_ptr[quote_depth]=='>') quote_depth++;
                quote_depth--;
            }
            RETURN_IF_ERROR(HTMLify_GrowStringIfNeeded(target, target_capacity, target_used, 1));
            target[target_used++] = *content_ptr;
        }

        content_ptr++;
        //if(!isalnum(temp0) && temp0 != '+' && temp0 != '-' && temp0 != '.')
        if(!uni_isalnum(temp0) && temp0 != '+' && temp0 != '-' && temp0 != '.') // 01/04/98 YNP
        {
            urlstart = content_ptr;
        }

        len --;
    }

    target[target_used] = 0;

    return OpStatus::OK;
}
Exemplo n.º 28
0
void SetDataFromItemData(const BookmarkItemData* item_data, BookmarkItem* bookmark)
{
	if (!bookmark || !item_data) return;

	// these 2 attributes must exist, as they have a different default value with others. (-1)
	::SetAttribute(bookmark, BOOKMARK_PERSONALBAR_POS, -1);
	::SetAttribute(bookmark, BOOKMARK_PANEL_POS, -1);	

	::SetAttribute(bookmark, BOOKMARK_URL,			item_data->url);
	::SetAttribute(bookmark, BOOKMARK_TITLE,		item_data->name);
	::SetAttribute(bookmark, BOOKMARK_DESCRIPTION,	item_data->description);
	::SetAttribute(bookmark, BOOKMARK_SHORTNAME,	item_data->shortname);
	::SetAttribute(bookmark, BOOKMARK_CREATED,		item_data->created);
	::SetAttribute(bookmark, BOOKMARK_VISITED,		item_data->visited);
	::SetAttribute(bookmark, BOOKMARK_TARGET,		item_data->target);
	::SetAttribute(bookmark, BOOKMARK_PERSONALBAR_POS,item_data->personalbar_position);
	::SetAttribute(bookmark, BOOKMARK_PANEL_POS,	item_data->panel_position);
	::SetAttribute(bookmark, BOOKMARK_ACTIVE,		item_data->active);
	::SetAttribute(bookmark, BOOKMARK_EXPANDED,		item_data->expanded);
	::SetAttribute(bookmark, BOOKMARK_SMALLSCREEN,	item_data->small_screen);
	::SetAttribute(bookmark, BOOKMARK_SHOW_IN_PERSONAL_BAR,item_data->personalbar_position >= 0);
	::SetAttribute(bookmark, BOOKMARK_SHOW_IN_PANEL,item_data->panel_position >= 0);
	::SetAttribute(bookmark, BOOKMARK_PARTNER_ID,	item_data->partner_id);
	::SetAttribute(bookmark, BOOKMARK_DISPLAY_URL,	item_data->display_url);

	// icon
	Image icon = g_favicon_manager->Get(item_data->url);
	OpString16 base64;
	OpBitmap *bitmap = icon.GetBitmap(NULL);
	if (bitmap)
	{
		TempBuffer buffer;
		if(OpStatus::IsSuccess(GetOpBitmapAsBase64PNG(bitmap, &buffer)))
		{
			if(OpStatus::IsSuccess(base64.Set(buffer.GetStorage(), buffer.Length())))
			{
				::SetAttribute(bookmark, BOOKMARK_FAVICON_FILE, base64);
			}
		}
		icon.ReleaseBitmap();
	}
	if (item_data->unique_id.HasContent())
	{
		OpString tmp;
		tmp.Set(item_data->unique_id);
		uni_char* uni_unique_id = OP_NEWA(uni_char, (tmp.Length()+1));
		if (uni_unique_id)
		{
			uni_strcpy(uni_unique_id, tmp.CStr());
			bookmark->SetUniqueId(uni_unique_id);
		}
	}

	bookmark->SetMaxCount(item_data->max_count);
	bookmark->SetMoveIsCopy(item_data->move_is_copy);
	bookmark->SetSubFoldersAllowed(item_data->subfolders_allowed);
	bookmark->SetSeparatorsAllowed(item_data->separators_allowed);
	bookmark->SetDeletable(item_data->deletable);

	bookmark->SetFolderType(item_data->type);
}
Exemplo n.º 29
0
uni_char*
Debug::InitSettings(const char* filename)
{
	// Load settings from file

	OpFile f;
	OpFile* in = &f;
	uni_char* uf = uni_up_strdup(filename);
	BOOL ok = uf && OpStatus::IsSuccess(in->Construct(uf));
	ok = ok && OpStatus::IsSuccess(in->Open(OPFILE_READ));
	op_free(uf);
	if (!ok)
	{
		uni_char* ufilename = uni_up_strdup(filename);
		if ( ufilename == 0 )
			return 0;

		const uni_char* full_path_and_name = f.GetFullPath();
		if (!full_path_and_name || !*full_path_and_name)
			full_path_and_name = ufilename;
		uni_char* buf = OP_NEWA(uni_char, 100 + uni_strlen(full_path_and_name));
		if ( buf != 0 )
			uni_sprintf(buf, UNI_L("Could not open debug settings file: %s"),
			full_path_and_name);
		op_free(ufilename);
		return buf;
	}

#define READLINE_BUFFER_SIZE 300

	uni_char str[READLINE_BUFFER_SIZE]; // ARRAY OK 2007-03-09 mortenro
	uni_char* tmp;
	int sLen;

	BOOL clearfile = FALSE;

	// Read all lines in file
	while (ReadLine(in, str, READLINE_BUFFER_SIZE))
	{
		if (*str == 0)
			continue;

		// Skip whitespace in the beginning of the line
		while (str[0] == ' ' || str[0] == '\t')
			uni_strcpy(str, str+1);

		if (*str == 0)
			continue;

		// Skip \r character at end of line
		if (str[uni_strlen(str) - 1] == '\r')
			str[uni_strlen(str) - 1] = '\0';

		if (*str == 0)
			continue;

		// Skip whitespace in the end of the line
		while (*str && (str[uni_strlen(str) - 1] == ' ' || str[uni_strlen(str) - 1] == '\t'))
			str[uni_strlen(str) - 1] = '\0';

		sLen = uni_strlen(str);

		if (sLen == 0)
			continue;

		// Skip lines starting with #
		if (*str == '#')
			continue;

		// Make all chars before equal sign lower case so we don't need to use FindI
		// which uses a table manager.
		uni_char* eq = uni_strstr(str, UNI_L("="));
		int eq_pos = -1;
		if (eq)
		{
			eq_pos = eq - str;

			for (int i=0; i < eq_pos && i < sLen; ++i)
			{
				str[i] = uni_tolower(str[i]);
			}
		}

		// Check for output=filename
		tmp = uni_strstr(str, UNI_L("output="));
		if (tmp)
		{
			tmp += 7;
			if (*tmp)
			{
				Debug::SetOutputFile(tmp);
			}
			continue;
		}

		// Check for clearfile=[on/off]
		tmp = uni_strstr(str, UNI_L("clearfile=on"));
		if (tmp == str)
		{
			clearfile = TRUE;
			continue;
		}

		// Check for debugging=[on/off]
		tmp = uni_strstr(str, UNI_L("debugging=on"));
		if (tmp == str)
		{
			g_dbg_debugging = TRUE;
			continue;
		}

		// Check for tracing=[on/off]
		tmp = uni_strstr(str, UNI_L("tracing=on"));
		if (tmp == str)
		{
			g_dbg_tracing = TRUE;
			continue;
		}

		// Check for prefix=off
		tmp = uni_strstr(str, UNI_L("prefix=off"));
		if (tmp == str)
		{
			g_dbg_prefix = FALSE;
			continue;
		}

		// Check for timing=[on/off]
		tmp = uni_strstr(str, UNI_L("timing=on"));
		if (tmp == str)
		{
			g_dbg_timing = TRUE;
			continue;
		}

		// Check for timestamp=[on/off]
		tmp = uni_strstr(str, UNI_L("timestamp=on"));
		if (tmp == str)
		{
			g_dbg_timestamp = TRUE;
			continue;
		}

		// Check for systemdebug=[on/off]
		tmp = uni_strstr(str, UNI_L("systemdebug=on"));
		if (tmp == str)
		{
			g_dbg_system_debug = TRUE;
			continue;
		}

		// Check for console=[on/off]
		tmp = uni_strstr(str, UNI_L("console=on"));
		if (tmp == str)
		{
			g_dbg_console = TRUE;
			continue;
		}

		// Add keyword
		if (uni_str_eq(str, "*")) 
			g_dbg_all_keywords = TRUE;
		else
			Debug::AddKeyword(str);
	}
	in->Close();

	// Clear output file if specified
	if (clearfile && g_dbg_filename && *g_dbg_filename)
	{
		uni_char* uf = uni_up_strdup(g_dbg_filename);
		if (uf)
		{
			OpFile f;
			f.Construct(uf);
			f.Open(OPFILE_WRITE);
			f.Close();
			op_free(uf);
		}
	}

	return NULL;
}