idlefw/plugins/shortcutplugin/src/aiscutextserv.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-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:  AI Shortcut xSP Extension API
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <s32mem.h>
       
    21 #include <gulicon.h>
       
    22 #include <fbs.h>
       
    23 
       
    24 #include <aiscutextserv.h>
       
    25 #include <aiscutextdefs.h>
       
    26 
       
    27 // ======== LOCAL DEFINITIONS ========
       
    28 
       
    29 namespace
       
    30     {
       
    31     //  LOCAL CONSTANTS
       
    32     /**
       
    33      * Default message slots
       
    34      */
       
    35     const TUint KDefaultMessageSlots = 4;
       
    36 
       
    37     /**
       
    38      * Marshalling buffer expand size
       
    39      */
       
    40     const TInt KBufExpandSize = 32;
       
    41 
       
    42     /**
       
    43      * Target string format that matches with aiscutplugin
       
    44      */
       
    45     _LIT( KTargetStringFormat, "localapp:0x%x" );
       
    46 
       
    47     //  LOCAL TYPES
       
    48     typedef TBuf<19> TTargetString;
       
    49 
       
    50     //  LOCAL FUNCTIONS
       
    51     /**
       
    52      * Panics server
       
    53      * @aReason Panic reason code
       
    54      */
       
    55     void Panic( TInt aReason )
       
    56         {
       
    57         User::Panic( KAiScutExtServerName, aReason );
       
    58         }
       
    59 
       
    60     /**
       
    61      * Generates target string from Uid3 of current process
       
    62      */
       
    63     TTargetString DefaultTargetString()
       
    64         {
       
    65         TUid uid3 = RProcess().Type()[ 2 ];
       
    66         TTargetString targetString;
       
    67         targetString.Format( KTargetStringFormat, uid3 );
       
    68         return targetString;
       
    69         }
       
    70     }
       
    71 
       
    72 // ======== MEMBER FUNCTIONS ========
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C TInt RAiScutExtServ::Connect()
       
    79     {
       
    80     return Connect( DefaultTargetString() );
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C TInt RAiScutExtServ::Connect( const TDesC& aTargetDefinition )
       
    88     {
       
    89     TInt err = CreateSession( KAiScutExtServerName, Version(),
       
    90         KDefaultMessageSlots );
       
    91     if( err == KErrNone )
       
    92         {
       
    93         TIpcArgs args( &aTargetDefinition );
       
    94         err = SendReceive( EAiScutExtServSetTargetDefinition, args );
       
    95         if( err != KErrNone )
       
    96             {
       
    97             Close();
       
    98             }
       
    99         }
       
   100     return err;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C TVersion RAiScutExtServ::Version() const
       
   108     {
       
   109     return( TVersion(
       
   110         KAiScutExtServMajorVersionNumber,
       
   111         KAiScutExtServMinorVersionNumber,
       
   112         KAiScutExtServBuildVersionNumber ) );
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C TInt RAiScutExtServ::UpdatePopupTextL(
       
   120     const MDesCArray& aPopupTextLines )
       
   121     {
       
   122     TInt lineCount = aPopupTextLines.MdcaCount();
       
   123     __ASSERT_ALWAYS( lineCount <= KMaxPopupTextLines, Panic( KErrArgument ) );
       
   124     CBufBase* lineArrayBuf = CBufFlat::NewL( KBufExpandSize );
       
   125     CleanupStack::PushL( lineArrayBuf );
       
   126 
       
   127     RBufWriteStream stream( *lineArrayBuf );
       
   128 
       
   129     stream.WriteUint8L( lineCount );
       
   130     for( TInt i = 0; i < lineCount; i++ )
       
   131         {
       
   132         stream << aPopupTextLines.MdcaPoint( i );
       
   133         }
       
   134 
       
   135     TPtr8 lineArray = lineArrayBuf->Ptr( 0 );
       
   136 
       
   137     TIpcArgs args( &lineArray );
       
   138     TInt err = SendReceive( EAiScutExtServSetPopupText, args );
       
   139 
       
   140     CleanupStack::PopAndDestroy( lineArrayBuf );
       
   141     return err;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C TInt RAiScutExtServ::ResetPopupText()
       
   149     {
       
   150     return SendReceive( EAiScutExtServResetPopupText );
       
   151     }
       
   152 
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C TInt RAiScutExtServ::UpdateIconL( const CGulIcon& aIcon )
       
   159     {
       
   160     CBufBase* marshallBuf = CBufFlat::NewL( KBufExpandSize );
       
   161     CleanupStack::PushL( marshallBuf );
       
   162 
       
   163     RBufWriteStream stream( *marshallBuf );
       
   164 
       
   165     aIcon.Bitmap()->ExternalizeL( stream );
       
   166     aIcon.Mask()->ExternalizeL( stream );
       
   167 
       
   168     TPtr8 marshalledData = marshallBuf->Ptr( 0 );
       
   169 
       
   170     TIpcArgs args( &marshalledData );
       
   171     TInt err = SendReceive( EAiScutExtServSetIcon, args );
       
   172 
       
   173     CleanupStack::PopAndDestroy( marshallBuf );
       
   174     return err;
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 EXPORT_C TInt RAiScutExtServ::ResetIcon()
       
   182     {
       
   183     return SendReceive( EAiScutExtServResetIcon );
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 EXPORT_C TInt RAiScutExtServ::IsInShortcuts( TBool& aIsInShortcuts ) const
       
   191     {
       
   192     TPtr8 isInShortcutsDes(
       
   193         reinterpret_cast< TUint8* >( &aIsInShortcuts ),
       
   194         sizeof( aIsInShortcuts ),
       
   195         sizeof( aIsInShortcuts ) );
       
   196 
       
   197     TIpcArgs args( &isInShortcutsDes );
       
   198 
       
   199     return SendReceive( EAiScutExtServIsInShortcuts, args );
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 EXPORT_C TInt RAiScutExtServ::IssuePutInShortcuts()
       
   207     {
       
   208     return SendReceive( EAiScutExtServIssuePutInShortcuts );
       
   209     }
       
   210 
       
   211 // End of File.