Revert "[Tizen] Support custom fonts registration"
[platform/core/uifw/dali-adaptor.git] / dali / internal / web-engine-lite / common / web-engine-lite-impl.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "web-engine-lite-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dlfcn.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/public-api/object/type-registry.h>
25 #include <dali/public-api/object/any.h>
26
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 namespace Adaptor
35 {
36
37 namespace // unnamed namespace
38 {
39 const char* WEB_ENGINE_LITE_PLUGIN_SO( "libdali-web-engine-lite-plugin.so" );
40
41 Dali::BaseHandle Create()
42 {
43   return Dali::WebEngineLite::New();
44 }
45
46 Dali::TypeRegistration type( typeid( Dali::WebEngineLite ), typeid( Dali::BaseHandle ), Create );
47
48 } // unnamed namespace
49
50 WebEngineLitePtr WebEngineLite::New()
51 {
52   WebEngineLitePtr webEngineLite = new WebEngineLite();
53   return webEngineLite;
54 }
55
56 WebEngineLite::WebEngineLite()
57 : mPlugin( NULL ),
58   mHandle( NULL ),
59   mCreateWebEngineLitePtr( NULL ),
60   mDestroyWebEngineLitePtr( NULL )
61 {
62 }
63
64 WebEngineLite::~WebEngineLite()
65 {
66   if( mHandle != NULL )
67   {
68     if( mDestroyWebEngineLitePtr != NULL )
69     {
70       mDestroyWebEngineLitePtr( mPlugin );
71     }
72
73     dlclose( mHandle );
74   }
75 }
76
77 void WebEngineLite::Initialize()
78 {
79   char* error = NULL;
80
81   mHandle = dlopen( WEB_ENGINE_LITE_PLUGIN_SO, RTLD_LAZY );
82
83   error = dlerror();
84   if( mHandle == NULL || error != NULL )
85   {
86     DALI_LOG_ERROR( "WebEngineLite::Initialize(), dlopen error: %s\n", error );
87     return;
88   }
89
90   mCreateWebEngineLitePtr = reinterpret_cast< CreateWebEngineLiteFunction >( dlsym( mHandle, "CreateWebEngineLitePlugin" ) );
91   if( mCreateWebEngineLitePtr == NULL )
92   {
93     DALI_LOG_ERROR( "Can't load symbol CreateWebEngineLitePlugin(), error: %s\n", error );
94     return;
95   }
96
97   mPlugin = mCreateWebEngineLitePtr();
98
99   if( mPlugin == NULL )
100   {
101     DALI_LOG_ERROR( "Can't create the WebEngineLitePlugin object\n" );
102     return;
103   }
104
105   mDestroyWebEngineLitePtr = reinterpret_cast< DestroyWebEngineLiteFunction >( dlsym( mHandle, "DestroyWebEngineLitePlugin" ) );
106   if( mDestroyWebEngineLitePtr == NULL )
107   {
108     DALI_LOG_ERROR( "Can't load symbol DestroyWebEngineLitePlugin(), error: %s\n", error );
109     return;
110   }
111
112 }
113
114 void WebEngineLite::CreateInstance(int width, int height, int windowX, int windowY, const std::string& locale, const std::string& timezoneID)
115 {
116   if( mPlugin != NULL )
117   {
118     mPlugin->CreateInstance(width, height, windowX, windowY, locale, timezoneID);
119   }
120 }
121
122 void WebEngineLite::DestroyInstance()
123 {
124   if( mPlugin != NULL )
125   {
126     mPlugin->DestroyInstance();
127   }
128 }
129
130 void WebEngineLite::LoadHtml(const std::string& path)
131 {
132   if( mPlugin != NULL )
133   {
134     mPlugin->LoadHtml(path);
135   }
136 }
137
138 Dali::WebEngineLitePlugin::WebEngineLiteSignalType& WebEngineLite::FinishedSignal()
139 {
140   if( mPlugin != NULL )
141   {
142     return mPlugin->FinishedSignal();
143   }
144
145   return mFinishedSignal;
146 }
147
148 } // namespace Adaptor;
149 } // namespace Internal;
150 } // namespace Dali;
151