imstutils/imconversationview/imcvlauncher/src/imcvlauncher.cpp
branchRCL_3
changeset 22 3104fc151679
parent 21 2b7283837edb
child 23 9a48e301e94b
equal deleted inserted replaced
21:2b7283837edb 22:3104fc151679
     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:  launcher class for launching the conversation view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "imcvlauncher.h"
       
    22 #include "imcvuiliterals.h"
       
    23 
       
    24 // logs file
       
    25 #include "imcvlogger.h"
       
    26 #include "imcvuiparams.h"
       
    27 
       
    28 //system includes
       
    29 #include <aknenv.h>
       
    30 
       
    31 #include <e32property.h>
       
    32 #include <imconnectionproviderconsts.h>
       
    33 #include <spsettings.h>
       
    34 #include <spentry.h>
       
    35 #include <spproperty.h>
       
    36 #include <spdefinitions.h>
       
    37 #include    <MVPbkContactLink.h>
       
    38 #include "xmppparams.h"
       
    39 #include "xmppservicesettingsapi.h"
       
    40 
       
    41 #include<apgtask.h> 
       
    42 
       
    43 // Unique implementation Uid for this example
       
    44 #define KIMCONTACTSEXTNIMPLEMENTATIONUID 0x20012423
       
    45 #define KIMCVUIAPPEXEUID3           0x20012425
       
    46  
       
    47 //-----------------------------------------------------------------------------
       
    48 // IMCVLauncher::LaunchImConversationViewL
       
    49 // ( Other items commented in header )
       
    50 //-----------------------------------------------------------------------------    
       
    51 EXPORT_C TInt IMCVLauncher::LaunchImConversationViewL(TVwsViewId aActiveViewId,
       
    52 														TInt aServiceId,
       
    53 														const TDesC& aRecipientUserId, 
       
    54 														const TDesC& aDisplayName , 
       
    55 														MVPbkContactLink* aContactLink ) 
       
    56 	{
       
    57 	IM_CV_LOGS(TXT("IMCVLauncher::LaunchImConversationViewL start") );
       
    58 	IM_CV_LOGS(TXT("IMCVLauncher:: aRecipientUserId = %s "), &aRecipientUserId );
       
    59 	
       
    60 	TInt err = RProperty::Define(KMeCoPropertyUid, KMeCoConvViewServiceIdKey, RProperty::EInt,
       
    61 					  ECapabilityReadUserData ,ECapabilityWriteUserData);			
       
    62 					  
       
    63 	RProperty::Set( KMeCoPropertyUid, KMeCoConvViewServiceIdKey, aServiceId );
       
    64 
       
    65 	//check whether its valid service and then only proceed
       
    66 	if (!CheckValidServiceL(aServiceId))	
       
    67 		{
       
    68 		return 	KErrArgument;
       
    69 		}
       
    70 	// packing of data ,passed to conversation view
       
    71 	TPckgBuf< TIMCVUiParams > params;
       
    72 	
       
    73 	params().iAppUid = aActiveViewId.iAppUid.iUid;
       
    74 	params().iViewUid = aActiveViewId.iViewUid.iUid;
       
    75 	params().iBuddyId = aRecipientUserId;
       
    76 	params().iBuddyName = aDisplayName;
       
    77 	 
       
    78 	if ( aContactLink )
       
    79 	    {
       
    80 	    params().iContactLink = aContactLink->PackLC()->Des();
       
    81 	    CleanupStack::PopAndDestroy(); //pop and destroy the hbufc8*
       
    82 	    }
       
    83 	       
       
    84 	TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
       
    85     TApaTask task = taskList.FindApp( KConversationViewAppUid );   
       
    86     if ( task.Exists() )    
       
    87 		{			
       
    88 		task.SendMessage(TUid::Uid( KUidApaMessageSwitchOpenFileValue ), params );
       
    89 		}
       
    90 	else
       
    91 		{		
       
    92 	// conversation view application uid and view uid
       
    93 	// system call will activate the same view.
       
    94 	TVwsViewId view( KConversationViewAppUid, KUidConversationsView );
       
    95 	
       
    96 	CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(view, 
       
    97 														 KUidIMCViewSoftNoteActivationId,
       
    98 														 params ) ;
       
    99 		}			        
       
   100 
       
   101 	
       
   102 														 
       
   103 	IM_CV_LOGS(TXT("IMCVLauncher::LaunchImConversationViewL end") );   
       
   104 	
       
   105 	return KErrNone;
       
   106 	
       
   107 	}
       
   108 	
       
   109 	
       
   110 
       
   111 //-----------------------------------------------------------------------------
       
   112 // IMCVLauncher::CheckValidServiceL
       
   113 // ( Other items commented in header )
       
   114 //----------------------------------------------------------------------------- 
       
   115 TBool IMCVLauncher::CheckValidServiceL(TInt aServiceId)	
       
   116 	{	
       
   117 	
       
   118 	CSPSettings* settings = CSPSettings::NewLC();
       
   119 	
       
   120 	//check whether it has IMSubservice    
       
   121     CSPProperty* property = CSPProperty::NewLC();
       
   122     TInt err = settings->FindPropertyL( aServiceId,
       
   123                                 ESubPropertyIMEnabled,
       
   124                                 *property );  	
       
   125 	
       
   126 	if ( err )
       
   127 		{
       
   128 		CleanupStack::PopAndDestroy( 2 );
       
   129 		return EFalse;
       
   130 		}
       
   131 	
       
   132 	//check whether it has IMSubservice valid for Meco ServiceTab
       
   133 	TInt contactViewUid = KErrNotFound;
       
   134     err = settings->FindPropertyL( aServiceId,
       
   135                                 EPropertyContactViewPluginId,
       
   136                                 *property );  	
       
   137 	if ( property )
       
   138         {
       
   139         property->GetValue( contactViewUid );
       
   140         }
       
   141 	
       
   142 	if ( err )
       
   143 		{
       
   144 		CleanupStack::PopAndDestroy( 2 );		
       
   145 		return EFalse;
       
   146 		}
       
   147 			
       
   148 	
       
   149 	if ( TUid::Uid( contactViewUid ) == 
       
   150              TUid::Uid( KIMCONTACTSEXTNIMPLEMENTATIONUID ) 
       
   151              || TUid::Uid( contactViewUid ) == 
       
   152              TUid::Uid( 0x20007B6D ) 
       
   153              || TUid::Uid(contactViewUid) ==
       
   154              TUid::Uid(0x2002B334))
       
   155 		{
       
   156 		CleanupStack::PopAndDestroy( 2 );
       
   157 		return ETrue;			
       
   158 		}
       
   159 	
       
   160 	CleanupStack::PopAndDestroy( 2 );
       
   161 	return EFalse;		
       
   162 	}
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // IMCVLauncher::PropertySettingsIdL()
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 TInt IMCVLauncher::PropertySettingsIdL(TUint32 aServiceId ) 
       
   169     {
       
   170     CSPSettings* settings = CSPSettings::NewLC();
       
   171 
       
   172     // default to english
       
   173     TInt settingsId = -1; 
       
   174     CSPProperty* property = CSPProperty::NewLC();
       
   175     settings->FindPropertyL( aServiceId,
       
   176                                 ESubPropertyIMSettingsId,
       
   177                                 *property );    
       
   178     if ( property )
       
   179         {
       
   180         property->GetValue( settingsId );
       
   181         }
       
   182     CleanupStack::PopAndDestroy( 2,settings );   
       
   183 
       
   184     return (settingsId);
       
   185     }
       
   186 //  End of File