void UPhilipsHueBridge::AquireUserID(bool FromFile)
{

	if (FromFile&&GetUserIDFromLocalFile())
	{
		// Test if the User ID stored local is authorized
		auto HttpRequest1 = FHttpModule::Get().CreateRequest();
		{
			HttpRequest1->OnProcessRequestComplete().BindUObject(this, &UPhilipsHueBridge::HandleUserIDTestRequestComplete);
			HttpRequest1->SetURL(FString(TEXT("http://")) + Configuration.IpAddress + TEXT("/api/") + ConnectedUser);
			HttpRequest1->SetVerb(TEXT("GET"));
			HttpRequest1->ProcessRequest();
		}
		return;
	}

	auto HttpRequest = FHttpModule::Get().CreateRequest();
	{
		HttpRequest->OnProcessRequestComplete().BindUObject(this, &UPhilipsHueBridge::HandleUserIDRequestComplete);
		HttpRequest->SetURL(FString(TEXT("http://")) + Configuration.IpAddress + TEXT("/api"));
		HttpRequest->SetHeader("Content-Type", "application/json");
		HttpRequest->SetVerb(TEXT("POST"));
		HttpRequest->SetContentAsString(UserRequestJson());
		HttpRequest->ProcessRequest();
	}
}
示例#2
0
bool FCrashUpload::SendCheckReportRequest()
{
	FString XMLString;

	UE_LOG(CrashReportClientLog, Log, TEXT("Sending HTTP request (checking report)"));
	auto Request = CreateHttpRequest();
	if (State == EUploadState::CheckingReport)
	{
		AssignReportIdToPostDataBuffer();
		Request->SetURL(UrlPrefix / TEXT("CheckReport"));
		Request->SetHeader(TEXT("Content-Type"), TEXT("text/plain; charset=us-ascii"));
	}
	else
	{
		// This part is Windows-specific on the server
		ErrorReport.LoadWindowsReportXmlFile( XMLString );

		// Convert the XMLString into the UTF-8.
		FTCHARToUTF8 Converter( (const TCHAR*)*XMLString, XMLString.Len() );
		const int32 Length = Converter.Length();
		PostData.Reset( Length );
		PostData.AddUninitialized( Length );
		CopyAssignItems( (ANSICHAR*)PostData.GetData(), Converter.Get(), Length );

		Request->SetURL(UrlPrefix / TEXT("CheckReportDetail"));
		Request->SetHeader(TEXT("Content-Type"), TEXT("text/plain; charset=utf-8"));
	}

	UE_LOG( CrashReportClientLog, Log, TEXT( "PostData Num: %i" ), PostData.Num() );
	Request->SetVerb(TEXT("POST"));
	Request->SetContent(PostData);

	return Request->ProcessRequest();
}
示例#3
0
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
    const wxString& label, const wxString& url, const wxPoint& pos,
    const wxSize& size, long style, const wxString& name)
{
    wxASSERT_MSG(!url.empty() || !label.empty(),
                 wxT("Both URL and label are empty ?"));

#ifdef __WXDEBUG__
    int alignment = (int)((style & wxHL_ALIGN_LEFT) != 0) +
                    (int)((style & wxHL_ALIGN_CENTRE) != 0) +
                    (int)((style & wxHL_ALIGN_RIGHT) != 0);
    wxASSERT_MSG(alignment == 1,
        wxT("Specify exactly one align flag!"));
#endif

    if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
        return false;

    // set to non empty strings both the url and the label
    if(url.empty())
        SetURL(label);
    else
        SetURL(url);

    if(label.empty())
        SetLabel(url);
    else
        SetLabel(label);

    m_rollover = false;
    m_clicking = false;
    m_visited = false;

    // colours
    m_normalColour = *wxBLUE;
    m_hoverColour = *wxRED;
    m_visitedColour = wxColour(wxT("#551a8b"));
    SetForegroundColour(m_normalColour);

    // by default the font of an hyperlink control is underlined
    wxFont f = GetFont();
    f.SetUnderlined(true);
    SetFont(f);

    SetInitialSize(size);

    return true;
}
bool CAddressBookDialog::Initialize(HWND hWndParent, IDispatch* pDispatch, bool bShow)
{
	if (::IsWindow(m_hWnd))
		return false;

	if (!pDispatch)
		return false;

	if (!hWndParent)
		hWndParent = ::GetDesktopWindow();

	m_pDisp = pDispatch;
	m_bShowOnInit = bShow;
	Create(hWndParent);
	//HICON hIcon = (HICON)::LoadImage(_AtlBaseModule.GetResourceInstance(),	(LPCTSTR)MAKEINTRESOURCE(IDI_LOGO), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR|LR_SHARED);
	//SetIcon(hIcon, true/*bBigIcon*/);
	//hIcon = (HICON)::LoadImage(_AtlBaseModule.GetResourceInstance(),	(LPCTSTR)MAKEINTRESOURCE(IDI_LOGO), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_SHARED);
	//SetIcon(hIcon, false/*bBigIcon*/);

	// Check registry for latest Host url and
	// Browse, Usage and Upgrade pages. If values
	// are empty in registry the hard coded defaults
	// are used.
	CString szBaseURL;
	ReadRegistryString(REGVAL_ADDRESSBOOK_URL, szBaseURL);
	SetURL(szBaseURL);
	
	return true;
}
示例#5
0
void FCrashUpload::PostReportComplete()
{
	if (PauseState == EUploadState::PostingReportComplete)
	{
		// Wait for confirmation
		SetCurrentState(EUploadState::WaitingToPostReportComplete);
		return;
	}

	AssignReportIdToPostDataBuffer();

	
	auto Request = CreateHttpRequest();
	Request->SetVerb( TEXT( "POST" ) );
	Request->SetURL(UrlPrefix / TEXT("UploadComplete"));
	Request->SetHeader( TEXT( "Content-Type" ), TEXT( "text/plain; charset=us-ascii" ) );
	Request->SetContent(PostData);
	UE_LOG( CrashReportClientLog, Log, TEXT( "Sending HTTP request: %s" ), *Request->GetURL() );

	if (Request->ProcessRequest())
	{
		SetCurrentState(EUploadState::PostingReportComplete);
	}
	else
	{
		CheckPendingReportsForFilesToUpload();
	}
}
示例#6
0
void CWkeWebkitUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
	if (_tcsicmp(pstrName, _T("URL")) == 0)
	{
		SetURL(pstrValue);
	}
	CControlUI::SetAttribute(pstrName,pstrValue);
}
void CAddressBookDialog::Load(LPCTSTR lpszURL)
{
	if (!::IsWindow(m_hWnd))
		return;

	CString szURL = GetURL();
	if (szURL != lpszURL)
		SetURL(lpszURL, TRUE/*bNavigate*/);
}
void WebPageWindow::LoadPage(QString url)
{
    qDebug("in LoadPAge, WebPageWindow");
    SetURL(url);
    if (m_pUrl && ! m_pUrl->isEmpty() && m_pUrl->isValid()){
        ui->m_webView->load(*m_pUrl);
        setWindowTitle(m_pUrl->toString()+" - ReallySimpleReader.");
    }
}
示例#9
0
void CWkeWebkitUI::DoInit()
{
	m_pWindow = new CWkeWebkitWnd();
	if(m_pWindow)
	{
		m_pWindow->Init(this);
		m_pWindow->ShowWindow();
		SetURL(m_startUrl);
	}	
}
示例#10
0
bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
                                    const wxString& label, const wxString& url, const wxPoint& pos,
                                    const wxSize& size, long style, const wxString& name)
{
    // do validation checks:
    CheckParams(label, url, style);

    if ((style & wxHL_ALIGN_LEFT) == 0)
        style |= wxFULL_REPAINT_ON_RESIZE;

    if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
        return false;

    // set to non empty strings both the url and the label
    SetURL(url.empty() ? label : url);
    SetLabel(label.empty() ? url : label);

    m_rollover = false;
    m_clicking = false;
    m_visited = false;

    // colours
    m_normalColour = *wxBLUE;
    m_hoverColour = *wxRED;
    m_visitedColour = wxColour("#551a8b");
    SetForegroundColour(m_normalColour);

    // by default the font of an hyperlink control is underlined
    wxFont f = GetFont();
    f.SetUnderlined(true);
    SetFont(f);

    SetInitialSize(size);


    // connect our event handlers:
    // NOTE: since this class is the base class of the GTK+'s native implementation
    //       of wxHyperlinkCtrl, we cannot use the static macros in BEGIN/END_EVENT_TABLE
    //       blocks, otherwise the GTK+'s native impl of wxHyperlinkCtrl would not
    //       behave correctly (as we intercept events doing things which interfere
    //       with GTK+'s native handling):

    Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) );
    Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) );

    Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) );
    Connect( wxEVT_LEFT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftUp) );
    Connect( wxEVT_RIGHT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnRightUp) );
    Connect( wxEVT_MOTION, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnMotion) );

    Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_COMMAND_MENU_SELECTED,
             wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) );

    return true;
}
示例#11
0
文件: BtnST.cpp 项目: bugou/test
CButtonST::CButtonST()
{
	m_bIsPressed		= FALSE;
	m_bIsFocused		= FALSE;
	m_bIsDisabled		= FALSE;
	m_bMouseOnButton	= FALSE;

	FreeResources(FALSE);

	// Default type is "flat" button
	m_bIsFlat = TRUE;
	// Button will be tracked also if when the window is inactive (like Internet Explorer)
	m_bAlwaysTrack = TRUE;	// @@ I change this default value to TRUE!!!

  
	// By default draw border in "flat" button 
	m_bDrawBorder = TRUE; 
  
	// By default icon is aligned horizontally
	m_byAlign = ST_ALIGN_HORIZ; 
  
	// By default, for "flat" button, don't draw the focus rect
	m_bDrawFlatFocus = FALSE;

	// By default the button is not the default button
	m_bIsDefault = FALSE;
	// Invalid value, since type still unknown
	m_nTypeStyle = BS_TYPEMASK;

	// By default the button is not a checkbox
	m_bIsCheckBox = FALSE;
	m_nCheck = 0;

	// Set default colors
	SetDefaultColors(FALSE);

	// No tooltip created
	m_ToolTip.m_hWnd = NULL;

	// Do not draw as a transparent button
	m_bDrawTransparent = FALSE;
	m_pbmpOldBk = NULL;

	// No URL defined
	SetURL(NULL);

	// No cursor defined
	m_hCursor = NULL;

	// No associated menu
	m_hMenu = NULL;
	m_hParentWndMenu = NULL;
	m_bMenuDisplayed = FALSE;

} // End of CButtonST
示例#12
0
文件: thread.cpp 项目: nohal/piman_pi
wxCurlThreadError wxCurlDownloadThread::Download(const wxString &url, wxOutputStream *out)
{
    wxCurlThreadError ret;

    if ((ret=SetURL(url)) != wxCTE_NO_ERROR)
        return ret;
    if ((ret=SetOutputStream(out)) != wxCTE_NO_ERROR)
        return ret;

    return Download();
}
示例#13
0
LRESULT CArtGalleryDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	ModifyStyleEx(WS_EX_APPWINDOW|WS_EX_CONTROLPARENT/*dwRemove*/, 0/*dwAdd*/);

	DlgResize_Init(false/*bAddGripper*/, true/*bUseMinTrackSize*/, WS_CLIPCHILDREN/*dwForceStyle*/);
	
	// Create the web browser control
	m_BrowserWnd = GetDlgItem(IDC_EXPLORER2);
	if (!::IsWindow(m_BrowserWnd.m_hWnd))
		return TRUE;

	HRESULT hr = m_BrowserWnd.QueryControl(&m_pBrowser);
	ATLASSERT(SUCCEEDED(hr));
	if (FAILED(hr))
		return IDOK;

	if (m_pDispatch)
		hr = m_BrowserWnd.SetExternalDispatch(m_pDispatch);
	ATLASSERT(SUCCEEDED(hr));
	
	if (m_pBrowser)
	{
		m_pBrowser->put_Silent(VARIANT_FALSE); // Allow dialog boxes such as security alerts.
		m_pBrowser->put_RegisterAsDropTarget(VARIANT_FALSE);
		Connect(m_pBrowser); // Connect DWebBrowserEvents
	}

	SetURL(m_szURL, true/*bNavigate*/);
	SetWindowText(m_szTitle);
	SetWindowPos(NULL, m_xpos, m_ypos, m_cx, m_cy, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);

	HICON hIcon = ::LoadIcon(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDI_AGICON));
	SetIcon(hIcon, true	 /*bBigIcon*/); // Big Icon
	SetIcon(hIcon, false /*bBigIcon*/); // Samll Icon
	
	
	// Suppress Drag/drop
	if (m_pBrowser)
		m_pBrowser->put_RegisterAsDropTarget(VARIANT_FALSE);
	
	DragAcceptFiles(false);
	m_BrowserWnd.DragAcceptFiles(false);

	// Allow client to override attributes
	if (m_pfnArtGalleryCallback)
	{
		m_pfnArtGalleryCallback(m_hWnd, WM_INITDIALOG, m_pCallbackParam, (LPARAM)this, m_szID);
	}
	
	ShowWindow(m_nShowCmd);

	
	return IDOK;  // Let the system set the focus
}
示例#14
0
文件: thread.cpp 项目: nohal/piman_pi
wxCurlThreadError wxCurlUploadThread::Upload(const wxString &url, wxInputStream *in)
{
    wxCurlThreadError ret;

    if ((ret=SetURL(url)) != wxCTE_NO_ERROR)
        return ret;
    if ((ret=SetInputStream(in)) != wxCTE_NO_ERROR)
        return ret;

    return Upload();
}
示例#15
0
CAddressBookDialog::CAddressBookDialog()
{
	m_pDisp = NULL;
	m_pBrowser = NULL;
	m_bShowOnInit = false;
	m_bWaiting = false;
	m_bBrowserError = false;
	m_dwResultStatus = 0;
	m_dwMode = -1;
	SetURL(DEFAULT_HOST);
}
示例#16
0
void FCrashUpload::UploadNextFile()
{
	UE_LOG(CrashReportClientLog, Log, TEXT("UploadNextFile: have %d pending files"), PendingFiles.Num());

	// Loop to keep trying files until a send succeeds or we run out of files
	while (PendingFiles.Num() != 0)
	{
		FString PathOfFileToUpload = PendingFiles.Pop();
		// Remember if there was already a diagnostics file in the report, so we don't send it twice
		if (PathOfFileToUpload.EndsWith(GDiagnosticsFilename))
		{
			bDiagnosticsFileSent = true;
		}
		
		if (FPlatformFileManager::Get().GetPlatformFile().FileSize(*PathOfFileToUpload) > MaxFileSizeToUpload)
		{
			UE_LOG(CrashReportClientLog, Warning, TEXT("Skipping large crash report file"));
			continue;
		}

		if (!FFileHelper::LoadFileToArray(PostData, *PathOfFileToUpload))
		{
			UE_LOG(CrashReportClientLog, Warning, TEXT("Failed to load crash report file"));
			continue;
		}

		UE_LOG(CrashReportClientLog, Log, TEXT("UploadNextFile: uploading %d bytes ('%s')"), PostData.Num(), *PathOfFileToUpload);
		FString Filename = FPaths::GetCleanFilename(PathOfFileToUpload);
		if (Filename == "diagnostics.txt")
		{
			// Ensure diagnostics file is capitalized for server
			Filename[0] = 'D';
		}

		// Set up request for upload
		UE_LOG(CrashReportClientLog, Log, TEXT("Sending HTTP request (posting file)"));
		auto Request = CreateHttpRequest();
		Request->SetVerb(TEXT("POST"));
		Request->SetHeader(TEXT("Content-Type"), TEXT("application/octet-stream"));
		Request->SetURL(UrlPrefix / TEXT("UploadReportFile"));
		Request->SetContent(PostData);
		Request->SetHeader(TEXT("DirectoryName"), *ErrorReport.GetReportDirectoryLeafName());
		Request->SetHeader(TEXT("FileName"), Filename);
		Request->SetHeader(TEXT("FileLength"), FString::FromInt(PostData.Num()));

		if (Request->ProcessRequest())
		{
			return;
		}

		UE_LOG(CrashReportClientLog, Warning, TEXT("Failed to send file upload request"));
	}
	PostReportComplete();
}
示例#17
0
status_t
SVNSourceControl::CloneRepository(const char *url, const char *dest)
{
	BString command("svn co --non-interactive ");
	command << "'" << url << "' '" << dest << "'";
	
	BString out;
	RunCommand(command,out);
	SetURL(url);
	
	return B_OK;
}
示例#18
0
bool wxHyperlinkCtrl::Create(wxWindow *parent,
                             wxWindowID id,
                             const wxString& label, const wxString& url,
                             const wxPoint& pos,
                             const wxSize& size,
                             long style,
                             const wxString& name)
{
    if ( !HasNativeHyperlinkCtrl() )
    {
        return wxGenericHyperlinkCtrl::Create( parent, id, label, url, pos,
                                               size, style, name );
    }

    if ( !CreateControl(parent, id, pos, size, style,
                        wxDefaultValidator, name) )
    {
        return false;
    }

    SetURL( url );
    SetVisited( false );

    WXDWORD exstyle;
    WXDWORD msStyle = MSWGetStyle(style, &exstyle);

    if ( !MSWCreateControl(WC_LINK, msStyle, pos, size,
                           GetLabelForSysLink( label, url ), exstyle) )
    {
        return false;
    }

    // Make sure both the label and URL are non-empty strings.
    SetURL(url.empty() ? label : url);
    SetLabel(label.empty() ? url : label);

    ConnectMenuHandlers();

    return true;
}
示例#19
0
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
    const wxString& label, const wxString& url, const wxPoint& pos,
    const wxSize& size, long style, const wxString& name)
{
    if ( UseNative() )
    {
        // do validation checks:
        CheckParams(label, url, style);

        if (!PreCreation( parent, pos, size ) ||
            !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
        {
            wxFAIL_MSG( wxT("wxHyperlinkCtrl creation failed") );
            return false;
        }

        m_widget = gtk_link_button_new("asdfsaf asdfdsaf asdfdsa");
        g_object_ref(m_widget);
        gtk_widget_show(m_widget);

        // alignment
        float x_alignment = 0.5;
        if (HasFlag(wxHL_ALIGN_LEFT))
            x_alignment = 0.0;
        else if (HasFlag(wxHL_ALIGN_RIGHT))
            x_alignment = 1.0;
        gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5);

        // set to non empty strings both the url and the label
        SetURL(url.empty() ? label : url);
        SetLabel(label.empty() ? url : label);

        // our signal handlers:
        g_signal_connect_after (m_widget, "clicked",
                                G_CALLBACK (gtk_hyperlink_clicked_callback),
                                this);

        m_parent->DoAddChild( this );

        PostCreation(size);
        SetInitialSize(size);

        // wxWindowGTK will connect to the enter_notify and leave_notify GTK+ signals
        // thus overriding GTK+'s internal signal handlers which set the cursor of
        // the widget - thus we need to manually set it here:
        SetCursor(wxCursor(wxCURSOR_HAND));
    }
    else
        return wxGenericHyperlinkCtrl::Create(parent, id, label, url, pos, size, style, name);

    return true;
}
示例#20
0
bool UPhilipsHueBridge::HandleTicker(float DeltaTime)
{
	
	auto HttpRequest = FHttpModule::Get().CreateRequest();
	{
		HttpRequest->OnProcessRequestComplete().BindUObject(this, &UPhilipsHueBridge::HandleHttpRequestComplete);
		HttpRequest->SetURL(FString(TEXT("http://")) + Configuration.IpAddress + TEXT("/api/") + ConnectedUser + TEXT("/lights"));
		HttpRequest->SetVerb(TEXT("GET"));
		HttpRequest->ProcessRequest();
	}

	return !ConnectedUser.IsEmpty();
}
示例#21
0
void UPhilipsHueBridge::SetLightStateByLightIDRaw(const int32 LightID, const FString StateJson)
{
	if (!Connected)return;
	auto HttpRequest = FHttpModule::Get().CreateRequest();
	{
		FString LightIDStr = FString::FromInt(LightID);
		HttpRequest->OnProcessRequestComplete().BindUObject(this, &UPhilipsHueBridge::HandleLightStateRequestComplete);
		HttpRequest->SetURL(FString(TEXT("http://")) + Configuration.IpAddress + TEXT("/api/") + ConnectedUser + TEXT("/lights/") + LightIDStr + TEXT("/state"));
		HttpRequest->SetHeader("Content-Type", "application/json");
		HttpRequest->SetVerb(TEXT("PUT"));
		HttpRequest->SetContentAsString(StateJson);
		HttpRequest->ProcessRequest();
	}
}
示例#22
0
bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
    const wxString& label, const wxString& url, const wxPoint& pos,
    const wxSize& size, long style, const wxString& name)
{
    // do validation checks:
    CheckParams(label, url, style);

    if ((style & wxHL_ALIGN_LEFT) == 0)
        style |= wxFULL_REPAINT_ON_RESIZE;

    if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
        return false;

    // set to non empty strings both the url and the label
    SetURL(url.empty() ? label : url);
    SetLabel(label.empty() ? url : label);

    Init();
    SetForegroundColour(m_normalColour);

    // by default the font of an hyperlink control is underlined
    wxFont f = GetFont();
    f.SetUnderlined(true);
    SetFont(f);

    SetInitialSize(size);


    // connect our event handlers:
    // NOTE: since this class is the base class of the GTK+'s native implementation
    //       of wxHyperlinkCtrl, we cannot use the static macros in BEGIN/END_EVENT_TABLE
    //       blocks, otherwise the GTK+'s native impl of wxHyperlinkCtrl would not
    //       behave correctly (as we intercept events doing things which interfere
    //       with GTK+'s native handling):

    Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) );
    Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
    Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
    Connect( wxEVT_CHAR, wxKeyEventHandler(wxGenericHyperlinkCtrl::OnChar) );
    Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) );

    Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) );
    Connect( wxEVT_LEFT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftUp) );
    Connect( wxEVT_MOTION, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnMotion) );

    ConnectMenuHandlers();

    return true;
}
示例#23
0
bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded )
{
    if ( !m_pWebView )
        return false;

    CefURLParts urlParts;
    if ( !CefParseURL ( strURL, urlParts ) )
        return false; // Invalid URL

    // Are we allowed to browse this website?
    if ( bFilterEnabled && g_pCore->GetWebCore ()->GetURLState ( UTF16ToMbUTF8 ( urlParts.host.str ), true ) != eURLState::WEBPAGE_ALLOWED )
        return false;

    // Load it!
    auto pFrame = m_pWebView->GetMainFrame ();
    if ( strPostData.empty () )
    {
        pFrame->LoadURL ( strURL );
    }
    else
    {
        // Load URL first, see https://bitbucket.org/chromiumembedded/cef/issue/579
        pFrame->LoadURL ( "about:blank" );

        // Perform HTTP POST
        auto request = CefRequest::Create ();
        auto postData = CefPostData::Create ();
        auto postDataElement = CefPostDataElement::Create ();
        postDataElement->SetToBytes ( strPostData.size (), strPostData.c_str () );
        postData->AddElement ( postDataElement );

        if ( bURLEncoded )
        {
            CefRequest::HeaderMap headerMap;
            headerMap.insert ( std::make_pair ( "Content-Type", "application/x-www-form-urlencoded" ) );
            headerMap.insert ( std::make_pair ( "Content-Length", std::to_string ( strPostData.size () ) ) );
            //headerMap.insert ( std::make_pair ( "Connection", "close" ) );
            request->SetHeaderMap ( headerMap );
        }

        request->SetURL ( strURL );
        request->SetMethod ( "POST" );
        request->SetPostData ( postData );
        pFrame->LoadRequest ( request );
    }
   
    return true;
}
示例#24
0
void btData::Init(string title, string size, string url, string type, 
				  string seed, string dl, string source)
{
	b_post = false;
	m_source = source;
	SetTitle(title);
	SetSize(size);
	SetURL(url);
	SetSeeds(seed);
	SetDownloads(dl);
	SetType(type);
	m_tracker = "";
	next = NULL;
	m_referer_url = "";
	m_hash = "";
	m_project_id = "0";
	m_files = "0";
}
示例#25
0
void FCrashUpload::SendPingRequest()
{
	SetCurrentState(EUploadState::PingingServer);

	auto Request = CreateHttpRequest();
	Request->SetVerb(TEXT("GET"));
	Request->SetURL(UrlPrefix / TEXT("Ping"));
	UE_LOG( CrashReportClientLog, Log, TEXT( "Sending HTTP request: %s" ), *Request->GetURL() );

	if (Request->ProcessRequest())
	{
		FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateRaw(this, &FCrashUpload::PingTimeout), PingTimeoutSeconds);
	}
	else
	{
		PingTimeout(0);
	}
}
示例#26
0
OP_STATUS SpeedDialData::Set(const SpeedDialData& original, bool retain_uid)
{
	RETURN_IF_ERROR(SetURL(original.GetURL()));
	RETURN_IF_ERROR(SetDisplayURL(original.HasDisplayURL() ? original.GetDisplayURL() : UNI_L("")));
	RETURN_IF_ERROR(SetTitle(original.GetTitle(), original.m_is_custom_title));
	RETURN_IF_ERROR(SetExtensionID(original.m_extension_id));
	RETURN_IF_ERROR(m_partner_id.Set(original.m_partner_id));
	RETURN_IF_ERROR(SetReload(original.GetReloadPolicy(), original.GetReloadTimeout(), original.GetReloadOnlyIfExpired()));

	if (!retain_uid)
	{
		RETURN_IF_ERROR(m_unique_id.Set(original.GetUniqueID().CStr()));
	}

	m_core_url = original.m_core_url;

	return GenerateIDIfNeeded();
}
示例#27
0
status_t
SVNSourceControl::CreateRepository(const char *path)
{
	// The SourceControl class runs under the DSCM idea of the local directory
	// being a repository. Seeing how SVN doesn't allow for this, we create a
	// repository elsewhere on the hard drive, check it out to the path we were
	// given, and add the files to the repository. Checking in is not part of
	// this call, however.
	DPath workingDir(path);
	
	DPath repoPath(sRepoPath);
	repoPath << workingDir.GetFileName();
	
	BDirectory dir(sRepoPath.String());
	if (dir.InitCheck() != B_OK)
		create_directory(sRepoPath.String(), 0777);
	
	BString command("svnadmin create ");
	command << "'" << repoPath.GetFullPath() << "'";
	
	BString out;
	RunCommand(command, out);
	
	BString repoURL = "file://";
	repoURL << repoPath.GetFullPath();
	SetURL(repoURL.String());
	
	SetWorkingDirectory(path);
	
	CloneRepository(repoURL.String(), path);
	
	BPath svnpath(path);
	svnpath.Append(".svn");
	if (!BEntry(svnpath.Path()).Exists())
		return B_ERROR;
	
	command = "";
	command << "cd '" << path << "'; "
			<< "svn add --non-interactive *";
	RunCommand(command, out);
	
	return B_OK;
}
示例#28
0
文件: URLView.cpp 项目: bbjimmy/YAB
URLView::URLView( BRect frame, const char *name, const char *label,
				  const char *url, uint32 resizingMode, uint32 flags )
		: BStringView( frame, name, label, resizingMode, flags ) {
	
	// Set the default values for the other definable instance variables.
	this->color = blue;
	this->clickColor = red;
	this->hoverColor = dark_blue;
	this->disabledColor = gray;
	this->hoverEnabled = true;
	this->draggable = true;
	this->iconSize = 16;
	this->underlineThickness = 1;
	
	// The link should be enabled by default (unless the URL is invalid, which
	// is handled by the SetURL() function).
	enabled = true;
	
	// Set the instance variables.
	this->url = 0;
	SetURL( url );
	
	// Create the cursor to use when over the link.
	this->linkCursor = new BCursor( url_cursor );
	
	// The link is not currently selected.
	selected = false;
	
	// The URL is currently not hover-colored.
	hovering = false;
	
	// The user has not dragged out of the view.
	draggedOut = false;
	
	// The user has not yet opened the popup menu.
	inPopup = false;
	
	// Initialize the attributes list (there are 14 standard
	// Person attributes).
	attributes = new BList( 14 );

}
示例#29
0
文件: stream.cpp 项目: IcaroL2ORK/pd
bool Stream::doInit(const char *url)
{
	if(isInitializing()) {
		// this is not completely clean (should be within the lock) but otherwise the 
		// caller would have to wait for the thread lock

		post("Still initializing %s/%s:%i",hostname.c_str(),mountpt.c_str(),port);
		return false;
	}

	bool ok = true;

	pthread_mutex_lock(&mutex);

	// close open file
	Reset();

	// try to set host name, mount point, port number
	if(ok) {
		char *err = "Invalid URL";
		try { ok = SetURL(url); }
		catch(char *tx) { err = tx;	ok = false;	}
		catch(...) { ok = false; }

		if(!ok) { post(err); ResetHost(); }
	}

	if(ok) {
		state = ST_INIT;
		pthread_cond_signal(&cond);
	}

	pthread_mutex_unlock(&mutex);

	// let the thread worker do the rest

	return ok;
}
示例#30
0
void FCrashUpload::CompressAndSendData()
{
	UE_LOG(CrashReportClientLog, Log, TEXT("CompressAndSendData have %d pending files"), PendingFiles.Num());

	// Compress all files into one archive.
	const int32 BufferSize = 16*1024*1024;

	TArray<uint8> UncompressedData;
	UncompressedData.Reserve( BufferSize );
	FMemoryWriter MemoryWriter( UncompressedData, false, true );

	int32 CurrentFileIndex = 0;

	// Loop to keep trying files until a send succeeds or we run out of files
	while (PendingFiles.Num() != 0)
	{
		const FString PathOfFileToUpload = PendingFiles.Pop();
		
		if (FPlatformFileManager::Get().GetPlatformFile().FileSize(*PathOfFileToUpload) > MaxFileSizeToUpload)
		{
			UE_LOG(CrashReportClientLog, Warning, TEXT("Skipping large crash report file"));
			continue;
		}

		if (!FFileHelper::LoadFileToArray(PostData, *PathOfFileToUpload))
		{
			UE_LOG(CrashReportClientLog, Warning, TEXT("Failed to load crash report file"));
			continue;
		}

		const bool bSkipLogFile = !FCrashReportClientConfig::Get().GetSendLogFile() && PathOfFileToUpload.EndsWith( TEXT( ".log" ) );
		if (bSkipLogFile)
		{
			UE_LOG( CrashReportClientLog, Warning, TEXT( "Skipping the log file" ) );
			continue;
		}

		UE_LOG(CrashReportClientLog, Log, TEXT("CompressAndSendData compressing %d bytes ('%s')"), PostData.Num(), *PathOfFileToUpload);
		FString Filename = FPaths::GetCleanFilename(PathOfFileToUpload);
		if (Filename == "diagnostics.txt")
		{
			// Ensure diagnostics file is capitalized for server
			Filename[0] = 'D';
		}

		FCompressedCrashFile FileToCompress( CurrentFileIndex, Filename, PostData );
		CurrentFileIndex++;

		MemoryWriter << FileToCompress;
	}

	
	uint8* CompressedDataRaw = new uint8[BufferSize];

	int32 CompressedSize = BufferSize;
	int32 UncompressedSize = UncompressedData.Num();
	const bool bResult = FCompression::CompressMemory( COMPRESS_ZLIB, CompressedDataRaw, CompressedSize, UncompressedData.GetData(), UncompressedSize );
	if( !bResult )
	{
		UE_LOG(CrashReportClientLog, Warning, TEXT("Couldn't compress the crash report files"));
		SetCurrentState(EUploadState::Cancelled);
		return;
	}
	
	const FString Filename = ErrorReport.GetReportDirectoryLeafName() + TEXT(".ue4crash");

	// Copy compressed data into the array.
	TArray<uint8> CompressedData;
	CompressedData.Append( CompressedDataRaw, CompressedSize );
	delete [] CompressedDataRaw;
	CompressedDataRaw = nullptr;

	// Set up request for upload
	auto Request = CreateHttpRequest();
	Request->SetVerb(TEXT("POST"));
	Request->SetHeader(TEXT("Content-Type"), TEXT("application/octet-stream"));
	Request->SetURL(UrlPrefix / TEXT("UploadReportFile"));
	Request->SetContent(CompressedData);
	Request->SetHeader(TEXT("DirectoryName"), *ErrorReport.GetReportDirectoryLeafName());
	Request->SetHeader(TEXT("FileName"), Filename);
	Request->SetHeader(TEXT("FileLength"), TTypeToString<int32>::ToString(CompressedData.Num()) );
	Request->SetHeader(TEXT("CompressedSize"), TTypeToString<int32>::ToString(CompressedSize) );
	Request->SetHeader(TEXT("UncompressedSize"), TTypeToString<int32>::ToString(UncompressedSize) );
	Request->SetHeader(TEXT("NumberOfFiles"), TTypeToString<int32>::ToString(CurrentFileIndex) );
	UE_LOG( CrashReportClientLog, Log, TEXT( "Sending HTTP request: %s" ), *Request->GetURL() );

	if (Request->ProcessRequest())
	{
		return;
	}
	else
	{
		UE_LOG(CrashReportClientLog, Warning, TEXT("Failed to send file upload request"));
		SetCurrentState(EUploadState::Cancelled);
	}	
}