phonebookui/Phonebook2/ServerApplication/src/CPbk2ContactSpeedDialAttributeUnassigner.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 speed dial attribute unassigner.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2ContactSpeedDialAttributeUnassigner.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "MPbk2ContactAssignerObserver.h"
       
    23 
       
    24 // Virtual Phonebook
       
    25 #include <CVPbkContactManager.h>
       
    26 #include <MVPbkStoreContactField.h>
       
    27 #include <CVPbkSpeedDialAttribute.h>
       
    28 #include <MVPbkContactOperationBase.h>
       
    29 
       
    30 
       
    31 // --------------------------------------------------------------------------
       
    32 // CPbk2ContactSpeedDialAttributeUnassigner::CPbk2ContactSpeedDialAttributeU.
       
    33 // --------------------------------------------------------------------------
       
    34 //
       
    35 CPbk2ContactSpeedDialAttributeUnassigner::
       
    36     CPbk2ContactSpeedDialAttributeUnassigner
       
    37         ( MPbk2ContactAssignerObserver& aObserver,
       
    38           CVPbkContactManager& aContactManager ) :
       
    39             CActive( EPriorityIdle ),
       
    40             iObserver( aObserver ),
       
    41             iContactManager( aContactManager )
       
    42     {
       
    43     CActiveScheduler::Add( this );
       
    44     }
       
    45 
       
    46 // --------------------------------------------------------------------------
       
    47 // CPbk2ContactSpeedDialAttributeUnassigner::~CPbk2ContactSpeedDialAttribute.
       
    48 // --------------------------------------------------------------------------
       
    49 //
       
    50 CPbk2ContactSpeedDialAttributeUnassigner::
       
    51         ~CPbk2ContactSpeedDialAttributeUnassigner()
       
    52     {
       
    53     Cancel();
       
    54 
       
    55     delete iUnassignOperation;
       
    56     delete iAttribute;
       
    57     delete iStoreContactField;
       
    58     }
       
    59 
       
    60 // --------------------------------------------------------------------------
       
    61 // CPbk2ContactSpeedDialAttributeUnassigner::NewL
       
    62 // --------------------------------------------------------------------------
       
    63 //
       
    64 CPbk2ContactSpeedDialAttributeUnassigner*
       
    65     CPbk2ContactSpeedDialAttributeUnassigner::NewL
       
    66         ( MPbk2ContactAssignerObserver& aObserver,
       
    67           CVPbkContactManager& aContactManager )
       
    68     {
       
    69     CPbk2ContactSpeedDialAttributeUnassigner* self =
       
    70         new ( ELeave ) CPbk2ContactSpeedDialAttributeUnassigner
       
    71             ( aObserver, aContactManager );
       
    72     return self;
       
    73     }
       
    74 
       
    75 // --------------------------------------------------------------------------
       
    76 // CPbk2ContactSpeedDialAttributeUnassigner::AssignDataL
       
    77 // --------------------------------------------------------------------------
       
    78 //
       
    79 void CPbk2ContactSpeedDialAttributeUnassigner::AssignDataL
       
    80         ( MVPbkStoreContact& /*aStoreContact*/,
       
    81           MVPbkStoreContactField* /*aContactField*/,
       
    82           const MVPbkFieldType* /*aFieldType*/,
       
    83           const HBufC* /*aDataBuffer*/ )
       
    84     {
       
    85     // Not supported
       
    86     User::Leave( KErrNotSupported );
       
    87     }
       
    88 
       
    89 // --------------------------------------------------------------------------
       
    90 // CPbk2ContactSpeedDialAttributeUnassigner::AssignAttributeL
       
    91 // --------------------------------------------------------------------------
       
    92 //
       
    93 void CPbk2ContactSpeedDialAttributeUnassigner::AssignAttributeL
       
    94         ( MVPbkStoreContact& /*aStoreContact*/,
       
    95           MVPbkStoreContactField* aContactField,
       
    96           TPbk2AttributeAssignData aAttributeAssignData )
       
    97     {
       
    98     iAttributeAssignData = aAttributeAssignData;
       
    99 
       
   100     if ( aContactField )
       
   101         {
       
   102         iStoreContactField = aContactField->CloneLC();
       
   103         CleanupStack::Pop(); // iStoreContactField
       
   104         }
       
   105     else
       
   106         {
       
   107         // Speed dial attribute works on contact field level
       
   108         User::Leave( KErrArgument );
       
   109         }
       
   110 
       
   111     IssueRequest();
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // CPbk2ContactSpeedDialAttributeUnassigner::AttributeOperationComplete
       
   116 // --------------------------------------------------------------------------
       
   117 //
       
   118 void CPbk2ContactSpeedDialAttributeUnassigner::AttributeOperationComplete
       
   119         ( MVPbkContactOperationBase& /*aOperation*/ )
       
   120     {
       
   121     iObserver.AssignComplete( *this, KErrNotSupported );
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // CPbk2ContactSpeedDialAttributeUnassigner::AttributeOperationFailed
       
   126 // --------------------------------------------------------------------------
       
   127 //
       
   128 void CPbk2ContactSpeedDialAttributeUnassigner::AttributeOperationFailed
       
   129         ( MVPbkContactOperationBase& /*aOperation*/, TInt aError )
       
   130     {
       
   131     iObserver.AssignFailed( *this, aError );
       
   132     }
       
   133 
       
   134 // --------------------------------------------------------------------------
       
   135 // CPbk2ContactSpeedDialAttributeUnassigner::RunL
       
   136 // --------------------------------------------------------------------------
       
   137 //
       
   138 void CPbk2ContactSpeedDialAttributeUnassigner::RunL()
       
   139     {
       
   140     UnassignAttributeL();
       
   141     }
       
   142 
       
   143 // --------------------------------------------------------------------------
       
   144 // CPbk2ContactSpeedDialAttributeUnassigner::DoCancel
       
   145 // --------------------------------------------------------------------------
       
   146 //
       
   147 void CPbk2ContactSpeedDialAttributeUnassigner::DoCancel()
       
   148     {
       
   149     // Nothing to do
       
   150     }
       
   151 
       
   152 // --------------------------------------------------------------------------
       
   153 // CPbk2ContactSpeedDialAttributeUnassigner::RunError
       
   154 // --------------------------------------------------------------------------
       
   155 //
       
   156 TInt CPbk2ContactSpeedDialAttributeUnassigner::RunError( TInt aError )
       
   157     {
       
   158     iObserver.AssignFailed( *this, aError );
       
   159     return KErrNone;
       
   160     }
       
   161 
       
   162 // --------------------------------------------------------------------------
       
   163 // CPbk2ContactSpeedDialAttributeUnassigner::UnassignAttributeL
       
   164 // --------------------------------------------------------------------------
       
   165 //
       
   166 void CPbk2ContactSpeedDialAttributeUnassigner::UnassignAttributeL()
       
   167     {
       
   168     delete iAttribute;
       
   169     iAttribute = NULL;
       
   170     iAttribute = CVPbkSpeedDialAttribute::NewL
       
   171         ( iAttributeAssignData.iAttributeValue );
       
   172 
       
   173     delete iUnassignOperation;
       
   174     iUnassignOperation = NULL;
       
   175     iUnassignOperation = iContactManager.ContactAttributeManagerL().
       
   176         RemoveFieldAttributeL( *iStoreContactField, *iAttribute, *this );
       
   177     }
       
   178 
       
   179 // --------------------------------------------------------------------------
       
   180 // CPbk2ContactSpeedDialAttributeUnassigner::IssueRequest
       
   181 // --------------------------------------------------------------------------
       
   182 //
       
   183 void CPbk2ContactSpeedDialAttributeUnassigner::IssueRequest()
       
   184     {
       
   185     TRequestStatus* status = &iStatus;
       
   186     User::RequestComplete( status, KErrNone );
       
   187     SetActive();
       
   188     }
       
   189 
       
   190 // End of File