uiservicetab/vimpstdetailsviewplugin/src/cvimpstdetailsviewfactory.cpp
branchRCL_3
changeset 29 9a48e301e94b
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2008 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 of detailsview plugin control container
       
    15  *
       
    16 */
       
    17 // settings
       
    18 
       
    19 #include    <spsettings.h>
       
    20 #include    <spentry.h>
       
    21 #include    <spproperty.h>
       
    22 #include <e32property.h>
       
    23 #include <imconnectionproviderconsts.h>
       
    24 
       
    25 #include "cvimpstdetailsviewpluginfactory.h"
       
    26 #include "cvimpstdetailsviewplugin.h"
       
    27 
       
    28 #include "uiservicetabtracer.h"
       
    29 // meco service uid
       
    30 #define KMECOIMPLEMENTATIONUID 0x20012423
       
    31 // ---------------------------------------------------------------------------
       
    32 // CVIMPSTDetailsViewPluginFactory::NewL
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CVIMPSTDetailsViewPluginFactory* CVIMPSTDetailsViewPluginFactory::NewL()  
       
    36     {
       
    37     CVIMPSTDetailsViewPluginFactory* self = new ( ELeave ) CVIMPSTDetailsViewPluginFactory();
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop();//self, do not pass the parameter to pop since this is an M Class..
       
    41     return self;    
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CVIMPSTDetailsViewPluginFactory::CVIMPSTDetailsViewPluginFactory
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CVIMPSTDetailsViewPluginFactory::CVIMPSTDetailsViewPluginFactory():
       
    49     iServiceId( 0 )
       
    50     {
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CVIMPSTDetailsViewPluginFactory::ConstructL
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void CVIMPSTDetailsViewPluginFactory::ConstructL()
       
    58     {
       
    59 	TRACER_AUTO;
       
    60 
       
    61     RProperty::Define(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, RProperty::EInt,
       
    62                              ECapabilityReadUserData ,ECapabilityWriteUserData); 
       
    63     
       
    64     ReadServiceIdL();
       
    65     if(iServiceIds.Count() == 0)
       
    66         {
       
    67         User::Leave(KErrArgument);
       
    68         }
       
    69 
       
    70     }
       
    71 // ---------------------------------------------------------------------------
       
    72 // CVIMPSTDetailsViewPluginFactory::~CVIMPSTDetailsViewPluginFactory
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CVIMPSTDetailsViewPluginFactory::~CVIMPSTDetailsViewPluginFactory()
       
    76     {
       
    77     iServiceIds.Reset();
       
    78     iServiceIds.Close();
       
    79     RProperty::Set(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, 0 );  //reset to zero
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CVIMPSTDetailsViewPluginFactory::TabViewCount
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 TInt CVIMPSTDetailsViewPluginFactory::TabViewCount()
       
    87     {
       
    88 	TRACER_AUTO;
       
    89     // read the service id from RProperty
       
    90     RProperty::Get(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, iServiceId ); 
       
    91     TInt returnVal = 0;
       
    92     if( iServiceId <= 0 )
       
    93         {     
       
    94         TRACE("iservice <=0");
       
    95         return iServiceIds.Count();
       
    96         }
       
    97     else
       
    98         {     
       
    99         TRACE("iservice > 0"); 
       
   100         iServiceIds.Reset();
       
   101         iServiceIds.Append( iServiceId );
       
   102         returnVal = 1;
       
   103         }
       
   104     return returnVal;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CVIMPSTDetailsViewPluginFactory::CreateTabViewL
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 CCCAppViewPluginBase* CVIMPSTDetailsViewPluginFactory::CreateTabViewL( TInt aIndex )
       
   112     {
       
   113 	TRACER_AUTO;
       
   114   
       
   115 	TRACE("aIndex = %d", aIndex);
       
   116     CCCAppViewPluginBase* viewPluginBase = NULL;    
       
   117     if( aIndex < iServiceIds.Count() && aIndex >= 0 )
       
   118         {
       
   119 		TRACE("creating view aIndex = %d", aIndex);
       
   120         viewPluginBase = CVIMPSTDetailsViewPlugin::NewL( iServiceIds[aIndex]);
       
   121         TRACE("view created"); 
       
   122         }
       
   123     else
       
   124         {
       
   125         User::Leave(KErrArgument);
       
   126         }   
       
   127   
       
   128     return viewPluginBase;
       
   129     }
       
   130  
       
   131 // ---------------------------------------------------------------------------
       
   132 // CVIMPSTDetailsViewPluginFactory::ReadServiceIdL
       
   133 // ---------------------------------------------------------------------------
       
   134 // 
       
   135 TInt CVIMPSTDetailsViewPluginFactory::ReadServiceIdL()
       
   136     {
       
   137 	TRACER_AUTO;
       
   138     CSPSettings* settings = CSPSettings::NewLC();
       
   139     iServiceIds.Reset();
       
   140     ///////////////////////Get Service Id////////////////    
       
   141     RArray<TServiceId> services;
       
   142     CleanupClosePushL( services );
       
   143     settings->FindServiceIdsL( services );
       
   144     const TInt serviceCount = services.Count();
       
   145     for ( TInt i( 0 ); i < serviceCount; i++ )
       
   146         {
       
   147         TInt refContactUid = KErrNotFound;
       
   148         CSPProperty* property = CSPProperty::NewLC();
       
   149         settings->FindPropertyL( services[i],EPropertyContactViewPluginId,*property );    
       
   150         if ( property )
       
   151             {
       
   152             property->GetValue( refContactUid );
       
   153             }
       
   154         CleanupStack::PopAndDestroy( property );
       
   155         if ( (TUid::Uid( refContactUid ) == TUid::Uid( KMECOIMPLEMENTATIONUID ))
       
   156                 || (TUid::Uid( refContactUid ) ==  TUid::Uid( 0x20007B6D ) )
       
   157                 || (TUid::Uid( refContactUid ) == TUid::Uid( 0x2002B334 )))
       
   158             {
       
   159             iServiceIds.Append( services[i] );
       
   160             }
       
   161         }
       
   162     CleanupStack::PopAndDestroy( &services );
       
   163     CleanupStack::PopAndDestroy( settings );
       
   164     return iServiceIds.Count();
       
   165     }