webengine/device/inc/ServiceObject.h
changeset 0 dd21522fd290
child 16 a359256acfc6
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 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 the License "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:  Device Service Object
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __DEVICE_SVC_OBJ_H__
       
    20 #define __DEVICE_SVC_OBJ_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <object.h>
       
    24 
       
    25 #include "Device.h"
       
    26 
       
    27 namespace KJS
       
    28     {
       
    29     class JSObject;
       
    30     class Identifier;
       
    31     class ClassInfo;
       
    32     class Value;
       
    33     class ExecState;
       
    34     class UString;
       
    35     class ServiceEventHandler;
       
    36     class MDeviceBinding;
       
    37     class ServiceObjectFunc;
       
    38     class ServiceObjectPrivate;
       
    39 
       
    40     class ServiceObject : public JSObject
       
    41         {
       
    42         friend class ServiceObjectFunc;
       
    43 
       
    44         public: // constructor and destructor
       
    45 
       
    46            /**
       
    47             * Constructor
       
    48             * @return none
       
    49             * @since 5.0
       
    50             **/
       
    51             ServiceObject( ExecState* exec,
       
    52                 HBufC8* svcName,
       
    53                 MDeviceBinding* deviceBinding );
       
    54 
       
    55            /**
       
    56             * Destructor
       
    57             * @return none
       
    58             * @since 5.0
       
    59             **/
       
    60             ~ServiceObject();
       
    61 
       
    62         public://From JSObject
       
    63 
       
    64            /**
       
    65             * Get property
       
    66             * @return Value
       
    67             * @since 5.0
       
    68             **/
       
    69             JSValue* getValueProperty(KJS::ExecState*, int token) const;
       
    70 
       
    71             /**
       
    72             * getOwnPropertySlot
       
    73             * @return bool
       
    74             * @since 5.0
       
    75             **/
       
    76             bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot);
       
    77 
       
    78             /**
       
    79             * IsRunningCallBack
       
    80             * @return TBool
       
    81             **/
       
    82             TBool IsRunningCallBack(ExecState *exec);
       
    83 
       
    84             /**
       
    85             * isValid
       
    86             */
       
    87             bool isValid() const { return m_valid; }
       
    88 
       
    89            /**
       
    90             * Get class info
       
    91             * @return const ClassInfo*
       
    92             * @since 5.0
       
    93             **/
       
    94             const ClassInfo* classInfo() const { return &info; }
       
    95 
       
    96             static const ClassInfo info;
       
    97 
       
    98            /**
       
    99             * toString
       
   100             * @return UString
       
   101             * @since 5.0
       
   102             **/
       
   103             virtual UString toString( ExecState* exec ) const;
       
   104 
       
   105         public:
       
   106             void Close( ExecState* exec, bool unmark );
       
   107             enum
       
   108                 {
       
   109                 close
       
   110                 };
       
   111             private:
       
   112             ServiceObjectPrivate* m_privateData;   // private object to hold data
       
   113             bool m_valid;                          // object is valid or not
       
   114         };
       
   115         
       
   116         class ServiceObjectPrivate
       
   117             {
       
   118             friend class ServiceObject;
       
   119             friend class ServiceObjectFunc;
       
   120             public:
       
   121                 ServiceObjectPrivate(HBufC8* svcName, MDeviceBinding* deviceBinding );
       
   122                 ~ServiceObjectPrivate()   { Close(); }
       
   123                 void Close();
       
   124                 MDeviceBinding* m_deviceBinding; // Not owned
       
   125                 Identifier m_propName;
       
   126                 HBufC8* m_svcName;    // owned
       
   127                 bool isClosing; 
       
   128             };
       
   129 
       
   130         class ServiceObjectFunc : public JSObject
       
   131                 {
       
   132 
       
   133                 public: // constructor and destructor
       
   134 
       
   135                    /**
       
   136                     * Constructor
       
   137                     * @return none
       
   138                     * @since 5.0
       
   139                     **/
       
   140                     ServiceObjectFunc( ExecState* exec, int token );
       
   141 
       
   142                    /**
       
   143                     * Destructor
       
   144                     * @return none
       
   145                     * @since 5.0
       
   146                     **/
       
   147                     virtual ~ServiceObjectFunc() {}
       
   148 
       
   149                 public: // From JSObject
       
   150 
       
   151                    /**
       
   152                     * implementsCall
       
   153                     * @return bool
       
   154                     * @since 5.0
       
   155                     **/
       
   156                     bool implementsCall() const { return true; }
       
   157 
       
   158                    /**
       
   159                     * call
       
   160                     * @return Value
       
   161                     * @since 5.0
       
   162                     **/
       
   163                     JSValue* callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
       
   164                 private:
       
   165                     int m_func;
       
   166                 };
       
   167 
       
   168     }
       
   169 
       
   170 #include "ServiceObject.lut.h"
       
   171 #endif //__DEVICE_SVC_OBJ_H__
       
   172 
       
   173 
       
   174