本文整理汇总了C++中URL::GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ URL::GetAttribute方法的具体用法?C++ URL::GetAttribute怎么用?C++ URL::GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsResumableURL
bool IsResumableURL(const URL& url)
{
OP_ASSERT(url.GetAttribute(URL::KMultimedia) != FALSE);
// Not using URL::KResumeSupported as it is set to Probably_Resumable
// when the Accept-Ranges: bytes header is present. Since we always
// make byte range requests, the response code is a better indicator.
int response = url.GetAttribute(URL::KHTTP_Response_Code, URL::KFollowRedirect);
return response == HTTP_PARTIAL_CONTENT;
}
示例2:
/**
* Check if the given file: URL is an allowed stylesheet import inside the
* generated document for an XML parse error. Only allowed if it is
* equal to the underlying pref or that of the 'standard' opera.css.
*
* @param the target URL being loaded inline.
* @return OpBoolean::IS_TRUE if allowed, OpBoolean::IS_FALSE.
* OpStatus::ERR_NO_MEMORY on OOM.
*/
static OP_BOOLEAN
IsAllowedStyleFileImport(const URL &url)
{
OpString file_path;
RETURN_IF_ERROR(url.GetAttribute(URL::KUniName, file_path));
OpString xmlerror_css;
RETURN_IF_LEAVE(g_pcfiles->GetFileURLL(PrefsCollectionFiles::StyleErrorFile, &xmlerror_css));
if (file_path.Compare(xmlerror_css) == 0)
return OpBoolean::IS_TRUE;
/* This is not complete, but we do also allow the importing
of the style folder's opera.css. Clearly someone could
provide a custom error.css that has an arbitrary collection
of imports. This will not work for generated XML error pages. */
OpFile opera_css;
RETURN_IF_ERROR(opera_css.Construct(UNI_L("opera.css"), OPFILE_STYLE_FOLDER));
const uni_char *path = opera_css.GetFullPath();
TempBuffer escaped_path;
RETURN_IF_ERROR(escaped_path.Expand(uni_strlen(path) * 3 + 1));
UriEscape::Escape(escaped_path.GetStorage(), path, UriEscape::Filename);
OpString opera_css_file;
RETURN_IF_LEAVE(g_url_api->ResolveUrlNameL(escaped_path.GetStorage(), opera_css_file));
if (file_path.Compare(opera_css_file) == 0)
return OpBoolean::IS_TRUE;
return OpBoolean::IS_FALSE;
}
示例3:
URL
MediaSourceManagerImpl::GetUrlWithMediaContext(const URL& url)
{
// Don't override anything but the default context for now.
if (url.GetContextId() != 0)
return url;
// Create new context manager if it doesn't exists already.
if (!m_url_context_id)
{
m_url_context_id = urlManager->GetNewContextID();
OpFileFolder media_cache_folder;
if (OpStatus::IsError(g_folder_manager->AddFolder(OPFILE_CACHE_FOLDER, UNI_L("media"), &media_cache_folder)))
{
OP_ASSERT(!"Failed to create folder for dedicated media cache. Falling back to default");
return url;
}
Context_Manager_Multimedia::CreateManager(m_url_context_id, media_cache_folder, media_cache_folder, FALSE, PrefsCollectionNetwork::MediaCacheSize);
}
// Create new url with the media context.
const OpStringC tmp_url_str
= url.GetAttribute(URL::KUniName_With_Fragment_Username_Password_NOT_FOR_UI,
URL::KNoRedirect);
return g_url_api->GetURL(tmp_url_str, m_url_context_id);
}
示例4: IsSuccessURL
bool IsSuccessURL(const URL& url)
{
if (url.IsEmpty())
return false;
switch (url.Type())
{
case URL_HTTP:
case URL_HTTPS:
switch (url.GetAttribute(URL::KHTTP_Response_Code))
{
case HTTP_OK:
case HTTP_PARTIAL_CONTENT:
case HTTP_NOT_MODIFIED:
return true;
default:
return false;
}
case URL_FTP:
case URL_FILE:
case URL_DATA:
case URL_WIDGET:
return true;
default:
return false;
}
}
示例5: HasCachedBGImageData
/* virtual */
BOOL DocumentInteractionContext::HasCachedBGImageData()
{
if (m_doc)
{
URL url = m_doc->GetBGImageURL();
return !url.IsEmpty() && url.GetAttribute(URL::KIsImage, TRUE);
}
return FALSE;
}
示例6: Redirected
virtual BOOL Redirected(XMLParser *parser)
{
URL url = parser->GetURL().GetAttribute(URL::KMovedToURL, FALSE);
while (!url.IsEmpty())
if (!DOM_XSLTAllowAccess(OpSecurityManager::XSLT_IMPORT_OR_INCLUDE, thread->GetScheduler()->GetFramesDocument(), url))
return FALSE;
else
url = url.GetAttribute(URL::KMovedToURL, FALSE);
return TRUE;
}
示例7: OnDragDrop
void TransfersPanel::OnDragDrop(OpWidget* widget,
OpDragObject* op_drag_object,
INT32 pos,
INT32 x,
INT32 y)
{
DesktopDragObject* drag_object = static_cast<DesktopDragObject *>(op_drag_object);
if( KioskManager::GetInstance()->GetNoDownload() )
{
return;
}
if (drag_object->GetURL())
{
// start download to download directory
// We could also check on url-type here, if it was a directory it could be traversed
// and the whole directory tree could be put into the transferqueue. We should have
// a better queueing system before this is added though. (Max simultaneous transfers,
// with a stack on the side.)
OpTransferItem* item;
OpString filename;
URL durl = g_url_api->GetURL(drag_object->GetURL());
OpString tmp_storage;
const OpStringC downloaddirectory = g_folder_manager->GetFolderPathIgnoreErrors(OPFILE_DOWNLOAD_FOLDER, tmp_storage);
filename.Set(downloaddirectory);
OpString tmp;
TRAPD(op_err, durl.GetAttribute(URL::KSuggestedFileName_L, tmp, TRUE));
filename.Append(tmp);
durl.LoadToFile(filename.CStr());
// need to set the timestamp, this is used for expiry in list when read from rescuefile
time_t loaded = (time_t) (g_op_time_info->GetTimeUTC()/1000.0);
durl.SetAttribute(URL::KVLocalTimeLoaded, &loaded);
if(OpStatus::IsError(((TransferManager*)g_transferManager)->AddTransferItem(durl, filename.CStr())))
{
return;
}
((TransferManager*)g_transferManager)->GetTransferItem(&item, drag_object->GetURL());
item->Continue();
}
}
示例8: UpdateExtensionView
OP_STATUS SpeedDialConfigController::UpdateExtensionView(unsigned pos,
const OpStringC& name, const URL& download_url,
const URL& screenshot_url)
{
OP_NEW_DBG("SpeedDialConfigController::UpdateExtensionView", "speeddial");
OP_DBG(("pos = ") << pos);
OP_DBG(("download URL = ") << download_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI));
OP_DBG(("screenshot URL = ") << screenshot_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI));
OP_ASSERT(pos < ARRAY_SIZE(m_extension_views));
if (OpStatus::IsError(m_extension_views[pos].m_image_downloader.Init(screenshot_url)))
m_extension_views[pos].DownloadFailed();
m_extension_views[pos].m_button->GetOpWidget()->GetAction()->SetActionDataString(
download_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI));
RETURN_IF_ERROR(m_extension_views[pos].m_name->SetText(name));
// Invisible, but useful for Watir tests.
RETURN_IF_ERROR(m_extension_views[pos].m_button->GetOpWidget()->SetText(name));
return OpStatus::OK;
}
示例9: cmessage
/* static */ void
ES_ImportedAPI::PostToConsole(const uni_char* message, FramesDocument* fd)
{
if (!g_console->IsLogging())
return;
URL* url = NULL;
const uni_char *url_name = UNI_L("Script of unknown origin");
if (fd != NULL)
{
url = &fd->GetURL();
url_name = url->GetAttribute(URL::KUniName_Username_Password_Hidden).CStr();
}
OpConsoleEngine::Message cmessage(OpConsoleEngine::EcmaScript, OpConsoleEngine::Error);
OP_STATUS rc1, rc2, rc3;
rc1 = cmessage.message.Set(message);
if (url)
{
if (0 == uni_strcmp(url_name, UNI_L("POSTED")))
{
// Message from opera.postError()
cmessage.url.Empty();
cmessage.severity = OpConsoleEngine::Information;
rc2 = OpStatus::OK;
}
else
rc2 = cmessage.url.Set(url_name);
}
else
rc2 = cmessage.url.Set(url_name);
if (fd && fd->GetWindow())
cmessage.window = fd->GetWindow()->Id();
if (fd && fd->GetESScheduler())
rc3 = cmessage.context.Set(fd->GetESScheduler()->GetThreadInfoString());
else
rc3 = cmessage.context.Set("Unknown thread");
if (OpStatus::IsSuccess(rc1) && OpStatus::IsSuccess(rc2) &&
OpStatus::IsSuccess(rc3))
{
TRAPD(rc, g_console->PostMessageL(&cmessage));
OpStatus::Ignore(rc); // FIXME:OOM
}
}
示例10: ExecuteTransferItem
void TransfersPanel::ExecuteTransferItem(TransferItem * t_item)
{
if(!t_item)
return;
OpString filename;
if(t_item->GetType() == TransferItem::TRANSFERTYPE_PEER2PEER_DOWNLOAD)
{
t_item->GetDownloadDirectory(filename);
UINT32 idx = filename.FindLastOf(PATHSEPCHAR);
if(idx + 1 != 0)
{
filename.Append(PATHSEP);
}
filename.Append(*(t_item->GetStorageFilename()));
}
else
{
filename.Set(*(t_item->GetStorageFilename()));
}
if(!filename.IsEmpty())
{
#ifdef MSWIN
Execute(filename.CStr(), NULL);
#else
OpString handler;
OpString content_type;
URL* url = t_item->GetURL();
if(url)
{
content_type.Set(url->GetAttribute(URL::KMIME_Type));
}
g_op_system_info->GetFileHandler(&filename, content_type, handler);
static_cast<DesktopOpSystemInfo*>(g_op_system_info)->OpenFileInApplication(
handler.CStr(), filename.CStr());
#endif
}
}
示例11: OnSetValue
OP_STATUS URL_DynamicUIntAttributeDescriptor::OnSetValue(URL &url, URL_DataStorage *url_ds, uint32 &in_out_value, BOOL &set_value) const
{
set_value = FALSE;
if(handler.get() != NULL)
{
OP_STATUS op_err = handler->OnSetValue(url, in_out_value, set_value);
if(OpStatus::IsSuccess(op_err) && is_flag && set_value)
{
uint32 mask_set = 0;
if(in_out_value != 0)
{
in_out_value = TRUE;
mask_set = flag_mask;
}
uint32 current_flags;
#ifdef SELFTEST
// Hack to allow selftests to test directly */
if(url_ds == NULL)
current_flags = url.GetAttribute(flag_attribute_id);
else
#endif
current_flags = url_ds->GetAttribute(flag_attribute_id);
current_flags = (current_flags & (~flag_mask)) | mask_set;
#ifdef SELFTEST
// Hack to allow selftests to test directly */
if(url_ds == NULL)
op_err = url.SetAttribute(flag_attribute_id, current_flags);
else
#endif
op_err = url_ds->SetAttribute(flag_attribute_id, current_flags);
set_value = FALSE;
}
return op_err;
}
return OpStatus::OK;
}
示例12: OnGetValue
OP_STATUS URL_DynamicUIntAttributeDescriptor::OnGetValue(URL &url, uint32 &in_out_value) const
{
if(handler.get() != NULL)
{
if(is_flag)
{
uint32 current_flags = url.GetAttribute(flag_attribute_id);
in_out_value = ((current_flags & flag_mask) != 0 ? TRUE : FALSE);
}
OP_STATUS op_err = handler->OnGetValue(url, in_out_value);
if(OpStatus::IsSuccess(op_err) && is_flag && in_out_value)
in_out_value = TRUE;
return op_err;
}
return OpStatus::OK;
}
示例13: DoWidgetSpecificHacks
void WidgetCreator::DoWidgetSpecificHacks(OpHelpTooltip* tooltip)
{
if (OpStatus::IsSuccess(tooltip->Init()))
{
if (m_action && m_action->HasActionDataString())
{
URL url = g_url_api->GetURL(m_action->GetActionDataString());
OpString8 host_name;
if (OpStatus::IsSuccess(url.GetAttribute(URL::KHostName, host_name))
&& host_name.HasContent())
{
tooltip->SetHelpUrl(m_action->GetActionDataString());
}
else
{
tooltip->SetHelpTopic(m_action->GetActionDataString());
}
}
tooltip->SetVisibility(FALSE);
}
}
示例14: GetButtonInfo
OP_STATUS SpeedDialGenericHandler::GetButtonInfo(GenericThumbnailContent::ButtonInfo& info) const
{
info.m_name.Empty();
RETURN_IF_ERROR(info.m_name.AppendFormat("Speed Dial %d", GetNumber()));
info.m_accessibility_text.Empty();
RETURN_IF_ERROR(info.m_accessibility_text.AppendFormat(
UNI_L("Thumbnail %d"), GetNumber()));
info.m_action = OpInputAction::ACTION_GOTO_SPEEDDIAL;
info.m_action_data = g_speeddial_manager->GetSpeedDialActionData(m_entry);
OpString tooltip_format;
RETURN_IF_ERROR(g_languageManager->GetString(Str::S_CLICK_TO_GO_TO_SPEED_DIAL_ENTRY, tooltip_format));
const URL url = urlManager->GetURL(m_entry->GetDisplayURL());
OpString url_string;
RETURN_IF_ERROR(url.GetAttribute(URL::KUniName_With_Fragment_Username, url_string));
RETURN_IF_ERROR(info.m_tooltip_text.AppendFormat(tooltip_format.CStr(), url_string.CStr()));
return OpStatus::OK;
}
示例15: ReportFailure
void BasicWindowListener::ReportFailure(URL &url, const char *format, ...)
{
OpString8 tempstring;
va_list args;
va_start(args, format);
if(format == NULL)
format = "";
OP_STATUS op_err = url.GetAttribute(URL::KName_Escaped, tempstring);
if(OpStatus::IsSuccess(op_err))
op_err = tempstring.Append(" :");
if(OpStatus::IsSuccess(op_err))
tempstring.AppendVFormat(format, args);
if(test_manager)
test_manager->ReportTheFailure(OpStatus::IsSuccess(op_err) ? tempstring.CStr() : format);
else
ST_failed(OpStatus::IsSuccess(op_err) ? tempstring.CStr() : format);
va_end(args);
}