1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
|
<refentry id="camel-camel-imap-command">
<refmeta>
<refentrytitle role="top_of_page" id="camel-camel-imap-command.top_of_page">camel-imap-command</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>CAMEL Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>camel-imap-command</refname>
<refpurpose></refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>
<refsynopsisdiv id="camel-camel-imap-command.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>
<synopsis>
enum <link linkend="CamelImapResponseType">CamelImapResponseType</link>;
struct <link linkend="CamelImapResponse">CamelImapResponse</link>;
<link linkend="CamelImapResponse">CamelImapResponse</link>* <link linkend="camel-imap-command">camel_imap_command</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelFolder">CamelFolder</link> *folder,
<link linkend="CamelException">CamelException</link> *ex,
const <link linkend="char">char</link> *fmt,
...);
<link linkend="CamelImapResponse">CamelImapResponse</link>* <link linkend="camel-imap-command-continuation">camel_imap_command_continuation</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
const <link linkend="char">char</link> *cmd,
<link linkend="size-t">size_t</link> cmdlen,
<link linkend="CamelException">CamelException</link> *ex);
<link linkend="void">void</link> <link linkend="camel-imap-response-free">camel_imap_response_free</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response);
<link linkend="void">void</link> <link linkend="camel-imap-response-free-without-processing">camel_imap_response_free_without_processing</link>
(<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response);
<link linkend="char">char</link>* <link linkend="camel-imap-response-extract">camel_imap_response_extract</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response,
const <link linkend="char">char</link> *type,
<link linkend="CamelException">CamelException</link> *ex);
<link linkend="char">char</link>* <link linkend="camel-imap-response-extract-continuation">camel_imap_response_extract_continuation</link>
(<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response,
<link linkend="CamelException">CamelException</link> *ex);
<link linkend="gboolean">gboolean</link> <link linkend="camel-imap-command-start">camel_imap_command_start</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelFolder">CamelFolder</link> *folder,
<link linkend="CamelException">CamelException</link> *ex,
const <link linkend="char">char</link> *fmt,
...);
<link linkend="CamelImapResponseType">CamelImapResponseType</link> <link linkend="camel-imap-command-response">camel_imap_command_response</link> (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="char">char</link> **respbuf,
<link linkend="CamelException">CamelException</link> *ex);
</synopsis>
</refsynopsisdiv>
<refsect1 id="camel-camel-imap-command.description" role="desc">
<title role="desc.title">Description</title>
<para>
</para>
</refsect1>
<refsect1 id="camel-camel-imap-command.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="CamelImapResponseType" role="enum">
<title>enum CamelImapResponseType</title>
<indexterm zone="CamelImapResponseType"><primary>CamelImapResponseType</primary></indexterm><programlisting>typedef enum {
CAMEL_IMAP_RESPONSE_ERROR,
CAMEL_IMAP_RESPONSE_CONTINUATION,
CAMEL_IMAP_RESPONSE_UNTAGGED,
CAMEL_IMAP_RESPONSE_TAGGED
} CamelImapResponseType;
</programlisting>
<para>
</para></refsect2>
<refsect2 id="CamelImapResponse" role="struct">
<title>struct CamelImapResponse</title>
<indexterm zone="CamelImapResponse"><primary>CamelImapResponse</primary></indexterm><programlisting>struct CamelImapResponse {
CamelFolder *folder;
GPtrArray *untagged;
char *status;
};
</programlisting>
<para>
</para></refsect2>
<refsect2 id="camel-imap-command" role="function">
<title>camel_imap_command ()</title>
<indexterm zone="camel-imap-command"><primary>camel_imap_command</primary></indexterm><programlisting><link linkend="CamelImapResponse">CamelImapResponse</link>* camel_imap_command (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelFolder">CamelFolder</link> *folder,
<link linkend="CamelException">CamelException</link> *ex,
const <link linkend="char">char</link> *fmt,
...);</programlisting>
<para>
This function calls <link linkend="camel-imap-command-start"><function>camel_imap_command_start()</function></link> to send the
command, then reads the complete response to it using
<link linkend="camel-imap-command-response"><function>camel_imap_command_response()</function></link> and returns a CamelImapResponse
structure.
</para>
<para>
As a special case, if <parameter>fmt</parameter> is <link linkend="NULL:CAPS"><literal>NULL</literal></link>, it will just select <parameter>folder</parameter>
and return the response from doing so.
</para>
<para>
See <link linkend="camel-imap-command-start"><function>camel_imap_command_start()</function></link> for details on <parameter>fmt</parameter>.
</para>
<para>
On success, the store's connect_lock will be locked. It will be freed
when you call camel_imap_response_free. (The lock is recursive, so
callers can grab and release it themselves if they need to run
multiple commands atomically.)</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the IMAP store
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>folder</parameter> :</term>
<listitem><simpara> The folder to perform the operation in (or <link linkend="NULL:CAPS"><literal>NULL</literal></link> if not
relevant).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fmt</parameter> :</term>
<listitem><simpara> a sort of printf-style format string, followed by arguments
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter> :</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> <link linkend="NULL:CAPS"><literal>NULL</literal></link> if an error occurred (in which case <parameter>ex</parameter> will
be set). Otherwise, a CamelImapResponse describing the server's
response, which the caller must free with <link linkend="camel-imap-response-free"><function>camel_imap_response_free()</function></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-command-continuation" role="function">
<title>camel_imap_command_continuation ()</title>
<indexterm zone="camel-imap-command-continuation"><primary>camel_imap_command_continuation</primary></indexterm><programlisting><link linkend="CamelImapResponse">CamelImapResponse</link>* camel_imap_command_continuation (<link linkend="CamelImapStore">CamelImapStore</link> *store,
const <link linkend="char">char</link> *cmd,
<link linkend="size-t">size_t</link> cmdlen,
<link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
This method is for sending continuing responses to the IMAP server
after <link linkend="camel-imap-command"><function>camel_imap_command()</function></link> or <link linkend="camel-imap-command-response"><function>camel_imap_command_response()</function></link> returns
a continuation response.
</para>
<para>
This function assumes you have an exclusive lock on the imap stream.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the IMAP store
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmd</parameter> :</term>
<listitem><simpara> buffer containing the response/request data
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmdlen</parameter> :</term>
<listitem><simpara> command length
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> as for <link linkend="camel-imap-command"><function>camel_imap_command()</function></link>. On failure, the store's
connect_lock will be released.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-response-free" role="function">
<title>camel_imap_response_free ()</title>
<indexterm zone="camel-imap-response-free"><primary>camel_imap_response_free</primary></indexterm><programlisting><link linkend="void">void</link> camel_imap_response_free (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response);</programlisting>
<para>
Frees all of the data in <parameter>response</parameter> and processes any untagged
EXPUNGE and EXISTS responses in it. Releases <parameter>store</parameter>'s connect_lock.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the CamelImapStore the response is from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>response</parameter> :</term>
<listitem><simpara> a CamelImapResponse
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-response-free-without-processing" role="function">
<title>camel_imap_response_free_without_processing ()</title>
<indexterm zone="camel-imap-response-free-without-processing"><primary>camel_imap_response_free_without_processing</primary></indexterm><programlisting><link linkend="void">void</link> camel_imap_response_free_without_processing
(<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response);</programlisting>
<para>
Frees all of the data in <parameter>response</parameter> without processing any untagged
responses. Releases <parameter>store</parameter>'s command lock.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the CamelImapStore the response is from.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>response</parameter> :</term>
<listitem><simpara> a CamelImapResponse:
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-response-extract" role="function">
<title>camel_imap_response_extract ()</title>
<indexterm zone="camel-imap-response-extract"><primary>camel_imap_response_extract</primary></indexterm><programlisting><link linkend="char">char</link>* camel_imap_response_extract (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response,
const <link linkend="char">char</link> *type,
<link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
This checks that <parameter>response</parameter> contains a single untagged response of
type <parameter>type</parameter> and returns just that response data. If <parameter>response</parameter>
doesn't contain the right information, the function will set <parameter>ex</parameter>
and return <link linkend="NULL:CAPS"><literal>NULL</literal></link>. Either way, <parameter>response</parameter> will be freed and the
store's connect_lock released.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the store the response came from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>response</parameter> :</term>
<listitem><simpara> the response data returned from camel_imap_command
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>type</parameter> :</term>
<listitem><simpara> the response type to extract
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the desired response string, which the caller must free.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-response-extract-continuation" role="function">
<title>camel_imap_response_extract_continuation ()</title>
<indexterm zone="camel-imap-response-extract-continuation"><primary>camel_imap_response_extract_continuation</primary></indexterm><programlisting><link linkend="char">char</link>* camel_imap_response_extract_continuation
(<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelImapResponse">CamelImapResponse</link> *response,
<link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
This checks that <parameter>response</parameter> contains a continuation response, and
returns just that data. If <parameter>response</parameter> doesn't contain a continuation
response, the function will set <parameter>ex</parameter>, release <parameter>store</parameter>'s connect_lock,
and return <link linkend="NULL:CAPS"><literal>NULL</literal></link>. Either way, <parameter>response</parameter> will be freed.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the store the response came from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>response</parameter> :</term>
<listitem><simpara> the response data returned from camel_imap_command
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the desired response string, which the caller must free.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-command-start" role="function">
<title>camel_imap_command_start ()</title>
<indexterm zone="camel-imap-command-start"><primary>camel_imap_command_start</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link> camel_imap_command_start (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="CamelFolder">CamelFolder</link> *folder,
<link linkend="CamelException">CamelException</link> *ex,
const <link linkend="char">char</link> *fmt,
...);</programlisting>
<para>
This function makes sure that <parameter>folder</parameter> (if non-<link linkend="NULL:CAPS"><literal>NULL</literal></link>) is the
currently-selected folder on <parameter>store</parameter> and then sends the IMAP command
specified by <parameter>fmt</parameter> and the following arguments.
</para>
<para>
<parameter>fmt</parameter> can include the following <link linkend="escapes"><literal>-escapes</literal></link> ONLY:
<link linkend="s"><literal>s</literal></link>, <link linkend="d"><literal>d</literal></link>, %%: as with printf
<link linkend="S:CAPS"><literal>S</literal></link>: an IMAP "string" (quoted string or literal)
<link linkend="F:CAPS"><literal>F</literal></link>: an IMAP folder name
<link linkend="G:CAPS"><literal>G</literal></link>: an IMAP folder name, with namespace already prepended
</para>
<para>
<link linkend="S:CAPS"><literal>S</literal></link> strings will be passed as literals if the server supports LITERAL+
and quoted strings otherwise. (<link linkend="S:CAPS"><literal>S</literal></link> does not support strings that
contain newlines.)
</para>
<para>
<link linkend="F:CAPS"><literal>F</literal></link> will have the imap store's namespace prepended; <link linkend="F:CAPS"><literal>F</literal></link> and <link linkend="G:CAPS"><literal>G</literal></link> will then
be converted to UTF-7 and processed like <link linkend="S:CAPS"><literal>S</literal></link>.
</para>
<para>
On success, the store's connect_lock will be locked. It will be
freed when <link linkend="CAMEL-IMAP-RESPONSE-TAGGED:CAPS"><literal>CAMEL_IMAP_RESPONSE_TAGGED</literal></link> or <link linkend="CAMEL-IMAP-RESPONSE-ERROR:CAPS"><literal>CAMEL_IMAP_RESPONSE_ERROR</literal></link>
is returned from <link linkend="camel-imap-command-response"><function>camel_imap_command_response()</function></link>. (The lock is
recursive, so callers can grab and release it themselves if they
need to run multiple commands atomically.)</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the IMAP store
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>folder</parameter> :</term>
<listitem><simpara> The folder to perform the operation in (or <link linkend="NULL:CAPS"><literal>NULL</literal></link> if not
relevant).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fmt</parameter> :</term>
<listitem><simpara> a sort of printf-style format string, followed by arguments
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter> :</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the command was sent successfully, <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if
an error occurred (in which case <parameter>ex</parameter> will be set).
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="camel-imap-command-response" role="function">
<title>camel_imap_command_response ()</title>
<indexterm zone="camel-imap-command-response"><primary>camel_imap_command_response</primary></indexterm><programlisting><link linkend="CamelImapResponseType">CamelImapResponseType</link> camel_imap_command_response (<link linkend="CamelImapStore">CamelImapStore</link> *store,
<link linkend="char">char</link> **respbuf,
<link linkend="CamelException">CamelException</link> *ex);</programlisting>
<para>
This reads a single tagged, untagged, or continuation response from
<parameter>store</parameter> into *<parameter>response</parameter>. The caller must free the string when it is
done with it.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>store</parameter> :</term>
<listitem><simpara> the IMAP store
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>respbuf</parameter> :</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>ex</parameter> :</term>
<listitem><simpara> a CamelException
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> One of <link linkend="CAMEL-IMAP-RESPONSE-CONTINUATION:CAPS"><literal>CAMEL_IMAP_RESPONSE_CONTINUATION</literal></link>,
<link linkend="CAMEL-IMAP-RESPONSE-UNTAGGED:CAPS"><literal>CAMEL_IMAP_RESPONSE_UNTAGGED</literal></link>, <link linkend="CAMEL-IMAP-RESPONSE-TAGGED:CAPS"><literal>CAMEL_IMAP_RESPONSE_TAGGED</literal></link>, or
<link linkend="CAMEL-IMAP-RESPONSE-ERROR:CAPS"><literal>CAMEL_IMAP_RESPONSE_ERROR</literal></link>. If either of the last two, <parameter>store</parameter>'s
command lock will be unlocked.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>
</refentry>
|