summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include/application_manager/application.h
blob: e018c28c54a62394ff5ba303752d168e6dd16a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
/*
 * Copyright (c) 2016, Ford Motor Company
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the Ford Motor Company nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_

#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>

#include "application_manager/app_extension.h"
#include "application_manager/application_state.h"
#include "application_manager/help_prompt_manager.h"
#include "application_manager/hmi_state.h"
#include "application_manager/message.h"
#include "connection_handler/device.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
#include "protocol_handler/protocol_handler.h"
#include "smart_objects/smart_object.h"
#include "utils/data_accessor.h"
#include "utils/macro.h"
#include "utils/semantic_version.h"

namespace application_manager {

namespace mobile_api = mobile_apis;
namespace custom_str = utils::custom_string;

typedef int32_t ErrorCode;

class UsageStatistics;

class DisplayCapabilitiesBuilder;

enum APIVersion {
  kUnknownAPI = -1,
  kAPIV0 = 0,
  kAPIV1 = 1,
  kAPIV2 = 2,
  kAPIV3 = 3,
  kAPIV4 = 4,
  kAPIV5 = 5,
  kAPIV6 = 6
};

enum TLimitSource { POLICY_TABLE = 0, CONFIG_FILE };

struct Version {
  APIVersion min_supported_api_version;
  APIVersion max_supported_api_version;

  Version()
      : min_supported_api_version(APIVersion::kUnknownAPI)
      , max_supported_api_version(APIVersion::kUnknownAPI) {}
};

struct AppFile {
  // need to use in std::map;
  AppFile()
      : is_persistent(false)
      , is_download_complete(false)
      , file_type(mobile_apis::FileType::INVALID_ENUM) {}
  AppFile(const std::string& name,
          bool persistent,
          bool download_complete,
          mobile_apis::FileType::eType type)
      : file_name(name)
      , is_persistent(persistent)
      , is_download_complete(download_complete)
      , file_type(type) {}
  std::string file_name;
  bool is_persistent;
  bool is_download_complete;
  mobile_apis::FileType::eType file_type;
};
typedef std::map<std::string, AppFile> AppFilesMap;
typedef std::map<int32_t, hmi_apis::Common_ButtonName::eType>
    ButtonSubscriptionsMap;
class InitialApplicationData {
 public:
  virtual ~InitialApplicationData() {}

  virtual const smart_objects::SmartObjectSPtr app_types() const = 0;
  virtual const smart_objects::SmartObjectSPtr vr_synonyms() const = 0;
  virtual const std::string& mac_address() const = 0;
  virtual const std::string& bundle_id() const = 0;
  virtual void set_bundle_id(const std::string& bundle_id) = 0;
  virtual std::string policy_app_id() const = 0;
  virtual const smart_objects::SmartObjectSPtr tts_name() const = 0;
  virtual const smart_objects::SmartObjectSPtr ngn_media_screen_name()
      const = 0;
  virtual const mobile_api::Language::eType& language() const = 0;
  virtual const mobile_api::Language::eType& ui_language() const = 0;
  virtual const utils::SemanticVersion& msg_version() const = 0;
  virtual void set_app_types(const smart_objects::SmartObject& app_types) = 0;
  virtual void set_vr_synonyms(
      const smart_objects::SmartObject& vr_synonyms) = 0;
  virtual void set_mobile_app_id(const std::string& policy_app_id) = 0;
  virtual void set_tts_name(const smart_objects::SmartObject& tts_name) = 0;
  virtual void set_ngn_media_screen_name(
      const smart_objects::SmartObject& ngn_name) = 0;
  virtual void set_language(const mobile_api::Language::eType& language) = 0;
  virtual void set_ui_language(
      const mobile_api::Language::eType& ui_language) = 0;
  virtual void set_msg_version(const utils::SemanticVersion& version) = 0;
};

/*
 * @brief Typedef for supported commands in application menu
 */
typedef std::map<uint32_t, smart_objects::SmartObject*> CommandsMap;

/*
 * @brief Typedef for supported sub menu in application menu
 */
typedef std::map<uint32_t, smart_objects::SmartObject*> SubMenuMap;

/*
 * @brief Typedef for interaction choice set
 */
typedef std::map<uint32_t, smart_objects::SmartObject*> ChoiceSetMap;

/*
 * @brief Typedef for map of window ids to data used as parameters
 * to CreateWindow request.
 */
typedef std::map<WindowID, smart_objects::SmartObjectSPtr> WindowParamsMap;

/*
 * @brief Typedef for perform interaction choice
 * @param choice id
 * @param SmartObject choice
 */
typedef std::map<uint32_t, smart_objects::SmartObject*> PerformChoice;

/*
 * @brief Typedef for perform interaction choice set
 * @param request corellation id
 * @param map of choices
 */
typedef std::map<uint32_t, PerformChoice> PerformChoiceSetMap;

/**
 * @brief Defines id of SoftButtons for specified WindowID
 */
typedef std::pair<WindowID, std::set<uint32_t> > WindowSoftButtons;

/**
 * @brief Defines id of SoftButtons related to a specified WindowID
 */
typedef std::set<WindowSoftButtons> SoftButtonIDs;

/**
 * @brief Defines set of buttons subscription
 */
typedef std::set<mobile_apis::ButtonName::eType> ButtonSubscriptions;

/**
 * @breif Collection for the mobile command smart object.
 */
typedef std::vector<smart_objects::SmartObjectSPtr> MobileMessageQueue;

class DynamicApplicationData {
 public:
  virtual ~DynamicApplicationData() {}
  virtual const smart_objects::SmartObjectSPtr help_prompt() const = 0;
  virtual const smart_objects::SmartObjectSPtr timeout_prompt() const = 0;
  virtual const smart_objects::SmartObjectSPtr vr_help_title() const = 0;
  virtual const smart_objects::SmartObjectSPtr vr_help() const = 0;
  virtual const mobile_api::TBTState::eType& tbt_state() const = 0;
  virtual const smart_objects::SmartObjectSPtr show_command() const = 0;
  virtual const smart_objects::SmartObjectSPtr tbt_show_command() const = 0;
  virtual DataAccessor<ButtonSubscriptions> SubscribedButtons() const = 0;
  virtual const smart_objects::SmartObjectSPtr keyboard_props() const = 0;
  virtual const smart_objects::SmartObjectSPtr menu_title() const = 0;
  virtual const smart_objects::SmartObjectSPtr menu_icon() const = 0;
  virtual const smart_objects::SmartObjectSPtr menu_layout() const = 0;
  virtual smart_objects::SmartObject day_color_scheme() const = 0;
  virtual smart_objects::SmartObject night_color_scheme() const = 0;
  virtual std::string display_layout() const = 0;

  /**
   * @brief Specific display capabilities of application
   * @return display capabilities of application or NULL-initialized pointer if
   * not specified
   */
  virtual smart_objects::SmartObjectSPtr display_capabilities() const = 0;

  /**
   * @brief Specific display capabilities of application
   * @param window id - id of an affected widget
   * @return display capabilities of application or NULL-initialized pointer if
   * not specified
   */
  virtual smart_objects::SmartObjectSPtr display_capabilities(
      const WindowID window_id) const = 0;

  virtual void load_global_properties(const smart_objects::SmartObject& so) = 0;
  virtual void set_help_prompt(
      const smart_objects::SmartObject& help_prompt) = 0;
  virtual void set_timeout_prompt(
      const smart_objects::SmartObject& timeout_prompt) = 0;
  virtual void set_vr_help_title(
      const smart_objects::SmartObject& vr_help_title) = 0;
  virtual void reset_vr_help_title() = 0;
  virtual void set_vr_help(const smart_objects::SmartObject& vr_help) = 0;
  virtual void reset_vr_help() = 0;
  virtual void set_tbt_state(const mobile_api::TBTState::eType& tbt_state) = 0;
  virtual void set_show_command(
      const smart_objects::SmartObject& show_command) = 0;
  virtual void set_tbt_show_command(
      const smart_objects::SmartObject& tbt_show) = 0;
  virtual void set_keyboard_props(
      const smart_objects::SmartObject& keyboard_props) = 0;
  virtual void set_menu_title(const smart_objects::SmartObject& menu_title) = 0;
  virtual void set_menu_icon(const smart_objects::SmartObject& menu_icon) = 0;
  virtual void set_menu_layout(
      const smart_objects::SmartObject& menu_layout) = 0;

  virtual uint32_t audio_stream_retry_number() const = 0;

  virtual void set_audio_stream_retry_number(
      const uint32_t& audio_stream_retry_number) = 0;

  virtual uint32_t video_stream_retry_number() const = 0;

  virtual void set_video_stream_retry_number(
      const uint32_t& video_stream_retry_number) = 0;

  virtual void set_display_layout(const std::string& layout) = 0;
  virtual void set_day_color_scheme(
      const smart_objects::SmartObject& color_scheme) = 0;
  virtual void set_night_color_scheme(
      const smart_objects::SmartObject& color_scheme) = 0;

  /**
   * @brief Set specific application display capabilities
   * @param display_capabilities new display capabilities of application
   */
  virtual void set_display_capabilities(
      const smart_objects::SmartObject& display_capabilities) = 0;

  /**
   * @brief deletes stored window capability for given window id
   * @param window id of capability to remove
   */
  virtual void remove_window_capability(const WindowID window_id) = 0;

  /**
   * @brief checks whether a specific menu layout is supported
   * @param menu layout to check
   */
  virtual bool menu_layout_supported(
      const mobile_apis::MenuLayout::eType layout) const = 0;

  /**
   * @brief Sets layout for application's specific window
   * @param window_id window id for which layout should be set
   * @param layout - layout to be set
   */
  virtual void set_window_layout(const WindowID window_id,
                                 const std::string& layout) = 0;

  /**
   * @brief Sets day color scheme for application's specific window
   * @param window_id window id for which day color scheme should be set
   * @param color_scheme - color scheme to be set
   */
  virtual void set_day_color_scheme(
      const WindowID window_id,
      const smart_objects::SmartObject& color_scheme) = 0;

  /**
   * @brief Sets night color scheme for application's specific window
   * @param window_id window id for which night color scheme should be set
   * @param color_scheme - color scheme to be set
   */
  virtual void set_night_color_scheme(
      const WindowID window_id,
      const smart_objects::SmartObject& color_scheme) = 0;

  /**
   * @brief Gets window layout for application's specific window_id
   * @param window_id window id for which display layout should be returned
   * @return string containing set display layout,
   * if no display layout is set - empty string is returned
   */
  virtual std::string window_layout(const WindowID window_id) const = 0;

  /**
   * @brief Gets day color scheme for application's specific window_id
   * @param window_id window id for which color scheme should be returned
   * @return day color scheme which is set for specified app window,
   * if no day color scheme is set - Smart object with NullType is returned
   */
  virtual smart_objects::SmartObject day_color_scheme(
      const WindowID window_id) const = 0;

  /**
   * @brief Gets night color scheme for application's specific window_id
   * @param window_id window id for which color scheme should be returned
   * @return night color scheme which is set for specified app window
   * if no night color scheme is set - Smart object with NullType is returned
   */
  virtual smart_objects::SmartObject night_color_scheme(
      const WindowID window_id) const = 0;

  /**
   * @brief Checks if application is media, voice communication or navigation
   * @return true if application is media, voice communication or navigation,
   * false otherwise
   */
  virtual bool is_audio() const = 0;

  /*
   * @brief Adds a command to the in application menu
   */
  virtual void AddCommand(uint32_t cmd_id,
                          const smart_objects::SmartObject& command) = 0;

  /*
   * @brief Deletes all commands from the application
   * menu with the specified command id
   */
  virtual void RemoveCommand(uint32_t cmd_id) = 0;

  /*
   * @brief Finds command with the specified command id
   */
  virtual smart_objects::SmartObject FindCommand(uint32_t cmd_id) = 0;

  /*
   * @brief Adds a menu to the application
   */
  virtual void AddSubMenu(uint32_t menu_id,
                          const smart_objects::SmartObject& menu) = 0;

  /*
   * @brief Deletes menu from the application menu
   */
  virtual void RemoveSubMenu(uint32_t menu_id) = 0;

  /*
   * @brief Finds menu with the specified id
   */
  virtual smart_objects::SmartObject FindSubMenu(uint32_t menu_id) const = 0;

  /*
   * @brief Adds a interaction choice set to the application
   *
   * @param choice_set_id Unique ID used for this interaction choice set
   * @param choice_set SmartObject that represent choice set
   */
  virtual void AddChoiceSet(uint32_t choice_set_id,
                            const smart_objects::SmartObject& choice_set) = 0;

  /*
   * @brief Deletes choice set from the application
   *
   * @param choice_set_id Unique ID of the interaction choice set
   */
  virtual void RemoveChoiceSet(uint32_t choice_set_id) = 0;

  /*
   * @brief Adds window info
   * @param window_id unique id of a window
   * @param window_info SmartObject that represent window info
   */
  virtual void SetWindowInfo(const WindowID window_id,
                             const smart_objects::SmartObject& window_info) = 0;

  /*
   * @brief Removes window info
   * @param window_id unique id of a window
   */
  virtual void RemoveWindowInfo(const WindowID window_id) = 0;

  /*
   * @brief Finds choice set with the specified choice_set_id id
   *
   * @param choice_set_id Unique ID of the interaction choice set
   */
  virtual smart_objects::SmartObject FindChoiceSet(uint32_t choice_set_id) = 0;

  /*
   * @brief Adds perform interaction choice set to the application
   *
   * @param correlation_id Unique ID of the request that added this choice set
   * @param choice_set_id  Unique ID used for this interaction choice set
   * @param choice_set SmartObject that represents choice set
   */
  virtual void AddPerformInteractionChoiceSet(
      uint32_t correlation_id,
      uint32_t choice_set_id,
      const smart_objects::SmartObject& choice_set) = 0;

  /*
   * @brief Deletes entirely perform interaction choice set for request
   * @param correlation_id Unique ID of the request that added this choice set
   *
   */
  virtual void DeletePerformInteractionChoiceSet(uint32_t correlation_id) = 0;

  /*
   * @brief Retrieves entirely ChoiceSet - VR commands map
   *
   * @return ChoiceSet map that is currently in use
   */
  virtual DataAccessor<PerformChoiceSetMap> performinteraction_choice_set_map()
      const = 0;

  /*
   * @brief Retrieves window info map
   */
  virtual DataAccessor<WindowParamsMap> window_optional_params_map() const = 0;

  /*
   * @brief Retrieves display capabilities builder
   */
  virtual DisplayCapabilitiesBuilder& display_capabilities_builder() = 0;

  /*
   * @brief Retrieve application commands
   */
  virtual DataAccessor<CommandsMap> commands_map() const = 0;

  /*
   * @brief Retrieve application sub menus
   */
  virtual DataAccessor<SubMenuMap> sub_menu_map() const = 0;

  /*
   * @brief Retrieve application choice set map
   */
  virtual DataAccessor<ChoiceSetMap> choice_set_map() const = 0;

  /*
   * @brief Sets perform interaction state
   *
   * @param active Current state of the perform interaction
   */
  virtual void set_perform_interaction_active(uint32_t active) = 0;

  /*
   * @brief Retrieves perform interaction state
   *
   * @return TRUE if perform interaction active, otherwise FALSE
   */
  virtual uint32_t is_perform_interaction_active() const = 0;

  /*
   * @brief Set perform interaction layout
   *
   * @param Current Interaction layout of the perform interaction
   */
  virtual void set_perform_interaction_layout(
      mobile_api::LayoutMode::eType layout) = 0;

  /*
   * @brief Retrieve perform interaction layout
   */
  virtual mobile_api::LayoutMode::eType perform_interaction_layout() const = 0;

  /*
   * @brief Sets the mode for perform interaction: UI/VR/BOTH
   *
   * @param mode Mode that was selected (MENU; VR; BOTH)
   */
  virtual void set_perform_interaction_mode(int32_t mode) = 0;

  /*
   * @brief Retrieve the mode that was PerformInteraction sent in
   *
   * @return mode of PerformInteraction
   */
  virtual int32_t perform_interaction_mode() const = 0;

  /*
   * @brief Sets reset global properties state
   *
   * @param active Current state of the reset global properties
   */
  virtual void set_reset_global_properties_active(bool active) = 0;

  /*
   * @brief Retrieves reset global properties state
   *
   * @return TRUE if perform interaction active, otherwise FALSE
   */
  virtual bool is_reset_global_properties_active() const = 0;

  /**
   * @brief Set allowed mode for specified choice_set_id.
   * @param choice_set_id Choice set id.
   * @param is_allowed TRUE if the choice set has to be allowed to perform,
   * otherwise FALSE.
   * Allow mode means that the choice_set is not fully processed or not fully
   * deleted (in both cases request is being processed on HMI side, and HMI
   * hasn't sent response with result yet)
   */
  virtual void set_choice_set_allow_mode(const uint32_t choice_set_id,
                                         const bool is_allowed) = 0;

  /**
   * @brief Check if choice set allowed.
   * @param choice_set_id Choice set id.
   * @return TRUE if the choice set is allowed to perform, otherwise FALSE.
   */
  virtual bool is_choice_set_allowed(const uint32_t choice_set_id) const = 0;
};

class Application : public virtual InitialApplicationData,
                    public virtual DynamicApplicationData {
 public:
  /**
   * @brief The StreamingState enum defines current streaming state
   */
  enum class StreamingState { kStopped, kStarted, kSuspended };

  enum ApplicationRegisterState { kRegistered = 0, kWaitingForRegistration };

  Application() : is_greyed_out_(false) {}
  virtual ~Application() {}

  /**
   * @brief Returns message belonging to the application
   * that is currently executed (i.e. on HMI).
   * @return smart_objects::SmartObject * Active message
   * @deprecated will always return NULL
   */
  DEPRECATED virtual const smart_objects::SmartObject* active_message()
      const = 0;

  /**
   * @brief returns current hash value
   * @return current hash value
   */
  virtual const std::string& curHash() const = 0;

  /**
   * @brief Change Hash for current application
   * and send notification to mobile
   * @return updated_hash
   */
  virtual void UpdateHash() = 0;

  /**
   * @brief checks is hashID was changed during suspended state
   * @return Returns TRUE if hashID was changed during suspended state
   * otherwise returns FALSE.
   */
  virtual bool IsHashChangedDuringSuspend() const = 0;

  /**
   * @brief changes state of the flag which tracks is hashID was changed during
   * suspended state or not
   * @param state new state of the flag
   */
  virtual void SetHashChangedDuringSuspend(const bool state) = 0;

  /**
   * @brief method is called when SDL is saving application data for resumption
   * @return TRUE if data of application need to save for resumption, otherwise
   * return FALSE
   */
  virtual bool is_application_data_changed() const = 0;

  /**
   * @brief method is called after SDL saved application data for resumption
   * @param state_application_data contains FALSE after saving data
   */
  virtual void set_is_application_data_changed(bool state_application_data) = 0;

  /**
   * @brief Checks if application data is allowed to be resumed
   * @return TRUE if data of application is allowed to be resumed, otherwise
   * return FALSE
   */
  virtual bool is_app_data_resumption_allowed() const = 0;

  /**
   * @brief Sets resumption allowance for application data
   * @param allowed - true if app data allowed to be resumed,
   * false value means that app data is disallowed for resumption
   */
  virtual void set_app_data_resumption_allowance(const bool allowed) = 0;

  // Deprecated, has no effect
  DEPRECATED virtual void CloseActiveMessage() = 0;
  virtual bool IsFullscreen() const = 0;
  virtual void ChangeSupportingAppHMIType() = 0;

  virtual bool is_navi() const = 0;
  virtual void set_is_navi(bool allow) = 0;

  /**
   * @brief Returns is_remote_control_supported_
   * @return true if app supports remote control, else false
   */
  virtual bool is_remote_control_supported() const = 0;

  /**
   * @brief Sets remote control supported,
   * which is used to determine app with remote control
   * @param allow, if true - remote control is supported,
   * else remote control is disable
   */
  virtual void set_remote_control_supported(const bool allow) = 0;

  virtual void set_mobile_projection_enabled(bool option) = 0;
  virtual bool mobile_projection_enabled() const = 0;

  virtual void set_webengine_projection_enabled(const bool option) = 0;
  virtual bool webengine_projection_enabled() const = 0;

  virtual bool video_streaming_approved() const = 0;
  virtual void set_video_streaming_approved(bool state) = 0;
  virtual bool audio_streaming_approved() const = 0;
  virtual void set_audio_streaming_approved(bool state) = 0;

  virtual bool video_streaming_allowed() const = 0;
  virtual void set_video_streaming_allowed(bool state) = 0;
  virtual bool audio_streaming_allowed() const = 0;
  virtual void set_audio_streaming_allowed(bool state) = 0;

  /**
   * @brief Sends SetVideoConfig request to HMI to configure streaming
   * @param service_type Type of streaming service, should be kMobileNav
   * @param params parameters of video streaming in key-value format
   * @return true if SetVideoConfig is sent, false otherwise
   */
  virtual bool SetVideoConfig(protocol_handler::ServiceType service_type,
                              const smart_objects::SmartObject& params) = 0;

  /**
   * @brief Starts streaming service for application
   * @param service_type Type of streaming service
   */
  virtual void StartStreaming(protocol_handler::ServiceType service_type) = 0;

  /**
   * @brief Stops streaming service for application
   * @param service_type Type of streaming service
   */
  virtual void StopStreaming(protocol_handler::ServiceType service_type) = 0;

  /**
   * @brief Stops streaming for application whether it is allowed or not HMI
   * @param service_type video or audio
   */
  virtual void StopStreamingForce(
      protocol_handler::ServiceType service_type) = 0;

  /**
   * @brief Suspends streaming process for application
   * @param service_type Type of streaming service
   */
  virtual void SuspendStreaming(protocol_handler::ServiceType service_type) = 0;

  /**
   * @brief Wakes up streaming process for application
   * @param service_type Type of streaming service
   * @param timer_len The amount of time in ms the timer will wait
   */
  virtual void WakeUpStreaming(protocol_handler::ServiceType service_type,
                               uint32_t timer_len = 0) = 0;

  virtual bool is_voice_communication_supported() const = 0;
  virtual void set_voice_communication_supported(
      bool is_voice_communication_supported) = 0;
  virtual bool app_allowed() const = 0;
  virtual bool has_been_activated() const = 0;
  virtual bool set_activated(bool is_active) = 0;
  virtual bool is_ready() const = 0;
  virtual bool set_is_ready(bool is_ready) = 0;

  virtual const Version& version() const = 0;
  virtual void set_hmi_application_id(uint32_t hmi_app_id) = 0;
  virtual uint32_t hmi_app_id() const = 0;
  virtual uint32_t app_id() const = 0;
  virtual const custom_str::CustomString& name() const = 0;
  /**
   * @brief Sets application folder name, which is used for storing of related
   * files, e.g. icons
   * @param folder_name Name of folder
   */
  virtual void set_folder_name(const std::string& folder_name) = 0;
  virtual const std::string folder_name() const = 0;
  virtual bool is_media_application() const = 0;
  virtual bool is_foreground() const = 0;
  virtual void set_foreground(const bool is_foreground) = 0;

  /**
   * @brief hmi_level current HMI level of application's window
   * @param window_id id of application's window to get
   * @return HMI level of application's window
   */
  virtual const mobile_api::HMILevel::eType hmi_level(
      const WindowID window_id) const = 0;

  virtual const uint32_t put_file_in_none_count() const = 0;
  virtual const uint32_t delete_file_in_none_count() const = 0;
  virtual const uint32_t list_files_in_none_count() const = 0;

  /**
   * @brief system_context current system context of application's window
   * @param window_id id of application's window to get
   * @return system context of application's window
   */
  virtual const mobile_api::SystemContext::eType system_context(
      const WindowID window_id) const = 0;
  virtual const mobile_api::AudioStreamingState::eType audio_streaming_state()
      const = 0;
  virtual const mobile_api::VideoStreamingState::eType video_streaming_state()
      const = 0;
  virtual const std::string& app_icon_path() const = 0;
  virtual connection_handler::DeviceHandle device() const = 0;
  /**
   * @brief Returns handle of the device on which secondary transport of this
   * app is running
   * @return handle of the device on which secondary transport is running
   */
  virtual connection_handler::DeviceHandle secondary_device() const = 0;

  /**
   * @brief sets true if application has sent TTS GlobalProperties
   * request with empty array help_prompt to HMI with level
   * NONE BACKGROUND
   * @param active contains state of sending TTS GlobalProperties
   */
  virtual void set_tts_properties_in_none(bool active) = 0;
  /**
   * @brief returns true if application has sent TTS GlobalProperties
   * otherwise return false
   * @return flag tts_properties_in_none
   */
  virtual bool tts_properties_in_none() = 0;
  /**
   * @brief sets true if application has sent TTS GlobalProperties
   * request with default array help_prompt to HMI with level
   * FULL LIMITED
   * @param active contains state of sending TTS GlobalProperties
   */
  virtual void set_tts_properties_in_full(bool active) = 0;
  /**
   * @brief  returns true if application has sent TTS GlobalProperties
   * otherwise return false
   * @return flag tts_properties_in_full
   */
  virtual bool tts_properties_in_full() = 0;
  /**
   * @brief sets true if application should keep it's HMI Level after an audio
   * source change
   * @param value of keep context
   */
  virtual void set_keep_context(bool keep_context) = 0;
  /**
   * @brief  returns true if application should keep keep it's HMI Level after
   * an audio source change, otherwise return false
   * @return value of keep_context flag
   */
  virtual bool keep_context() = 0;
  virtual void set_version(const Version& version) = 0;
  virtual void set_name(const custom_str::CustomString& name) = 0;
  virtual void set_is_media_application(bool is_media) = 0;
  virtual void increment_put_file_in_none_count() = 0;
  virtual void increment_delete_file_in_none_count() = 0;
  virtual void increment_list_files_in_none_count() = 0;
  virtual bool set_app_icon_path(const std::string& file_name) = 0;
  virtual void set_app_allowed(const bool allowed) = 0;
  /**
   * @brief Sets the handle of the device on which secondary transport of this
   * app is running
   * @param handle of the device on which secondary transport is running
   */
  virtual void set_secondary_device(
      connection_handler::DeviceHandle secondary_device) = 0;
  virtual uint32_t get_grammar_id() const = 0;
  virtual void set_grammar_id(uint32_t value) = 0;

  virtual void set_protocol_version(
      const protocol_handler::MajorProtocolVersion& protocol_version) = 0;
  virtual protocol_handler::MajorProtocolVersion protocol_version() const = 0;

  virtual void set_is_resuming(bool is_resuming) = 0;
  virtual bool is_resuming() const = 0;

  /**
   * @brief Remembers the HMI level which the app would resume into if high-
   * bandwidth transport were available.
   * @param level The HMI level which the app would resume into. Specify
   * INVALID_ENUM to clear the state.
   */
  virtual void set_deferred_resumption_hmi_level(
      mobile_api::HMILevel::eType level) = 0;
  /**
   * @brief Returns the HMI level which the app would resume into if high-
   * bandwidth transport were available.
   *
   * A value of INVALID_ENUM indicates that the app does not have deferred
   * HMI level.
   * @return HMI level which the app would resume into
   */
  virtual mobile_api::HMILevel::eType deferred_resumption_hmi_level() const = 0;

  virtual bool AddFile(const AppFile& file) = 0;
  virtual const AppFilesMap& getAppFiles() const = 0;

  /**
   * @brief Updates fields of existing file
   * @param file_name File name, that need to update
   * @param is_persistent Bollean describes is file persistent?
   * @param is_download_complete Bollean describes is file downloaded fully on
   * need to finish downloading?
   * @return TRUE if file exist and updated sucsesfuly, othervise return false
   */
  virtual bool UpdateFile(const AppFile& file) = 0;
  virtual bool DeleteFile(const std::string& file_name) = 0;
  virtual const AppFile* GetFile(const std::string& file_name) = 0;

  virtual bool SubscribeToButton(mobile_apis::ButtonName::eType btn_name) = 0;
  virtual bool IsSubscribedToButton(
      mobile_apis::ButtonName::eType btn_name) = 0;
  virtual bool UnsubscribeFromButton(
      mobile_apis::ButtonName::eType btn_name) = 0;

  /**
   * @brief ResetDataInNone reset data counters in NONE
   */
  virtual void ResetDataInNone() = 0;

  /**
   * @brief Check, if limits for command number per time is exceeded
   * @param cmd_id Unique command id from mobile API
   * @param source Limits source, e.g. policy table, config file etc.
   * @return true, if - excedeed, otherwise - false
   */
  virtual bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id,
                                        TLimitSource source) = 0;

  /**
   * Returns object for recording statistics
   * @return object for recording statistics
   */
  virtual UsageStatistics& usage_report() = 0;

  /**
   * @brief Access to HelpPromptManager interface
   * @return object for Handling VR help
   */
  virtual HelpPromptManager& help_prompt_manager() = 0;

  /**
   * @brief SetInitialState sets initial HMI state for application on
   * registration
   * @param window_id window id for HMI state
   * @param window_name name of inited window
   * @param state Hmi state value
   */
  virtual void SetInitialState(const WindowID window_id,
                               const std::string& window_name,
                               HmiStatePtr state) = 0;

  /**
   * @brief SetRegularState set permanent state of application
   * @param window_id window id for HMI state
   * @param state state to setup
   */
  virtual void SetRegularState(const WindowID window_id, HmiStatePtr state) = 0;

  /**
   * @brief SetPostponedState sets postponed state to application.
   * This state could be set as regular later
   * @param window_id window id for HMI state
   * @param state state to setup
   */
  virtual void SetPostponedState(const WindowID window_id,
                                 HmiStatePtr state) = 0;

  /**
   * @brief RemovePostponedState removes postponed state for application
   * After removal, this state will not be set as regular later
   * @param window_id window id for HMI state
   */
  virtual void RemovePostponedState(const WindowID window_id) = 0;

  /**
   * @brief AddHMIState the function that will change application's
   * hmi state.
   *
   * @param window_id window id for HMI state
   *
   * @param state new hmi state for certain application.
   */
  virtual void AddHMIState(const WindowID window_id, HmiStatePtr state) = 0;

  /**
   * @brief RemoveHMIState the function that will turn back hmi_level after end
   * of some event
   *
   * @param window_id window id for HMI state
   *
   * @param state_id that should be removed
   */
  virtual void RemoveHMIState(const WindowID window_id,
                              HmiState::StateID state_id) = 0;

  /**
   * @brief HmiState of application within active events PhoneCall, TTS< etc ...
   * @param window_id window id for HMI state
   * @return Active HmiState of application
   */
  virtual const HmiStatePtr CurrentHmiState(const WindowID window_id) const = 0;

  /**
   * @brief Getter for a list of available application windows including the
   * main
   * @return list of available window IDs created by application
   */
  virtual WindowIds GetWindowIds() const = 0;

  /**
   * @brief Getter for a list of all existing window names
   * @return list of available window names created by application
   */
  virtual WindowNames GetWindowNames() const = 0;

  /**
   * @brief Check if application has specified window
   * @param window_id - id of window to check
   * @return true if app has specified window , otherwise false
   */
  virtual bool WindowIdExists(const WindowID window_id) const = 0;

  /**
   * @brief RegularHmiState of application without active events VR, TTS etc ...
   * @param window_id window id for HMI state
   * @return HmiState of application
   */
  virtual const HmiStatePtr RegularHmiState(const WindowID window_id) const = 0;

  /**
   * @brief Checks if app is allowed to change audio source
   * @return True - if allowed, otherwise - False
   */
  virtual bool IsAllowedToChangeAudioSource() const = 0;

  /**
   * @brief PostponedHmiState returns postponed hmi state of application
   * if it's present
   * @param window_id window id for HMI state
   * @return Postponed hmi state of application
   */
  virtual const HmiStatePtr PostponedHmiState(
      const WindowID window_id) const = 0;

  /**
   * @brief Keeps id of softbuttons which is created in commands:
   * Alert, Show, ScrollableMessage, ShowConstantTBT, AlertManeuver,
   * UpdateTurnList
   * @param cmd_id Unique command id from mobile API
   * @param window_softbuttons list of softbuttons were created by command.
   */
  virtual void SubscribeToSoftButtons(
      int32_t cmd_id, const WindowSoftButtons& window_softbuttons) = 0;

  /**
   * @brief Retreives window id on which given button is created
   * @param button_id identifier of a button
   * @param window id of a widget containing button
   */
  virtual WindowID GetSoftButtonWindowID(const uint32_t button_id) = 0;

  /**
   * @brief Determine the existence of softbutton
   * @param Softbutton_id contains id of softbutton
   * @return Returns true if application contains softbutton id otherwise
   * returns false.
   */
  virtual bool IsSubscribedToSoftButton(const uint32_t softbutton_id) = 0;

  /**
   * @brief Removes list of softbuttons which is created in commands
   * @param cmd_id Unique command id from mobile API
   */
  virtual void UnsubscribeFromSoftButtons(int32_t cmd_id) = 0;

  /**
   * @brief Check's if it is media, voice communication or navigation
   * application
   *
   * @return true if application is media, voice communication or navigation
   */
  virtual bool IsAudioApplication() const = 0;

  /**
   * @brief Check's if it is projection or navigation application
   *
   * @return true if application is projection or navigation
   */
  virtual bool IsVideoApplication() const = 0;

  /**
   * @brief IsRegistered allows to distinguish if this
   * application has been registered.
   *
   * @return true if registered, false otherwise.
   */
  virtual bool IsRegistered() const = 0;
  /**
   * @brief MarkRegistered allows to mark application as registered.
   */
  void MarkRegistered() {
    app_state_ = kRegistered;
  }

  /**
   * @brief MarkUnregistered allows to mark application as unregistered.
   */
  void MarkUnregistered() {
    app_state_ = kWaitingForRegistration;
  }

  /**
   * @brief schemaUrl contains application's url (for 4th protocol version)
   *
   * @return application's url.
   */
  std::string SchemaUrl() const {
    return url_;
  }

  /**
   * @brief SetShemaUrl allows to store schema url for application.
   *
   * @param url url to store.
   */
  void SetShemaUrl(const std::string& url) {
    url_ = url;
  }

  /**
   * @brief packagName allows to obtain application's package name.
   *
   * @return pakage name.
   */
  std::string PackageName() const {
    return package_name_;
  }

  /**
   * @brief SetPackageName allows to store package name for application.
   *
   * @param packageName package name to store.
   */
  void SetPackageName(const std::string& packageName) {
    package_name_ = packageName;
  }

  /**
   * @brief Returns is application should be greyed out on HMI
   */
  bool is_greyed_out() const {
    return is_greyed_out_;
  }

  /**
   * @brief Sets application as should be greyed out on HMI
   * @param is_greyed_out True, if should be greyed out on HMI,
   * otherwise - false
   */
  void set_greyed_out(bool is_greyed_out) {
    is_greyed_out_ = is_greyed_out;
  }
  /**
   * @brief Load persistent files from application folder.
   */
  virtual void LoadPersistentFiles() = 0;

  /**
   * @brief Get available app space
   * @param name of the app folder(make + mobile app id)
   * @return free app space.
   */
  virtual uint32_t GetAvailableDiskSpace() = 0;

  /**
   * @brief Allows to save mobile's command smart object in order to perform
   * this command later.
   * @param mobile_message the message smart_object.
   */
  virtual void PushMobileMessage(
      smart_objects::SmartObjectSPtr mobile_message) = 0;

  /**
   * @brief Allows to obtain the whole list of pending commands in order to
   * process them.
   * @param mobile_message the messages array which is filled by the method.
   */
  virtual void SwapMobileMessageQueue(MobileMessageQueue& mobile_messages) = 0;

  /**
   * @brief set_system_context Set system context for application
   * @param window_id window id for HMI state
   * @param system_context Current context
   */
  virtual void set_system_context(
      const WindowID window_id,
      const mobile_api::SystemContext::eType& system_context) = 0;

  /**
   * @brief set_audio_streaming_state Set audio streaming state for application
   * @param state Current audio streaming state
   */
  virtual void set_audio_streaming_state(
      const mobile_api::AudioStreamingState::eType& state) = 0;

  /**
   * @brief set_hmi_level Set HMI level for application
   * @param window_id window id for HMI state
   * @param hmi_level Current HMI level
   */
  virtual void set_hmi_level(const WindowID window_id,
                             const mobile_api::HMILevel::eType& hmi_level) = 0;

  /**
   * @brief Return pointer to extension by uid
   * @param uid uid of extension
   * @return Pointer to extension, if extension was initialized, otherwise NULL
   */
  virtual AppExtensionPtr QueryInterface(AppExtensionUID uid) = 0;

  /**
   * @brief Add extension to application
   * @param extension pointer to extension
   * @return true if success, false if extension already initialized
   */
  virtual bool AddExtension(AppExtensionPtr extention) = 0;

  /**
   * @brief Remove extension from application
   * @param uid uid of extension
   * @return true if success, false if extension is not present
   */
  virtual bool RemoveExtension(AppExtensionUID uid) = 0;

  /**
   * @brief Get list of available application extensions
   * @return application extensions
   */
  virtual const std::list<AppExtensionPtr>& Extensions() const = 0;

  /**
   * @brief Get cloud app endpoint for websocket connection
   * @return cloud app endpoint
   */
  virtual const std::string& cloud_app_endpoint() const = 0;

  /**
   * @brief Get cloud app auth token to be used in connection handshake after
   * websocket open.
   * @return cloud app auth token
   */
  virtual const std::string& auth_token() const = 0;

  /**
   * @brief Get cloud app transport type. Defines the type of websocket
   * connection used.
   * @return cloud app transport type
   */
  virtual const std::string& cloud_app_transport_type() const = 0;

  /**
   * @brief Get hybrid app preference. Defines behaviour for when a similar
   * mobile and cloud app are connected simultaneously.
   * @return hybrid app preference
   */
  virtual const mobile_apis::HybridAppPreference::eType& hybrid_app_preference()
      const = 0;

  /**
   * @brief Get cloud app certificate. Used for secured websocket connections.
   * @return cloud app certificate.
   */
  virtual const std::string& cloud_app_certificate() const = 0;

  /**
   * @brief Check whether the given application is a cloud app.
   * @return true if the application is a cloud application, false otherwise.
   */
  virtual bool is_cloud_app() const = 0;

  /**
   * @brief Set cloud app endpoint
   */
  virtual void set_cloud_app_endpoint(const std::string& endpoint) = 0;

  /**
   * @brief Set cloud app auth token
   */
  virtual void set_auth_token(const std::string& auth_token) = 0;

  /**
   * @brief Set cloud app transport type
   */
  virtual void set_cloud_app_transport_type(
      const std::string& transport_type) = 0;

  /**
   * @brief Set hybrid app preference
   */
  virtual void set_hybrid_app_preference(
      const mobile_apis::HybridAppPreference::eType& hybrid_app_preference) = 0;

  /**
   * @brief Set cloud app certificate
   */
  virtual void set_cloud_app_certificate(const std::string& certificate) = 0;

  /**
   * @brief Set user location
   * @param smart object of user location
   */
  virtual void set_user_location(
      const smart_objects::SmartObject& user_location) = 0;

  /**
   * @brief Get user location
   * @return smart object of user location
   */
  virtual const smart_objects::SmartObject& get_user_location() const = 0;

 protected:
  mutable sync_primitives::Lock hmi_states_lock_;

  ApplicationRegisterState app_state_;
  ApplicationState state_;
  std::string url_;
  std::string package_name_;
  std::string device_id_;
  ssize_t connection_id_;
  bool is_greyed_out_;
};

typedef std::shared_ptr<Application> ApplicationSharedPtr;
typedef std::shared_ptr<const Application> ApplicationConstSharedPtr;
typedef uint32_t ApplicationId;

}  // namespace application_manager

#endif  // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_