instantmessagesalert/tsrc/testinstantmsgalert/src/stubs/s_imcache.cpp
branchRCL_3
changeset 28 3104fc151679
parent 27 2b7283837edb
child 29 9a48e301e94b
equal deleted inserted replaced
27:2b7283837edb 28:3104fc151679
     1 /*
       
     2 * s_imcache.cpp :    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:s_imcache.cpp 
       
    15 *
       
    16 */
       
    17 // imcache  related headers
       
    18 #include "cimcachefactory.h"
       
    19 #include "mimcacheaccessor.h"
       
    20 #include "mimcacheupdater.h"
       
    21 
       
    22 TBool gConversationExist = EFalse;
       
    23 TBool gConversationUnreadCount = EFalse;
       
    24 
       
    25 class MyMIMCacheAccessor : public MIMCacheAccessor
       
    26      {
       
    27      public:
       
    28      
       
    29  		/**
       
    30     	* Register to observer conversation data updates
       
    31     	* @param aObserver the observer interface
       
    32     	*/
       
    33         void RegisterObserverL( MIMCacheEventHandler& /*aObserver*/ ) {}
       
    34 
       
    35     	/**
       
    36     	* Unregister a conversation data update observer
       
    37     	* @param aObserver the observer interface
       
    38     	*/
       
    39         void UnRegisterObserver( MIMCacheEventHandler& /*aObserver*/ ) {}
       
    40 		
       
    41        	/**
       
    42     	* to get the unread message count from server
       
    43     	* @param aOwnUserId , logged in user id
       
    44     	* @return number of unread msg count
       
    45     	*/
       
    46 		TInt GetUnreadMessageCountL( const TDesC& /*aBuddyId*/ ) 
       
    47 			{
       
    48 			if (gConversationUnreadCount)
       
    49 				{
       
    50 				return 1;
       
    51 				}
       
    52 
       
    53 			return 0;
       
    54 	        }
       
    55 		
       
    56 	   /**
       
    57     	* to get the all unread message count from server
       
    58     	* @param , aOwnUserId logged in user id
       
    59     	* @return number of all unread msg count
       
    60     	*/
       
    61         TInt GetAllUnreadMessageCountL() { return KErrNone; }
       
    62         						
       
    63 		 /**
       
    64          * check if already conversation opened
       
    65          * @param aServiceId, serviceid to use
       
    66          * @param aOwnUserId, own user id 
       
    67          * @param aRecipientId, the selected user id with whom conversation is started
       
    68          * @return ETrue if already exist else EFlase.
       
    69          */
       
    70         TBool IsConversationExistL( const TDesC& /*aBuddyId*/ ) 
       
    71 	        {
       
    72 			if (gConversationExist)
       
    73 				{
       
    74 				return ETrue;
       
    75 				}
       
    76 
       
    77 			return EFalse;
       
    78 	        }	
       
    79 
       
    80 		/**
       
    81 		* closes conversation and commit operation
       
    82 		* @param aServiceId service id.
       
    83 		* @param aOwnId own user id.
       
    84 		* @param aRecipientId recipient's user id.
       
    85 		*/
       
    86 		void CloseConversationL( const TDesC& /*aBuddyId*/ ) {}
       
    87 		                           
       
    88          /**
       
    89     	* to get the friend request count from server
       
    90     	* @param , aOwnUserId logged in user id
       
    91     	* @return number of all request
       
    92     	*/
       
    93         TInt GetFriendRequestCountL( ) { return KErrNone; }
       
    94         
       
    95         
       
    96         /**
       
    97 		* Remove friend request from cahce and commit operation
       
    98 		* @param aServiceId service id.
       
    99 		* @param aOwnId own user id.
       
   100 		* @param aRequesterId ,requester user id.
       
   101 		*/
       
   102 		void RemoveFriendRequestL( const TDesC& /*aBuddyId*/  ) {}
       
   103 		 
       
   104 
       
   105      	/**
       
   106      	* Destructor
       
   107      	*/
       
   108      	~MyMIMCacheAccessor() {};
       
   109      	
       
   110      	MyMIMCacheAccessor() {};
       
   111      };
       
   112 
       
   113 class MyMIMCacheUpdater : public MIMCacheUpdater
       
   114      {
       
   115      public:
       
   116 
       
   117         void RegisterObserverL( MIMCacheEventHandler& /*aObserver*/ ) {}
       
   118 
       
   119         void UnRegisterObserver( MIMCacheEventHandler& /*aObserver*/ ) {}
       
   120 
       
   121         void StartNewConversationL(const TDesC& /*aBuddyId*/ ) {};
       
   122        
       
   123         void AppendReceiveMessageL(const TDesC& /*aBuddyId*/,
       
   124                                    const TDesC& /*aText*/ ){};
       
   125         
       
   126         void AppendSendMessageL(const TDesC& /*aText*/ ){};
       
   127         
       
   128         void AppendMessageL(const TDesC& /*aBuddyId*/, const TDesC& /*aText*/){};
       
   129         
       
   130         void CloseConversationL( const TDesC& /*aBuddyId*/ ){};
       
   131         
       
   132         TInt DeactivateConversationL()
       
   133             {
       
   134             return KErrNone;
       
   135             }
       
   136         
       
   137         void AppendAddRequestL( const TDesC& /*aBuddyId*/, 
       
   138                                 TInt /*aServiceId*/ ){};
       
   139         
       
   140         RArray<SIMCacheChatItem> GetChatListL( const TInt& /*aServiceId*/  )
       
   141             {
       
   142             RArray<SIMCacheChatItem> array;
       
   143             return array;
       
   144             }
       
   145 
       
   146         ~MyMIMCacheUpdater() {};
       
   147          
       
   148          MyMIMCacheUpdater() {};
       
   149      };
       
   150 
       
   151 CIMCacheFactory* gIMCacheFactory = NULL;
       
   152 MyMIMCacheAccessor* gMyMIMCacheAccessor = NULL;
       
   153 MyMIMCacheUpdater* gMyMIMCacheUpdater = NULL;
       
   154 
       
   155 CIMCacheFactory* CIMCacheFactory::InstanceL() 
       
   156 	{
       
   157 	if (!gIMCacheFactory)
       
   158 		{
       
   159 		gIMCacheFactory = new ( ELeave ) CIMCacheFactory();
       
   160 		}
       
   161 	return gIMCacheFactory;
       
   162 	}
       
   163     	
       
   164 void  CIMCacheFactory::Release()
       
   165 	{
       
   166 	
       
   167 	delete gMyMIMCacheAccessor;
       
   168 	gMyMIMCacheAccessor = NULL;
       
   169 	
       
   170 	delete gMyMIMCacheUpdater;
       
   171 	gMyMIMCacheUpdater = NULL;
       
   172 	
       
   173 	delete gIMCacheFactory;
       
   174 	gIMCacheFactory = NULL;
       
   175 	
       
   176 		
       
   177 	}
       
   178     	
       
   179 MIMCacheAccessor* CIMCacheFactory::CreateAccessorL(TInt /*aServiceId*/,
       
   180 									const TDesC& /*aUserId*/  )
       
   181 	{
       
   182 	if (!gMyMIMCacheAccessor)
       
   183 		{
       
   184 		gMyMIMCacheAccessor = new (ELeave) 	MyMIMCacheAccessor();
       
   185 		}
       
   186 	return gMyMIMCacheAccessor;		
       
   187 	}
       
   188 
       
   189 	
       
   190 CIMCacheFactory::~CIMCacheFactory()
       
   191 	{
       
   192 		
       
   193 	}
       
   194 
       
   195 CIMCacheFactory::CIMCacheFactory()
       
   196 	{
       
   197 		
       
   198 	}
       
   199 
       
   200 void CIMCacheFactory::ConstructL()
       
   201 	{
       
   202 		
       
   203 	}
       
   204 	
       
   205 MIMCacheUpdater* CIMCacheFactory::CreateUpdaterL(TInt /*aServiceId*/,
       
   206 												const TDesC& /*aUserId*/ ,
       
   207 												TBool /*aRegistrationNeeded*/ )
       
   208 	{
       
   209 	if (!gMyMIMCacheUpdater)
       
   210 	    {
       
   211 	    gMyMIMCacheUpdater = new (ELeave)  MyMIMCacheUpdater();
       
   212 	    }
       
   213 	return gMyMIMCacheUpdater;     
       
   214 	}
       
   215 
       
   216 
       
   217 
       
   218