phonebookui/Phonebook2/CommonUtility/src/Pbk2LaunchNewContact.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Implements Phonebook 2 launch New Contact directly from client application.
       
    15 *
       
    16 */
       
    17 
       
    18 // Phonebook 2
       
    19 #include "Pbk2LaunchNewContact.h"
       
    20 #include <e32property.h>
       
    21 #include <e32std.h>
       
    22 #include <Pbk2InternalUID.h>
       
    23 #include <apgtask.h>
       
    24 #include <apgcli.h> 
       
    25 #include <eikenv.h>
       
    26 // System includes
       
    27 //const TUid KPbk2LaunchNewContactProperty = {0xEC42FD42};//AnyKey Uid//0x2002680C(protected UID) //0x3D335E82(random)
       
    28 const TUid KNewContactLauncherUid = {0x20026FC2};
       
    29 
       
    30 EXPORT_C void Pbk2LaunchNewContact::LaunchNewContactL()
       
    31     {
       
    32     _LIT8(dontActivate, "dontactivate");
       
    33     HBufC* param = HBufC::NewLC( 256 );
       
    34     param->Des().Format( _L( "4 %S" ),&dontActivate );
       
    35 
       
    36     TUid id( KNewContactLauncherUid );
       
    37 
       
    38     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
    39     TApaTask task = taskList.FindApp( id );
       
    40     if ( task.Exists() )
       
    41     {
       
    42          HBufC8* param8 = HBufC8::NewLC( param->Length() );
       
    43          param8->Des().Append( *param );
       
    44          task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
       
    45          task.BringToForeground();
       
    46          CleanupStack::PopAndDestroy(); // param8
       
    47     }
       
    48     else
       
    49     {
       
    50          RApaLsSession appArcSession;
       
    51          User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server
       
    52          TThreadId id;
       
    53          appArcSession.StartDocument( *param, KNewContactLauncherUid, id );
       
    54          appArcSession.Close();
       
    55     }
       
    56     CleanupStack::PopAndDestroy(); // param
       
    57 
       
    58 
       
    59     }
       
    60 
       
    61 // End of File