wvuing/wvuiprocess/Src/CCAGroupPropertiesPC.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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 "CCAGroupPropertiesPC.h"
       
    22 #include "MCAStoredGroups.h"
       
    23 #include "CCAStorageManagerFactory.h"
       
    24 #include "CCAEngine.h"
       
    25 #include "MCAStoredGroup.h"
       
    26 #include "MCAStoredContacts.h"
       
    27 #include "MCAGroupOperations.h"
       
    28 #include "MCAGroupManagerInterface.h"
       
    29 #include "MCAExtendedStoredGroup.h"
       
    30 
       
    31 #include "CCAServerContactsArrayPC.h"
       
    32 #include "CAPresenceManager.h"
       
    33 #include "MCAPresence.h"
       
    34 //const definitions
       
    35 
       
    36 
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CCAGroupPropertiesPC: Constructor
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CCAGroupPropertiesPC::CCAGroupPropertiesPC(
       
    46     MCAGroupManagerInterface& aGroupMgrInterface )
       
    47         : iGroupMgrInterface( aGroupMgrInterface )
       
    48 
       
    49     {
       
    50     }
       
    51 
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CCAGroupPropertiesPC: NewL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CCAGroupPropertiesPC* CCAGroupPropertiesPC::NewL(
       
    58     MCAGroupManagerInterface& aGroupMgrInterface )
       
    59     {
       
    60     CCAGroupPropertiesPC* self =
       
    61         new ( ELeave ) CCAGroupPropertiesPC( aGroupMgrInterface );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CCAGroupPropertiesPC: ConstructL
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CCAGroupPropertiesPC::ConstructL(  )
       
    73     {
       
    74     iChatGroups = CCAStorageManagerFactory::GroupListInterfaceL();
       
    75     iStoredContacts = CCAStorageManagerFactory::ContactListInterfaceL();
       
    76     }
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CCAGroupPropertiesPC: Destructor
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CCAGroupPropertiesPC::~CCAGroupPropertiesPC()
       
    84     {
       
    85     }
       
    86 
       
    87 
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CCAGroupPropertiesPC: GetPropertiesL
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CImpsCommonGroupProps* CCAGroupPropertiesPC::GetEdittedProperties()
       
    94     {
       
    95     return iGroupPropsForGrpPropDialog;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CCAGroupPropertiesPC: GetPropertiesL
       
   100 // Note: CodeScanner is likely to return false positives for this situation,
       
   101 // because some returned TInt values will not be error codes
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TInt CCAGroupPropertiesPC::InitializeForEdittingL( const TDesC& aGroupId )
       
   105     {
       
   106     TInt err( KErrNone );
       
   107     MCAGroupOperations * groupOps = iGroupMgrInterface.GroupOperationsL( aGroupId );
       
   108     if ( groupOps )
       
   109         {
       
   110         err = groupOps->GetPropertiesL( iGroupPropsForGrpPropDialog, iPrivatePropsForGrpPropDialog );
       
   111         }
       
   112     return err;
       
   113     }
       
   114 
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CCAGroupPropertiesPC: IsPrivateAllowed
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TEnumsPC::TImpsPropertyBoolPC CCAGroupPropertiesPC::IsPrivateAllowed()
       
   121     {
       
   122     return ConvertTImpsPropertyBoolToTEnumsPC(
       
   123                iGroupPropsForGrpPropDialog->IsPrivateAllowed() );
       
   124     }
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CCAGroupPropertiesPC: IsOpen
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TEnumsPC::TImpsPropertyBoolPC CCAGroupPropertiesPC::IsOpen()
       
   132     {
       
   133 
       
   134 
       
   135     TEnumsPC::TImpsPropertyBoolPC impsProperty;
       
   136     switch ( iGroupPropsForGrpPropDialog->IsOpen() )
       
   137         {
       
   138         case EImpsPropUndef:
       
   139             {
       
   140             impsProperty = TEnumsPC::EImpsPropUndef;
       
   141             break;
       
   142             }
       
   143         case EImpsPropNo:
       
   144             {
       
   145             impsProperty = TEnumsPC::EImpsPropYes;
       
   146             break;
       
   147             }
       
   148         case EImpsPropYes:
       
   149             {
       
   150             impsProperty = TEnumsPC::EImpsPropNo;
       
   151             break;
       
   152             }
       
   153 
       
   154         default:
       
   155             {
       
   156             impsProperty = TEnumsPC::EImpsPropUndef;
       
   157             break;
       
   158             }
       
   159         }
       
   160     return impsProperty;
       
   161 
       
   162     }
       
   163 
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CCAGroupPropertiesPC::ConvertTImpsPropertyBoolToTEnumsPC
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 TEnumsPC::TImpsPropertyBoolPC CCAGroupPropertiesPC::ConvertTImpsPropertyBoolToTEnumsPC
       
   170 ( TImpsPropertyBool aEventSource )
       
   171     {
       
   172     TEnumsPC::TImpsPropertyBoolPC impsProperty;
       
   173     switch ( aEventSource )
       
   174         {
       
   175         case EImpsPropUndef:
       
   176             {
       
   177             impsProperty = TEnumsPC::EImpsPropUndef;
       
   178             break;
       
   179             }
       
   180         case EImpsPropNo:
       
   181             {
       
   182             impsProperty = TEnumsPC::EImpsPropNo;
       
   183             break;
       
   184             }
       
   185         case EImpsPropYes:
       
   186             {
       
   187             impsProperty = TEnumsPC::EImpsPropYes;
       
   188             break;
       
   189             }
       
   190 
       
   191         default:
       
   192             {
       
   193             impsProperty = TEnumsPC::EImpsPropUndef;
       
   194             break;
       
   195             }
       
   196         }
       
   197     return impsProperty;
       
   198     }
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CCAGroupPropertiesPC: NumberOfCreatedGroupsDuringSession
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 TInt CCAGroupPropertiesPC::NumberOfCreatedGroupsDuringSession()
       
   205     {
       
   206     return iGroupMgrInterface.NumberOfCreatedGroupsDuringSession();
       
   207     }
       
   208 
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CCAGroupPropertiesPC: IsSearchable
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TEnumsPC::TImpsPropertyBoolPC CCAGroupPropertiesPC::IsSearchable( )
       
   216     {
       
   217     return ConvertTImpsPropertyBoolToTEnumsPC( iGroupPropsForGrpPropDialog->IsSearchable() );
       
   218     }
       
   219 
       
   220 
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CCAGroupPropertiesPC: GetIdentification
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 const TPtrC CCAGroupPropertiesPC::GetIdentificationL( const TDesC& aWvId )
       
   227     {
       
   228     MCAStoredContacts* contacts =
       
   229         CCAStorageManagerFactory::ContactListInterfaceL();
       
   230     if ( contacts )
       
   231         {
       
   232         return contacts->Identification( aWvId ) ;
       
   233         }
       
   234     else
       
   235         {
       
   236         return KNullDesC();
       
   237         }
       
   238 
       
   239     }
       
   240 
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // CCAGroupPropertiesPC::IsFavouriteChatGroup
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 TBool CCAGroupPropertiesPC::IsFavouriteChatGroup( const TDesC& aGroupId ) const
       
   247     {
       
   248     TBool isFavourite( EFalse );
       
   249     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   250     if ( group )
       
   251         {
       
   252         isFavourite = ( group->StorageType() ==
       
   253                         TStorageManagerGlobals::EStoragePersistent );
       
   254         }
       
   255     return isFavourite;
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CCAGroupPropertiesPC::FindGroup
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 TBool CCAGroupPropertiesPC::FindGroup( const TDesC& aGroupId ) const
       
   263     {
       
   264     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   265     if ( group )
       
   266         {
       
   267         return ETrue;
       
   268         }
       
   269     else
       
   270         {
       
   271         return EFalse;
       
   272         }
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CCAGroupPropertiesPC::GetGroupName
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 const TDesC& CCAGroupPropertiesPC::GetGroupName( const TDesC& aGroupId ) const
       
   280     {
       
   281     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   282     if ( group )
       
   283         {
       
   284         return group->GroupName();
       
   285         }
       
   286     else
       
   287         {
       
   288         return KNullDesC();
       
   289         }
       
   290     }
       
   291 
       
   292 
       
   293 // ---------------------------------------------------------
       
   294 // CCAGroupPropertiesPC::IsJoined
       
   295 // ---------------------------------------------------------
       
   296 //
       
   297 TBool CCAGroupPropertiesPC::IsJoined( const TDesC& aGroupId ) const
       
   298     {
       
   299     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   300 
       
   301     if ( group )
       
   302         {
       
   303         return group->IsJoined();
       
   304         }
       
   305     else
       
   306         {
       
   307         return EFalse;
       
   308         }
       
   309     }
       
   310 
       
   311 
       
   312 // ---------------------------------------------------------
       
   313 // CCAGroupPropertiesPC::IsOwnGroup
       
   314 // ---------------------------------------------------------
       
   315 //
       
   316 TBool CCAGroupPropertiesPC::IsOwnGroup( const TDesC& aGroupId ) const
       
   317     {
       
   318     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   319 
       
   320     if ( group )
       
   321         {
       
   322         return group->IsOwnGroup();
       
   323         }
       
   324     else
       
   325         {
       
   326         return EFalse;
       
   327         }
       
   328     }
       
   329 
       
   330 
       
   331 // ---------------------------------------------------------
       
   332 // CCAGroupPropertiesPC::IsAdmin
       
   333 // ---------------------------------------------------------
       
   334 //
       
   335 TBool CCAGroupPropertiesPC::IsAdmin( const TDesC& aGroupId ) const
       
   336     {
       
   337     MCAStoredGroup* group = iChatGroups->FindGroup( aGroupId );
       
   338     if ( group )
       
   339         {
       
   340         return group->IsAdmin();
       
   341         }
       
   342     else
       
   343         {
       
   344         return EFalse;
       
   345         }
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------
       
   349 // CCAGroupPropertiesPC::SetOpen
       
   350 // ---------------------------------------------------------
       
   351 //
       
   352 void CCAGroupPropertiesPC::SetOpen( TEnumsPC::TImpsPropertyBoolPC aType )
       
   353     {
       
   354 
       
   355     TImpsPropertyBool impsProperty;
       
   356     switch ( aType )
       
   357         {
       
   358         case TEnumsPC::EImpsPropUndef:
       
   359             {
       
   360             impsProperty = EImpsPropUndef;
       
   361             break;
       
   362             }
       
   363         case TEnumsPC::EImpsPropNo:
       
   364             {
       
   365             impsProperty = EImpsPropYes;
       
   366             break;
       
   367             }
       
   368         case TEnumsPC::EImpsPropYes:
       
   369             {
       
   370             impsProperty = EImpsPropNo;
       
   371             break;
       
   372             }
       
   373 
       
   374         default:
       
   375             {
       
   376             impsProperty = EImpsPropUndef;
       
   377             break;
       
   378             }
       
   379         }
       
   380 
       
   381     iGroupPropsForGrpPropDialog->SetOpen( impsProperty );
       
   382     }
       
   383 
       
   384 // End of File
       
   385