wvuing/wvuiprocess/Src/ccainviteeditorpc.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation for PC Group Interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include	"CCAInvitationRequest.h"
       
    22 #include	"MCAInvite.h"
       
    23 #include	"MCAPresence.h"
       
    24 #include    "MCAStoredContact.h"
       
    25 #include    "MCAStoredContacts.h"
       
    26 #include    "CCAStorageManagerFactory.h"
       
    27 #include    "CCAEngine.h"
       
    28 #include    "MCAContactListModel.h"
       
    29 #include    "MCAInviteConflictResolver.h"
       
    30 #include    "MCAServerContactsArrayPC.h"
       
    31 #include    "CCAServerContactsArrayPC.h"
       
    32 
       
    33 
       
    34 #include    "CCAInviteEditorPC.h"
       
    35 
       
    36 //const definitions
       
    37 
       
    38 
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CCAInviteEditorPC: Constructor
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CCAInviteEditorPC::CCAInviteEditorPC( MCAInvite& aInviteAPI,
       
    47                                       MCAPresence& aPresenceAP )
       
    48         : iInviteAPI( aInviteAPI ),
       
    49         iPresenceAPI( aPresenceAP )
       
    50     {
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CCAInviteEditorPC: NewL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CCAInviteEditorPC* CCAInviteEditorPC::NewL( MCAInvite& aInviteAPI,
       
    59                                             MCAPresence& aPresenceAPI )
       
    60     {
       
    61     CCAInviteEditorPC* self = new ( ELeave ) CCAInviteEditorPC( aInviteAPI,
       
    62                                                                 aPresenceAPI );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL( );
       
    65     CleanupStack::Pop( self );
       
    66 
       
    67     return self;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CCAInviteEditorPC: ConstructL
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CCAInviteEditorPC::ConstructL(  )
       
    75     {
       
    76     // codescanner warning can be ignored
       
    77     }
       
    78 
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CCAInviteEditorPC: Destructor
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CCAInviteEditorPC::~CCAInviteEditorPC()
       
    85     {
       
    86 
       
    87     }
       
    88 
       
    89 
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CCAInviteEditorPC: SendInvitationL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TInt CCAInviteEditorPC::SendInvitationL( const CDesCArray& aUserIDs,
       
    96                                          const TDesC& aGroupID,
       
    97                                          const TDesC& aMessage )
       
    98     {
       
    99     // Create invitation
       
   100     TInt retVal = KErrNone;
       
   101     CCAInvitationRequest* invitation = CCAInvitationRequest::NewL( aUserIDs,
       
   102                                                                    aGroupID,
       
   103                                                                    aMessage );
       
   104 
       
   105     CleanupStack::PushL( invitation );
       
   106 
       
   107     iInviteAPI.SendInvitationL( *invitation );
       
   108 
       
   109     CleanupStack::PopAndDestroy( invitation );
       
   110 
       
   111     return retVal;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CCAInviteEditorPC: SendInvitationL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 MCAServerContactsArrayPC*  CCAInviteEditorPC::GetOnlineFriendsLC( const TDesC& aIconTabulator )
       
   119     {
       
   120     CDesCArray* onlineList = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   121     CleanupStack::PushL( onlineList );
       
   122 
       
   123 
       
   124     CDesCArray* onlineIdentificationList =
       
   125         new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   126     CleanupStack::PushL( onlineIdentificationList );
       
   127 
       
   128     CDesCArray* onlineNicknameList =
       
   129         new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   130     CleanupStack::PushL( onlineNicknameList );
       
   131 
       
   132     iPresenceAPI.GetOnlineFriendsL( *onlineList );
       
   133 
       
   134     MCAStoredContacts* contacts = CCAStorageManagerFactory::ContactListInterfaceL();
       
   135 
       
   136     // getting nicnames for contact id's
       
   137     TInt onlineListCount( onlineList->MdcaCount() );
       
   138     for ( TInt i( 0 ); i < onlineListCount; i++ )
       
   139         {
       
   140         onlineIdentificationList->AppendL( contacts->Identification(
       
   141                                                onlineList->MdcaPoint( i ) ) );
       
   142         MCAStoredContact* contact = contacts->FindAnyContact( onlineList->MdcaPoint( i ) );
       
   143         if ( contact )
       
   144             {
       
   145             onlineNicknameList->AppendL( contact->Nickname() );
       
   146             }
       
   147         else
       
   148             {
       
   149             onlineNicknameList->AppendL( KNullDesC );
       
   150             }
       
   151         }
       
   152 
       
   153     // servercontactsarray takes the ownership
       
   154     CCAServerContactsArrayPC* pairsArray =
       
   155         CCAServerContactsArrayPC::NewL( onlineNicknameList,
       
   156                                         onlineList,
       
   157                                         aIconTabulator,
       
   158                                         onlineIdentificationList );
       
   159     //ownership is transfered to the caller.
       
   160     CleanupStack::Pop( onlineNicknameList );
       
   161     CleanupStack::Pop( onlineIdentificationList );
       
   162     CleanupStack::Pop( onlineList );
       
   163     CleanupStack::PushL( pairsArray );
       
   164     return pairsArray;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CCAInviteEditorPC: PopulateInviteListL
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CCAInviteEditorPC::PopulateInviteListL( CDesCArray& aInviteList,
       
   172                                              const MCAServerContactsArrayPC& aRawOnlineList,
       
   173                                              const CArrayFixFlat<TInt>& aSelectionArray )
       
   174     {
       
   175     TInt inviteCount( aSelectionArray.Count() );
       
   176     CCAServerContactsArrayPC& rawOnlineList = dynamic_cast<CCAServerContactsArrayPC&>(
       
   177                                                   const_cast<MCAServerContactsArrayPC&>( aRawOnlineList ) );
       
   178     for ( TInt ii( 0 ); ii < inviteCount; ++ii )
       
   179         {
       
   180         TInt index ( aSelectionArray.At( ii ) );
       
   181         if ( index >= 0 && index < rawOnlineList.MdcaCount() )
       
   182             {
       
   183             aInviteList.AppendL( rawOnlineList[ index ].iWVID );
       
   184             }
       
   185         }
       
   186     }
       
   187 
       
   188 
       
   189 //End of file