contextframework/cfw/inc/basicoperationsplugin/cfcontextoperationutils.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2004-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:  CFContextOperationUtils class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CFCONTEXTOPERATIONUTILS_H
       
    21 #define CFCONTEXTOPERATIONUTILS_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "cfcontextoperation.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CMDXMLNode;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 *  Context Framework Context Operation utils class.
       
    35 *
       
    36 *  @lib CFScriptEngine
       
    37 *  @since S60 v5.0
       
    38 */
       
    39 NONSHARABLE_CLASS( CFContextOperationUtils )
       
    40     {
       
    41 public: // Util functions
       
    42 
       
    43     /**
       
    44     * Parses data for a comparison operation having two arguments. Iterates
       
    45     * through all siblings so only two nodes are allowed to have real content.
       
    46     * @param aNode is the operation node whose two arguments will be parsed.
       
    47     * @param aContextSource will be set to context source of the contextRef.
       
    48     * @param aContextType will be set to context type of the contextRef.
       
    49     * @param aCompareType will be set to compare type of the comparison.
       
    50     * @param aCompareValue will be set to compare value of the comparison.
       
    51     * @param aContextLevelDelay will be set to the value of context level delay
       
    52     *   attribute if it was present.
       
    53     * @return ETrue if exactly two arguments were found and parsed successfully,
       
    54     *   EFalse otherwise.
       
    55     */
       
    56     static TBool ParseTwoComparisonArgs( CMDXMLNode& aNode,
       
    57             TPtrC& aContextSource,
       
    58             TPtrC& aContextType,
       
    59             CCFContextOperation::TCmpType& aCompareType,
       
    60             TPtrC& aCompareValue,
       
    61             TInt& aContextLevelDelay );
       
    62 
       
    63     /**
       
    64     * Parses data from a contextRef xml node.
       
    65     * @param aNode is the node to be parsed.
       
    66     * @param aContextSource will be set to context source of the contextRef.
       
    67     * @param aContextType will be set to context type of the contextRef.
       
    68     * @param aContextValue will be set to context value of the contextRef or
       
    69     *   its' data is cleared if value was not defined by the contextRef.
       
    70     * @param aContextLevelDelay will be set to the value of context level delay
       
    71     *   attribute if it was present.
       
    72     * @return ETrue if context ref was found and at least source and type were
       
    73     *   parsed successfully, EFalse otherwise.
       
    74     */
       
    75     static TBool ParseContextRef( CMDXMLNode& aNode,
       
    76             TPtrC& aContextSource,
       
    77             TPtrC& aContextType,
       
    78             TPtrC& aContextValue,
       
    79             TInt& aContextLevelDelay );
       
    80 
       
    81     /**
       
    82     * Parses a script data type definition xml node (e.g. used by comparisons).
       
    83     * @param aNode is the node to be parsed.
       
    84     * @param aCompareType will be set to compare type of the comparison.
       
    85     * @param aCompareValue will be set to compare value of the comparison.
       
    86     * @return ETrue if script data type definition was found and parsed
       
    87     *   successfully, EFalse otherwise.
       
    88     */
       
    89     static TBool ParseComparisonTypeValue( CMDXMLNode& aNode,
       
    90             CCFContextOperation::TCmpType& aCompareType,
       
    91             TPtrC& aCompareValue );
       
    92 
       
    93     /**
       
    94     * Gets comparison type for a context operation.
       
    95     * @param aComparisonType is the descriptor defining comparison type.
       
    96     * @return CCFContextOperation::TCmpType comparison type.
       
    97     *   CCFContextOperation::EInvalidCmpType if aComparisonType is unknown.
       
    98     */
       
    99     static CCFContextOperation::TCmpType ComparisonType(
       
   100         const TDesC& aComparisonType );
       
   101 
       
   102 
       
   103     /**
       
   104     * Parses a descriptor to TTime object.
       
   105     * @param aString is the time in a descriptor.
       
   106     * @return TTime object based on aString.
       
   107     */
       
   108     static TTime StringToTimeL( const TDesC& aString );
       
   109 
       
   110     /**
       
   111     * Converts a string to TReal object.
       
   112     * @param aString is the string to convert.
       
   113     * @return TReal object created from aString.
       
   114     */
       
   115     static TReal StringToRealL( const TDesC& aString );
       
   116 
       
   117     /**
       
   118     * Converts a string containing latitude and longitude values into two reals.
       
   119     * Note! Unable to handle position values larger than 128 characters.
       
   120     * @param aString is the string containing position of format
       
   121     *   "latitude:longitude".
       
   122     * @param aLatitude will be the latitude extracted from the string.
       
   123     * @param aLongitude will be the longitude extracted from the string.
       
   124     */
       
   125     static void PositionToRealsL( const TDesC& aString,
       
   126             TReal& aLatitude,
       
   127             TReal& aLongitude );
       
   128 
       
   129     /**
       
   130     * Converts a string to an integer value.
       
   131     * @param aString is the string to convert to an integer.
       
   132     * @return TInt converted from aString.
       
   133     */
       
   134     static TInt StringToIntL( const TDesC& aString );
       
   135 
       
   136     };
       
   137 
       
   138 
       
   139 #endif // CFCONTEXTOPERATIONUTILS_H