wvuing/wvuiprocess/Src/CCAIMUtilsPC.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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: IM Utils Class on Process Component Side
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CAUtils.h"
       
    20 #include "CCAIMUtilsPC.h"
       
    21 #include "CAPresenceManager.h"
       
    22 #include "MCAPresence.h"
       
    23 #include "MCAContactLists.h"
       
    24 #include "MCAContactList.h"
       
    25 #include "MCAStoredContacts.h"
       
    26 #include "CCAStorageManagerFactory.h"
       
    27 #include "ChatDefinitions.h"
       
    28 
       
    29 #include    <collate.h>
       
    30 
       
    31 CCAIMUtilsPC :: CCAIMUtilsPC()
       
    32     {
       
    33     iPresence = NULL;
       
    34     iContactList = NULL;
       
    35     }
       
    36 
       
    37 CCAIMUtilsPC* CCAIMUtilsPC :: NewL()
       
    38     {
       
    39     CCAIMUtilsPC* self = new( ELeave ) CCAIMUtilsPC();
       
    40 
       
    41     CleanupStack::PushL( self );
       
    42 
       
    43     self->ConstructL();
       
    44 
       
    45 
       
    46     CleanupStack::Pop( self );
       
    47 
       
    48     return self;
       
    49     }
       
    50 
       
    51 
       
    52 void CCAIMUtilsPC::ConstructL()
       
    53     {
       
    54     iPresence = CAPresenceManager::InstanceL();
       
    55 
       
    56     }
       
    57 
       
    58 
       
    59 EXPORT_C TBool CCAIMUtilsPC :: PresenceContactPCL()
       
    60     {
       
    61     iContactList = iPresence->ContactLists();
       
    62 
       
    63     if ( iContactList )
       
    64         {
       
    65         return ETrue;
       
    66         }
       
    67     else
       
    68         {
       
    69         return EFalse;
       
    70         }
       
    71     }
       
    72 
       
    73 EXPORT_C TInt CCAIMUtilsPC::IdsAlreadyExistsOrNotL( TPtr aNamePtr )
       
    74     {
       
    75     // check the display id's of local lists
       
    76     MCAStoredContacts* contacts =
       
    77         CCAStorageManagerFactory::ContactListInterfaceL();
       
    78     TInt count( contacts->ListCount() );
       
    79     TInt err = KErrNone;
       
    80 
       
    81     // get the standard method
       
    82     TCollationMethod m = *Mem::CollationMethodByIndex( 0 );
       
    83     m.iFlags |= TCollationMethod::EIgnoreNone; // dont ignore punctuation and spaces
       
    84 
       
    85     for ( TInt i( 0 ); i < count && err == KErrNone; ++i )
       
    86         {
       
    87         if ( contacts->ListAt( i ).DisplayName().CompareC(
       
    88                  aNamePtr, KCollationLevel, &m ) == 0 )
       
    89             {
       
    90             // list with this name already exists
       
    91             err = KErrAlreadyExists;
       
    92             }
       
    93         }
       
    94 
       
    95     return err;
       
    96 
       
    97     }
       
    98 
       
    99 EXPORT_C TInt  CCAIMUtilsPC::CreateContactListPCL( const TDesC& aname )
       
   100     {
       
   101     TInt err = iContactList->CreateContactListL( aname );
       
   102     return err;
       
   103     }
       
   104 
       
   105 EXPORT_C TBool CCAIMUtilsPC::IsThereAnyContactsL()
       
   106     {
       
   107 
       
   108     MCAStoredContacts* contacts =
       
   109         CCAStorageManagerFactory::ContactListInterfaceL();
       
   110 
       
   111     TInt count( contacts->ListCount() );
       
   112 
       
   113     if ( 0 == count )
       
   114         {
       
   115         return EFalse;
       
   116         }
       
   117     else
       
   118         {
       
   119         return ETrue;
       
   120         }
       
   121     }
       
   122 
       
   123 EXPORT_C MCAContactLists* CCAIMUtilsPC::GetContactList()
       
   124     {
       
   125     return iContactList;
       
   126     }
       
   127 
       
   128 
       
   129 CCAIMUtilsPC::~CCAIMUtilsPC()
       
   130     {
       
   131     //
       
   132     }