Merge "Changes needed for https://review.tizen.org/gerrit/#/c/191202/" into devel...
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / 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 <dali/internal/adaptor/common/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 <dali/internal/system/common/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
416     if( event && event->value )
417     {
418       framework->SetLanguage( std::string( static_cast<const char *>(event->value) ) );
419       observer->OnLanguageChanged();
420     }
421     else
422     {
423       DALI_LOG_ERROR( "NULL pointer in Language changed event\n" );
424     }
425   }
426
427   static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void *data)
428   {
429   }
430
431   static void AppRegionChanged(AppCore::AppEventInfoPtr event, void *data)
432   {
433     Framework* framework = static_cast<Framework*>(data);
434     Observer *observer = &framework->mObserver;
435
436     if( event && event->value )
437     {
438       framework->SetRegion( std::string( static_cast<const char *>(event->value) ) );
439       observer->OnRegionChanged();
440     }
441     else
442     {
443       DALI_LOG_ERROR( "NULL pointer in Region changed event\n" );
444     }
445   }
446
447   static void AppBatteryLow(AppCore::AppEventInfoPtr event, void *data)
448   {
449     Observer *observer = &static_cast<Framework*>(data)->mObserver;
450     int status = *static_cast<int *>(event->value);
451     Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::NORMAL;
452
453     // convert to dali battery status
454     switch( status )
455     {
456       case 1:
457       {
458         result = Dali::DeviceStatus::Battery::POWER_OFF;
459         break;
460       }
461       case 2:
462       {
463         result = Dali::DeviceStatus::Battery::CRITICALLY_LOW;
464         break;
465       }
466       default :
467         break;
468     }
469     observer->OnBatteryLow(result);
470   }
471
472   static void AppMemoryLow(AppCore::AppEventInfoPtr event, void *data)
473   {
474     Observer *observer = &static_cast<Framework*>(data)->mObserver;
475     int status = *static_cast<int *>(event->value);
476     Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::NORMAL;
477
478     // convert to dali memmory status
479     switch( status )
480     {
481       case 1:
482       {
483         result = Dali::DeviceStatus::Memory::NORMAL;
484         break;
485       }
486       case 2:
487       {
488         result = Dali::DeviceStatus::Memory::LOW;
489         break;
490       }
491       case 4:
492       {
493         result = Dali::DeviceStatus::Memory::CRITICALLY_LOW;
494         break;
495       }
496       default :
497         break;
498     }
499     observer->OnMemoryLow(result);
500   }
501
502
503   int AppNormalMain()
504   {
505     int ret;
506
507     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
508     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
509     AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
510     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
511     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
512
513     appcore_ui_base_ops ops = appcore_ui_base_get_default_ops();
514
515     /* override methods */
516     ops.base.create = AppCreate;
517     ops.base.control = AppControl;
518     ops.base.terminate = AppTerminate;
519     ops.pause = AppPause;
520     ops.resume = AppResume;
521     ops.base.init = AppInit;
522     ops.base.finish = AppFinish;
523     ops.base.run = AppRun;
524     ops.base.exit = AppExit;
525
526     ret = appcore_ui_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework, APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL |
527                                                                                         APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL |
528                                                                                         APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL |
529                                                                                         APPCORE_UI_BASE_HINT_HW_ACC_CONTROL |
530                                                                                         APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL );
531
532     if (ret != TIZEN_ERROR_NONE)
533       return ret;
534
535     appcore_ui_base_fini();
536
537     return TIZEN_ERROR_NONE;
538   }
539
540   void AppNormalExit()
541   {
542     appcore_ui_base_exit();
543   }
544
545   void AppWidgetExit()
546   {
547     widget_base_exit();
548   }
549
550   static int WidgetAppCreate( void *data )
551   {
552     widget_base_on_create();
553     return static_cast<int>( static_cast<Framework*>(data)->Create() );
554   }
555
556   static int WidgetAppTerminate( void *data )
557   {
558     Observer *observer = &static_cast<Framework*>(data)->mObserver;
559     observer->OnTerminate();
560
561     widget_base_on_terminate();
562     return 0;
563   }
564
565   int AppWidgetMain()
566   {
567     if( !IsWidgetFeatureEnabled() )
568     {
569       DALI_LOG_ERROR("widget feature is not supported");
570       return 0;
571     }
572
573     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
574     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
575     AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
576     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
577     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
578
579     widget_base_ops ops = widget_base_get_default_ops();
580
581     /* override methods */
582     ops.create = WidgetAppCreate;
583     ops.terminate = WidgetAppTerminate;
584     ops.init = AppInit;
585     ops.finish = AppFinish;
586     ops.run = AppRun;
587     ops.exit = AppExit;
588
589     int result = widget_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework);
590
591     widget_base_fini();
592
593     return result;
594   }
595
596 #ifdef APPCORE_WATCH_AVAILABLE
597   static bool WatchAppCreate(int width, int height, void *data)
598   {
599     return static_cast<Framework*>(data)->Create();
600   }
601
602   static void WatchAppTimeTick(watch_time_h time, void *data)
603   {
604     Observer *observer = &static_cast<Framework*>(data)->mObserver;
605     WatchTime curTime(time);
606
607     observer->OnTimeTick(curTime);
608   }
609
610   static void WatchAppAmbientTick(watch_time_h time, void *data)
611   {
612     Observer *observer = &static_cast<Framework*>(data)->mObserver;
613     WatchTime curTime(time);
614
615     observer->OnAmbientTick(curTime);
616   }
617
618   static void WatchAppAmbientChanged(bool ambient, void *data)
619   {
620     Observer *observer = &static_cast<Framework*>(data)->mObserver;
621
622     observer->OnAmbientChanged(ambient);
623   }
624
625   static void WatchAppControl(app_control_h app_control, void *data)
626   {
627     Framework* framework = static_cast<Framework*>(data);
628     Observer *observer = &framework->mObserver;
629     bundle *bundleData = NULL;
630
631     app_control_to_bundle(app_control, &bundleData);
632     ProcessBundle(framework, bundleData);
633
634     observer->OnReset();
635     observer->OnAppControl(app_control);
636   }
637
638   static void WatchAppTerminate(void *data)
639   {
640     Observer *observer = &static_cast<Framework*>(data)->mObserver;
641
642     observer->OnTerminate();
643   }
644
645   static void WatchAppPause(void *data)
646   {
647     Observer *observer = &static_cast<Framework*>(data)->mObserver;
648
649     observer->OnPause();
650   }
651
652   static void WatchAppResume(void *data)
653   {
654     Observer *observer = &static_cast<Framework*>(data)->mObserver;
655
656     observer->OnResume();
657   }
658
659 #endif
660
661   int AppWatchMain()
662   {
663     int ret = true;
664
665 #ifdef APPCORE_WATCH_AVAILABLE
666     mWatchCallback.create = WatchAppCreate;
667     mWatchCallback.app_control = WatchAppControl;
668     mWatchCallback.terminate = WatchAppTerminate;
669     mWatchCallback.pause = WatchAppPause;
670     mWatchCallback.resume = WatchAppResume;
671     mWatchCallback.time_tick = WatchAppTimeTick;
672     mWatchCallback.ambient_tick = WatchAppAmbientTick;
673     mWatchCallback.ambient_changed = WatchAppAmbientChanged;
674
675     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
676     AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
677     AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
678     AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
679
680     ret = watch_app_main(*mFramework->mArgc, *mFramework->mArgv, &mWatchCallback, mFramework);
681 #endif
682     return ret;
683   }
684
685   void AppWatchExit()
686   {
687 #ifdef APPCORE_WATCH_AVAILABLE
688     watch_app_exit();
689 #endif
690   }
691
692 private:
693   // Undefined
694   Impl( const Impl& impl );
695
696   // Undefined
697   Impl& operator=( const Impl& impl );
698 };
699
700 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
701 : mObserver(observer),
702   mInitialised(false),
703   mRunning(false),
704   mArgc(argc),
705   mArgv(argv),
706   mBundleName(""),
707   mBundleId(""),
708   mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
709   mImpl(NULL)
710 {
711   bool featureFlag = true;
712   system_info_get_platform_bool( "tizen.org/feature/opengles.version.2_0", &featureFlag );
713
714   if( featureFlag == false )
715   {
716     set_last_result( TIZEN_ERROR_NOT_SUPPORTED );
717   }
718 #ifdef DALI_ELDBUS_AVAILABLE
719   // Initialize ElDBus.
720   DALI_LOG_INFO( gDBusLogging, Debug::General, "Starting DBus Initialization\n" );
721   eldbus_init();
722 #endif
723   InitThreads();
724
725   mImpl = new Impl(this, type);
726 }
727
728 Framework::~Framework()
729 {
730   if (mRunning)
731   {
732     Quit();
733   }
734
735 #ifdef DALI_ELDBUS_AVAILABLE
736   // Shutdown ELDBus.
737   DALI_LOG_INFO( gDBusLogging, Debug::General, "Shutting down DBus\n" );
738   eldbus_shutdown();
739 #endif
740
741   delete mImpl;
742 }
743
744 bool Framework::Create()
745 {
746   mInitialised = true;
747   mObserver.OnInit();
748   return true;
749 }
750
751 void Framework::Run()
752 {
753   mRunning = true;
754   int ret;
755
756   ret = mImpl->AppMain();
757   if (ret != APP_ERROR_NONE)
758   {
759     DALI_LOG_ERROR("Framework::Run(), ui_app_main() is failed. err = %d\n", ret);
760   }
761   mRunning = false;
762 }
763
764 void Framework::Quit()
765 {
766   mImpl->AppExit();
767 }
768
769 bool Framework::IsMainLoopRunning()
770 {
771   return mRunning;
772 }
773
774 void Framework::AddAbortCallback( CallbackBase* callback )
775 {
776   mImpl->mAbortCallBack = callback;
777 }
778
779 std::string Framework::GetBundleName() const
780 {
781   return mBundleName;
782 }
783
784 void Framework::SetBundleName(const std::string& name)
785 {
786   mBundleName = name;
787 }
788
789 std::string Framework::GetBundleId() const
790 {
791   return mBundleId;
792 }
793
794 std::string Framework::GetResourcePath()
795 {
796   std::string resourcePath = "";
797 #if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
798   char* app_rsc_path = app_get_resource_path();
799   if (app_rsc_path)
800   {
801     resourcePath = app_rsc_path;
802     free(app_rsc_path);
803   }
804 #else // For backwards compatibility with older Tizen versions
805
806   // "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
807   const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
808   char* value = getenv( environmentVariable );
809   if ( value != NULL )
810   {
811     resourcePath = value;
812   }
813 #endif //TIZEN_PLATFORM_CONFIG_SUPPORTED
814
815   return resourcePath;
816 }
817
818 void Framework::SetBundleId(const std::string& id)
819 {
820   mBundleId = id;
821 }
822
823 void Framework::AbortCallback( )
824 {
825   // if an abort call back has been installed run it.
826   if (mImpl->mAbortCallBack)
827   {
828     CallbackBase::Execute( *mImpl->mAbortCallBack );
829   }
830   else
831   {
832     Quit();
833   }
834 }
835
836 void Framework::SetLanguage( const std::string& language )
837 {
838   mImpl->SetLanguage( language );
839 }
840
841 void Framework::SetRegion( const std::string& region )
842 {
843   mImpl->SetRegion( region );
844 }
845
846 std::string Framework::GetLanguage() const
847 {
848   return mImpl->GetLanguage();
849 }
850
851 std::string Framework::GetRegion() const
852 {
853   return mImpl->GetRegion();
854 }
855
856 } // namespace Adaptor
857
858 } // namespace Internal
859
860 } // namespace Dali