GpgFrontend-Doxygen/docs/html/GpgContext_8h_source.html
2022-05-09 03:59:26 +08:00

176 lines
18 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>GpgFrontend Project: src/core/GpgContext.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">GpgFrontend Project
</div>
<div id="projectbrief">A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('GpgContext_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle"><div class="title">GpgContext.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="preprocessor">#ifndef __SGPGMEPP_CONTEXT_H__</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="preprocessor">#define __SGPGMEPP_CONTEXT_H__</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span><span class="preprocessor">#include &quot;GpgConstants.h&quot;</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="preprocessor">#include &quot;GpgFunctionObject.h&quot;</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="preprocessor">#include &quot;GpgInfo.h&quot;</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#include &quot;GpgModel.h&quot;</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> </div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceGpgFrontend.html">GpgFrontend</a> {</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> </div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="structGpgFrontend_1_1GpgContextInitArgs.html"> 43</a></span><span class="keyword">struct </span><a class="code hl_struct" href="structGpgFrontend_1_1GpgContextInitArgs.html">GpgContextInitArgs</a> {</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <span class="comment">// make no sense for gpg2</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> <span class="keywordtype">bool</span> independent_database = <span class="keyword">false</span>; </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> std::string db_path = {};</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keywordtype">bool</span> gpg_alone = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> std::string gpg_path = {};</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordtype">bool</span> test_mode = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="keywordtype">bool</span> ascii = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <a class="code hl_struct" href="structGpgFrontend_1_1GpgContextInitArgs.html">GpgContextInitArgs</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span>};</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"><a class="line" href="classGpgFrontend_1_1GpgContext.html"> 59</a></span><span class="keyword">class </span>GPGFRONTEND_CORE_EXPORT <a class="code hl_class" href="classGpgFrontend_1_1GpgContext.html">GpgContext</a></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> : <span class="keyword">public</span> <a class="code hl_class" href="classGpgFrontend_1_1SingletonFunctionObject.html">SingletonFunctionObject</a>&lt;GpgContext&gt; {</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keyword">public</span>:</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="keyword">explicit</span> <a class="code hl_class" href="classGpgFrontend_1_1GpgContext.html">GpgContext</a>(<span class="keyword">const</span> <a class="code hl_struct" href="structGpgFrontend_1_1GpgContextInitArgs.html">GpgContextInitArgs</a>&amp; args = {});</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="keyword">explicit</span> <a class="code hl_class" href="classGpgFrontend_1_1GpgContext.html">GpgContext</a>(<span class="keywordtype">int</span> channel);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"><a class="line" href="classGpgFrontend_1_1GpgContext.html#ae89dee551354c1541337881898832725"> 80</a></span> <a class="code hl_function" href="classGpgFrontend_1_1GpgContext.html#ae89dee551354c1541337881898832725">~GpgContext</a>() <span class="keyword">override</span> = <span class="keywordflow">default</span>;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> [[nodiscard]] <span class="keywordtype">bool</span> good() <span class="keyword">const</span>;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"><a class="line" href="classGpgFrontend_1_1GpgContext.html#aca13ae9f849ca894cdd0da8572b5c9e3"> 95</a></span> [[nodiscard]] <span class="keyword">const</span> <a class="code hl_class" href="classGpgFrontend_1_1GpgInfo.html">GpgInfo</a>&amp; <a class="code hl_function" href="classGpgFrontend_1_1GpgContext.html#aca13ae9f849ca894cdd0da8572b5c9e3">GetInfo</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> info_; }</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> </div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"><a class="line" href="classGpgFrontend_1_1GpgContext.html#a5b419175bd9927f3d449637db8ba6524"> 102</a></span> <span class="keyword">operator</span> gpgme_ctx_t()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _ctx_ref.get(); }</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> </div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> <span class="keyword">private</span>:</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <a class="code hl_class" href="classGpgFrontend_1_1GpgInfo.html">GpgInfo</a> info_; </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <a class="code hl_struct" href="structGpgFrontend_1_1GpgContextInitArgs.html">GpgContextInitArgs</a> args_; </div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> </div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keywordtype">void</span> init_ctx();</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> </div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"><a class="line" href="structGpgFrontend_1_1GpgContext_1_1__ctx__ref__deleter.html"> 118</a></span> <span class="keyword">struct </span><a class="code hl_struct" href="structGpgFrontend_1_1GpgContext_1_1__ctx__ref__deleter.html">_ctx_ref_deleter</a> {</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <span class="keywordtype">void</span> operator()(gpgme_ctx_t _ctx) {</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> <span class="keywordflow">if</span> (_ctx != <span class="keyword">nullptr</span>) gpgme_release(_ctx);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> }</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> };</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> </div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="keyword">using</span> CtxRefHandler =</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> std::unique_ptr&lt;struct gpgme_context, _ctx_ref_deleter&gt;; </div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> CtxRefHandler _ctx_ref = <span class="keyword">nullptr</span>; </div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="keywordtype">bool</span> good_ = <span class="keyword">true</span>; </div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> </div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keyword">public</span>:</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> <span class="keyword">static</span> gpgme_error_t test_passphrase_cb(<span class="keywordtype">void</span>* opaque, <span class="keyword">const</span> <span class="keywordtype">char</span>* uid_hint,</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* passphrase_info,</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <span class="keywordtype">int</span> last_was_bad, <span class="keywordtype">int</span> fd);</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> </div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> <span class="keyword">static</span> gpgme_error_t test_status_cb(<span class="keywordtype">void</span>* hook, <span class="keyword">const</span> <span class="keywordtype">char</span>* keyword,</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* args);</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> </div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <span class="keywordtype">void</span> SetPassphraseCb(gpgme_passphrase_cb_t func) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span>};</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span>} <span class="comment">// namespace GpgFrontend</span></div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> </div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span><span class="preprocessor">#endif </span><span class="comment">// __SGPGMEPP_CONTEXT_H__</span></div>
<div class="ttc" id="aclassGpgFrontend_1_1GpgContext_html"><div class="ttname"><a href="classGpgFrontend_1_1GpgContext.html">GpgFrontend::GpgContext</a></div><div class="ttdef"><b>Definition:</b> GpgContext.h:60</div></div>
<div class="ttc" id="aclassGpgFrontend_1_1GpgContext_html_aca13ae9f849ca894cdd0da8572b5c9e3"><div class="ttname"><a href="classGpgFrontend_1_1GpgContext.html#aca13ae9f849ca894cdd0da8572b5c9e3">GpgFrontend::GpgContext::GetInfo</a></div><div class="ttdeci">const GpgInfo &amp; GetInfo() const</div><div class="ttdoc">Get the Info object.</div><div class="ttdef"><b>Definition:</b> GpgContext.h:95</div></div>
<div class="ttc" id="aclassGpgFrontend_1_1GpgContext_html_ae89dee551354c1541337881898832725"><div class="ttname"><a href="classGpgFrontend_1_1GpgContext.html#ae89dee551354c1541337881898832725">GpgFrontend::GpgContext::~GpgContext</a></div><div class="ttdeci">~GpgContext() override=default</div><div class="ttdoc">Destroy the Gpg Context object.</div></div>
<div class="ttc" id="aclassGpgFrontend_1_1GpgInfo_html"><div class="ttname"><a href="classGpgFrontend_1_1GpgInfo.html">GpgFrontend::GpgInfo</a></div><div class="ttdoc">Use to record some info about gnupg.</div><div class="ttdef"><b>Definition:</b> GpgInfo.h:39</div></div>
<div class="ttc" id="aclassGpgFrontend_1_1SingletonFunctionObject_html"><div class="ttname"><a href="classGpgFrontend_1_1SingletonFunctionObject.html">GpgFrontend::SingletonFunctionObject</a></div><div class="ttdef"><b>Definition:</b> GpgFunctionObject.h:49</div></div>
<div class="ttc" id="anamespaceGpgFrontend_html"><div class="ttname"><a href="namespaceGpgFrontend.html">GpgFrontend</a></div><div class="ttdef"><b>Definition:</b> CoreCommonUtil.cpp:29</div></div>
<div class="ttc" id="astructGpgFrontend_1_1GpgContextInitArgs_html"><div class="ttname"><a href="structGpgFrontend_1_1GpgContextInitArgs.html">GpgFrontend::GpgContextInitArgs</a></div><div class="ttdef"><b>Definition:</b> GpgContext.h:43</div></div>
<div class="ttc" id="astructGpgFrontend_1_1GpgContext_1_1__ctx__ref__deleter_html"><div class="ttname"><a href="structGpgFrontend_1_1GpgContext_1_1__ctx__ref__deleter.html">GpgFrontend::GpgContext::_ctx_ref_deleter</a></div><div class="ttdef"><b>Definition:</b> GpgContext.h:118</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_aebb8dcc11953d78e620bbef0b9e2183.html">core</a></li><li class="navelem"><b>GpgContext.h</b></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
</html>