| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * ============================================================================ | |||
| 3 | * Name : cvimpstcmdfactory.cpp | |||
| 4 | * Part of : IMUiServiceTab/vimpstcmdprocess | |||
| 5 | * Description : | |||
| 6 | * Version : %version: 34 % | |||
| 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 "cvimpstcmdfactory.h" | |||
| 21 | #include "cvimpstprocessarray.h" | |||
| 22 | #include "cvimpstcmdcca.h" | |||
| 23 | #include "cvimpstcmdlogin.h" | |||
| 24 | #include "cvimpstcmdlogout.h" | |||
| 25 | #include "cvimpstcmdcancellogin.h" | |||
| 26 | ||||
| 27 | #include "mvimpstcmdobserver.h" | |||
| 28 | #include "mvimpstengine.h" | |||
| 29 | #include "tvimpstconsts.h" | |||
| 30 | #include "cvimpststoragemanagerfactory.h" | |||
| 31 | #include "cvimpstcmdaddcontact.h" | |||
| 32 | #include "cvimpstcmddeletecontact.h" | |||
| 33 | #include "TVImpstConsts.h" | |||
| 34 | #include "cvimpstcmdchangeownstatus.h" | |||
| 35 | #include "cvimpstcmdchangeownmessage.h" | |||
| 36 | #include "cvimpstcmdsearch.h" | |||
| 37 | #include "cvimstcmdfriendrequest.h" | |||
| 38 | #include "cvimpstcmdchangeownavtar.h" | |||
| 39 | #include "cvimpstcmdcloseconversation.h" | |||
| 40 | #include "cvimpstcmdaddtopbk.h" | |||
| 41 | #include "cvimpstcmdprocessselectedcontact.h" | |||
| 42 | #include "cvimpstcmdblockcontact.h" | |||
| 43 | #include "cvimpstcmdunblockcontact.h" | |||
| 44 | #include "cvimpstcmdfetchblockedlist.h" | |||
| 45 | ||||
| 46 | ||||
| 47 | // ================= MEMBER FUNCTIONS ======================= | |||
| 48 | ||||
| 49 | ||||
| 50 | // -------------------------------------------------------------------------- | |||
| 51 | // CVIMPSTCmdFactory::CVIMPSTCmdFactory | |||
| 52 | // -------------------------------------------------------------------------- | |||
| 53 | // | |||
| 76 | 76 | 54 | CVIMPSTCmdFactory::CVIMPSTCmdFactory(MVIMPSTEngine& aEngine) : | |
| 55 | iEngine(aEngine) | |||
| 56 | { | |||
| 57 | } | |||
| 58 | ||||
| 59 | ||||
| 60 | // -------------------------------------------------------------------------- | |||
| 61 | // CVIMPSTCmdFactory::ConstructL | |||
| 62 | // -------------------------------------------------------------------------- | |||
| 63 | // | |||
| 76 | 76 | 64 | void CVIMPSTCmdFactory::ConstructL() | |
| 65 | { | |||
| 66 | ||||
| 67 | TUint32 serviceId = iEngine.ServiceId(); | |||
| 68 | ||||
| 69 | //Make sure we initialise the Storage view for this service | |||
| 70 | HBufC* storeName = HBufC::NewLC( KVIMPSTUISPSMaxPropertyLength ); | |||
| 71 | ||||
| 72 | TPtr storeNamePtr( storeName->Des() ); | |||
| 73 | ||||
| 74 | iEngine.ContactStoreIdL(storeNamePtr); | |||
| 75 | ||||
| 76 | CVIMPSTStorageManagerFactory::InitialiseViewL(serviceId, *storeName, iEngine.ServiceName()); | |||
| 77 | ||||
| 78 | CleanupStack::PopAndDestroy(); //storeName | |||
| 79 | ||||
| 80 | iEngine.IntializeStorageL(); | |||
| 81 | ||||
| 82 | ||||
| 83 | //create the array process | |||
| 84 | iArrayProcess = CVIMPSTProcessArray::NewL( iEngine ); | |||
| 85 | ||||
| 86 | iEngine.RegisterServiceSessionObserverL(this); | |||
| 87 | ||||
| 88 | } | |||
| 89 | ||||
| 90 | ||||
| 91 | // -------------------------------------------------------------------------- | |||
| 92 | // CVIMPSTCmdFactory::NewL | |||
| 93 | // -------------------------------------------------------------------------- | |||
| 94 | // | |||
| 76 | 0 | 95 | CVIMPSTCmdFactory* CVIMPSTCmdFactory::NewL(MVIMPSTEngine& aEngine) | |
| 96 | { | |||
| 97 | CVIMPSTCmdFactory* self = new (ELeave) CVIMPSTCmdFactory(aEngine); | |||
| 98 | CleanupStack::PushL(self); | |||
| 99 | self->ConstructL(); | |||
| 100 | CleanupStack::Pop(self); | |||
| 101 | return self; | |||
| 102 | } | |||
| 103 | ||||
| 104 | ||||
| 105 | // -------------------------------------------------------------------------- | |||
| 106 | // CVIMPSTCmdFactory::~CVIMPSTCmdFactory | |||
| 107 | // -------------------------------------------------------------------------- | |||
| 108 | // | |||
| 46 | 46 | 109 | CVIMPSTCmdFactory::~CVIMPSTCmdFactory() | |
| 110 | { | |||
| 111 | ||||
| 112 | iEngine.UnIntializeStorage(); | |||
| 113 | iEngine.UnRegisterServiceSessionObserver(this); | |||
| 114 | ||||
| 115 | delete iArrayProcess; | |||
| 116 | iArrayProcess = NULL; | |||
| 117 | ||||
| 118 | iObservers.Reset(); | |||
| 119 | iObservers.Close(); | |||
| 120 | } | |||
| 121 | ||||
| 122 | ||||
| 123 | // -------------------------------------------------------------------------- | |||
| 124 | // CVIMPSTCmdFactory::CreateCommandForIdL | |||
| 125 | // -------------------------------------------------------------------------- | |||
| 126 | // | |||
| 76 | 0 | 127 | MVIMPSTCmd* CVIMPSTCmdFactory::CreateCommandForIdL( | |
| 128 | TImCommandId aCommandId,TAny* aData /*NULL*/) | |||
| 129 | { | |||
| 130 | ||||
| 131 | MVIMPSTCmd* commd = NULL; | |||
| 132 | ||||
| 133 | //Instantiate appropriate command | |||
| 134 | switch ( aCommandId ) | |||
| 135 | { | |||
| 136 | case ELoginService: | |||
| 137 | { | |||
| 138 | commd = CVIMPSTCmdLogin::NewL(aCommandId,*(TUint32*)aData, iEngine); | |||
| 139 | break; | |||
| 140 | } | |||
| 141 | ||||
| 142 | case ELogoutService: | |||
| 143 | { | |||
| 144 | commd = CVIMPSTCmdLogout::NewL(aCommandId,*(TUint32*)aData, iEngine); | |||
| 145 | break; | |||
| 146 | } | |||
| 147 | case ELaunchCCA: | |||
| 148 | { | |||
| 149 | commd = CVIMPSTCmdCCA::NewL(aCommandId, | |||
| 150 | (*(TLaunchCCAData*)aData).iIndex, | |||
| 151 | (*(TLaunchCCAData*)aData).iConnection, | |||
| 152 | *iArrayProcess, | |||
| 153 | iEngine ); | |||
| 154 | break; | |||
| 155 | ||||
| 156 | } | |||
| 157 | case EAddContact: | |||
| 158 | { | |||
| 159 | commd = CVIMPSTCmdAddContact::NewL(aCommandId,*(TDesC*) aData, iEngine); | |||
| 160 | break; | |||
| 161 | ||||
| 162 | } | |||
| 163 | case EDeleteContact: | |||
| 164 | { | |||
| 165 | commd = CVIMPSTCmdDeleteContact::NewL(aCommandId,*(MVPbkContactLink**) aData, iEngine); | |||
| 166 | break; | |||
| 167 | ||||
| 168 | } | |||
| 169 | case EChangeOwnStatus: | |||
| 170 | { | |||
| 171 | commd = CVIMPSTCmdChangeOwnStatus::NewL(aCommandId,*(TStatusAndStatusText*) aData, iEngine); | |||
| 172 | break; | |||
| 173 | ||||
| 174 | } | |||
| 175 | case EChangeOwnMessage: | |||
| 176 | { | |||
| 177 | commd = CVIMPSTCmdChangeOwnMessage::NewL(aCommandId,*(TStatusAndStatusText*) aData, iEngine); | |||
| 178 | break; | |||
| 179 | ||||
| 180 | } | |||
| 181 | case ESearch: | |||
| 182 | { | |||
| 183 | commd = CVIMPSTCmdSearch::NewL(aCommandId,*(RArray<TVIMPSTSearchKeyData>*) aData, iEngine); | |||
| 184 | break; | |||
| 185 | ||||
| 186 | } | |||
| 187 | case EFriendAccpeted: | |||
| 188 | case EFriendRejected: | |||
| 189 | { | |||
| 190 | commd = CVIMPSTCmdFriendRequest::NewL(aCommandId,*(TDesC*) aData, iEngine); | |||
| 191 | break; | |||
| 192 | } | |||
| 193 | case EChangeOwnAvtar: | |||
| 194 | { | |||
| 195 | commd = CVIMPSTCmdChangeOwnAvtar::NewL(aCommandId,*(TAvatarData*) aData, iEngine); | |||
| 196 | break; | |||
| 197 | } | |||
| 198 | case ECloseConversation: | |||
| 199 | { | |||
| 200 | commd = CVIMPSTCmdCloseConversation::NewL(aCommandId,*(TDesC*) aData, iEngine); | |||
| 201 | break; | |||
| 202 | } | |||
| 203 | ||||
| 204 | case EAddToPbk: | |||
| 205 | { | |||
| 206 | commd = CVIMPSTCmdAddToPbk::NewL(aCommandId,*(MVIMPSTStorageContact*) aData, iEngine); | |||
| 207 | break; | |||
| 208 | } | |||
| 209 | case ECancelLogin: | |||
| 210 | { | |||
| 211 | commd = CVIMPSTCmdCancelLogin::NewL(aCommandId ,iEngine); | |||
| 212 | break; | |||
| 213 | } | |||
| 214 | ||||
| 215 | case ECmdProcessAcceptedContactNew: | |||
| 216 | case ECmdProcessSelectedContactNew: | |||
| 217 | case ECmdProcessAcceptedContactExist: | |||
| 218 | case ECmdProcessSelectedContactExist: | |||
| 219 | { | |||
| 220 | commd = CVIMPSTCmdProcessSelectedContact::NewL( aCommandId, *(TVPbkSelectedData*)aData, iEngine ); | |||
| 221 | break; | |||
| 222 | } | |||
| 223 | case ECmdBlockContact: | |||
| 224 | { | |||
| 225 | commd = CVIMPSTCmdBlockContact::NewL(aCommandId,*(TDesC*) aData, *iArrayProcess , iEngine); | |||
| 226 | break; | |||
| 227 | ||||
| 228 | } | |||
| 229 | case ECmdUnBlockContact: | |||
| 230 | { | |||
| 231 | commd = CVIMPSTCmdUnBlockContact::NewL(aCommandId,*(TDesC*) aData, iEngine); | |||
| 232 | break; | |||
| 233 | ||||
| 234 | } | |||
| 235 | case EFetchBlockedList: | |||
| 236 | { | |||
| 237 | commd = CVIMPSTCmdFetchBlockedContactList::NewL(aCommandId, iEngine); | |||
| 238 | break; | |||
| 239 | } | |||
| 240 | default: | |||
| 241 | { | |||
| 242 | break; | |||
| 243 | } | |||
| 244 | ||||
| 245 | } | |||
| 246 | ||||
| 247 | return commd; | |||
| 248 | ||||
| 249 | } | |||
| 250 | ||||
| 251 | // -------------------------------------------------------------------------- | |||
| 252 | // CVIMPSTCmdFactory::HandleServiceEventL | |||
| 253 | // -------------------------------------------------------------------------- | |||
| 254 | // | |||
| 0 | 0 | - | 255 | void CVIMPSTCmdFactory::HandleServiceEventL |
| 256 | ( TVIMPSTEnums::TVIMPSTRegistrationState aState,TInt aServiceError ) | |||
| 257 | { | |||
| 258 | // need not to store update complete state | |||
| 259 | iArrayProcess->SetLoginStateL( aState ); | |||
| 260 | for( TInt index( 0 ); index < iObservers.Count(); ++index ) | |||
| 261 | { | |||
| 262 | iObservers[index]->HandleCommandEventL(aState,aServiceError); | |||
| 263 | } | |||
| 264 | ||||
| 265 | } | |||
| 266 | // -------------------------------------------------------------------------- | |||
| 267 | // CVIMPSTCmdFactory::AddObserver | |||
| 268 | // -------------------------------------------------------------------------- | |||
| 269 | // | |||
| 0 | 0 | - | 270 | void CVIMPSTCmdFactory::AddObserverL(MVIMPSTCmdObserver* aObserver) |
| 271 | { | |||
| 272 | if( iObservers.Find( aObserver ) == KErrNotFound ) | |||
| 273 | { | |||
| 274 | User::LeaveIfError( iObservers.Append( aObserver ) ); | |||
| 275 | } | |||
| 276 | ||||
| 277 | } | |||
| 278 | // -------------------------------------------------------------------------- | |||
| 279 | // CVIMPSTCmdFactory::RemoveObserver | |||
| 280 | // -------------------------------------------------------------------------- | |||
| 281 | // | |||
| 0 | 0 | - | 282 | void CVIMPSTCmdFactory::RemoveObserver(MVIMPSTCmdObserver* aObserver) |
| 283 | { | |||
| 284 | ||||
| 285 | TInt index( iObservers.Find( aObserver) ); | |||
| 286 | ||||
| 287 | if( index != KErrNotFound ) | |||
| 288 | { | |||
| 289 | iObservers.Remove( index ); | |||
| 290 | } | |||
| 291 | ||||
| 292 | } | |||
| 293 | ||||
| 294 | ||||
| 295 | // -------------------------------------------------------------------------- | |||
| 296 | // CVIMPSTCmdFactory::GetProcessInterface | |||
| 297 | // -------------------------------------------------------------------------- | |||
| 298 | // | |||
| 0 | 0 | - | 299 | MVIMPSTProcessArray& CVIMPSTCmdFactory::GetProcessInterface() |
| 300 | { | |||
| 301 | return *iArrayProcess; | |||
| 302 | } | |||
| 303 | // End of File | |||
| 304 | ||||
| ***TER 56% (5/9) of SOURCE FILE cvimpstcmdfactory.cpp | ||||