6cfe739e267a2ae83f0f8bd9128bcfa7fe5d2081
[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 #include <dlog.h>
50 namespace Dali
51 {
52
53 namespace Internal
54 {
55
56 namespace Adaptor
57 {
58
59 namespace
60 {
61 #if defined(DEBUG_ENABLED)
62 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS" );
63 #endif
64
65 bool IsWidgetFeatureEnabled()
66 {
67   static bool feature = false;
68   static bool retrieved = false;
69   int ret;
70
71   if(retrieved == true)
72     return feature;
73
74   ret = system_info_get_platform_bool("http://tizen.org/feature/shell.appwidget", &feature);
75   if(ret != SYSTEM_INFO_ERROR_NONE)
76   {
77     DALI_LOG_ERROR("failed to get system info"); /* LCOV_EXCL_LINE */
78     return false; /* LCOV_EXCL_LINE */
79   }
80
81   retrieved = true;
82   return feature;
83 }
84
85 } // anonymous namespace
86
87 namespace AppCore
88 {
89
90 typedef enum
91 {
92   LOW_MEMORY,                 //< The low memory event
93   LOW_BATTERY,                //< The low battery event
94   LANGUAGE_CHANGED,           //< The system language changed event
95   DEVICE_ORIENTATION_CHANGED, //< The device orientation changed event
96   REGION_FORMAT_CHANGED,      //< The region format changed event
97   SUSPENDED_STATE_CHANGED,    //< The suspended state changed event of the application
98   UPDATE_REQUESTED,           //< The update requested event. This event can occur when an app needs to be updated. It is dependent on target devices.
99 } AppEventType;
100
101 static int AppEventConverter[APPCORE_BASE_EVENT_MAX] =
102 {
103   [LOW_MEMORY] = APPCORE_BASE_EVENT_LOW_MEMORY,
104   [LOW_BATTERY] = APPCORE_BASE_EVENT_LOW_BATTERY,
105   [LANGUAGE_CHANGED] = APPCORE_BASE_EVENT_LANG_CHANGE,
106   [DEVICE_ORIENTATION_CHANGED] = APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
107   [REGION_FORMAT_CHANGED] = APPCORE_BASE_EVENT_REGION_CHANGE,
108   [SUSPENDED_STATE_CHANGED] = APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
109 };
110
111 struct AppEventInfo
112 {
113   AppEventType type;
114   void *value;
115 };
116
117 typedef struct AppEventInfo *AppEventInfoPtr;
118
119 typedef void (*AppEventCallback)(AppEventInfoPtr eventInfo, void *userData);
120
121 struct AppEventHandler
122 {
123   AppEventType type;
124   AppEventCallback cb;
125   void *data;
126   void *raw;
127 };
128
129 typedef struct AppEventHandler *AppEventHandlerPtr;
130
131 int EventCallback(void *event, void *data)
132 {
133   AppEventHandlerPtr handler = static_cast<AppEventHandlerPtr>(data);
134
135   struct AppEventInfo appEvent;
136
137   appEvent.type = handler->type;
138   appEvent.value = event;
139
140   if (handler->cb)
141     handler->cb(&appEvent, handler->data);
142
143   return 0;
144 }
145
146 int AppAddEventHandler(AppEventHandlerPtr *eventHandler, AppEventType eventType, AppEventCallback callback, void *userData)
147 {
148   AppEventHandlerPtr handler;
149
150   handler = static_cast<AppEventHandlerPtr>( calloc(1, sizeof(struct AppEventHandler)) );
151   if (!handler)
152   {
153     DALI_LOG_ERROR( "failed to create handler" );
154     return TIZEN_ERROR_UNKNOWN;
155   }
156   else
157   {
158     handler->type = eventType;
159     handler->cb = callback;
160     handler->data = userData;
161     handler->raw = appcore_base_add_event( static_cast<appcore_base_event>(AppEventConverter[static_cast<int>(eventType)]), EventCallback, handler);
162
163     *eventHandler = handler;
164
165     return TIZEN_ERROR_NONE;
166   }
167 }
168
169 } // namespace Appcore
170
171 /**
172  * Impl to hide EFL data members
173  */
174 struct Framework::Impl
175 {
176 // Constructor
177   Impl(void* data, Type type )
178   : mAbortCallBack( NULL ),
179     mCallbackManager( NULL )
180 #ifdef APPCORE_WATCH_AVAILABLE
181     , mWatchCallback()
182 #endif
183   {
184     mFramework = static_cast<Framework*>(data);
185
186 #ifndef APPCORE_WATCH_AVAILABLE
187     if ( type == WATCH )
188     {
189       throw Dali::DaliException( "", "Watch Application is not supported." );
190     }
191 #endif
192     mApplicationType = type;
193     mCallbackManager = CallbackManager::New();
194
195     char* region;
196     char* language;
197     system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &region );
198     system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language );
199     mRegion = std::string( region );
200     mLanguage = std::string( language );
201   }
202
203   ~Impl()
204   {
205     delete mAbortCallBack;
206
207     // we're quiting the main loop so
208     // mCallbackManager->RemoveAllCallBacks() does not need to be called
209     // to delete our abort handler
210     delete mCallbackManager;
211   }
212
213   int AppMain()
214   {
215     int ret;
216
217     if (mApplicationType == NORMAL)
218     {
219       ret = AppNormalMain();
220     }
221     else if(mApplicationType == WIDGET)
222     {
223       ret = AppWidgetMain();
224     }
225     else
226     {
227       ret = AppWatchMain();
228     }
229     return ret;
230   }
231
232   void AppExit()
233   {
234     if (mApplicationType == NORMAL)
235     {
236       AppNormalExit();
237     }
238     else if(mApplicationType == WIDGET)
239     {
240       AppWidgetExit();
241     }
242     else
243     {
244       AppWatchExit();
245     }
246   }
247
248   void SetLanguage( const std::string& language )
249   {
250     mLanguage = language;
251   }
252
253   void SetRegion( const std::string& region )
254   {
255     mRegion = region;
256   }
257
258   std::string GetLanguage() const
259   {
260     return mLanguage;
261   }
262
263   std::string GetRegion() const
264   {
265     return mRegion;
266   }
267
268   // Data
269   Type mApplicationType;
270   CallbackBase* mAbortCallBack;
271   CallbackManager *mCallbackManager;
272   std::string mLanguage;
273   std::string mRegion;
274
275   Framework* mFramework;
276   AppCore::AppEventHandlerPtr handlers[5];
277 #ifdef APPCORE_WATCH_AVAILABLE
278   watch_app_lifecycle_callback_s mWatchCallback;
279   app_event_handler_h watchHandlers[5];
280 #endif
281
282   static int AppCreate(void *data)
283   {
284     appcore_ui_base_on_create();
285     return static_cast<int>( static_cast<Framework*>(data)->Create() );
286   }
287
288   static int AppTerminate(void *data)
289   {
290     appcore_ui_base_on_terminate();
291     Observer *observer = &static_cast<Framework*>(data)->mObserver;
292
293     observer->OnTerminate();
294
295     return 0;
296   }
297
298   static int AppPause(void *data)
299   {
300     appcore_ui_base_on_pause();
301     Observer *observer = &static_cast<Framework*>(data)->mObserver;
302
303     observer->OnPause();
304
305     return 0;
306   }
307
308   static int AppResume(void *data)
309   {
310     appcore_ui_base_on_resume();
311     Observer *observer = &static_cast<Framework*>(data)->mObserver;
312
313     observer->OnResume();
314
315     return 0;
316   }
317
318   static void ProcessBundle(Framework* framework, bundle *bundleData)
319   {
320     if(bundleData == NULL)
321     {
322       return;
323     }
324
325     // get bundle name
326     char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
327     if(bundleName != NULL)
328     {
329       framework->SetBundleName(bundleName);
330     }
331
332     // get bundle? id
333     char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
334     if(bundleId != NULL)
335     {
336       framework->SetBundleId(bundleId);
337     }
338   }
339
340   /**
341    * Called by AppCore when the application is launched from another module (e.g. homescreen).
342    * @param[in] b the bundle data which the launcher module sent
343    */
344   static int AppControl(bundle* bundleData, void *data)
345   {
346     app_control_h appControl = NULL;
347
348     appcore_ui_base_on_control(bundleData);
349
350     if (bundleData)
351     {
352       if (app_control_create_event(bundleData, &appControl) != TIZEN_ERROR_NONE)
353       {
354         DALI_LOG_ERROR("Failed to create an app_control handle");
355       }
356     }
357     else
358     {
359       if (app_control_create(&appControl) != TIZEN_ERROR_NONE)
360       {
361         DALI_LOG_ERROR("Failed to create an app_control handle");
362       }
363     }
364
365     Framework* framework = static_cast<Framework*>(data);
366     Observer *observer = &framework->mObserver;
367
368     ProcessBundle(framework, bundleData);
369
370     observer->OnReset();
371     observer->OnAppControl(appControl);
372
373     app_control_destroy(appControl);
374
375     return 0;
376   }
377
378   static void AppInit(int argc, char **argv, void *data)
379   {
380 #pragma GCC diagnostic push
381 #pragma GCC diagnostic ignored "-Wold-style-cast"
382
383     ecore_init();
384     ecore_app_args_set( argc, (const char **)argv );
385
386 #pragma GCC diagnostic pop
387   }
388
389   static void AppFinish(void)
390   {
391     ecore_shutdown();
392
393     if(getenv("AUL_LOADER_INIT"))
394     {
395       unsetenv("AUL_LOADER_INIT");
396       ecore_shutdown();
397     }
398   }
399
400   static void AppRun(void *data)
401   {
402     ecore_main_loop_begin();
403   }
404
405   static void AppExit(void *data)
406   {
407     ecore_main_loop_quit();
408   }
409
410   static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void *data)
411   {
412     Framework* framework = static_cast<Framework*>(data);
413     Observer *observer = &framework->mObserver;
414     framework->SetLanguage( std::string( static_cast<const char *>(event->value) ) );
415     observer->OnLanguageChanged();
416   }
417
418   static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void *data)
419   {
420   }
421
422   static void AppRegionChanged(AppCore::AppEventInfoPtr event, void *data)
423   {
424     Framework* framework = static_cast<Framework*>(data);
425     Observer *observer = &framework->mObserver;
426     framework->SetRegion( std::string( static_cast<const char *>(event->value) ) );
427     observer->OnRegionChanged();
428   }
429
430   static void AppBatteryLow(AppCore::AppEventInfoPtr event, void *data)
431   {
432     Observer *observer = &static_cast<Framework*>(data)->mObserver;
433     int status = *static_cast<int *>(event->value);
434     Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::NORMAL;
435
436     // convert to dali battery status
437     switch( status )
438     {
439       case 1:
440       {
441         result = Dali::DeviceStatus::Battery::POWER_OFF;
442         break;
443       }
444       case 2:
445       {
446         result = Dali::DeviceStatus::Battery::CRITICALLY_LOW;
447         break;
448       }
449       default :
450         break;
451     }
452     observer->OnBatteryLow(result);
453   }
454
455   static void AppMemoryLow(AppCore::AppEventInfoPtr event, void *data)
456   {
457     Observer *observer = &static_cast<Framework*>(data)->mObserver;
458     int status = *static_cast<int *>(event->value);
459     Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::NORMAL;
460
461     // convert to dali memmory status
462     switch( status )
463     {
464       case 1:
465       {
466         result = Dali::DeviceStatus::Memory::NORMAL;
467         break;
468       }
469       case 2:
470       {
471         result = Dali::DeviceStatus::Memory::LOW;
472         break;
473       }
474       case 4:
475       {
476         result = Dali::DeviceStatus::Memory::CRITICALLY_LOW;
477         break;
478       }
479       default :
480         break;
481     }
482     observer->OnMemoryLow(result);
483   }
484
485
486   int AppNormalMain()
487   {
488     int ret;
489
490     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
491     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
492     AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
493     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
494     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
495
496     appcore_ui_base_ops ops = appcore_ui_base_get_default_ops();
497
498     /* override methods */
499     ops.base.create = AppCreate;
500     ops.base.control = AppControl;
501     ops.base.terminate = AppTerminate;
502     ops.pause = AppPause;
503     ops.resume = AppResume;
504     ops.base.init = AppInit;
505     ops.base.finish = AppFinish;
506     ops.base.run = AppRun;
507     ops.base.exit = AppExit;
508
509     ret = appcore_ui_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework, APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL |
510                                                                                         APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL |
511                                                                                         APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL |
512                                                                                         APPCORE_UI_BASE_HINT_HW_ACC_CONTROL |
513                                                                                         APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL );
514
515     if (ret != TIZEN_ERROR_NONE)
516       return ret;
517
518     appcore_ui_base_fini();
519
520     return TIZEN_ERROR_NONE;
521   }
522
523   void AppNormalExit()
524   {
525     appcore_ui_base_exit();
526   }
527
528   void AppWidgetExit()
529   {
530     widget_base_exit();
531   }
532
533   static int WidgetAppCreate( void *data )
534   {
535     dlog_print(DLOG_ERROR,"DALI","WidgetAppCreate!\n");
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