MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / open_uri

Function open_uri

src/common/open-uri.cpp:25–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24
25OpenURIresult open_uri(const std::string &uri)
26{
27 GError *error = nullptr; // RIAA not possible: crosses initialization of ‘GError* error’
28 OpenURIresult ret = NewOpenURIresult();
29 char *scheme = g_uri_parse_scheme(uri.c_str());
30 if (!scheme || 0 == scheme[0])
31 {
32 ret->status = OpenURIstatus::INVALID;
33 ret->message = std::string("Could not parse URI: ") + uri;
34 goto exit;
35 }
36
37 if (g_app_info_launch_default_for_uri(uri.c_str(), nullptr, &error))
38 {
39 ret->status = OpenURIstatus::SUCCESS;
40 }
41 else
42 {
43 ret->status = OpenURIstatus::FAIL;
44 ret->message = std::string("Failed to open URI: ")
45 + std::string(error->message);
46 g_clear_error(&error);
47 }
48
49exit:
50 g_free(scheme);
51 return ret;
52}

Callers 2

start_url_authFunction · 0.85
mainFunction · 0.85

Calls 1

NewOpenURIresultFunction · 0.85

Tested by 1

mainFunction · 0.68