| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * =========================================================================== | |||
| 3 | * Name : cvimpstcmddaletecontact.cpp | |||
| 4 | * Part of : IMUiServiceTab/vimpstcmdprocess | |||
| 5 | * Description : | |||
| 6 | * Version : %version: ou1s60rt#14 % | |||
| 7 | * | |||
| 8 | * Copyright © 2008 Nokia. All rights reserved. | |||
| 9 | * This material, including documentation and any related computer | |||
| 10 | * programs, is protected by copyright controlled by Nokia. All | |||
| 11 | * rights are reserved. Copying, including reproducing, storing, | |||
| 12 | * adapting or translating, any or all of this material requires the | |||
| 13 | * prior written consent of Nokia. This material also contains | |||
| 14 | * confidential information which may not be disclosed to others | |||
| 15 | * without the prior written consent of Nokia. | |||
| 16 | * ============================================================================ | |||
| 17 | */ | |||
| 18 | ||||
| 19 | // INCLUDE FILES | |||
| 20 | #include "cvimpstcmddeletecontact.h" | |||
| 21 | ||||
| 22 | #include "vimpstcmd.hrh" | |||
| 23 | #include "mvimpstcmdobserver.h" | |||
| 24 | #include "vimpstdebugprint.h" | |||
| 25 | ||||
| 26 | #include <e32def.h> | |||
| 27 | #include "mvimpstengine.h" | |||
| 28 | #include "cvimpststoragemanagerfactory.h" | |||
| 29 | #include "mvimpststorageserviceview.h" | |||
| 30 | #include "mvimpstenginesubservice.h" | |||
| 31 | #include "mvimpstenginecontactmgmtextention.h" | |||
| 32 | #include "mvimpstengineextentionfeatures.h" | |||
| 33 | #include "mvimpstengineimsubservice.h" | |||
| 34 | #include "tvimpstenums.h" | |||
| 35 | #include "tvimpstconsts.h" | |||
| 36 | #include "mvimpstenginesubservice.h" | |||
| 37 | #include "mvimpstenginepresencesubservice.h" | |||
| 38 | #include "mvimpstenginepresencesubservice.h" | |||
| 39 | ||||
| 40 | // Constants | |||
| 41 | _LIT( KListNameAllBuddy ,"buddylist" ); | |||
| 42 | _LIT( KPresenceBlockedList, "blockedcontacts"); | |||
| 43 | ||||
| 44 | ||||
| 45 | // -------------------------------------------------------------------------- | |||
| 46 | // CVIMPSTCmdDeleteContact::CVIMPSTCmdDeleteContact | |||
| 47 | // -------------------------------------------------------------------------- | |||
| 48 | // | |||
| 4 | 4 | 49 | CVIMPSTCmdDeleteContact::CVIMPSTCmdDeleteContact( | |
| 50 | const TInt aCommandId , MVPbkContactLink* aContactLink, | |||
| 51 | MVIMPSTEngine& aEngine) : | |||
| 52 | iCommandId( aCommandId ), | |||
| 53 | iContactLink( aContactLink ), | |||
| 54 | iEngine(aEngine) | |||
| 55 | { | |||
| 56 | } | |||
| 57 | ||||
| 58 | // -------------------------------------------------------------------------- | |||
| 59 | // CVIMPSTCmdDeleteContact::~CVIMPSTCmdDeleteContact | |||
| 60 | // -------------------------------------------------------------------------- | |||
| 61 | // | |||
| 4 | 4 | 62 | CVIMPSTCmdDeleteContact::~CVIMPSTCmdDeleteContact() | |
| 63 | { | |||
| 64 | ||||
| 65 | } | |||
| 66 | ||||
| 67 | // -------------------------------------------------------------------------- | |||
| 68 | // CVIMPSTCmdDeleteContact::NewL | |||
| 69 | // -------------------------------------------------------------------------- | |||
| 70 | // | |||
| 4 | 0 | 71 | CVIMPSTCmdDeleteContact* CVIMPSTCmdDeleteContact::NewL( | |
| 72 | const TInt aCommandId, MVPbkContactLink* aContactLink, | |||
| 73 | MVIMPSTEngine& aEngine) | |||
| 74 | { | |||
| 75 | CVIMPSTCmdDeleteContact* self = new (ELeave ) CVIMPSTCmdDeleteContact( aCommandId ,aContactLink, aEngine); | |||
| 76 | self->ConstructL(); //use contsurctL if necessary | |||
| 77 | return self; | |||
| 78 | } | |||
| 79 | // -------------------------------------------------------------------------- | |||
| 80 | // CVIMPSTCmdDeleteContact::ConstructL | |||
| 81 | // -------------------------------------------------------------------------- | |||
| 82 | // | |||
| 4 | 4 | 83 | void CVIMPSTCmdDeleteContact::ConstructL() | |
| 84 | { | |||
| 85 | iError = KErrNone; | |||
| 86 | } | |||
| 87 | ||||
| 88 | // -------------------------------------------------------------------------- | |||
| 89 | // CVIMPSTCmdDeleteContact::ExecuteLD | |||
| 90 | // -------------------------------------------------------------------------- | |||
| 91 | // | |||
| 4 | 4 | 92 | void CVIMPSTCmdDeleteContact::ExecuteLD() | |
| 93 | { | |||
| 94 | CHAT_DP_FUNC_ENTER("CVIMPSTCmdDeleteContact::ExecuteLD"); | |||
| 95 | //push to the cleanupstack | |||
| 96 | CleanupStack::PushL( this ); | |||
| 97 | iError = KErrNone; | |||
| 98 | MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL( iEngine.ServiceId()) ; | |||
| 99 | if(storage) | |||
| 100 | { | |||
| 101 | MVIMPSTStorageContact* contact = storage->FindContactByLink( *iContactLink ); | |||
| 102 | if (contact ) | |||
| 103 | { | |||
| 104 | TBuf<KUsernameMaxLength> listId; | |||
| 105 | listId.Zero(); | |||
| 106 | listId.Append(KListNameAllBuddy); | |||
| 107 | if(TVIMPSTEnums::EBlocked == contact->OnlineStatus()) | |||
| 108 | { | |||
| 109 | listId.Zero(); | |||
| 110 | listId.Append(KPresenceBlockedList); | |||
| 111 | } | |||
| 112 | TPtrC userIdPtr = contact->UserId(); | |||
| 113 | MVIMPSTEngineSubService* subService = iEngine.SubService(TVIMPSTEnums::EPresence); | |||
| 114 | MVIMPSTEngineExtentionFeatures* feature = iEngine.ExtentionFeatures(TVIMPSTEnums::EContactManagement); | |||
| 115 | //Get IM SubService | |||
| 116 | MVIMPSTEngineSubService* imService = iEngine.SubService(TVIMPSTEnums::EIM) ; | |||
| 117 | //for each userid in the service details, unsubscribe | |||
| 118 | if( userIdPtr.Length() ) | |||
| 119 | { | |||
| 120 | if( subService ) | |||
| 121 | { | |||
| 122 | MVIMPSTEnginePresenceSubService& presenceSubService = MVIMPSTEnginePresenceSubService::Cast(*subService); | |||
| 123 | presenceSubService.UnSubscribePresenceOfSingleContactL( userIdPtr ); | |||
| 124 | } | |||
| 125 | if (feature ) | |||
| 126 | { | |||
| 127 | MVIMPSTEngineContactMgmtExtention& contactMgr = MVIMPSTEngineContactMgmtExtention::Cast(*feature); | |||
| 128 | TRAP(iError, contactMgr.DeleteServerContactL(listId, userIdPtr ) ); | |||
| 129 | } | |||
| 130 | if(imService ) | |||
| 131 | { | |||
| 132 | MVIMPSTEngineIMSubService& imSubService = | |||
| 133 | MVIMPSTEngineIMSubService::Cast (*imService); | |||
| 134 | TRAP_IGNORE( imSubService.CloseConversationL( userIdPtr )); | |||
| 135 | } | |||
| 136 | } | |||
| 137 | if( iError == KErrNone ) | |||
| 138 | { | |||
| 139 | storage->RemoveContactL( contact ); | |||
| 140 | } | |||
| 141 | } // contact | |||
| 142 | } // storage | |||
| 143 | CHAT_DP_FUNC_ENTER("CVIMPSTCmdDeleteContact:: CommandFinished"); | |||
| 144 | ||||
| 145 | if(iObserver) | |||
| 146 | { | |||
| 147 | iObserver->CommandFinishedL(*this); | |||
| 148 | } | |||
| 149 | CHAT_DP_FUNC_ENTER("CVIMPSTCmdDeleteContact:: CommandFinished"); | |||
| 150 | CleanupStack::PopAndDestroy(); | |||
| 151 | CHAT_DP_FUNC_DONE("CVIMPSTCmdDeleteContact::ExecuteLD"); | |||
| 152 | } | |||
| 153 | ||||
| 154 | ||||
| 155 | // -------------------------------------------------------------------------- | |||
| 156 | // CVIMPSTCmdDeleteContact::AddObserver | |||
| 157 | // -------------------------------------------------------------------------- | |||
| 158 | // | |||
| 2 | 2 | 159 | void CVIMPSTCmdDeleteContact::AddObserver( MVIMPSTCmdObserver& aObserver ) | |
| 160 | { | |||
| 161 | // store the observer to notify the command completion | |||
| 162 | iObserver = &aObserver; | |||
| 163 | } | |||
| 164 | ||||
| 165 | ||||
| 166 | // -------------------------------------------------------------------------- | |||
| 167 | // CVIMPSTCmdDeleteContact::CommandId | |||
| 168 | // -------------------------------------------------------------------------- | |||
| 169 | // | |||
| 4 | 0 | 170 | TInt CVIMPSTCmdDeleteContact::CommandId() const | |
| 171 | { | |||
| 172 | return iCommandId; | |||
| 173 | } | |||
| 174 | ||||
| 175 | // -------------------------------------------------------------------------- | |||
| 176 | // CVIMPSTCmdDeleteContact::Result | |||
| 177 | // -------------------------------------------------------------------------- | |||
| 178 | // | |||
| 2 | 0 | 179 | TInt CVIMPSTCmdDeleteContact::Result() const | |
| 180 | { | |||
| 181 | //return valid data regd the command operation | |||
| 182 | return iError; | |||
| 183 | } | |||
| 184 | ||||
| 185 | // End of File | |||
| ***TER 100% (8/8) of SOURCE FILE cvimpstcmddeletecontact.cpp | ||||