presadap12/impsplugin/src/presenceauthorization/cwithdrawpresencegrantfromeveryonerequest.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Create Presentity Group Request to the Network Server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ximpprotocolconnectionhost.h>
       
    20 #include "CWithdrawPresenceGrantFromEveryoneRequest.h"
       
    21 #include "impsconnectionmanagercontrolif.h"
       
    22 #include "impsdebugprint.h"
       
    23 #include "CImpsPluginAccessHandler.h"
       
    24 #include "CImpsPluginPureDataHandler.h"
       
    25 #include <protocolpresenceauthorizationdatahost.h>
       
    26 
       
    27 #include "CPEngXMLParser.h"
       
    28 #include "MPEngXMLParser.h"
       
    29 #include "CPEngXmlSerializer.h"
       
    30 #include "MPEngXmlSerializer.h"
       
    31 #include "CImpsPluginConnectionManager.h"
       
    32 #include "PEngXMLTags.h"
       
    33 
       
    34 #include <ximpobjectfactory.h>
       
    35 #include <ximpobjectcollection.h>
       
    36 #include <protocolpresentitygroupsdatahost.h>
       
    37 #include <presentitygroupinfo.h>
       
    38 #include <presentitygroupmemberinfo.h>
       
    39 #include <ximpidentity.h>
       
    40 #include "PImpsAdapXMLTools.h"
       
    41 
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CWithdrawPresenceGrantFromEveryoneRequest::CWithdrawPresenceGrantFromEveryoneRequest
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CWithdrawPresenceGrantFromEveryoneRequest::CWithdrawPresenceGrantFromEveryoneRequest(
       
    50     MImpsPrtPluginConnectionManager& aConnMan,
       
    51     TXIMPRequestId aRequestId ) :
       
    52         CActive( EPriorityNormal ),
       
    53         iRequestId( aRequestId ),
       
    54         iConnMan( aConnMan )
       
    55     {
       
    56     IMPS_DP( D_IMPS_LIT( "::CWithdrawPresenceGrantFromEveryoneRequest Start" ) );
       
    57     CActiveScheduler::Add( this );
       
    58     IMPS_DP( D_IMPS_LIT( "::CWithdrawPresenceGrantFromEveryoneRequest End" ) );
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CWithdrawPresenceGrantFromEveryoneRequest::ConstructL
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CWithdrawPresenceGrantFromEveryoneRequest::ConstructL()
       
    67     {
       
    68     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::ConstructL Start-End" ) );
       
    69 
       
    70     iParser = CreateXMLParserL();
       
    71 
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CWithdrawPresenceGrantFromEveryoneRequest::NewL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CWithdrawPresenceGrantFromEveryoneRequest* CWithdrawPresenceGrantFromEveryoneRequest::NewL(
       
    80     MImpsPrtPluginConnectionManager& aConnMan,
       
    81     TXIMPRequestId aRequestId )
       
    82     {
       
    83     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::NewL Start" ) );
       
    84 
       
    85     CWithdrawPresenceGrantFromEveryoneRequest* self = new( ELeave )
       
    86     CWithdrawPresenceGrantFromEveryoneRequest( aConnMan, aRequestId );
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop( self );
       
    90 
       
    91     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::NewL End" ) );
       
    92     return self;
       
    93     }
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CWithdrawPresenceGrantFromEveryoneRequest::NewLC
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 CWithdrawPresenceGrantFromEveryoneRequest* CWithdrawPresenceGrantFromEveryoneRequest::NewLC(
       
   101     MImpsPrtPluginConnectionManager& aConnMan,
       
   102     TXIMPRequestId aRequestId )
       
   103     {
       
   104     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::NewLC Start" ) );
       
   105 
       
   106     CWithdrawPresenceGrantFromEveryoneRequest* self =
       
   107         CWithdrawPresenceGrantFromEveryoneRequest::NewL( aConnMan, aRequestId );
       
   108     CleanupStack::PushL( self );
       
   109 
       
   110     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::NewLC End" ) );
       
   111     return self;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CWithdrawPresenceGrantFromEveryoneRequest::~CWithdrawPresenceGrantFromEveryoneRequest
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 CWithdrawPresenceGrantFromEveryoneRequest::~CWithdrawPresenceGrantFromEveryoneRequest()
       
   119     {
       
   120     IMPS_DP( D_IMPS_LIT( "::~CWithdrawPresenceGrantFromEveryoneRequest Start-End" ) );
       
   121     delete iResponse;
       
   122     CActive::Cancel();
       
   123     iConnMan.Remove( this );
       
   124     delete iParser;
       
   125     delete iGroupName;
       
   126     delete iContactName;
       
   127     delete iUserId;
       
   128     }
       
   129 
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // CWithdrawPresenceGrantFromEveryoneRequest::DoCancel()
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CWithdrawPresenceGrantFromEveryoneRequest::DoCancel()
       
   136     {
       
   137     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::DoCancel Start" ) );
       
   138 
       
   139     iConnMan.DataHandler().CancelSending( iSendId );
       
   140 
       
   141     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::DoCancel End" ) );
       
   142     }
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CWithdrawPresenceGrantFromEveryoneRequest::RunL()
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CWithdrawPresenceGrantFromEveryoneRequest::RunL()
       
   150     {
       
   151     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::RunL Start" ) );
       
   152 
       
   153     User::LeaveIfError( iStatus.Int() );
       
   154 
       
   155     iResponse = iConnMan.DataHandler().ResponseL( iSendId );
       
   156 
       
   157     TPtrC8 resultBlock( NULL, 0 );
       
   158     TInt wvErrorCode = KErrNone;
       
   159 
       
   160     // Check if we got 200
       
   161     if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) )
       
   162         {
       
   163         resultBlock.Set( iParser->ResultL() );
       
   164         if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) )
       
   165             {
       
   166             TPtrC8 cspStatusCodeBlock( iParser->ResultL() );
       
   167             TInt cspStatusInt;
       
   168             TLex8 lexer( cspStatusCodeBlock );
       
   169             lexer.SkipSpace();
       
   170             TInt lexErr = lexer.Val( cspStatusInt );
       
   171             if ( lexErr == KErrNone )
       
   172                 {
       
   173                 wvErrorCode = cspStatusInt;
       
   174                 }
       
   175             }
       
   176         }
       
   177 
       
   178     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest  %d" ), wvErrorCode );
       
   179     iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode );
       
   180 
       
   181     delete this;
       
   182     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::RunL End" ) );
       
   183     }
       
   184 
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // CWithdrawPresenceGrantFromEveryoneRequest::RunError
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 TInt CWithdrawPresenceGrantFromEveryoneRequest::RunError( TInt  aError )
       
   191     {
       
   192     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::RunError Start" ) );
       
   193 
       
   194     iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError );
       
   195 
       
   196     delete this;
       
   197     IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromEveryoneRequest::RunError End" ) );
       
   198     return KErrNone;
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // CWithdrawPresenceGrantFromEveryoneRequest::WithdrawPresenceGrantFromEveryoneL
       
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 void CWithdrawPresenceGrantFromEveryoneRequest::WithdrawPresenceGrantFromEveryoneL()
       
   206     {
       
   207     IMPS_DP( D_IMPS_LIT( "::WithdrawPresenceGrantFromEveryoneL Start" ) );
       
   208 
       
   209     TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() );
       
   210     MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer );
       
   211 
       
   212     NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() );
       
   213 
       
   214     serializer->StartTagL( KCreateAttributeList );
       
   215     serializer->StartTagL( KPresenceSubList );
       
   216     serializer->AttributeL( KXmlXmlns, KPresenceSubListAttributesNS_CSP12 );
       
   217     // empty list so that all attributes
       
   218     serializer->EndTagL( KPresenceSubList );
       
   219 
       
   220     // set some duplicate attribute to true.
       
   221     serializer->StartTagL( KTimeZone ).EndTagL( KTimeZone );
       
   222     serializer->StartTagL( KDefaultList ).NarrowTextL( KXMLValueTrue ).EndTagL( KDefaultList );
       
   223     serializer->EndTagL( KCreateAttributeList );
       
   224     serializer->EndTagL( KTransactionContent );
       
   225 
       
   226     IMPS_DP( D_IMPS_LIT( "WithdrawPresenceGrantFromEveryoneL" ) );
       
   227 
       
   228     CleanupStack::PopAndDestroy(); //serializer
       
   229 
       
   230     iSendId = iConnMan.DataHandler().SendDataL( iStatus );
       
   231 
       
   232     // signal the scheduler
       
   233     SetActive();
       
   234 
       
   235     IMPS_DP( D_IMPS_LIT( "::WithdrawPresenceGrantFromEveryoneL End" ) );
       
   236     }
       
   237 
       
   238 // End of file