webengine/device/inc/ServiceObject.h
changeset 0 dd21522fd290
child 16 a359256acfc6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/device/inc/ServiceObject.h	Mon Mar 30 12:54:55 2009 +0300
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Device Service Object
+*
+*/
+
+
+#ifndef __DEVICE_SVC_OBJ_H__
+#define __DEVICE_SVC_OBJ_H__
+
+#include <e32base.h>
+#include <object.h>
+
+#include "Device.h"
+
+namespace KJS
+    {
+    class JSObject;
+    class Identifier;
+    class ClassInfo;
+    class Value;
+    class ExecState;
+    class UString;
+    class ServiceEventHandler;
+    class MDeviceBinding;
+    class ServiceObjectFunc;
+    class ServiceObjectPrivate;
+
+    class ServiceObject : public JSObject
+        {
+        friend class ServiceObjectFunc;
+
+        public: // constructor and destructor
+
+           /**
+            * Constructor
+            * @return none
+            * @since 5.0
+            **/
+            ServiceObject( ExecState* exec,
+                HBufC8* svcName,
+                MDeviceBinding* deviceBinding );
+
+           /**
+            * Destructor
+            * @return none
+            * @since 5.0
+            **/
+            ~ServiceObject();
+
+        public://From JSObject
+
+           /**
+            * Get property
+            * @return Value
+            * @since 5.0
+            **/
+            JSValue* getValueProperty(KJS::ExecState*, int token) const;
+
+            /**
+            * getOwnPropertySlot
+            * @return bool
+            * @since 5.0
+            **/
+            bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot);
+
+            /**
+            * IsRunningCallBack
+            * @return TBool
+            **/
+            TBool IsRunningCallBack(ExecState *exec);
+
+            /**
+            * isValid
+            */
+            bool isValid() const { return m_valid; }
+
+           /**
+            * Get class info
+            * @return const ClassInfo*
+            * @since 5.0
+            **/
+            const ClassInfo* classInfo() const { return &info; }
+
+            static const ClassInfo info;
+
+           /**
+            * toString
+            * @return UString
+            * @since 5.0
+            **/
+            virtual UString toString( ExecState* exec ) const;
+
+        public:
+            void Close( ExecState* exec, bool unmark );
+            enum
+                {
+                close
+                };
+            private:
+            ServiceObjectPrivate* m_privateData;   // private object to hold data
+            bool m_valid;                          // object is valid or not
+        };
+        
+        class ServiceObjectPrivate
+            {
+            friend class ServiceObject;
+            friend class ServiceObjectFunc;
+            public:
+                ServiceObjectPrivate(HBufC8* svcName, MDeviceBinding* deviceBinding );
+                ~ServiceObjectPrivate()   { Close(); }
+                void Close();
+                MDeviceBinding* m_deviceBinding; // Not owned
+                Identifier m_propName;
+                HBufC8* m_svcName;    // owned
+                bool isClosing; 
+            };
+
+        class ServiceObjectFunc : public JSObject
+                {
+
+                public: // constructor and destructor
+
+                   /**
+                    * Constructor
+                    * @return none
+                    * @since 5.0
+                    **/
+                    ServiceObjectFunc( ExecState* exec, int token );
+
+                   /**
+                    * Destructor
+                    * @return none
+                    * @since 5.0
+                    **/
+                    virtual ~ServiceObjectFunc() {}
+
+                public: // From JSObject
+
+                   /**
+                    * implementsCall
+                    * @return bool
+                    * @since 5.0
+                    **/
+                    bool implementsCall() const { return true; }
+
+                   /**
+                    * call
+                    * @return Value
+                    * @since 5.0
+                    **/
+                    JSValue* callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
+                private:
+                    int m_func;
+                };
+
+    }
+
+#include "ServiceObject.lut.h"
+#endif //__DEVICE_SVC_OBJ_H__
+
+
+