wvuing/wvuieng/EngSrc/CCAInviteManager.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:  Handles incoming invitations
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "PrivateEngineDefinitions.h"
       
    21 #include "PublicEngineDefinitions.h"
       
    22 #include "CCAInviteManager.h"                   // Own header
       
    23 #include "MCAInviteObserver.h"                  // Observer interface
       
    24 #include "MCASettings.h"                        // Internal settings
       
    25 #include "ChatDebugPrint.h"                     // For debug macros
       
    26 #include "CCARequestMapper.h"
       
    27 #include "CCAInviteTracker.h"
       
    28 #include "CCAStoragemanagerFactory.h"
       
    29 #include "CCAInvitation.h"
       
    30 
       
    31 #include "MCAStoredContacts.h"
       
    32 #include "MCAStoredGroup.h"
       
    33 #include "MCAStoredGroups.h"
       
    34 #include "MCAGroupManagerInterface.h"
       
    35 #include "MCAExtendedStoredGroup.h"
       
    36 #include "MCAGroupOperations.h"
       
    37 
       
    38 #include "MCAImpsFactory.h"
       
    39 
       
    40 #include "ChatDebugAssert.h"
       
    41 
       
    42 #include <e32base.h>
       
    43 
       
    44 // CONSTANTS
       
    45 const TInt KMaxIDNumberLength = 5; //also used in ChatDefinitions.
       
    46 //both must be synchronous
       
    47 
       
    48 _LIT( KInviteFormatString, "%d" );
       
    49 
       
    50 // ================= MEMBER FUNCTIONS =======================
       
    51 
       
    52 // Symbian OS default constructor can leave.
       
    53 void CCAInviteManager::ConstructL()
       
    54     {
       
    55     iRejectReason = HBufC::NewL( KMaxRejectReasonLength );
       
    56     iImpsFundAPI = iImpsFactory->CreateFundClientL();
       
    57     }
       
    58 
       
    59 // Two-phased constructor.
       
    60 CCAInviteManager* CCAInviteManager::NewL(
       
    61     MCAImpsFactory* aIMPSFactory,
       
    62     MCASettings& aSettingsAPI,
       
    63     CCARequestMapper& aRequestMapper,
       
    64     MCAGroupManagerInterface& aGroupManager )
       
    65     {
       
    66     CCAInviteManager* self = new ( ELeave ) CCAInviteManager(
       
    67         aIMPSFactory,
       
    68         aSettingsAPI,
       
    69         aRequestMapper,
       
    70         aGroupManager );
       
    71 
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop( self );
       
    75 
       
    76     return self;
       
    77     }
       
    78 
       
    79 // Destructor
       
    80 CCAInviteManager::~CCAInviteManager()
       
    81     {
       
    82     iInviteTrackerQueue.ResetAndDestroy();
       
    83     iInviteTrackerQueue.Close();
       
    84 
       
    85     iInviteObservers.Close();
       
    86     delete iLastInviteId;
       
    87     delete iRejectReason;
       
    88     }
       
    89 
       
    90 // C++ default constructor can NOT contain any code, that
       
    91 // might leave.
       
    92 //
       
    93 CCAInviteManager::CCAInviteManager(
       
    94     MCAImpsFactory* aIMPSFactory,
       
    95     MCASettings& aSettingsAPI,
       
    96     CCARequestMapper& aRequestMapper,
       
    97     MCAGroupManagerInterface& aGroupManager ) :
       
    98         iRequestMapper( &aRequestMapper ),
       
    99         iSettingsAPI( aSettingsAPI ),
       
   100         iImpsFactory( aIMPSFactory ),
       
   101         iGroupManager( &aGroupManager )
       
   102     {
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------
       
   106 // CCAInviteManager::InviteExpired
       
   107 // (other items were commented in a header).
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 void CCAInviteManager::InviteExpiredL( const MCAInvitation* aInvitation )
       
   111     {
       
   112     CHAT_DP_TXT( "CCAInviteManager::InviteExpiredL" );
       
   113 
       
   114     // signal observers
       
   115     TInt count( iInviteObservers.Count() );
       
   116     for ( TInt i( 0 ); i < count; i++ )
       
   117         {
       
   118         if ( iInviteObservers[ i ] )
       
   119             {
       
   120             // it's a non-NULL
       
   121             iInviteObservers[ i ]->HandleInvitationEventL(
       
   122                 MCAInviteObserver::EInviteExpired, aInvitation );
       
   123             }
       
   124         }
       
   125 
       
   126     RemoveInviteL( aInvitation );
       
   127     }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------
       
   131 // CCAInviteManager::AddInviteObserver
       
   132 // (other items were commented in a header).
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 TInt CCAInviteManager::AddInviteObserver( MCAInviteObserver* aObserver )
       
   136     {
       
   137     return iInviteObservers.Append( aObserver );
       
   138     }
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // CCAInviteManager::RemoveInviteObserver
       
   143 // (other items were commented in a header).
       
   144 // ---------------------------------------------------------
       
   145 //
       
   146 void CCAInviteManager::RemoveInviteObserver( MCAInviteObserver* aObserver )
       
   147     {
       
   148     TInt pos( iInviteObservers.Find( aObserver ) );
       
   149     if ( pos != KErrNotFound )
       
   150         {
       
   151         iInviteObservers.Remove( pos );
       
   152         iInviteObservers.Compress();
       
   153         }
       
   154     }
       
   155 
       
   156 
       
   157 // ---------------------------------------------------------
       
   158 // CCAInviteManager::SendInvitationL
       
   159 // (other items were commented in a header).
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 void CCAInviteManager::SendInvitationL(
       
   163     const CCAInvitationRequest& aInvitation )
       
   164     {
       
   165     CHAT_DP( D_CHAT_LIT( "Sending invite to group %S" ), &aInvitation.GroupID() );
       
   166 
       
   167     PrepareGroupForInviteeL( aInvitation );
       
   168 
       
   169     HBufC* loggedUser = iSettingsAPI.ValueL( MCASettings::EOwnWVUserID );
       
   170     CleanupStack::PushL( loggedUser );
       
   171 
       
   172     HBufC* idTemplate = loggedUser->ReAllocL( loggedUser->Length() +
       
   173                                               KMaxIDNumberLength );
       
   174     CleanupStack::Pop( loggedUser );
       
   175 
       
   176     TPtr idPtr( idTemplate->Des() );
       
   177     idPtr.Append( KInviteFormatString );
       
   178 
       
   179     CleanupStack::PushL( idTemplate );
       
   180 
       
   181     iLastInviteId = HBufC::NewL( idTemplate->Length() );
       
   182     TPtr generatedIDPtr( iLastInviteId->Des() );
       
   183     generatedIDPtr.Format( *idTemplate, iInviteIDOrdinal++ );
       
   184 
       
   185     iCurrentInviteRequest = &aInvitation;
       
   186 
       
   187     CHAT_DP( D_CHAT_LIT( "Sending invite: id=%S" ), iLastInviteId );
       
   188 
       
   189     iCurrentOpId = iImpsFundAPI->InviteGroupRequestL(
       
   190                        *iLastInviteId,             // Invite ID
       
   191                        &aInvitation.Invitees(),    // Invited user IDs
       
   192                        NULL,                       // Screen names
       
   193                        NULL,                       // Group names
       
   194                        aInvitation.GroupID(),      // Group
       
   195                        KNullDesC,                  // Own screenname
       
   196                        KNullDesC,                  // Owns groupname
       
   197                        aInvitation.Message(),      // Invite message
       
   198                        aInvitation.Timeout() );    // Validity period
       
   199 
       
   200     CCARequest* request = iRequestMapper->CreateRequestL( iCurrentOpId );   // CSI: 35 # Ownership is not transferred to caller.
       
   201 
       
   202     delete iLastInviteId;
       
   203     iLastInviteId = NULL;
       
   204     iCurrentInviteRequest = NULL;
       
   205 
       
   206     iRequestMapper->RemoveRequestAndLeaveIfErrorL( request );
       
   207 
       
   208     CleanupStack::PopAndDestroy( idTemplate );
       
   209     }
       
   210 
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // CCAInviteManager::PopulateInviteList
       
   214 // (other items were commented in a header).
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 void CCAInviteManager::PopulateInviteList(
       
   218     RPointerArray< MCAInvitation >& aList )
       
   219     {
       
   220     aList.Reset();
       
   221     TInt count( iInviteTrackerQueue.Count() - 1 );
       
   222     // populate the list backwards so that the most recently received
       
   223     // invitation gets the first slot in the list
       
   224     for ( ; count >= 0; count-- )
       
   225         {
       
   226         // the error codes can be ignored, because it's not so fatal
       
   227         // if one invitation is missing from the list.
       
   228         // The other methods in UI will fail in any case.
       
   229         aList.Append( iInviteTrackerQueue[ count ]->Invitation() );
       
   230         }
       
   231     }
       
   232 
       
   233 
       
   234 // ---------------------------------------------------------
       
   235 // CCAInviteManager::ActiveInvitations
       
   236 // (other items were commented in a header).
       
   237 // ---------------------------------------------------------
       
   238 //
       
   239 TInt CCAInviteManager::ActiveInvitations()
       
   240     {
       
   241     return iInviteTrackerQueue.Count();
       
   242     }
       
   243 
       
   244 
       
   245 // ---------------------------------------------------------
       
   246 // CCAInviteManager::RemoveInvitation
       
   247 // (other items were commented in a header).
       
   248 // ---------------------------------------------------------
       
   249 //
       
   250 void CCAInviteManager::RemoveInvitationL( MCAInvitation* aInvitation )
       
   251     {
       
   252     RemoveInviteL( aInvitation );
       
   253     }
       
   254 
       
   255 
       
   256 // ---------------------------------------------------------
       
   257 // CCAInviteManager::RejectReasonPtr
       
   258 // (other items were commented in a header).
       
   259 // ---------------------------------------------------------
       
   260 //
       
   261 HBufC* CCAInviteManager::RejectReasonPtr()
       
   262     {
       
   263     return iRejectReason;
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------
       
   267 // CCAInviteManager::UnreadInvitesCount
       
   268 // (other items were commented in a header).
       
   269 // ---------------------------------------------------------
       
   270 //
       
   271 TInt CCAInviteManager::UnreadInvitesCount() const
       
   272     {
       
   273     TInt inviteCount( iInviteTrackerQueue.Count() );
       
   274     TInt unreadCount( 0 );
       
   275     for ( TInt i( 0 ); i < inviteCount; i++ )
       
   276         {
       
   277         if ( !iInviteTrackerQueue[ i ]->Invitation()->IsRead() )
       
   278             {
       
   279             ++unreadCount;
       
   280             }
       
   281         }
       
   282     return unreadCount;
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // CCAInviteManager::HandleGroupInviteL
       
   287 // (other items were commented in a header).
       
   288 // ---------------------------------------------------------
       
   289 //
       
   290 void CCAInviteManager::HandleGroupInviteL( const TDesC& aInviteID,
       
   291                                            const TDesC& aUserID,
       
   292                                            const TDesC& aScreenName,
       
   293                                            const TDesC& aGroupName,
       
   294                                            const TDesC& aInviteReason,
       
   295                                            const TInt aValidityPeriod,
       
   296                                            TImpsCspIdentifier& /* aCspId */ )
       
   297     {
       
   298     CHAT_DP_TXT( "Received new invitation!" );
       
   299     CHAT_DP( D_CHAT_LIT( " * %S invites us to group: %S" ),
       
   300              &aUserID, &aGroupName );
       
   301 
       
   302     MCAStoredContacts* contactList = NULL;
       
   303 
       
   304     TRAPD( err, contactList =
       
   305                CCAStorageManagerFactory::ContactListInterfaceL() );
       
   306     if ( ( err != KErrNone ) || ( ! contactList ) )
       
   307         {
       
   308         // we can't leave, but we can return
       
   309         CHAT_DP_TXT( "CCAInviteManager::GroupInviteUserRequest - Couldn't \
       
   310                       get contactlist interface" );
       
   311         return;
       
   312         }
       
   313 
       
   314     // check if the invitation should be blocked
       
   315     TInt receiveInvitations( iSettingsAPI.Value(
       
   316                                  MCASettings::EReceiveInvitations ) );
       
   317     if ( receiveInvitations == MCASettings::ENobody )
       
   318         {
       
   319         // ignore invites from everyone
       
   320         CHAT_DP_TXT( " * invitations blocked from everyone" );
       
   321         return;
       
   322         }
       
   323     else if ( receiveInvitations == MCASettings::EFriends &&
       
   324               ( ! contactList->FindAnyContact( aUserID ) ) )
       
   325         {
       
   326         // invite sender not found from friends list, ignore invite
       
   327         CHAT_DP_TXT( " * invitations blocked from everyone except friends" );
       
   328         return;
       
   329         }
       
   330 
       
   331     // ok, the invitation should be processed
       
   332     MCAInvitation* invitation = NULL;
       
   333     err = KErrNone;
       
   334     TRAP( err, invitation = CreateInviteRequestL( aInviteID,
       
   335                                                   aUserID,
       
   336                                                   aScreenName,
       
   337                                                   aGroupName,
       
   338                                                   aInviteReason,
       
   339                                                   aValidityPeriod ) );
       
   340 
       
   341     if ( err != KErrNone )
       
   342         {
       
   343         return;
       
   344         }
       
   345 
       
   346     CHAT_DP_TXT( " * invitation created" );
       
   347 
       
   348     // create a invitetracker that takes care of expiring the invite
       
   349     CCAInviteTracker* trackedInvite = NULL;
       
   350     err = KErrNone;
       
   351     TRAP( err, trackedInvite = CCAInviteTracker::NewL( this, invitation ) );
       
   352 
       
   353     if ( err != KErrNone )
       
   354         {
       
   355         delete invitation;
       
   356         return;
       
   357         }
       
   358 
       
   359     // append the invite to the list
       
   360     if ( iInviteTrackerQueue.Append( trackedInvite ) != KErrNone )
       
   361         {
       
   362         delete trackedInvite;
       
   363         return;
       
   364         }
       
   365 
       
   366     CHAT_DP_TXT( " * signalling observers" );
       
   367     // signal observers
       
   368     TInt count( iInviteObservers.Count() );
       
   369     for ( TInt i( 0 ); i < count; i++ )
       
   370         {
       
   371         if ( iInviteObservers[ i ] )
       
   372             {
       
   373             // it's non-NULL
       
   374             iInviteObservers[ i ]->HandleInvitationEventL(
       
   375                 MCAInviteObserver::ENewInvite, invitation );
       
   376             }
       
   377         }
       
   378 
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------
       
   382 // CCAInviteManager::ReplyInvitationL
       
   383 // (other items were commented in a header).
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 void CCAInviteManager::HandleImInviteL( const TDesC& /* aInviteID */,
       
   387                                         const TDesC& /* aUserID */,
       
   388                                         const TDesC& /* aInviteReason */,
       
   389                                         const TInt /* aValidityPeriod */,
       
   390                                         TImpsCspIdentifier& /* aCspId */ )
       
   391     {
       
   392     __CHAT_ASSERT_DEBUG( EFalse );
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------
       
   396 // CCAInviteManager::ReplyInvitationL
       
   397 // (other items were commented in a header).
       
   398 // ---------------------------------------------------------
       
   399 //
       
   400 void CCAInviteManager::HandleContentInviteL( const TDesC& /* aInviteID */,
       
   401                                              const TDesC& /* aUserID */,
       
   402                                              MDesCArray* /* aUrlList */,
       
   403                                              const TDesC& /* aInviteReason */,
       
   404                                              const TInt /* aValidityPeriod */,
       
   405                                              TImpsCspIdentifier& /* aCspId */ )
       
   406     {
       
   407     __CHAT_ASSERT_DEBUG( EFalse );
       
   408     }
       
   409 
       
   410 // ---------------------------------------------------------
       
   411 // CCAInviteManager::ReplyInvitationL
       
   412 // (other items were commented in a header).
       
   413 // ---------------------------------------------------------
       
   414 //
       
   415 void CCAInviteManager::ReplyInvitationL( const MCAInvitation* aInvitation,
       
   416                                          const TBool aInviteAccepted,
       
   417                                          const TDesC& aResponse,
       
   418                                          const TDesC& aScreenName
       
   419                                        )
       
   420     {
       
   421     CHAT_DP_TXT( "Reply to invite" );
       
   422 
       
   423     CCARequest* request = iRequestMapper->CreateRequestL(
       
   424                               iImpsFundAPI->GroupInviteUserResponseL( aInvitation->InviteID(),
       
   425                                                                       aInviteAccepted,
       
   426                                                                       aResponse,
       
   427                                                                       aScreenName,
       
   428                                                                       aInvitation->GroupId() ) );
       
   429 
       
   430     iRequestMapper->RemoveRequest( request );
       
   431 
       
   432     RemoveInviteL( aInvitation );
       
   433     }
       
   434 
       
   435 
       
   436 // ---------------------------------------------------------
       
   437 // CCAInviteManager::HandleInviteResponseL
       
   438 // (other items were commented in a header).
       
   439 // ---------------------------------------------------------
       
   440 //
       
   441 void CCAInviteManager::HandleInviteResponseL( const TDesC& /* aInviteID */,
       
   442                                               const TBool aAcceptance,
       
   443                                               const TDesC& aUserID,
       
   444                                               const TDesC& aScreenName,
       
   445                                               const TDesC& aGroupName,
       
   446                                               const TDesC& aResponse,
       
   447                                               TImpsCspIdentifier& /* aCspId */ )
       
   448     {
       
   449     CHAT_DP_TXT( "Received response to our invitation" );
       
   450     if ( aAcceptance )
       
   451         {
       
   452         CHAT_DP( D_CHAT_LIT( "%S accepts our invite to %S with comment %S" ),
       
   453                  &aScreenName, &aGroupName, &aResponse );
       
   454         }
       
   455     else
       
   456         {
       
   457         CHAT_DP( D_CHAT_LIT( "%S rejects our invitation to %S with comment %S" ),
       
   458                  &aScreenName, &aGroupName, &aResponse );
       
   459         }
       
   460 
       
   461     // identification for user can be in aScreenName or in aUserId
       
   462     TPtrC user( aUserID );
       
   463     if ( user.Length() == 0 )
       
   464         {
       
   465         user.Set( aScreenName );
       
   466         }
       
   467 
       
   468     // signal the observers
       
   469     TInt count( iInviteObservers.Count() );
       
   470     for ( TInt i( 0 ); i < count; i++ )
       
   471         {
       
   472         if ( iInviteObservers[ i ] )
       
   473             {
       
   474             // it's non-NULL
       
   475             iInviteObservers[ i ]->HandleInvitationResponse( aAcceptance, user,
       
   476                                                              aGroupName, aResponse );
       
   477             }
       
   478         }
       
   479     }
       
   480 
       
   481 
       
   482 // ---------------------------------------------------------
       
   483 // CCAInviteManager::CancelGroupInviteUserRequestL
       
   484 // (other items were commented in a header).
       
   485 // ---------------------------------------------------------
       
   486 //
       
   487 void CCAInviteManager::HandleInviteCancelL( const TDesC& aInviteID,
       
   488                                             const TDesC& /* aUserID */,
       
   489                                             const TDesC& /* aScreenName */,
       
   490                                             const TDesC& /* aGroupName */,
       
   491                                             const TDesC& /* aResponse */,
       
   492                                             TImpsCspIdentifier& /* aCspId */ )
       
   493     {
       
   494     CHAT_DP_TXT( "Received cancelled invitation signal" );
       
   495 
       
   496     MCAInvitation* invite = FindInvite( aInviteID );
       
   497     if ( invite )
       
   498         {
       
   499         // signal the observers
       
   500         TInt count( iInviteObservers.Count() );
       
   501         for ( TInt i( 0 ); i < count; i++ )
       
   502             {
       
   503             if ( iInviteObservers[ i ] )
       
   504                 {
       
   505                 // it's non-NULL
       
   506                 iInviteObservers[ i ]->HandleInvitationEventL(
       
   507                     MCAInviteObserver::EInviteCancel, invite );
       
   508                 }
       
   509             }
       
   510 
       
   511         // Failed remove can be safely ignored.
       
   512         RemoveInviteL( invite );
       
   513         }
       
   514     }
       
   515 
       
   516 
       
   517 // ---------------------------------------------------------
       
   518 // CCAInviteManager::HandleCompleteL
       
   519 // (other items were commented in a header).
       
   520 // ---------------------------------------------------------
       
   521 //
       
   522 void  CCAInviteManager::HandleCompleteL( TInt aOperationId,
       
   523                                          TImpsCspIdentifier& /* aCspId */ )
       
   524     {
       
   525     CHAT_DP_TXT( "Received invitation's HandleCompleteL" );
       
   526     // If code added before HandleRequest, then make sure that
       
   527     // code does not Leave before HandleRequest, because request
       
   528     // response waiting does not stop (and waitnote) before calling
       
   529     // HandleRequest
       
   530     iRequestMapper->HandleRequest( aOperationId, KErrNone );
       
   531     }
       
   532 
       
   533 void CCAInviteManager::HandleInviteReadL() const
       
   534     {
       
   535     // signal the observers
       
   536     TInt count( iInviteObservers.Count() );
       
   537     for ( TInt i( 0 ); i < count; i++ )
       
   538         {
       
   539         if ( iInviteObservers[ i ] )
       
   540             {
       
   541             // it's non-NULL
       
   542             iInviteObservers[ i ]->HandleInvitationEventL(
       
   543                 MCAInviteObserver::EInviteRead, NULL );
       
   544             }
       
   545         }
       
   546     }
       
   547 
       
   548 
       
   549 // ---------------------------------------------------------
       
   550 // CCAInviteManager::PrepareGroupForInviteeL( const CCAInvitation& aInvitation )
       
   551 // Checks if group is closed. If it's closed, then check if invitee is in
       
   552 // access-list. If not, then check is the logged user admin in group.
       
   553 // If so, then try to add invitee to access list.
       
   554 // (other items were commented in a header).
       
   555 // ---------------------------------------------------------
       
   556 //
       
   557 void CCAInviteManager::PrepareGroupForInviteeL(
       
   558     const CCAInvitationRequest& aInvitation )
       
   559     {
       
   560     const TDesC& groupID = aInvitation.GroupID();
       
   561 
       
   562     // Check if group is open or not
       
   563     if ( iGroupManager->IsGroupOpenL( groupID ) )
       
   564         {
       
   565         CHAT_DP_TXT( "PrepareGroupForInviteeL, Group is open for everyone" );
       
   566         return;
       
   567         }
       
   568 
       
   569     CHAT_DP_TXT( "PrepareGroupForInviteeL, Group closed, fetching access lists" );
       
   570 
       
   571     // Check if invitees are in access lists
       
   572     CDesCArray* failedList = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   573     CleanupStack::PushL( failedList );
       
   574 
       
   575     TBool adminStatus =
       
   576         iGroupManager->IsAllowedAccessL( groupID, aInvitation.Invitees(),
       
   577                                          *failedList );
       
   578 
       
   579     // Try to add not found users to access list as normal users
       
   580     if ( failedList->Count() > 0 )
       
   581         {
       
   582         // there is something in the list
       
   583 
       
   584         if ( !adminStatus )
       
   585             {
       
   586             User::Leave( EUserNotAdmin );
       
   587             }
       
   588 
       
   589         CHAT_DP_TXT( "PrepareGroupForInviteeL, Trying to add new users to \
       
   590                       access list as normal users" );
       
   591 
       
   592         // adds to network. we don't know screen names
       
   593         MCAGroupOperations* grOp = iGroupManager->GroupOperationsL( groupID );
       
   594         TInt err( grOp->AddMembersL( *failedList, *failedList ) );
       
   595         User::LeaveIfError( err );
       
   596         }
       
   597 
       
   598     CleanupStack::PopAndDestroy( failedList );
       
   599     }
       
   600 
       
   601 
       
   602 
       
   603 // ---------------------------------------------------------
       
   604 // CCAInviteManager::RemoveInviteL
       
   605 // (other items were commented in a header).
       
   606 // ---------------------------------------------------------
       
   607 //
       
   608 TBool CCAInviteManager::RemoveInviteL( const MCAInvitation* aInvitation )
       
   609     {
       
   610     TInt inviteCount( iInviteTrackerQueue.Count() );
       
   611     for ( TInt i( 0 ); i < inviteCount; i++ )
       
   612         {
       
   613         if ( iInviteTrackerQueue[ i ]->Invitation() == aInvitation )
       
   614             {
       
   615             delete iInviteTrackerQueue[ i ];
       
   616             iInviteTrackerQueue.Remove( i );
       
   617             iInviteTrackerQueue.Compress();
       
   618 
       
   619             // Signal the observers
       
   620             TInt count( iInviteObservers.Count() );
       
   621             for ( TInt i( 0 ); i < count; i++ )
       
   622                 {
       
   623                 if ( iInviteObservers[ i ] )
       
   624                     {
       
   625                     // Using read event to cause unread message indicators
       
   626                     // to be updated
       
   627                     iInviteObservers[ i ]->HandleInvitationEventL(
       
   628                         MCAInviteObserver::EInviteRead, NULL );
       
   629                     }
       
   630                 }
       
   631 
       
   632             return ETrue;
       
   633             }
       
   634         }
       
   635     return EFalse;
       
   636     }
       
   637 
       
   638 
       
   639 // ---------------------------------------------------------
       
   640 // CCAInviteManager::FindInvite
       
   641 // (other items were commented in a header).
       
   642 // ---------------------------------------------------------
       
   643 //
       
   644 MCAInvitation* CCAInviteManager::FindInvite( const TDesC& aInviteId )
       
   645     {
       
   646     TInt inviteCount( iInviteTrackerQueue.Count() );
       
   647     for ( TInt i( 0 ); i < inviteCount; i++ )
       
   648         {
       
   649         if ( iInviteTrackerQueue[ i ]->Invitation()->InviteID().CompareC(
       
   650                  aInviteId, KCollationLevel, NULL ) == 0 )
       
   651             {
       
   652             return iInviteTrackerQueue[ i ]->Invitation();
       
   653             }
       
   654         }
       
   655     return NULL;
       
   656     }
       
   657 
       
   658 
       
   659 // ---------------------------------------------------------
       
   660 // CCAInviteManager::CreateInviteRequestL
       
   661 // (other items were commented in a header).
       
   662 // ---------------------------------------------------------
       
   663 //
       
   664 MCAInvitation* CCAInviteManager::CreateInviteRequestL( const TDesC& aInviteID,
       
   665                                                        const TDesC& aUserID,
       
   666                                                        const TDesC& aScreenName,
       
   667                                                        const TDesC& aGroupID,
       
   668                                                        const TDesC& aInviteReason,
       
   669                                                        const TInt aValidityPeriod )
       
   670     {
       
   671     TPtrC groupName( aGroupID );
       
   672     MCAStoredGroups* groups = CCAStorageManagerFactory::GroupListInterfaceL();
       
   673     MCAStoredGroup* group = groups->FindGroup( aGroupID );
       
   674     if ( group )
       
   675         {
       
   676         groupName.Set( group->GroupName() );
       
   677         }
       
   678 
       
   679     CCAInvitation* invitation = CCAInvitation::NewL( aInviteID,
       
   680                                                      aUserID,
       
   681                                                      aGroupID,
       
   682                                                      aScreenName,
       
   683                                                      groupName,
       
   684                                                      aInviteReason,
       
   685                                                      aValidityPeriod );
       
   686 
       
   687     invitation->AddReadObserver( this );
       
   688 
       
   689     return invitation;
       
   690     }
       
   691 
       
   692 //  End of File