| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * =========================================================================== | |||
| 3 | * Name : cvimpstcmdaddcontact.cpp | |||
| 4 | * Part of : IMUiServiceTab/vimpstcmdprocess | |||
| 5 | * Description : | |||
| 6 | * Version : %version: ou1s60rt#19 % | |||
| 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 "cvimpstcmdaddcontact.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 "mvimpstenginecontactmgmtextention.h" | |||
| 29 | #include "mvimpstengineextentionfeatures.h" | |||
| 30 | #include <MVPbkStoreContact.h> | |||
| 31 | #include <MVPbkFieldType.h> | |||
| 32 | #include <MVPbkContactFieldTextData.h> | |||
| 33 | #include <MVPbkContactFieldUriData.h> | |||
| 34 | ||||
| 35 | #include "cvimpststoragemanagerfactory.h" | |||
| 36 | #include "mvimpststorageserviceview.h" | |||
| 37 | #include "mvimpststoragecontact.h" | |||
| 38 | #include "tvimpstenums.h" | |||
| 39 | #include "tvimpstconsts.h" | |||
| 40 | #include "mvimpstenginesubservice.h" | |||
| 41 | #include "mvimpstenginepresencesubservice.h" | |||
| 42 | ||||
| 43 | // Constants | |||
| 44 | _LIT( KListNameAllBuddy ,"buddylist" ); | |||
| 45 | ||||
| 46 | // -------------------------------------------------------------------------- | |||
| 47 | // CVIMPSTCmdAddContact::CVIMPSTCmdAddContact | |||
| 48 | // -------------------------------------------------------------------------- | |||
| 49 | // | |||
| 4 | 4 | 50 | CVIMPSTCmdAddContact::CVIMPSTCmdAddContact( | |
| 51 | const TInt aCommandId ,const TDesC& aContactId, | |||
| 52 | MVIMPSTEngine& aEngine) : | |||
| 53 | iCommandId( aCommandId ), | |||
| 54 | iContactId( aContactId ), | |||
| 55 | iEngine(aEngine) | |||
| 56 | { | |||
| 57 | } | |||
| 58 | ||||
| 59 | // -------------------------------------------------------------------------- | |||
| 60 | // CVIMPSTCmdAddContact::~CVIMPSTCmdAddContact | |||
| 61 | // -------------------------------------------------------------------------- | |||
| 62 | // | |||
| 4 | 4 | 63 | CVIMPSTCmdAddContact::~CVIMPSTCmdAddContact() | |
| 64 | { | |||
| 65 | ||||
| 66 | } | |||
| 67 | ||||
| 68 | // -------------------------------------------------------------------------- | |||
| 69 | // CVIMPSTCmdAddContact::NewL | |||
| 70 | // -------------------------------------------------------------------------- | |||
| 71 | // | |||
| 4 | 0 | 72 | CVIMPSTCmdAddContact* CVIMPSTCmdAddContact::NewL( | |
| 73 | const TInt aCommandId,const TDesC& aContactId, | |||
| 74 | MVIMPSTEngine& aEngine) | |||
| 75 | { | |||
| 76 | CVIMPSTCmdAddContact* self = new (ELeave ) CVIMPSTCmdAddContact( aCommandId ,aContactId, aEngine); | |||
| 77 | self->ConstructL(); //use contsurctL if necessary | |||
| 78 | return self; | |||
| 79 | } | |||
| 80 | // -------------------------------------------------------------------------- | |||
| 81 | // CVIMPSTCmdAddContact::ConstructL | |||
| 82 | // -------------------------------------------------------------------------- | |||
| 83 | // | |||
| 4 | 4 | 84 | void CVIMPSTCmdAddContact::ConstructL() | |
| 85 | { | |||
| 86 | iError = KErrNone; | |||
| 87 | } | |||
| 88 | ||||
| 89 | // -------------------------------------------------------------------------- | |||
| 90 | // CVIMPSTCmdAddContact::ExecuteLD | |||
| 91 | // -------------------------------------------------------------------------- | |||
| 92 | // | |||
| 4 | 4 | 93 | void CVIMPSTCmdAddContact::ExecuteLD() | |
| 94 | { | |||
| 95 | CHAT_DP_FUNC_ENTER("CVIMPSTEnableServiceCmd::ExecuteLD"); | |||
| 96 | //push to the cleanupstack | |||
| 97 | CleanupStack::PushL( this ); | |||
| 98 | MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iEngine.ServiceId()) ; | |||
| 99 | if(storage ) | |||
| 100 | { | |||
| 101 | if( !IsContactBlocked(iContactId) ) | |||
| 102 | { | |||
| 103 | MVIMPSTStorageContact* alreadyExist = storage->FindContactByUserId( iContactId ); | |||
| 104 | if( !alreadyExist ) | |||
| 105 | { | |||
| 106 | iError = KErrNone; | |||
| 107 | MVIMPSTEngineExtentionFeatures* feature = iEngine.ExtentionFeatures(TVIMPSTEnums::EContactManagement); | |||
| 108 | if (feature) | |||
| 109 | { | |||
| 110 | MVIMPSTEngineContactMgmtExtention& contactMgr = | |||
| 111 | MVIMPSTEngineContactMgmtExtention::Cast (*feature); | |||
| 112 | // if there is a scenario when the user enters only the firstname , then userid is null. | |||
| 113 | //In this case don't send it to the server, Add the contact to the servicetab and | |||
| 114 | //presence will not be visible. | |||
| 115 | // check if contact is in the blocked list. | |||
| 116 | // iError already exist | |||
| 117 | if( iContactId.Length() ) | |||
| 118 | { | |||
| 119 | iError = contactMgr.AddServerContactL(KListNameAllBuddy,iContactId, KNullDesC() ); | |||
| 120 | }//End if(iContactId) | |||
| 121 | } //End if(feature) | |||
| 122 | if(KErrNone == iError) | |||
| 123 | { | |||
| 124 | storage->CreateNewContactL( iContactId ); | |||
| 125 | } | |||
| 126 | }//End if(alreadyExist) | |||
| 127 | else | |||
| 128 | { | |||
| 129 | iError = EErrExistInContactList; | |||
| 130 | } | |||
| 131 | } | |||
| 132 | else | |||
| 133 | { | |||
| 134 | iError = EErrExistInBlockList; | |||
| 135 | } | |||
| 136 | }//End if(storage) | |||
| 137 | ||||
| 138 | CHAT_DP_FUNC_ENTER("CVIMPSTEnableServiceCmd:: CommandFinished"); | |||
| 139 | ||||
| 140 | if(iObserver) | |||
| 141 | { | |||
| 142 | iObserver->CommandFinishedL(*this); | |||
| 143 | } | |||
| 144 | CHAT_DP_FUNC_ENTER("CVIMPSTEnableServiceCmd:: CommandFinished"); | |||
| 145 | CleanupStack::PopAndDestroy(); | |||
| 146 | CHAT_DP_FUNC_DONE("CVIMPSTEnableServiceCmd::ExecuteLD"); | |||
| 147 | } | |||
| 148 | ||||
| 149 | // -------------------------------------------------------------------------- | |||
| 150 | // CVIMPSTCmdAddContact::IsContactBlocked | |||
| 151 | // -------------------------------------------------------------------------- | |||
| 4 | 0 | 152 | TBool CVIMPSTCmdAddContact::IsContactBlocked(const TDesC& aUserId) | |
| 153 | { | |||
| 154 | MVIMPSTEngineSubService* subService = | |||
| 155 | (iEngine.SubService(TVIMPSTEnums::EPresence)); | |||
| 156 | if(subService) | |||
| 157 | { | |||
| 158 | MVIMPSTEnginePresenceSubService& presence = | |||
| 159 | MVIMPSTEnginePresenceSubService::Cast (*subService); | |||
| 160 | ||||
| 161 | RPointerArray<HBufC> *blockedlist = presence .GetBlockedList(); | |||
| 162 | ||||
| 163 | if(blockedlist) | |||
| 164 | { | |||
| 165 | for(TInt i=0; i<blockedlist->Count(); ++i) | |||
| 166 | { | |||
| 167 | if(0 == aUserId.CompareC((*blockedlist)[i]->Des())) | |||
| 168 | { | |||
| 169 | return ETrue; | |||
| 170 | } | |||
| 171 | } | |||
| 172 | } | |||
| 173 | } | |||
| 174 | return EFalse; | |||
| 175 | } | |||
| 176 | ||||
| 177 | // -------------------------------------------------------------------------- | |||
| 178 | // CVIMPSTCmdAddContact::AddObserver | |||
| 179 | // -------------------------------------------------------------------------- | |||
| 180 | // | |||
| 2 | 2 | 181 | void CVIMPSTCmdAddContact::AddObserver( MVIMPSTCmdObserver& aObserver ) | |
| 182 | { | |||
| 183 | // store the observer to notify the command completion | |||
| 184 | iObserver = &aObserver; | |||
| 185 | } | |||
| 186 | ||||
| 187 | ||||
| 188 | // -------------------------------------------------------------------------- | |||
| 189 | // CVIMPSTCmdAddContact::CommandId | |||
| 190 | // -------------------------------------------------------------------------- | |||
| 191 | // | |||
| 4 | 0 | 192 | TInt CVIMPSTCmdAddContact::CommandId() const | |
| 193 | { | |||
| 194 | return iCommandId; | |||
| 195 | } | |||
| 196 | ||||
| 197 | // -------------------------------------------------------------------------- | |||
| 198 | // CVIMPSTCmdAddContact::Result | |||
| 199 | // -------------------------------------------------------------------------- | |||
| 200 | // | |||
| 2 | 0 | 201 | TInt CVIMPSTCmdAddContact::Result() const | |
| 202 | { | |||
| 203 | //return valid data regd the command operation | |||
| 204 | return iError; | |||
| 205 | } | |||
| 206 | ||||
| 207 | // End of File | |||
| ***TER 100% (9/9) of SOURCE FILE cvimpstcmdaddcontact.cpp | ||||