Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_send_as2_example_8cpp_source.html
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 6 43e37759235e
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
<title>TB9.2 Example Applications: examples/Messaging/SendAs2Example/SendAs2Example.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2 -->
<h1>examples/Messaging/SendAs2Example/SendAs2Example.cpp</h1><a href="_send_as2_example_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of &quot;Eclipse Public License v1.0&quot;</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL &quot;http://www.eclipse.org/legal/epl-v10.html&quot;.</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description:</span>
<a name="l00014"></a>00014 <span class="comment">// This is a simple example that demonstrates the use of the SendAs v2 protocol to send messages </span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;SendAs2Example.h&quot;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KBodyText, <span class="stringliteral">&quot;You are limited only by your fears. Remember it is attitude, more than aptitude,that determines your altitude&quot;</span>);
<a name="l00025"></a>00025 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAddress1, <span class="stringliteral">&quot;ban-sindhub01@ban-sindhub01.intra&quot;</span>);
<a name="l00026"></a>00026 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAddress3, <span class="stringliteral">&quot;ban-sindhub01@ban-sindhub01.intra&quot;</span>);
<a name="l00027"></a>00027 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAddress4, <span class="stringliteral">&quot;test1@nokia.com&quot;</span>);
<a name="l00028"></a>00028 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAlias1, <span class="stringliteral">&quot;Alias1&quot;</span>);
<a name="l00029"></a>00029 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAlias2, <span class="stringliteral">&quot;Alias2&quot;</span>);
<a name="l00030"></a>00030 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAccount1, <span class="stringliteral">&quot; \n SendAs Account1 \n&quot;</span>);
<a name="l00031"></a>00031 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAccount2, <span class="stringliteral">&quot; \n SendAs Account2 \n&quot;</span>);
<a name="l00032"></a>00032 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAccount3, <span class="stringliteral">&quot; \n SendAs Account3 \n&quot;</span>);
<a name="l00033"></a>00033 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KAccountNames,<span class="stringliteral">&quot;\n The list of accounts present are: \n&quot;</span>);
<a name="l00034"></a>00034 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextWelcome, <span class="stringliteral">&quot; SendAs2 Example \n&quot;</span>);
<a name="l00035"></a>00035 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextStartApp, <span class="stringliteral">&quot;\n Starting the SendAs2 Example application .... \n&quot;</span>);
<a name="l00036"></a>00036 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextPressAKey, <span class="stringliteral">&quot;\n Press any key to step through the example .... \n&quot;</span>);
<a name="l00037"></a>00037 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextConn, <span class="stringliteral">&quot;\n Connecting to sendAs server .... \n&quot;</span>);
<a name="l00038"></a>00038 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextErrInn, <span class="stringliteral">&quot;\n Connection is successful\n&quot;</span>);
<a name="l00039"></a>00039 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextErrOut, <span class="stringliteral">&quot;\n\n Connection has failed\n&quot;</span>);      
<a name="l00040"></a>00040 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextCreate, <span class="stringliteral">&quot;\n Creating a SendAs message .... \n&quot;</span>);
<a name="l00041"></a>00041 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextSend, <span class="stringliteral">&quot;\n Sending the sendAs message .... \n&quot;</span>);
<a name="l00042"></a>00042 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextClose, <span class="stringliteral">&quot;\n The SendAs message has been sent \n&quot;</span>);
<a name="l00043"></a>00043 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KPressAnyKey, <span class="stringliteral">&quot;\n Press any key.... \n&quot;</span>);
<a name="l00044"></a>00044 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KExitKey, <span class="stringliteral">&quot;\n Press any key to exit the application.... \n&quot;</span>);
<a name="l00045"></a>00045 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KSmsClient, <span class="stringliteral">&quot;SMS Client&quot;</span>);
<a name="l00046"></a>00046 
<a name="l00051"></a><a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">00051</a> <a class="code" href="class_c_send_as2_example.html">CSendAs2Example</a>* <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CSendAs2Example::NewL</a>()
<a name="l00052"></a>00052         {
<a name="l00053"></a>00053         <a class="code" href="class_c_send_as2_example.html">CSendAs2Example</a>* <span class="keyword">self</span> = <span class="keyword">new</span> (ELeave) <a class="code" href="class_c_send_as2_example.html">CSendAs2Example</a>();
<a name="l00054"></a>00054         CleanupStack::PushL(<span class="keyword">self</span>);
<a name="l00055"></a>00055         <span class="keyword">self</span>-&gt;ConstructL();
<a name="l00056"></a>00056         CleanupStack::Pop();
<a name="l00057"></a>00057         <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00058"></a>00058         }
<a name="l00059"></a>00059         
<a name="l00063"></a>00063 CSendAs2Example::CSendAs2Example()
<a name="l00064"></a>00064         {       
<a name="l00065"></a>00065                 
<a name="l00066"></a>00066         }
<a name="l00067"></a>00067 
<a name="l00071"></a>00071 <span class="keywordtype">void</span> CSendAs2Example::ConstructL()
<a name="l00072"></a>00072         {
<a name="l00073"></a>00073         iConsole = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">Console::NewL</a>(KTextWelcome,TSize(KConsFullScreen,KConsFullScreen));
<a name="l00074"></a>00074         iConsole-&gt;Printf ( KTextStartApp );
<a name="l00075"></a>00075         iConsole-&gt;Printf ( KTextPressAKey );
<a name="l00076"></a>00076         iConsole-&gt;Getch ();
<a name="l00077"></a>00077         }       
<a name="l00078"></a>00078         
<a name="l00085"></a><a class="code" href="class_c_send_as2_example.html#a62977f8fc97dc3ff5f271046ce8e93b6">00085</a> <a class="code" href="class_c_send_as2_example.html#a62977f8fc97dc3ff5f271046ce8e93b6">CSendAs2Example::~CSendAs2Example</a>()
<a name="l00086"></a>00086         {       
<a name="l00087"></a>00087         <span class="keyword">delete</span> iSelection;
<a name="l00088"></a>00088         iSelection = NULL;
<a name="l00089"></a>00089         
<a name="l00090"></a>00090         <span class="keyword">delete</span> iEntry;
<a name="l00091"></a>00091         iEntry = NULL;
<a name="l00092"></a>00092         
<a name="l00093"></a>00093         <span class="keyword">delete</span> iSession;
<a name="l00094"></a>00094         iSession = NULL;
<a name="l00095"></a>00095         
<a name="l00096"></a>00096         <span class="keyword">delete</span> iObserver;
<a name="l00097"></a>00097         iObserver = NULL;
<a name="l00098"></a>00098         
<a name="l00099"></a>00099         iSendAs.Close();        
<a name="l00100"></a>00100         <span class="keyword">delete</span> iConsole;
<a name="l00101"></a>00101         }
<a name="l00102"></a>00102         
<a name="l00109"></a><a class="code" href="class_c_send_as2_example.html#a7ccdc243eaf209d64a5e1850f4d6ed26">00109</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#a7ccdc243eaf209d64a5e1850f4d6ed26">CSendAs2Example::StartL</a>()
<a name="l00110"></a>00110         {
<a name="l00111"></a>00111         iObserver = <span class="keyword">new</span>(ELeave) <a class="code" href="class_c_dummy_observer.html">CDummyObserver</a>;
<a name="l00112"></a>00112         iSession = CMsvSession::OpenSyncL(*iObserver);
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         TMsvId aFolderId = KMsvDraftEntryId;
<a name="l00115"></a>00115         iEntry = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CMsvEntry::NewL</a>(*iSession, aFolderId, 
<a name="l00116"></a>00116                 TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
<a name="l00117"></a>00117         
<a name="l00118"></a>00118         iSelection = iEntry-&gt;ChildrenL();
<a name="l00119"></a>00119 
<a name="l00120"></a>00120         <a class="code" href="class_c_send_as2_example.html#ab6d9f868e9f8e742ca0c935bd08c855d">Connect</a>();
<a name="l00121"></a>00121         RSendAsMessage message;
<a name="l00122"></a>00122         CleanMessageFolderL();
<a name="l00123"></a>00123         <a class="code" href="class_c_send_as2_example.html#a762ac16c692ec849b8e60639d026645e">CreateL</a>(message);
<a name="l00124"></a>00124         <a class="code" href="class_c_send_as2_example.html#a1621f9de94164edff4d459d06cb82f44">DisplayAccountL</a>();
<a name="l00125"></a>00125         <a class="code" href="class_c_send_as2_example.html#a40f320dceace4d1ff163a3944d8755fb">CapabilityFilterL</a>();
<a name="l00126"></a>00126         <a class="code" href="class_c_send_as2_example.html#ad91005c90f3863a181b7a54dc8f0c969">SendL</a>(message);
<a name="l00127"></a>00127         }
<a name="l00128"></a>00128 
<a name="l00135"></a><a class="code" href="class_c_send_as2_example.html#ab6d9f868e9f8e742ca0c935bd08c855d">00135</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#ab6d9f868e9f8e742ca0c935bd08c855d">CSendAs2Example::Connect</a>()
<a name="l00136"></a>00136         {
<a name="l00137"></a>00137         iConsole-&gt;Printf ( KTextConn );
<a name="l00138"></a>00138         TInt err = iSendAs.Connect(KSendAsDefaultMessageSlots);
<a name="l00139"></a>00139         <span class="keywordflow">if</span> ( err == KErrNone)
<a name="l00140"></a>00140                 {
<a name="l00141"></a>00141                 iConsole-&gt;Printf ( KTextErrInn );
<a name="l00142"></a>00142                 }
<a name="l00143"></a>00143         <span class="keywordflow">else</span>
<a name="l00144"></a>00144                 {
<a name="l00145"></a>00145                 iConsole-&gt;Printf ( KTextErrOut );
<a name="l00146"></a>00146                 }
<a name="l00147"></a>00147         }
<a name="l00148"></a>00148 
<a name="l00152"></a>00152 <span class="keywordtype">void</span> CSendAs2Example::CleanMessageFolderL()
<a name="l00153"></a>00153         {
<a name="l00154"></a>00154         TMsvLocalOperationProgress progress;
<a name="l00155"></a>00155         <span class="keywordflow">if</span> (iSelection-&gt;Count() &gt; 0)
<a name="l00156"></a>00156                 {
<a name="l00157"></a>00157                 iEntry-&gt;DeleteL(*iSelection, progress);
<a name="l00158"></a>00158                 }       
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160 
<a name="l00165"></a><a class="code" href="class_c_send_as2_example.html#a762ac16c692ec849b8e60639d026645e">00165</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#a762ac16c692ec849b8e60639d026645e">CSendAs2Example::CreateL</a>( RSendAsMessage&amp; aMessage)
<a name="l00166"></a>00166         {
<a name="l00167"></a>00167                 
<a name="l00168"></a>00168         CSendAsMessageTypes* messageTypes = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CSendAsMessageTypes::NewL</a>();
<a name="l00169"></a>00169         CleanupStack::PushL(messageTypes);      
<a name="l00170"></a>00170 
<a name="l00171"></a>00171         <span class="comment">// Filter all MTMs that can send messages. </span>
<a name="l00172"></a>00172         <span class="comment">// This list can be refined by applying filters using FilterAgainstCapability.</span>
<a name="l00173"></a>00173         iSendAs.FilteredMessageTypesL(*messageTypes);
<a name="l00174"></a>00174 
<a name="l00175"></a>00175         TUid sendAsMtmUid;
<a name="l00176"></a>00176                 
<a name="l00177"></a>00177         <span class="comment">// Returning the message UID based on the message type </span>
<a name="l00178"></a>00178         <span class="comment">// such as 0 for SMTP Client, 1 for SMS Client</span>
<a name="l00179"></a>00179         <span class="comment">// 2 for Infrared client MTM and 3 for Bluetooth client MTM.</span>
<a name="l00180"></a>00180         sendAsMtmUid = messageTypes-&gt;UidFromNameL(KSmsClient);
<a name="l00181"></a>00181         
<a name="l00182"></a>00182         CleanupStack::PopAndDestroy(messageTypes);      
<a name="l00183"></a>00183         iConsole-&gt;Printf ( KTextCreate );
<a name="l00184"></a>00184         
<a name="l00185"></a>00185         
<a name="l00186"></a>00186         iEntry-&gt;SetEntryL(KMsvDraftEntryId);
<a name="l00187"></a>00187         
<a name="l00188"></a>00188         aMessage.CreateL(iSendAs, sendAsMtmUid);
<a name="l00189"></a>00189         <span class="comment">// Set the body text of this message using a plain descriptor. </span>
<a name="l00190"></a>00190         <span class="comment">// The object must have an open message to use this method.</span>
<a name="l00191"></a>00191         aMessage.SetBodyTextL(KBodyText);
<a name="l00192"></a>00192         <span class="comment">// Add recipients to this message.</span>
<a name="l00193"></a>00193         aMessage.AddRecipientL(KAddress1, KAlias1, RSendAsMessage::ESendAsRecipientTo);
<a name="l00194"></a>00194         aMessage.AddRecipientL(KAddress3, RSendAsMessage::ESendAsRecipientCc);
<a name="l00195"></a>00195         aMessage.AddRecipientL(KAddress4, KAlias2, RSendAsMessage::ESendAsRecipientCc);
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         CMsvEntry* entry = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CMsvEntry::NewL</a>(*iSession, KMsvDraftEntryId, 
<a name="l00198"></a>00198                 TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
<a name="l00199"></a>00199         CleanupStack::PushL(entry);
<a name="l00200"></a>00200         
<a name="l00201"></a>00201         <span class="comment">// Sets the context to the specified entry.</span>
<a name="l00202"></a>00202         entry-&gt;SetEntryL(KMsvDraftEntryId);
<a name="l00203"></a>00203         <span class="keywordflow">if</span>(iSelection-&gt;Count() &gt;= 1)
<a name="l00204"></a>00204                 {
<a name="l00205"></a>00205                 entry-&gt;SetEntryL((*iSelection)[0]);
<a name="l00206"></a>00206                 };
<a name="l00207"></a>00207                 
<a name="l00208"></a>00208         CleanupStack::PopAndDestroy(entry);
<a name="l00209"></a>00209         }
<a name="l00210"></a>00210         
<a name="l00215"></a><a class="code" href="class_c_send_as2_example.html#a1621f9de94164edff4d459d06cb82f44">00215</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#a1621f9de94164edff4d459d06cb82f44">CSendAs2Example::DisplayAccountL</a>()
<a name="l00216"></a>00216         {
<a name="l00217"></a>00217         CSendAsAccounts* accounts = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CSendAsAccounts::NewL</a>();
<a name="l00218"></a>00218         CleanupStack::PushL(accounts);
<a name="l00219"></a>00219         
<a name="l00220"></a>00220         <span class="comment">// Append 3 new accounts and associated name pair.</span>
<a name="l00221"></a>00221         <span class="keywordflow">if</span>(accounts-&gt;Count()==0)
<a name="l00222"></a>00222                 {
<a name="l00223"></a>00223                 accounts-&gt;AppendAccountL(KAccount1, 0xaaaaaaaa);        
<a name="l00224"></a>00224                 }
<a name="l00225"></a>00225         
<a name="l00226"></a>00226         <span class="keywordflow">if</span>(accounts-&gt;Count()==1)
<a name="l00227"></a>00227                 {
<a name="l00228"></a>00228                 accounts-&gt;AppendAccountL(KAccount2, 0x55555555);        
<a name="l00229"></a>00229                 }
<a name="l00230"></a>00230                 
<a name="l00231"></a>00231         <span class="keywordflow">if</span>(accounts-&gt;Count()==2)
<a name="l00232"></a>00232                 {
<a name="l00233"></a>00233                 accounts-&gt;AppendAccountL(KAccount3, 0x22222222);        
<a name="l00234"></a>00234                 }
<a name="l00235"></a>00235         iConsole-&gt;Printf( KAccountNames );
<a name="l00236"></a>00236         iConsole-&gt;Printf ( KPressAnyKey );
<a name="l00237"></a>00237         iConsole-&gt;Getch ();
<a name="l00238"></a>00238         
<a name="l00239"></a>00239         <span class="comment">// Display the array of names of accounts for this message type</span>
<a name="l00240"></a>00240         <span class="keywordflow">for</span>(TInt i = 0; i &lt; 3; i++)
<a name="l00241"></a>00241                 {
<a name="l00242"></a>00242                 TPtrC array = accounts-&gt;AccountNames().MdcaPoint(i);
<a name="l00243"></a>00243                 iConsole-&gt;Printf( array );      
<a name="l00244"></a>00244                 }
<a name="l00245"></a>00245                 
<a name="l00246"></a>00246         CleanupStack::PopAndDestroy(accounts);
<a name="l00247"></a>00247         
<a name="l00248"></a>00248         }
<a name="l00249"></a>00249 
<a name="l00255"></a><a class="code" href="class_c_send_as2_example.html#a40f320dceace4d1ff163a3944d8755fb">00255</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#a40f320dceace4d1ff163a3944d8755fb">CSendAs2Example::CapabilityFilterL</a>()
<a name="l00256"></a>00256         {
<a name="l00257"></a>00257         <span class="comment">// Get a list of MTMs available to send the message</span>
<a name="l00258"></a>00258         <span class="comment">// By specifying the features that the MTMs must have.</span>
<a name="l00259"></a>00259         <span class="comment">// Eg: set filter to test that KUidMtmQueryMaxBodySize &gt;= bodySize</span>
<a name="l00260"></a>00260         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQuerySupportAttachments));
<a name="l00261"></a>00261         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQueryMaxBodySize, 0x10, RSendAs::ESendAsGreaterThan));
<a name="l00262"></a>00262         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQuerySupportedBody, KMtm16BitBody, RSendAs::ESendAsBitwiseAnd));
<a name="l00263"></a>00263         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQuerySupportedBody, KMtm16BitBody, RSendAs::ESendAsBitwiseAnd));
<a name="l00264"></a>00264         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQuerySupportSubject));
<a name="l00265"></a>00265         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQuerySupportsFolder));
<a name="l00266"></a>00266         User::LeaveIfError(iSendAs.FilterAgainstCapability(KUidMtmQueryMaxRecipientCount));
<a name="l00267"></a>00267         }
<a name="l00268"></a>00268         
<a name="l00273"></a><a class="code" href="class_c_send_as2_example.html#ad91005c90f3863a181b7a54dc8f0c969">00273</a> <span class="keywordtype">void</span> <a class="code" href="class_c_send_as2_example.html#ad91005c90f3863a181b7a54dc8f0c969">CSendAs2Example::SendL</a>(RSendAsMessage&amp; aMessage)
<a name="l00274"></a>00274         {
<a name="l00275"></a>00275         iConsole-&gt;Printf ( KTextSend );
<a name="l00276"></a>00276         iConsole-&gt;Printf ( KPressAnyKey );
<a name="l00277"></a>00277         iConsole-&gt;Getch ();
<a name="l00278"></a>00278         
<a name="l00279"></a>00279         CMsvOperationWait* wait = CMsvOperationWait::NewLC();
<a name="l00280"></a>00280         wait-&gt;iStatus = KRequestPending;
<a name="l00281"></a>00281         wait-&gt;Start();
<a name="l00282"></a>00282         <span class="comment">// Asynchronously send the message.</span>
<a name="l00283"></a>00283         <span class="comment">// This will only be allowed to happen if the caller </span>
<a name="l00284"></a>00284         <span class="comment">// holds sufficient capabilities to perform this action. </span>
<a name="l00285"></a>00285         <span class="comment">// If the caller does not hold these capabilities, then </span>
<a name="l00286"></a>00286         <span class="comment">// the message send will be automatically demoted to a confirmed send.</span>
<a name="l00287"></a>00287         aMessage.SendMessage(wait-&gt;iStatus);
<a name="l00288"></a>00288         
<a name="l00289"></a>00289         CleanupStack::PopAndDestroy(wait);
<a name="l00290"></a>00290         iConsole-&gt;Printf ( KTextClose );
<a name="l00291"></a>00291         iConsole-&gt;Printf ( KExitKey );
<a name="l00292"></a>00292         iConsole-&gt;Getch ();
<a name="l00293"></a>00293         }
<a name="l00294"></a>00294 
<a name="l00295"></a><a class="code" href="_send_as2_example_8cpp.html#a689e0bf9aa924a1d7dc108665d44736c">00295</a> LOCAL_C <span class="keywordtype">void</span> MainL()
<a name="l00296"></a>00296         {
<a name="l00297"></a>00297         <span class="comment">// Creates an Active Scheduler to handle asychronous calls.</span>
<a name="l00298"></a>00298         CActiveScheduler* scheduler = <span class="keyword">new</span> (ELeave) CActiveScheduler;
<a name="l00299"></a>00299         <span class="comment">/*</span>
<a name="l00300"></a>00300 <span class="comment">        If an Active Scheduler has been created, installs it .</span>
<a name="l00301"></a>00301 <span class="comment">        As it is an asychronous call we need to install it explicitly.</span>
<a name="l00302"></a>00302 <span class="comment">        */</span>
<a name="l00303"></a>00303         CActiveScheduler::Install( scheduler );
<a name="l00304"></a>00304         
<a name="l00305"></a>00305         <a class="code" href="class_c_send_as2_example.html">CSendAs2Example</a>* app = <a class="code" href="class_c_send_as2_example.html#a2e08d46acb9714ab572ce1aff21f3d71">CSendAs2Example::NewL</a>();
<a name="l00306"></a>00306         CleanupStack::PushL(app);
<a name="l00307"></a>00307         <span class="comment">// Calls the main function in which other functions are called.</span>
<a name="l00308"></a>00308         app-&gt;<a class="code" href="class_c_send_as2_example.html#a7ccdc243eaf209d64a5e1850f4d6ed26">StartL</a>();
<a name="l00309"></a>00309         CleanupStack::PopAndDestroy(app);
<a name="l00310"></a>00310         
<a name="l00311"></a>00311         <span class="keyword">delete</span> scheduler;
<a name="l00312"></a>00312         }
<a name="l00313"></a>00313         
<a name="l00314"></a><a class="code" href="_send_as2_example_8cpp.html#a0f358e9c4355138f629b8c4f37310295">00314</a> GLDEF_C TInt E32Main()
<a name="l00315"></a>00315         {
<a name="l00316"></a>00316     __UHEAP_MARK;
<a name="l00317"></a>00317     CTrapCleanup* cleanup = CTrapCleanup::New();
<a name="l00318"></a>00318     <span class="keywordflow">if</span>(cleanup == NULL)
<a name="l00319"></a>00319         {
<a name="l00320"></a>00320         <span class="keywordflow">return</span> KErrNoMemory;
<a name="l00321"></a>00321         }
<a name="l00322"></a>00322     TRAPD(err, MainL());
<a name="l00323"></a>00323         <span class="keywordflow">if</span>(err != KErrNone)
<a name="l00324"></a>00324                 {       
<a name="l00325"></a>00325                 User::Panic(_L(<span class="stringliteral">&quot;failed to complete&quot;</span>),err);
<a name="l00326"></a>00326                 }
<a name="l00327"></a>00327 
<a name="l00328"></a>00328     <span class="keyword">delete</span> cleanup;
<a name="l00329"></a>00329     __UHEAP_MARKEND;
<a name="l00330"></a>00330     <span class="keywordflow">return</span> KErrNone;
<a name="l00331"></a>00331         }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>