messagingappbase/obexmtms/TObexMTM/SRC/SetObexMessageRecipientState.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // $Workfile: CSetObexMessageRecipientState.cpp $
       
    15 // $Author: ChristopherR $
       
    16 // $Revision: 5 $
       
    17 // $Date: 31/01/02 10:07 $
       
    18 // 
       
    19 //
       
    20 
       
    21 
       
    22 #include "SetObexMessageRecipientStates.h"
       
    23 
       
    24 //TODO:- check that all these headers are required
       
    25 
       
    26 // System includes
       
    27 #include <btmsgtypeuid.h>   // KUidMsgTypeBt
       
    28 #include <btmtmcmds.h>      // TBtMtmAsyncCmds
       
    29 #include <irmsgtypeuid.h>   // KUidMsgTypeIr
       
    30 #include <irmtmcmds.h>      // TIrMtmAsyncCmds
       
    31 #include <msvuids.h>        // KUidMsvMessageEntry
       
    32 
       
    33 // User includes
       
    34 #include "obexharness.h"
       
    35 #include "obextestutils.h"
       
    36 #include "sendasstates.h"
       
    37 //
       
    38 // CSetObexMessageBTRecipientState
       
    39 //
       
    40 CSetObexMessageBTRecipientState::CSetObexMessageBTRecipientState(const TDesC& aRecipient, CObexClientTest& aClientTest) :
       
    41  iClientTest(aClientTest)
       
    42     {
       
    43 	TPtrC16 ptr16 = aRecipient;
       
    44 
       
    45 	int ii;
       
    46 
       
    47 	for(ii=0;ii<12;ii+=4)
       
    48 		{
       
    49 		// do 4 characters to get one out. We're going to force the compiler to do the character endianness.
       
    50 		TUint8 byte1 = CObexSendAsAddBTRecipientState::GetByteFromUnicodeHexTextChar(&ptr16[ii]);
       
    51 		TUint8 byte2 = CObexSendAsAddBTRecipientState::GetByteFromUnicodeHexTextChar(&ptr16[ii+1]);
       
    52 		TUint8 byte3 = CObexSendAsAddBTRecipientState::GetByteFromUnicodeHexTextChar(&ptr16[ii+2]);
       
    53 		TUint8 byte4 = CObexSendAsAddBTRecipientState::GetByteFromUnicodeHexTextChar(&ptr16[ii+3]);
       
    54 
       
    55 		byte1 = (TUint8) ( ((byte1 & 0x0F) << 4) | (byte2 & 0x0f) );
       
    56 		byte3 = (TUint8) ( ((byte3 & 0x0F) << 4) | (byte4 & 0x0f) );
       
    57 
       
    58 		// make sure this is put together in network endianness
       
    59 		TUint16 result = (TUint16)( (TUint16)(byte3 << 8) | byte1 );
       
    60 
       
    61 		iRecipient.Append( result );
       
    62 		}
       
    63     }
       
    64 
       
    65 void CSetObexMessageBTRecipientState::StartL(TRequestStatus& aStatus)
       
    66     {
       
    67     // open our existing entry and set the addressee.
       
    68     CObexTestUtils& testUtils = iClientTest.ObexTestUtils();
       
    69     TUid mtm = testUtils.CurrentObexMtm();
       
    70     (mtm == KUidMsgTypeBt) ? testUtils.InstantiateBTClientMtmL() : testUtils.InstantiateIRClientMtmL();
       
    71     CBaseMtm& client = testUtils.GetCurrentObexClientMtm();
       
    72     
       
    73     client.SwitchCurrentEntryL(testUtils.Entry().Id());
       
    74     client.LoadMessageL();
       
    75 	client.AddAddresseeL(iRecipient);
       
    76 	client.SaveMessageL();
       
    77 
       
    78     TRequestStatus* status = &aStatus;
       
    79 	User::RequestComplete(status, KErrNone);
       
    80     }
       
    81 
       
    82 
       
    83 //
       
    84 // CSetObexMessageRecipientState
       
    85 //
       
    86 CSetObexMessageRecipientState::CSetObexMessageRecipientState(const TDesC& aRecipient, CObexClientTest& aClientTest) :
       
    87  iClientTest(aClientTest),
       
    88  iRecipient(aRecipient)
       
    89     {
       
    90     }
       
    91 
       
    92 void CSetObexMessageRecipientState::StartL(TRequestStatus& aStatus)
       
    93     {
       
    94     // open our existing entry and set the addressee.
       
    95     CObexTestUtils& testUtils = iClientTest.ObexTestUtils();
       
    96     TUid mtm = testUtils.CurrentObexMtm();
       
    97     (mtm == KUidMsgTypeBt) ? testUtils.InstantiateBTClientMtmL() : testUtils.InstantiateIRClientMtmL();
       
    98     CBaseMtm& client = testUtils.GetCurrentObexClientMtm();
       
    99     
       
   100     client.SwitchCurrentEntryL(testUtils.Entry().Id());
       
   101     client.LoadMessageL();
       
   102 	client.AddAddresseeL(iRecipient);
       
   103 	client.SaveMessageL();
       
   104 
       
   105     TRequestStatus* status = &aStatus;
       
   106 	User::RequestComplete(status, KErrNone);
       
   107     }