messagingapp/msgui/appengine/tsrc/testconversationengine/src/testccsrequesthandler.cpp
changeset 37 518b245aa84c
child 48 4f501b74aeb1
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
       
     1 /*
       
     2  * Copyright (c) 2009 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:
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // SYSTEM INCLUDES
       
    22 #include <ccsconversationentry.h>
       
    23 #include <ccsclientconversation.h>
       
    24 #include <mcsresultsobserver.h>
       
    25 #include <mcsconversationlistchangeobserver.h>
       
    26 #include <mcsconversationchangeobserver.h>
       
    27 #include <mcscachingstatusobserver.h>
       
    28 #include <ccsrequesthandler.h>
       
    29 #include <rcssession.h>
       
    30 
       
    31 
       
    32 //USER INCLUDES
       
    33 
       
    34 #include "ccsconversationchangeobserver.h"
       
    35 #include "testconversationenginestub.h"
       
    36 
       
    37 // ========================= MEMBER FUNCTIONS ==================================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CCSRequestHandler::NewL()
       
    41 // Two-phased constructor.
       
    42 // -----------------------------------------------------------------------------
       
    43 EXPORT_C CCSRequestHandler* CCSRequestHandler::NewL()
       
    44     {
       
    45 
       
    46     CCSRequestHandler* self = NewLC( );
       
    47     CleanupStack::Pop( self );
       
    48 
       
    49     return( self ) ;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CCSRequestHandler::NewLC()
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 EXPORT_C CCSRequestHandler* CCSRequestHandler::NewLC()
       
    57     {
       
    58 
       
    59     CCSRequestHandler* self = new ( ELeave ) CCSRequestHandler();
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62 
       
    63     return self;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CCSRequestHandler::CCSAsyncRequestHandler()
       
    68 // C++ default constructor can NOT contain any code, that might leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 CCSRequestHandler::CCSRequestHandler()
       
    71 : CActive( EPriorityStandard )
       
    72     {
       
    73     
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CCSRequestHandler::ConstructL()
       
    78 // Symbian 2nd phase constructor can leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 void CCSRequestHandler::ConstructL()
       
    81     {
       
    82     TestConversationEngineStub::Instance();
       
    83     
       
    84     // Observers
       
    85     iResultsObserver = NULL;
       
    86     iCachingStatusObserver = NULL;
       
    87     iConversationListChangeObserver = NULL;
       
    88     iConversationChangeObserver = NULL;
       
    89 
       
    90     }
       
    91 
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CCSRequestHandler::~CCSRequestHandler()
       
    95 // Destructor.
       
    96 // -----------------------------------------------------------------------------
       
    97 CCSRequestHandler::~CCSRequestHandler()
       
    98     {
       
    99 
       
   100     Cancel(); 
       
   101 
       
   102     // Cleanup
       
   103     if ( iBuffer )
       
   104         {
       
   105         delete iBuffer;
       
   106         iBuffer = NULL;
       
   107         }
       
   108    
       
   109     if ( iResultsBuffer )
       
   110         {
       
   111         delete iResultsBuffer;
       
   112         iResultsBuffer = NULL;
       
   113         }
       
   114     
       
   115     if ( iNotificationHandler )
       
   116         {
       
   117         //delete iNotificationHandler;
       
   118         iNotificationHandler = NULL;
       
   119         }
       
   120     
       
   121     if( iListResultsBuffer )
       
   122         {
       
   123         delete iListResultsBuffer;
       
   124         iListResultsBuffer=NULL;
       
   125         }
       
   126     if( iConvResultsBuffer )
       
   127         {
       
   128         delete iConvResultsBuffer;
       
   129         iConvResultsBuffer=NULL;
       
   130         }
       
   131     
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CCSRequestHandler::HandleGetConversationListResults()
       
   136 // This shall handle all entry list result from server
       
   137 //
       
   138 // -----------------------------------------------------------------------------
       
   139 void CCSRequestHandler::HandleGetConversationListResults()
       
   140     {
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CCSRequestHandler::HandleGetConversationResults()
       
   145 // This shall handle GetCoversation results async from server
       
   146 //
       
   147 // -----------------------------------------------------------------------------
       
   148 void CCSRequestHandler::HandleGetConversationResults()
       
   149     {
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CCSRequestHandler::HandleGetEntryListOverflow()
       
   154 // Handle the buffer overflow error for get entry list results
       
   155 // -----------------------------------------------------------------------------
       
   156 void CCSRequestHandler::HandleGetConversationListOverflow()
       
   157     {
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CCSRequestHandler::HandleGetConversationOverflow()
       
   162 // Handle the buffer overflow error for get conversation results
       
   163 // -----------------------------------------------------------------------------
       
   164 void CCSRequestHandler::HandleGetConversationOverflow()
       
   165     {
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CCSRequestHandler::RequestResultsEventL()
       
   170 // Add conversation result Observer
       
   171 // -----------------------------------------------------------------------------
       
   172 EXPORT_C void CCSRequestHandler::RequestResultsEventL(
       
   173         MCsResultsObserver* aObserver)
       
   174     {
       
   175     iResultsObserver = aObserver;
       
   176     TestConversationEngineStub::Instance()->SetResultObserver(aObserver);
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CCSRequestHandler::RemoveResultsEventL()
       
   181 // Remove conversation result observer
       
   182 // -----------------------------------------------------------------------------
       
   183 EXPORT_C void CCSRequestHandler::RemoveResultsEventL
       
   184 (MCsResultsObserver* /*aObserver*/)
       
   185     {
       
   186     iResultsObserver = NULL;
       
   187     TestConversationEngineStub::Instance()->RemoveResultObserver();
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CCSRequestHandler::RequestConversationListChangeEventL()
       
   192 // Add conversation list change event Observer
       
   193 // -----------------------------------------------------------------------------
       
   194 EXPORT_C void CCSRequestHandler::RequestConversationListChangeEventL(
       
   195         MCsConversationListChangeObserver* aObserver)
       
   196     {
       
   197     iConversationListChangeObserver = aObserver;
       
   198     TestConversationEngineStub::Instance()->SetConversationListChangeObserver(aObserver);
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CCSRequestHandler::RemoveConversationListChangeEventL()
       
   203 // Remove conversation list change event Observer
       
   204 // -----------------------------------------------------------------------------
       
   205 EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL(
       
   206         MCsConversationListChangeObserver* /*aObserver*/)
       
   207     {
       
   208     iConversationListChangeObserver = NULL;
       
   209     TestConversationEngineStub::Instance()->RemoveConversationListChangeObserver();
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CCSRequestHandler::RequestConversationChangeEventL()
       
   214 // Add conversation change event Observer
       
   215 // -----------------------------------------------------------------------------
       
   216 EXPORT_C void CCSRequestHandler::RequestConversationChangeEventL(
       
   217         MCsConversationChangeObserver* aObserver,
       
   218         CCsClientConversation* aClientConversation)
       
   219     {
       
   220         TestConversationEngineStub::Instance()->SetConversationChangeObserver(aObserver, aClientConversation);
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CCSRequestHandler::RemoveConversationChangeEventL()
       
   225 // Remove conversation change event observer
       
   226 // -----------------------------------------------------------------------------
       
   227 EXPORT_C void CCSRequestHandler::RemoveConversationChangeEventL(
       
   228         MCsConversationChangeObserver* /*aObserver*/,
       
   229         CCsClientConversation* /*aClientConversation*/)
       
   230     {
       
   231 
       
   232     if ( iConversationChangeObserver )
       
   233         {
       
   234         TestConversationEngineStub::Instance()->RemoveConversationChangeObserver();
       
   235         delete iConversationChangeObserver;
       
   236         iConversationChangeObserver = NULL;
       
   237         }
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CCSRequestHandler::RequestCachingStatusEventL()
       
   242 // Add caching status Observer
       
   243 // -----------------------------------------------------------------------------
       
   244 EXPORT_C void CCSRequestHandler::RequestCachingStatusEventL(
       
   245         MCsCachingStatusObserver* /*aObserver*/)
       
   246     {
       
   247     User::Leave(KErrNotSupported);
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CCSRequestHandler::RemoveCachingStatusEventL()
       
   252 // Remove caching status Observer
       
   253 // -----------------------------------------------------------------------------
       
   254 EXPORT_C void CCSRequestHandler::RemoveCachingStatusEventL(
       
   255         MCsCachingStatusObserver* /*aObserver*/)
       
   256     {
       
   257     User::Leave(KErrNotSupported);
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CCSRequestHandler::RunL()
       
   262 // Invoked to handle responses from the server.
       
   263 // -----------------------------------------------------------------------------
       
   264 void CCSRequestHandler::RunL()
       
   265     { 
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CCSRequestHandler::HandleErrorL()
       
   270 // Send the error code to the client.
       
   271 // -----------------------------------------------------------------------------
       
   272 void CCSRequestHandler::HandleErrorL(TInt /*aErrorCode*/)
       
   273     {
       
   274     // Not supported
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CCSRequestHandler::DoCancel()
       
   279 // Cancels any outstanding operation.
       
   280 // -----------------------------------------------------------------------------
       
   281 void CCSRequestHandler::DoCancel()
       
   282     {
       
   283     // Do nothing
       
   284     }
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CCSRequestHandler::Version()
       
   288 // Recovers the conversation server version.
       
   289 // -----------------------------------------------------------------------------
       
   290 EXPORT_C TVersion CCSRequestHandler::Version() const
       
   291     {
       
   292     TVersion ver(1, 2, 3);
       
   293     return (ver);
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CCSRequestHandler::ShutdownServerL()
       
   298 // Shuts down the conversation server.
       
   299 // -----------------------------------------------------------------------------
       
   300 EXPORT_C void CCSRequestHandler::ShutdownServerL()
       
   301     {
       
   302     //Do nothing
       
   303     return;
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CCSRequestHandler::GetConversationListL()
       
   308 // Get Recent Conversation Entry list with display name
       
   309 // for all stored conversation entry IDs.
       
   310 // This API can be used to prepare conversation list view.
       
   311 // -----------------------------------------------------------------------------
       
   312 EXPORT_C void CCSRequestHandler::GetConversationListL()
       
   313     {
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CCSRequestHandler::GetConversationUnreadListL()
       
   318 // Get Recent unread Conversation Entry list with display name
       
   319 // for all stored conversation entry IDs.
       
   320 // This API can be used to prepare conversation list view.
       
   321 // -----------------------------------------------------------------------------
       
   322 EXPORT_C void CCSRequestHandler::GetConversationUnreadListL(RPointerArray<
       
   323         CCsClientConversation>* /*aClientConversationList*/)
       
   324     {
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CCSRequestHandler::GetConversationsL()
       
   329 // Get Conversation Entry list for given Conversation Entry ID to prepare
       
   330 // convresation view.
       
   331 // -----------------------------------------------------------------------------
       
   332 EXPORT_C void CCSRequestHandler::GetConversationsL(
       
   333         CCsClientConversation*  aClientConversation)
       
   334     {
       
   335     // check if the aclientconversation is null then return
       
   336     if ( !aClientConversation)
       
   337         {
       
   338             User::Leave(KErrArgument);
       
   339         }
       
   340     if (TestConversationEngineStub::Instance()->GetConversationID() 
       
   341                     != aClientConversation->GetConversationEntryId())
       
   342         {
       
   343             User::Leave(KErrNotFound);
       
   344         }
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // CCSRequestHandler::GetCachingStatusL()
       
   349 // Get caching status
       
   350 // Synchronous
       
   351 // -----------------------------------------------------------------------------
       
   352 EXPORT_C TUint8 CCSRequestHandler::GetCachingStatusL()
       
   353     {
       
   354     return 0;
       
   355     }
       
   356 
       
   357 // -----------------------------------------------------------------------------
       
   358 // CCSRequestHandler::GetTotalUnreadCountL()
       
   359 // Get total unread count
       
   360 // Synchronous
       
   361 // -----------------------------------------------------------------------------
       
   362 EXPORT_C TUint32 CCSRequestHandler::GetTotalUnreadCountL()
       
   363     {
       
   364     TUint32 unreadCount = 10;
       
   365     return unreadCount;
       
   366     }
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CCSRequestHandler::HandleAddConversationList()
       
   370 // Process add conversation list event received from server
       
   371 // -----------------------------------------------------------------------------
       
   372 void CCSRequestHandler::HandleAddConversationList(HBufC8* /*aResultsBuffer*/)
       
   373     {
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CCSRequestHandler::HandleDeleteConversationList()
       
   378 // Process delete conversation lsit event received from server
       
   379 // -----------------------------------------------------------------------------
       
   380 void CCSRequestHandler::HandleDeleteConversationList(HBufC8* /*aResultsBuffer*/)
       
   381     {
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CCSRequestHandler::HandleModifyConversationList
       
   386 // Process modify conversation lsit event received from server
       
   387 // -----------------------------------------------------------------------------
       
   388 void CCSRequestHandler::HandleModifyConversationList(HBufC8* /*aResultsBuffer*/)
       
   389     {
       
   390     }
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // CCSRequestHandler::HandleAddConversation
       
   394 // Process add conversation event received from server
       
   395 // -----------------------------------------------------------------------------
       
   396 void CCSRequestHandler::HandleAddConversation(HBufC8* /*aResultsBuffer*/)
       
   397     {
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // CCSRequestHandler::HandleDeleteConversation
       
   402 // Process delete conversation event received from server
       
   403 // -----------------------------------------------------------------------------
       
   404 void CCSRequestHandler::HandleDeleteConversation(HBufC8* /*aResultsBuffer*/)
       
   405     {
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CCSRequestHandler::HandleModifyConversation
       
   410 // Process Modify conversation event received from server
       
   411 // -----------------------------------------------------------------------------
       
   412 void CCSRequestHandler::HandleModifyConversation(HBufC8* /*aResultsBuffer*/)
       
   413     {
       
   414     }
       
   415 
       
   416 // -----------------------------------------------------------------------------
       
   417 // CCSRequestHandler::HandleCachingStarted
       
   418 // Process caching started event received from server
       
   419 // -----------------------------------------------------------------------------
       
   420 void CCSRequestHandler::HandleCachingStarted(HBufC8* /*aResultsBuffer*/)
       
   421     {
       
   422     User::Leave(KErrNotSupported);
       
   423     }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 // CCSRequestHandler::HandleCachingCompleted
       
   427 // Process caching completed event received from server
       
   428 // -----------------------------------------------------------------------------
       
   429 void CCSRequestHandler::HandleCachingCompleted(HBufC8* /*aResultsBuffer*/)
       
   430     {
       
   431     User::Leave(KErrNotSupported);
       
   432     }
       
   433 
       
   434 // -----------------------------------------------------------------------------
       
   435 // CCSRequestHandler::HandleCachingError
       
   436 // Process caching error event received from server
       
   437 // -----------------------------------------------------------------------------
       
   438 void CCSRequestHandler::HandleCachingError(HBufC8* /*aResultsBuffer*/)
       
   439     {
       
   440     User::Leave(KErrNotSupported);
       
   441     }
       
   442 
       
   443 // -----------------------------------------------------------------------------
       
   444 // CCSRequestHandler::DeleteConversationL()
       
   445 // -----------------------------------------------------------------------------
       
   446 EXPORT_C void CCSRequestHandler::DeleteConversationL(TInt aConversationId)        
       
   447     {
       
   448         TestConversationEngineStub::Instance()->DeleteConversation(aConversationId);
       
   449     }
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CCSRequestHandler::HandleRefreshConversationList
       
   453 // Process refresh from server
       
   454 // -----------------------------------------------------------------------------
       
   455 void CCSRequestHandler::HandleRefreshConversationList(HBufC8* /*aResultsBuffer*/)
       
   456     {
       
   457     }
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // Ccsrequesthandler::HandleRefreshConversationList
       
   461 // Process refresh from server
       
   462 // -----------------------------------------------------------------------------
       
   463 void CCSRequestHandler::HandleRefreshConversation(HBufC8* /*aResultsBuffer*/)
       
   464     {
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // CCSRequestHandler::GetConversationIdL()
       
   469 // -----------------------------------------------------------------------------
       
   470 EXPORT_C TInt CCSRequestHandler::GetConversationIdL(TInt aContactId)        
       
   471     {    
       
   472     TInt conversationId = -1;
       
   473     
       
   474     //Get the associated conversation id from the contact id
       
   475     conversationId = TestConversationEngineStub::Instance()->GetClientConversationID(aContactId);
       
   476 
       
   477     return conversationId;
       
   478     }
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // CCSRequestHandler::GetConversationIdFromAddressL()
       
   482 // -----------------------------------------------------------------------------
       
   483 EXPORT_C TInt CCSRequestHandler::GetConversationIdFromAddressL(TDesC& aContactAddress)        
       
   484     {    
       
   485     TInt conversationId = -1;
       
   486 
       
   487     //Read the conversation id from file with associated contact.
       
   488     conversationId = TestConversationEngineStub::Instance()->GetClientConversationID(aContactAddress);
       
   489     
       
   490     return conversationId;
       
   491     }
       
   492 // -----------------------------------------------------------------------------
       
   493 // CCSRequestHandler::GetMessagingHistoryL()
       
   494 // -----------------------------------------------------------------------------
       
   495 EXPORT_C void CCSRequestHandler::GetMessagingHistoryL(TInt /*aContactId*/)
       
   496     {
       
   497     }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CCSRequestHandler::GetConversationIdL()
       
   501 // -----------------------------------------------------------------------------
       
   502 EXPORT_C void CCSRequestHandler::ClearMessagingHistoryL(TInt /*aContactId*/)
       
   503     {
       
   504     }
       
   505 
       
   506 // -----------------------------------------------------------------------------
       
   507 // CCSRequestHandler::MarkConversationReadL()
       
   508 // -----------------------------------------------------------------------------
       
   509 EXPORT_C void CCSRequestHandler::MarkConversationReadL(TInt aConversationId)        
       
   510     {
       
   511         TestConversationEngineStub::Instance()->MarkConversationRead(aConversationId);
       
   512     }
       
   513 
       
   514 // -----------------------------------------------------------------------------
       
   515 // CCSRequestHandler::MarkMessagingHistoryReadL()
       
   516 // -----------------------------------------------------------------------------
       
   517 EXPORT_C void CCSRequestHandler::MarkMessagingHistoryReadL(TInt /*aContactId*/)        
       
   518     {
       
   519     }
       
   520 
       
   521 // End of File