Support Widget Application
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / framework-tizen.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 "framework.h"
20
21 // EXTERNAL INCLUDES
22 #include <appcore_ui_base.h>
23 #include <app_control_internal.h>
24 #include <app_common.h>
25 #include <bundle.h>
26 #include <Ecore.h>
27
28 #include <system_info.h>
29 #include <system_settings.h>
30 #include <bundle_internal.h>
31 #include <widget_base.h>
32 // CONDITIONAL INCLUDES
33 #ifdef APPCORE_WATCH_AVAILABLE
34 #include <appcore-watch/watch_app.h>
35 #endif
36 #ifdef DALI_ELDBUS_AVAILABLE
37 #include <Eldbus.h>
38 #endif // DALI_ELDBUS_AVAILABLE
39
40 #if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
41 #include <tzplatform_config.h>
42 #endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
43
44 #include <dali/integration-api/debug.h>
45
46 // INTERNAL INCLUDES
47 #include <callback-manager.h>
48
49 namespace Dali
50 {
51
52 namespace Internal
53 {
54
55 namespace Adaptor
56 {
57
58 namespace
59 {
60 #if defined(DEBUG_ENABLED)
61 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS" );
62 #endif
63
64 bool IsWidgetFeatureEnabled()
65 {
66   static bool feature = false;
67   static bool retrieved = false;
68   int ret;
69
70   if(retrieved == true)
71   {
72     return feature;
73   }
74
75   ret = system_info_get_platform_bool("http://tizen.org/feature/shell.appwidget", &feature);
76   if(ret != SYSTEM_INFO_ERROR_NONE)
77   {
78     DALI_LOG_ERROR("failed to get system info");
79     return false;
80   }
81
82   retrieved = true;
83   return feature;
84 }
85
86 } // anonymous namespace
87
88 namespace AppCore
89 {
90
91 typedef enum
92 {
93   LOW_MEMORY,                 //< The low memory event
94   LOW_BATTERY,                //< The low battery event
95   LANGUAGE_CHANGED,           //< The system language changed event
96   DEVICE_ORIENTATION_CHANGED, //< The device orientation changed event
97   REGION_FORMAT_CHANGED,      //< The region format changed event
98   SUSPENDED_STATE_CHANGED,    //< The suspended state changed event of the application
99   UPDATE_REQUESTED,           //< The update requested event. This event can occur when an app needs to be updated. It is dependent on target devices.
100 } AppEventType;
101
102 static int AppEventConverter[APPCORE_BASE_EVENT_MAX] =
103 {
104   [LOW_MEMORY] = APPCORE_BASE_EVENT_LOW_MEMORY,
105   [LOW_BATTERY] = APPCORE_BASE_EVENT_LOW_BATTERY,
106   [LANGUAGE_CHANGED] = APPCORE_BASE_EVENT_LANG_CHANGE,
107   [DEVICE_ORIENTATION_CHANGED] = APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
108   [REGION_FORMAT_CHANGED] = APPCORE_BASE_EVENT_REGION_CHANGE,
109   [SUSPENDED_STATE_CHANGED] = APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
110 };
111
112 struct AppEventInfo
113 {
114   AppEventType type;
115   void *value;
116 };
117
118 typedef struct AppEventInfo *AppEventInfoPtr;
119
120 typedef void (*AppEventCallback)(AppEventInfoPtr eventInfo, void *userData);
121
122 struct AppEventHandler
123 {
124   AppEventType type;
125   AppEventCallback cb;
126   void *data;
127   void *raw;
128 };
129
130 typedef struct AppEventHandler *AppEventHandlerPtr;
131
132 int EventCallback(void *event, void *data)
133 {
134   AppEventHandlerPtr handler = static_cast<AppEventHandlerPtr>(data);
135
136   struct AppEventInfo appEvent;
137
138   appEvent.type = handler->type;
139   appEvent.value = event;
140
141   if (handler->cb)
142     handler->cb(&appEvent, handler->data);
143
144   return 0;
145 }
146
147 int AppAddEventHandler(AppEventHandlerPtr *eventHandler, AppEventType eventType, AppEventCallback callback, void *userData)
148 {
149   AppEventHandlerPtr handler;
150
151   handler = static_cast<AppEventHandlerPtr>( calloc(1, sizeof(struct AppEventHandler)) );
152   if (!handler)
153   {
154     DALI_LOG_ERROR( "failed to create handler" );
155     return TIZEN_ERROR_UNKNOWN;
156   }
157   else
158   {
159     handler->type = eventType;
160     handler->cb = callback;
161     handler->data = userData;
162     handler->raw = appcore_base_add_event( static_cast<appcore_base_event>(AppEventConverter[static_cast<int>(eventType)]), EventCallback, handler);
163
164     *eventHandler = handler;
165
166     return TIZEN_ERROR_NONE;
167   }
168 }
169
170 } // namespace Appcore
171
172 /**
173  * Impl to hide EFL data members
174  */
175 struct Framework::Impl
176 {
177 // Constructor
178   Impl(void* data, Type type )
179   : mAbortCallBack( NULL ),
180     mCallbackManager( NULL )
181 #ifdef APPCORE_WATCH_AVAILABLE
182     , mWatchCallback()
183 #endif
184   {
185     mFramework = static_cast<Framework*>(data);
186
187 #ifndef APPCORE_WATCH_AVAILABLE
188     if ( type == WATCH )
189     {
190       throw Dali::DaliException( "", "Watch Application is not supported." );
191     }
192 #endif
193     mApplicationType = type;
194     mCallbackManager = CallbackManager::New();
195
196     char* region;
197     char* language;
198     system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &region );
199     system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language );
200     mRegion = std::string( region );
201     mLanguage = std::string( language );
202   }
203
204   ~Impl()
205   {
206     delete mAbortCallBack;
207
208     // we're quiting the main loop so
209     // mCallbackManager->RemoveAllCallBacks() does not need to be called
210     // to delete our abort handler
211     delete mCallbackManager;
212   }
213
214   int AppMain()
215   {
216     int ret;
217
218     if (mApplicationType == NORMAL)
219     {
220       ret = AppNormalMain();
221     }
222     else if(mApplicationType == WIDGET)
223     {
224       ret = AppWidgetMain();
225     }
226     else
227     {
228       ret = AppWatchMain();
229     }
230     return ret;
231   }
232
233   void AppExit()
234   {
235     if (mApplicationType == NORMAL)
236     {
237       AppNormalExit();
238     }
239     else if(mApplicationType == WIDGET)
240     {
241       AppWidgetExit();
242     }
243     else
244     {
245       AppWatchExit();
246     }
247   }
248
249   void SetLanguage( const std::string& language )
250   {
251     mLanguage = language;
252   }
253
254   void SetRegion( const std::string& region )
255   {
256     mRegion = region;
257   }
258
259   std::string GetLanguage() const
260   {
261     return mLanguage;
262   }
263
264   std::string GetRegion() const
265   {
266     return mRegion;
267   }
268
269   // Data
270   Type mApplicationType;
271   CallbackBase* mAbortCallBack;
272   CallbackManager *mCallbackManager;
273   std::string mLanguage;
274   std::string mRegion;
275
276   Framework* mFramework;
277   AppCore::AppEventHandlerPtr handlers[5];
278 #ifdef APPCORE_WATCH_AVAILABLE
279   watch_app_lifecycle_callback_s mWatchCallback;
280   app_event_handler_h watchHandlers[5];
281 #endif
282
283   static int AppCreate(void *data)
284   {
285     appcore_ui_base_on_create();
286     return static_cast<int>( static_cast<Framework*>(data)->Create() );
287   }
288
289   static int AppTerminate(void *data)
290   {
291     appcore_ui_base_on_terminate();
292     Observer *observer = &static_cast<Framework*>(data)->mObserver;
293
294     observer->OnTerminate();
295
296     return 0;
297   }
298
299   static int AppPause(void *data)
300   {
301     appcore_ui_base_on_pause();
302     Observer *observer = &static_cast<Framework*>(data)->mObserver;
303
304     observer->OnPause();
305
306     return 0;
307   }
308
309   static int AppResume(void *data)
310   {
311     appcore_ui_base_on_resume();
312     Observer *observer = &static_cast<Framework*>(data)->mObserver;
313
314     observer->OnResume();
315
316     return 0;
317   }
318
319   static void ProcessBundle(Framework* framework, bundle *bundleData)
320   {
321     if(bundleData == NULL)
322     {
323       return;
324     }
325
326     // get bundle name
327     char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
328     if(bundleName != NULL)
329     {
330       framework->SetBundleName(bundleName);
331     }
332
333     // get bundle? id
334     char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
335     if(bundleId != NULL)
336     {
337       framework->SetBundleId(bundleId);
338     }
339   }
340
341   /**
342    * Called by AppCore when the application is launched from another module (e.g. homescreen).
343    * @param[in] b the bundle data which the launcher module sent
344    */
345   static int AppControl(bundle* bundleData, void *data)
346   {
347     app_control_h appControl = NULL;
348
349     appcore_ui_base_on_control(bundleData);
350
351     if (bundleData)
352     {
353       if (app_control_create_event(bundleData, &appControl) != TIZEN_ERROR_NONE)
354       {
355         DALI_LOG_ERROR("Failed to create an app_control handle");
356       }
357     }
358     else
359     {
360       if (app_control_create(&appControl) != TIZEN_ERROR_NONE)
361       {
362         DALI_LOG_ERROR("Failed to create an app_control handle");
363       }
364     }
365
366     Framework* framework = static_cast<Framework*>(data);
367     Observer *observer = &framework->mObserver;
368
369     ProcessBundle(framework, bundleData);
370
371     observer->OnReset();
372     observer->OnAppControl(appControl);
373
374     app_control_destroy(appControl);
375
376     return 0;
377   }
378
379   static void AppInit(int argc, char **argv, void *data)
380   {
381 #pragma GCC diagnostic push
382 #pragma GCC diagnostic ignored "-Wold-style-cast"
383
384     ecore_init();
385     ecore_app_args_set( argc, (const char **)argv );
386
387 #pragma GCC diagnostic pop
388   }
389
390   static void AppFinish(void)
391   {
392     ecore_shutdown();
393
394     if(getenv("AUL_LOADER_INIT"))
395     {
396       unsetenv("AUL_LOADER_INIT");
397       ecore_shutdown();
398     }
399   }
400
401   static void AppRun(void *data)
402   {
403     ecore_main_loop_begin();
404   }
405
406   static void AppExit(void *data)
407   {
408     ecore_main_loop_quit();
409   }
410
411   static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void *data)
412   {
413     Framework* framework = static_cast<Framework*>(data);
414     Observer *observer = &framework->mObserver;
415     framework->SetLanguage( std::string( static_cast<const char *>(event->value) ) );
416     observer->OnLanguageChanged();
417   }
418
419   static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void *data)
420   {
421   }
422
423   static void AppRegionChanged(AppCore::AppEventInfoPtr event, void *data)
424   {
425     Framework* framework = static_cast<Framework*>(data);
426     Observer *observer = &framework->mObserver;
427     framework->SetRegion( std::string( static_cast<const char *>(event->value) ) );
428     observer->OnRegionChanged();
429   }
430
431   static void AppBatteryLow(AppCore::AppEventInfoPtr event, void *data)
432   {
433     Observer *observer = &static_cast<Framework*>(data)->mObserver;
434     int status = *static_cast<int *>(event->value);
435     Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::NORMAL;
436
437     // convert to dali battery status
438     switch( status )
439     {
440       case 1:
441       {
442         result = Dali::DeviceStatus::Battery::POWER_OFF;
443         break;
444       }
445       case 2:
446       {
447         result = Dali::DeviceStatus::Battery::CRITICALLY_LOW;
448         break;
449       }
450       default :
451         break;
452     }
453     observer->OnBatteryLow(result);
454   }
455
456   static void AppMemoryLow(AppCore::AppEventInfoPtr event, void *data)
457   {
458     Observer *observer = &static_cast<Framework*>(data)->mObserver;
459     int status = *static_cast<int *>(event->value);
460     Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::NORMAL;
461
462     // convert to dali memmory status
463     switch( status )
464     {
465       case 1:
466       {
467         result = Dali::DeviceStatus::Memory::NORMAL;
468         break;
469       }
470       case 2:
471       {
472         result = Dali::DeviceStatus::Memory::LOW;
473         break;
474       }
475       case 4:
476       {
477         result = Dali::DeviceStatus::Memory::CRITICALLY_LOW;
478         break;
479       }
480       default :
481         break;
482     }
483     observer->OnMemoryLow(result);
484   }
485
486
487   int AppNormalMain()
488   {
489     int ret;
490
491     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
492     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
493     AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
494     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
495     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
496
497     appcore_ui_base_ops ops = appcore_ui_base_get_default_ops();
498
499     /* override methods */
500     ops.base.create = AppCreate;
501     ops.base.control = AppControl;
502     ops.base.terminate = AppTerminate;
503     ops.pause = AppPause;
504     ops.resume = AppResume;
505     ops.base.init = AppInit;
506     ops.base.finish = AppFinish;
507     ops.base.run = AppRun;
508     ops.base.exit = AppExit;
509
510     ret = appcore_ui_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework, APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL |
511                                                                                         APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL |
512                                                                                         APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL |
513                                                                                         APPCORE_UI_BASE_HINT_HW_ACC_CONTROL |
514                                                                                         APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL );
515
516     if (ret != TIZEN_ERROR_NONE)
517       return ret;
518
519     appcore_ui_base_fini();
520
521     return TIZEN_ERROR_NONE;
522   }
523
524   void AppNormalExit()
525   {
526     appcore_ui_base_exit();
527   }
528
529   void AppWidgetExit()
530   {
531     widget_base_exit();
532   }
533
534   static int WidgetAppCreate( void *data )
535   {
536     widget_base_on_create();
537     return static_cast<int>( static_cast<Framework*>(data)->Create() );
538   }
539
540   static int WidgetAppTerminate( void *data )
541   {
542     Observer *observer = &static_cast<Framework*>(data)->mObserver;
543     observer->OnTerminate();
544
545     widget_base_on_terminate();
546     return 0;
547   }
548
549   int AppWidgetMain()
550   {
551     if( !IsWidgetFeatureEnabled() )
552     {
553       DALI_LOG_ERROR("widget feature is not supported");
554       return 0;
555     }
556
557     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
558     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
559     AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
560     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
561     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
562
563     widget_base_ops ops = widget_base_get_default_ops();
564
565     /* override methods */
566     ops.create = WidgetAppCreate;
567     ops.terminate = WidgetAppTerminate;
568     ops.init = AppInit;
569     ops.finish = AppFinish;
570     ops.run = AppRun;
571     ops.exit = AppExit;
572
573     int result = widget_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework);
574
575     widget_base_fini();
576
577     return result;
578   }
579
580 #ifdef APPCORE_WATCH_AVAILABLE
581   static bool WatchAppCreate(int width, int height, void *data)
582   {
583     return static_cast<Framework*>(data)->Create();
584   }
585
586   static void WatchAppTimeTick(watch_time_h time, void *data)
587   {
588     Observer *observer = &static_cast<Framework*>(data)->mObserver;
589     WatchTime curTime(time);
590
591     observer->OnTimeTick(curTime);
592   }
593
594   static void WatchAppAmbientTick(watch_time_h time, void *data)
595   {
596     Observer *observer = &static_cast<Framework*>(data)->mObserver;
597     WatchTime curTime(time);
598
599     observer->OnAmbientTick(curTime);
600   }
601
602   static void WatchAppAmbientChanged(bool ambient, void *data)
603   {
604     Observer *observer = &static_cast<Framework*>(data)->mObserver;
605
606     observer->OnAmbientChanged(ambient);
607   }
608
609   static void WatchAppControl(app_control_h app_control, void *data)
610   {
611     Framework* framework = static_cast<Framework*>(data);
612     Observer *observer = &framework->mObserver;
613     bundle *bundleData = NULL;
614
615     app_control_to_bundle(app_control, &bundleData);
616     ProcessBundle(framework, bundleData);
617
618     observer->OnReset();
619     observer->OnAppControl(app_control);
620   }
621
622   static void WatchAppTerminate(void *data)
623   {
624     Observer *observer = &static_cast<Framework*>(data)->mObserver;
625
626     observer->OnTerminate();
627   }
628
629   static void WatchAppPause(void *data)
630   {
631     Observer *observer = &static_cast<Framework*>(data)->mObserver;
632
633     observer->OnPause();
634   }
635
636   static void WatchAppResume(void *data)
637   {
638     Observer *observer = &static_cast<Framework*>(data)->mObserver;
639
640     observer->OnResume();
641   }
642
643 #endif
644
645   int AppWatchMain()
646   {
647     int ret = true;
648
649 #ifdef APPCORE_WATCH_AVAILABLE
650     mWatchCallback.create = WatchAppCreate;
651     mWatchCallback.app_control = WatchAppControl;
652     mWatchCallback.terminate = WatchAppTerminate;
653     mWatchCallback.pause = WatchAppPause;
654     mWatchCallback.resume = WatchAppResume;
655     mWatchCallback.time_tick = WatchAppTimeTick;
656     mWatchCallback.ambient_tick = WatchAppAmbientTick;
657     mWatchCallback.ambient_changed = WatchAppAmbientChanged;
658
659     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
660     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
661     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
662     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
663
664     ret = watch_app_main(*mFramework->mArgc, *mFramework->mArgv, &mWatchCallback, mFramework);
665 #endif
666     return ret;
667   }
668
669   void AppWatchExit()
670   {
671 #ifdef APPCORE_WATCH_AVAILABLE
672     watch_app_exit();
673 #endif
674   }
675
676 private:
677   // Undefined
678   Impl( const Impl& impl );
679
680   // Undefined
681   Impl& operator=( const Impl& impl );
682 };
683
684 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
685 : mObserver(observer),
686   mInitialised(false),
687   mRunning(false),
688   mArgc(argc),
689   mArgv(argv),
690   mBundleName(""),
691   mBundleId(""),
692   mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
693   mImpl(NULL)
694 {
695   bool featureFlag = true;
696   system_info_get_platform_bool( "tizen.org/feature/opengles.version.2_0", &featureFlag );
697
698   if( featureFlag == false )
699   {
700     set_last_result( TIZEN_ERROR_NOT_SUPPORTED );
701   }
702 #ifdef DALI_ELDBUS_AVAILABLE
703   // Initialize ElDBus.
704   DALI_LOG_INFO( gDBusLogging, Debug::General, "Starting DBus Initialization\n" );
705   eldbus_init();
706 #endif
707   InitThreads();
708
709   mImpl = new Impl(this, type);
710 }
711
712 Framework::~Framework()
713 {
714   if (mRunning)
715   {
716     Quit();
717   }
718
719 #ifdef DALI_ELDBUS_AVAILABLE
720   // Shutdown ELDBus.
721   DALI_LOG_INFO( gDBusLogging, Debug::General, "Shutting down DBus\n" );
722   eldbus_shutdown();
723 #endif
724
725   delete mImpl;
726 }
727
728 bool Framework::Create()
729 {
730   mInitialised = true;
731   mObserver.OnInit();
732   return true;
733 }
734
735 void Framework::Run()
736 {
737   mRunning = true;
738   int ret;
739
740   ret = mImpl->AppMain();
741   if (ret != APP_ERROR_NONE)
742   {
743     DALI_LOG_ERROR("Framework::Run(), ui_app_main() is failed. err = %d\n", ret);
744   }
745   mRunning = false;
746 }
747
748 void Framework::Quit()
749 {
750   mImpl->AppExit();
751 }
752
753 bool Framework::IsMainLoopRunning()
754 {
755   return mRunning;
756 }
757
758 void Framework::AddAbortCallback( CallbackBase* callback )
759 {
760   mImpl->mAbortCallBack = callback;
761 }
762
763 std::string Framework::GetBundleName() const
764 {
765   return mBundleName;
766 }
767
768 void Framework::SetBundleName(const std::string& name)
769 {
770   mBundleName = name;
771 }
772
773 std::string Framework::GetBundleId() const
774 {
775   return mBundleId;
776 }
777
778 std::string Framework::GetResourcePath()
779 {
780   std::string resourcePath = "";
781 #if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
782   resourcePath = app_get_resource_path();
783 #else // For backwards compatibility with older Tizen versions
784
785   // "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
786   const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
787   char* value = getenv( environmentVariable );
788   if ( value != NULL )
789   {
790     resourcePath = value;
791   }
792 #endif //TIZEN_PLATFORM_CONFIG_SUPPORTED
793
794   return resourcePath;
795 }
796
797 void Framework::SetBundleId(const std::string& id)
798 {
799   mBundleId = id;
800 }
801
802 void Framework::AbortCallback( )
803 {
804   // if an abort call back has been installed run it.
805   if (mImpl->mAbortCallBack)
806   {
807     CallbackBase::Execute( *mImpl->mAbortCallBack );
808   }
809   else
810   {
811     Quit();
812   }
813 }
814
815 void Framework::SetLanguage( const std::string& language )
816 {
817   mImpl->SetLanguage( language );
818 }
819
820 void Framework::SetRegion( const std::string& region )
821 {
822   mImpl->SetRegion( region );
823 }
824
825 std::string Framework::GetLanguage() const
826 {
827   return mImpl->GetLanguage();
828 }
829
830 std::string Framework::GetRegion() const
831 {
832   return mImpl->GetRegion();
833 }
834
835 } // namespace Adaptor
836
837 } // namespace Internal
838
839 } // namespace Dali