-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotePad.txt
1381 lines (1296 loc) · 59.7 KB
/
notePad.txt
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
/**********************************************************************
*
* \author vanhuy.tran@lge.com
*
* \date 12/12/2017
*
* \class %{Cpp:License:ClassName}
*
* \brief
*
***********************************************************************/
#include <QDebug>
#include <QObject>
#include <QQmlContext>
#include <QJsonArray>
#include <QJsonObject>
#include "SelectSourceInterface.h"
#include "SelectSourceDefine.h"
#include "util/JsonObject.h"
#include "util/SourceElement.h"
#include "SelectSourceAppMain.h"
#ifdef APP_ON_TARGET
#include "util/SelectSourceLog.h"
#include "ccf/CcfProvider.h"
#include "resourceservice/ResourceMsgDef.h"
#include "service/HmiBluetoothA2dpService.h"
#include "service/HmiBluetoothAvrcpService.h"
#include "service/HmiBluetoothPairedService.h"
#include "service/HmiMediaService.h"
#include "service/PopupService.h"
#ifndef EXCLUDE_ONLINEMEDIA
#include "service/HmiOnlineMediaService.h"
#endif
#include "service/SelectSourceService.h"
#include "service/HmiMediaSourceControlService.h"
#else
#include "resourceservice/ResourceMsgDef.h" // For S_RES_AUDIO_SOURCE_ID_LIST_T
#endif
SelectSourceInterface::SelectSourceInterface(QObject *parent)
: ISelectSourceInterface(parent)
, m_rootObject(nullptr)
, m_rootContext(nullptr)
, m_currentSource("")
, m_connectingSource("")
, m_strCurrAppBinaryName("")
, m_lastReceivedProvider("")
, m_isAnimation(false)
, m_lastSourceName("")
, m_isAppleExist(false)
{
#ifdef APP_ON_TARGET
m_selectSourceService = new SelectSourceService(this);
m_bluetoothA2dpService = new HmiBluetoothA2dpService(this);
m_bluetoothAvrcpService = new HmiBluetoothAvrcpService(this);
m_bluetoothPairedService = new HmiBluetoothPairedService(this);
m_hmiMediaService = new HmiMediaService(this);
m_popupService = new PopupService(this);
#ifndef EXCLUDE_ONLINEMEDIA
m_hmiOnlineMediaService = new HmiOnlineMediaService(this);
#endif
m_hmiMediaSourceControlService = new HmiMediaSourceControlService(this);
#endif
}
SelectSourceInterface::~SelectSourceInterface()
{
#ifdef APP_ON_TARGET
DELETE_PTR(m_selectSourceService);
DELETE_PTR(m_bluetoothA2dpService);
DELETE_PTR(m_bluetoothAvrcpService);
DELETE_PTR(m_bluetoothPairedService);
DELETE_PTR(m_hmiMediaService);
DELETE_PTR(m_popupService);
#ifndef EXCLUDE_ONLINEMEDIA
DELETE_PTR(m_hmiOnlineMediaService);
#endif
DELETE_PTR(m_popupService);
DELETE_PTR(m_hmiMediaSourceControlService);
#endif
}
void SelectSourceInterface::setRootObject(QObject *rootObject)
{
m_rootObject = rootObject;
}
void SelectSourceInterface::setRootContext(QQmlContext *rootContext)
{
m_rootContext = rootContext;
}
/************* virtual functions **************/
#ifdef APP_ON_TARGET
void SelectSourceInterface::initialize(OnBaseListener* engine)
{
this->initializeSelectSourceService(engine);
this->initializeBluetoothA2dpService(engine);
this->initializeBluetoothAvrcpService(engine);
this->initializeBluetoothPairedService();
this->initializeHmiMediaService(engine);
this->initializePopupService(engine);
this->initializeHmiOnlineMediaService(engine);
this->initializeHmiMediaSourceControlService(engine);
}
void SelectSourceInterface::registerListeners(OnBaseListener* engine)
{
this->registerListenersSelectSourceService(engine);
this->registerListenersBluetoothA2dpService(engine);
this->registerListenersBluetoothAvrcpService(engine);
this->registerListenersBluetoothPairedService(engine);
this->registerListenersHmiMediaService(engine);
this->registerListenersPopupService(engine);
this->registerListenersHmiOnlineMediaService(engine);
this->registerListenersHmiMediaSourceControlService(engine);
}
void SelectSourceInterface::terminate()
{
}
void SelectSourceInterface::terminateSelectSourceService()
{
m_selectSourceService->terminate();
}
void SelectSourceInterface::terminateBluetoothA2dpService()
{
m_bluetoothA2dpService->terminate();
}
void SelectSourceInterface::terminateBluetoothAvrcpService()
{
m_bluetoothAvrcpService->terminate();
}
void SelectSourceInterface::terminateBluetoothPairedService()
{
m_bluetoothPairedService->terminate();
}
void SelectSourceInterface::terminateHmiMediaService()
{
m_hmiMediaService->terminate();
}
void SelectSourceInterface::terminatePopupService()
{
m_popupService->terminate();
}
void SelectSourceInterface::terminateHmiOnlineMediaService()
{
#ifndef EXCLUDE_ONLINEMEDIA
m_hmiOnlineMediaService->terminate();
#endif
}
void SelectSourceInterface::terminateHmiMediaSourceControlService()
{
m_hmiMediaSourceControlService->terminate();
}
void SelectSourceInterface::unRegisterListeners(OnBaseListener *_engine)
{
}
void SelectSourceInterface::unRegisterListenersSelectSourceService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnResourceListener*)m_selectSourceService);
}
void SelectSourceInterface::unRegisterListenersBluetoothA2dpService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnBtA2dpListener*)m_bluetoothA2dpService);
}
void SelectSourceInterface::unRegisterListenersBluetoothAvrcpService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnBtAvrcpListener*)m_bluetoothAvrcpService);
_engine->unRegisterListener((IOnBtGapListener*)m_bluetoothAvrcpService);
}
void SelectSourceInterface::unRegisterListenersBluetoothPairedService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnBtGapListener*)m_bluetoothPairedService);
}
void SelectSourceInterface::unRegisterListenersHmiMediaService(OnBaseListener *_engine)
{
_engine->unRegisterListener((MediaLib::IOnMediaListener*)m_hmiMediaService);
}
void SelectSourceInterface::unRegisterListenersPopupService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnPopupListener*)m_popupService);
}
void SelectSourceInterface::unRegisterListenersHmiOnlineMediaService(OnBaseListener *_engine)
{
#ifndef EXCLUDE_ONLINEMEDIA
_engine->unRegisterListener((OnlineMediaLib::IOnOnlineMediaListener*)m_hmiOnlineMediaService);
#endif
}
void SelectSourceInterface::unRegisterListenersHmiMediaSourceControlService(OnBaseListener *_engine)
{
_engine->unRegisterListener((IOnMediaSourceControlListener*)m_hmiMediaSourceControlService);
}
void SelectSourceInterface::initializeSelectSourceService(OnBaseListener *_engine)
{
m_selectSourceService->initialize(_engine);
}
void SelectSourceInterface::initializeBluetoothA2dpService(OnBaseListener *_engine)
{
m_bluetoothA2dpService->initialize(_engine);
}
void SelectSourceInterface::initializeBluetoothAvrcpService(OnBaseListener *_engine)
{
m_bluetoothAvrcpService->initialize(_engine);
}
void SelectSourceInterface::initializeBluetoothPairedService()
{
m_bluetoothPairedService->initialize();
}
void SelectSourceInterface::initializeHmiMediaService(OnBaseListener *_engine)
{
m_hmiMediaService->initialize(_engine);
}
void SelectSourceInterface::initializePopupService(OnBaseListener *_engine)
{
m_popupService->initialize(_engine);
}
void SelectSourceInterface::initializeHmiOnlineMediaService(OnBaseListener *_engine)
{
#ifndef EXCLUDE_ONLINEMEDIA
m_hmiOnlineMediaService->initialize(_engine);
#endif
}
void SelectSourceInterface::initializeHmiMediaSourceControlService(OnBaseListener *_engine)
{
m_hmiMediaSourceControlService->initialize(_engine);
}
void SelectSourceInterface::registerListenersSelectSourceService(OnBaseListener *_engine)
{
_engine->registerListener((BrResourceListener*)m_selectSourceService);
_engine->registerListener((BrAppListener*)m_selectSourceService);
_engine->registerListener((IOnResourceListener*)m_selectSourceService);
}
void SelectSourceInterface::registerListenersBluetoothA2dpService(OnBaseListener *_engine)
{
_engine->registerListener((BrBtA2dpListener*)m_bluetoothA2dpService);
_engine->registerListener((IOnBtA2dpListener*)m_bluetoothA2dpService);
}
void SelectSourceInterface::registerListenersBluetoothAvrcpService(OnBaseListener *_engine)
{
_engine->registerListener((BrBtAvrcpListener*)m_bluetoothAvrcpService);
_engine->registerListener((IOnBtAvrcpListener*)m_bluetoothAvrcpService);
_engine->registerListener((IOnBtGapListener*)m_bluetoothAvrcpService);
}
void SelectSourceInterface::registerListenersBluetoothPairedService(OnBaseListener *_engine)
{
_engine->registerListener((IOnBtGapListener*)m_bluetoothPairedService);
}
void SelectSourceInterface::registerListenersHmiMediaService(OnBaseListener *_engine)
{
_engine->registerListener((MediaLib::IOnMediaListener*)m_hmiMediaService);
}
void SelectSourceInterface::registerListenersPopupService(OnBaseListener *_engine)
{
_engine->registerListener((IOnPopupListener*)m_popupService);
}
void SelectSourceInterface::registerListenersHmiOnlineMediaService(OnBaseListener *_engine)
{
#ifndef EXCLUDE_ONLINEMEDIA
_engine->registerListener((OnlineMediaLib::IOnOnlineMediaListener*)m_hmiOnlineMediaService);
#endif
}
void SelectSourceInterface::registerListenersHmiMediaSourceControlService(OnBaseListener *_engine)
{
_engine->registerListener((BrMediaSourceControlListener*)m_hmiMediaSourceControlService);
_engine->registerListener((IOnMediaSourceControlListener*)m_hmiMediaSourceControlService);
}
#endif
/*******************************************
** HMI -> service
*******************************************/
void SelectSourceInterface::requestGetAvailableAudioSources(QString source, int deviceStatus)
{
#ifdef APP_ON_TARGET
if(source == "")
m_selectSourceService->requestResourceSvc_GetAvailableAudioSources(0);
else {
SourceElementPtr sourceElement;
bool isKnewSource = false;
for(int i = 0; i < m_fullList.count(); i++) {
if(m_fullList[i]->deviceId().contains(source)) {
sourceElement = m_fullList[i];
isKnewSource = true;
break;
}
}
if(isKnewSource == false) {
m_selectSourceService->requestResourceSvc_GetAvailableAudioSources(0);
}
else {
if(deviceStatus == E_BT_GAP_STATE_CONNECTED) {
this->requestUpdateReadyLoading(source, true, false);
if(source == m_connectingSource) {
m_connectingSource = "";
string addr = "";
int sourceId = sourceElement->sourceId();
E_BT_SERVICE_ERROR_CODE result;
m_bluetoothA2dpService->getSourceIdAddressSync(E_RES_BT_A2DP0, addr, result);
MTLOG_I(TAG, "Source[%s] A2DP0[%s]", source.toStdString().c_str(), addr.c_str());
if (addr.compare(source.toStdString()) == 0) {
sourceId = E_RES_BT_A2DP0;
MTLOG_I(TAG, "Source ID: A2DP0");
} else {
m_bluetoothA2dpService->getSourceIdAddressSync(E_RES_BT_A2DP1, addr, result);
MTLOG_I(TAG, "Source[%s] A2DP1[%s]", source.toStdString().c_str(), addr.c_str());
if (addr.compare(source.toStdString()) == 0) {
sourceId = E_RES_BT_A2DP1;
MTLOG_I(TAG, "Source ID: A2DP1");
}
}
emit requestToGoToApplication(sourceId, sourceElement->name(),
sourceElement->deviceId(), sourceElement->basePath(),
sourceElement->deviceType(), sourceElement->providerId(),
sourceElement->urlImage(), sourceElement->supportAnonymous(),
sourceElement->supportFreemium(), sourceElement->supportPremium(),
sourceElement->isSelected(), sourceElement->isAuthorized(), sourceElement->hasMediaFile(),
sourceElement->macAddress(), m_lastSourceQML, false);
}
} else if(deviceStatus == E_BT_GAP_STATE_DISCONNECTED){
this->requestUpdateReadyLoading(source, false, false);
if(source == m_currentSource){
m_currentSource = "";
this->clearWhenDisconnectedDevice(m_currentSource , -1);
}
if(source == m_connectingSource) {
m_connectingSource = "";
this->requestShowPopupReconnectFail();
}
}
}
}
#else
m_fullList.clear();
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_DEFAULT_AUDIO_SOURCE,
"ADD", "selectSourceItemAdd")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BROADCAST_AM,
"AM RADIO", "selectSourceItemAM")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BROADCAST_SXM_SAT,
"SXM SAT RADIO", "selectSourceItemSxm")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BROADCAST_DAB, "DAB RADIO", "selectSourceItemDab")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_MEDIA_PLAYBACK_USB0,
"USB", "selectSourceItemUsb")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_MEDIA_PLAYBACK_USB0,
"S7 EDGE", "selectSourceItemPhone")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_MEDIA_PLAYBACK_USB0,
"AUX", "selectSourceItemAux")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BT_A2DP0,
"Galaxy A5", "selectSourceItemBluetooth")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BT_A2DP1,
"Galaxy S8", "selectSourceItemBluetooth")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_BT_A2DP1,
"iPhone XS", "selectSourceItemBluetooth")));
m_fullList[m_fullList.count() - 1]->setIsReady(false);
m_fullList[m_fullList.count() - 1]->setDeviceId("2B:3E:4F:4D");
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_CARPLAY_MEDIA,
"Car Play", "selectSourceItemCarPlay")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_ANDROID_AUTO_MEDIA,
"Android Auto", "selectSourceItemAndroidAuto")));
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_CARLIFE_MEDIA,
"Baidu Carlife", "selectSourceItemBaiduCarlife")));
m_offlineList = m_fullList;
this->getOnlineMediaSourceList();
#endif
}
bool SelectSourceInterface::isSourceFromMediaApp(SourceElementPtr source)
{
bool result = false;
switch(source->sourceId()) {
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB0:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB1:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB2:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB3:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB4:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB5:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB6:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB7:
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP0:
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP1:
case E_RES_AUDIO_SOURCE_ID::E_RES_CARPLAY_MEDIA:
case E_RES_AUDIO_SOURCE_ID::E_RES_ANDROID_AUTO_MEDIA:
case E_RES_AUDIO_SOURCE_ID::E_RES_CARLIFE_MEDIA:
result = true;
break;
default:
break;
}
return result;
}
void SelectSourceInterface::onSigSetCurrentProviderId(QString providerId)
{
this->MediaSvc_SetCurrentProviderId(providerId.toStdString());
}
void SelectSourceInterface::getOnlineMediaSourceList()
{
#ifdef APP_ON_TARGET
#ifndef EXCLUDE_ONLINEMEDIA
MTLOG_I(TAG, "Request get online provider\n");
m_hmiOnlineMediaService->MediaSvc_GetProviders();
#endif
#else
QString rcvDataStr("{\"data\":[{\"providerId\":\"spotify\",\"providerName\":\"Spotify\",\"supportAnonymous\":false,\"supportFreemium\":false,\"supportPremium\":true,\"isSelected\":true,\"isAuthorized\":true,\"providerArtwork\":\"https://s3-us-west-1.amazonaws.com/static.justdrive.cloudcar.com/image/provider/provider_spotify.png\",\"supportedContentTypes\":[\"track\",\"album\",\"artist\",\"playlist\",\"radio\",\"genre\"]},{\"providerId\":\"deezer\",\"providerName\":\"Deezer\",\"supportAnonymous\":false,\"supportFreemium\":true,\"supportPremium\":true,\"isSelected\":true,\"isAuthorized\":true,\"providerArtwork\":\"https://s3-us-west-1.amazonaws.com/static.justdrive.cloudcar.com/image/provider/provider_deezer.png\",\"supportedContentTypes\":[\"track\",\"album\",\"artist\",\"playlist\",\"radio\",\"genre\",\"ccflow\"],\"isPremium\":true},{\"providerId\":\"npr\",\"providerName\":\"NPR\",\"supportAnonymous\":false,\"supportFreemium\":true,\"supportPremium\":false,\"isSelected\":true,\"isAuthorized\":false,\"providerArtwork\":\"https://s3-us-west-1.amazonaws.com/static.justdrive.cloudcar.com/image/provider/provider_npr.png\",\"supportedContentTypes\":[\"podcast\",\"episode\"]},{\"providerId\":\"tunein\",\"providerName\":\"TuneIn\",\"supportAnonymous\":true,\"supportFreemium\":false,\"supportPremium\":false,\"isSelected\":true,\"isAuthorized\":false,\"providerArtwork\":\"https://s3-us-west-1.amazonaws.com/static.justdrive.cloudcar.com/image/provider/provider_tunein.png\",\"supportedContentTypes\":[\"podcast\",\"station\",\"episode\"]},{\"providerId\":\"amazon\",\"providerName\":\"amazon\",\"supportAnonymous\":false,\"supportFreemium\":false,\"supportPremium\":true,\"isSelected\":true,\"isAuthorized\":false,\"providerArtwork\":\"https://s3-us-west-1.amazonaws.com/static.justdrive.cloudcar.com/image/provider/provider_amazon_music.svg\",\"supportedContentTypes\":[\"track\",\"album\",\"artist\",\"playlist\",\"radio\",\"genreee\"]}]}");
this->MediaSvc_onGetProviders(rcvDataStr);
#endif
}
/*******************************************
** Service -> HMI
*******************************************/
#ifdef APP_ON_TARGET
void SelectSourceInterface::getAvailableRadioSources(const S_RES_AUDIO_SOURCE_ID_LIST_T& availableSourceIds)
{
SourceElementPtr sourceBroadcastAM = nullptr;
SourceElementPtr sourceBroadcastFM = nullptr;
SourceElementPtr sourceBroadcastDAB = nullptr;
SourceElementPtr sourceBroadcastSXMSAT = nullptr;
for (int dwCount = 0; dwCount < availableSourceIds.count; dwCount++) {
switch(availableSourceIds.data[dwCount]) {
case E_RES_AUDIO_SOURCE_ID::E_RES_INVALID_AUDIO_SOURCE:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_DEFAULT_AUDIO_SOURCE:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB0:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB1:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB2:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB3:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB4:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB5:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB6:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB7:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_SPOTIFY:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_AUDIBLE:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_TUNEIN:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_DEEZER:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING0:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING1:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING2:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING3:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING4:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING5:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING6:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING7:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING8:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING9:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING10:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING11:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING12:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING13:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING14:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING15:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING16:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING17:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING18:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING19:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP0:
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP1:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_AM:
sourceBroadcastAM = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceBroadcastAM->setName("AM RADIO");
sourceBroadcastAM->setDeviceId("AM");
sourceBroadcastAM->setObjectImage("selectSourceItemAM");
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM:
sourceBroadcastFM = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceBroadcastFM->setName("FM RADIO");
sourceBroadcastFM->setDeviceId("FM");
sourceBroadcastFM->setObjectImage("selectSourceItemFM");
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DAB:
sourceBroadcastDAB = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceBroadcastDAB->setName("DAB RADIO");
sourceBroadcastDAB->setDeviceId("DAB");
sourceBroadcastDAB->setObjectImage("selectSourceItemDab");
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DRM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_SXM_SAT:
sourceBroadcastSXMSAT = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceBroadcastSXMSAT->setName("SXM SAT RADIO");
sourceBroadcastSXMSAT->setDeviceId("SXM");
sourceBroadcastSXMSAT->setObjectImage("selectSourceItemSxm");
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_SXM_IP:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_CONNECTEDRADIO_IP:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_ISDBT:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_CARPLAY_MEDIA:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_ANDROID_AUTO_MEDIA:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_CARLIFE_MEDIA:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_TTS_EMAIL:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_TTS_SMS:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_NEWS:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_TA:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_ALARM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DAB_ANNOUNCEMENT:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_MAX_AUDIO_SOURCE_ID:
MTLOG_W(TAG, "WARNING: Did not process source E_RES_MAX_AUDIO_SOURCE_ID\n");
break;
default:
MTLOG_W(TAG, "WARNING: Did not process source default: %d\n", availableSourceIds.data[dwCount]);
break;
}
}
if(sourceBroadcastAM != nullptr){
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceBroadcastAM->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceBroadcastAM);
}
}
if(sourceBroadcastFM != nullptr){
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceBroadcastFM->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceBroadcastFM);
}
}
if(sourceBroadcastDAB != nullptr){
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceBroadcastDAB->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceBroadcastDAB);
}
}
if(sourceBroadcastSXMSAT != nullptr){
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceBroadcastSXMSAT->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceBroadcastSXMSAT);
}
}
}
void SelectSourceInterface::getAvailableAdditionalDevices(const S_RES_AUDIO_SOURCE_ID_LIST_T &availableSourceIds)
{
SourceElementPtr sourceCarPlayMedia = nullptr;
SourceElementPtr sourceAndroidAutoMedia = nullptr;
SourceElementPtr sourceCarLifeMedia = nullptr;
for (int dwCount = 0; dwCount < availableSourceIds.count; dwCount++) {
MTLOG_I(TAG, "availableSourceIds: %d dwCount %d \n", availableSourceIds.data[dwCount], dwCount);
switch(availableSourceIds.data[dwCount]) {
case E_RES_AUDIO_SOURCE_ID::E_RES_INVALID_AUDIO_SOURCE:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_DEFAULT_AUDIO_SOURCE:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB0:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB1:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB2:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB3:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB4:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB5:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB6:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_USB7:
this->getConnectedMediaDeviceListSync();
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_SPOTIFY:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_AUDIBLE:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_TUNEIN:
case E_RES_AUDIO_SOURCE_ID::E_RES_MEDIA_PLAYBACK_STREAMING_DEEZER:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING0:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING1:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING2:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING3:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING4:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING5:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING6:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING7:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING8:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING9:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING10:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING11:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING12:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING13:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING14:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING15:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING16:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING17:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING18:
case E_RES_AUDIO_SOURCE_ID::E_RES_ONLINEMEDIA_STREAMING19:
this->getOnlineMediaList();
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP0:
case E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP1:
this->getConnectedBluetoothDevices();
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_AM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DAB:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DRM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_SXM_SAT:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_SXM_IP:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_CONNECTEDRADIO_IP:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_ISDBT:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_CARPLAY_MEDIA:{
sourceCarPlayMedia = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceCarPlayMedia->setName("Car Play");
sourceCarPlayMedia->setDeviceId("CAR_PLAY");
sourceCarPlayMedia->setObjectImage("selectSourceItemCarPlay");
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceCarPlayMedia->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceCarPlayMedia);
}
break;
}
case E_RES_AUDIO_SOURCE_ID::E_RES_ANDROID_AUTO_MEDIA:{
sourceAndroidAutoMedia = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceAndroidAutoMedia->setName("Android Auto");
sourceAndroidAutoMedia->setDeviceId("ANDROID_AUTO");
sourceAndroidAutoMedia->setObjectImage("selectSourceItemAndroidAuto");
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceAndroidAutoMedia->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceAndroidAutoMedia);
}
break;
}
case E_RES_AUDIO_SOURCE_ID::E_RES_CARLIFE_MEDIA:{
sourceCarLifeMedia = SourceElementPtr(new SourceElement(availableSourceIds.data[dwCount]));
sourceCarLifeMedia->setName("Baidu Carlife");
sourceCarLifeMedia->setDeviceId("BAIDU_CARLIFE");
sourceCarLifeMedia->setObjectImage("selectSourceItemBaiduCarlife");
bool check = false;
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->name() == sourceCarLifeMedia->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(sourceCarLifeMedia);
}
break;
}
case E_RES_AUDIO_SOURCE_ID::E_RES_TTS_EMAIL:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_TTS_SMS:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_NEWS:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_TA:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_FM_ALARM:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_BROADCAST_DAB_ANNOUNCEMENT:
break;
case E_RES_AUDIO_SOURCE_ID::E_RES_MAX_AUDIO_SOURCE_ID:
MTLOG_W(TAG, "WARNING: Did not process source E_RES_MAX_AUDIO_SOURCE_ID\n");
break;
default:
MTLOG_W(TAG, "WARNING: Did not process source default: %d\n", availableSourceIds.data[dwCount]);
break;
}
}
MTLOG_I(TAG, "Available audio source: %d\n", availableSourceIds.count);
}
SourceElementPtr SelectSourceInterface::convertSourceUSBFromMediaDevice(std::list<MediaLib::mediaDevice>::iterator& it)
{
SourceElementPtr source = SourceElementPtr(new SourceElement(0));
source->setSourceId(E_RES_AUDIO_SOURCE_ID(it->audioSourceID));
source->setName(QString(it->name.c_str()));
source->setDeviceId(QString(it->deviceID.c_str()));
source->setBasePath(QString(it->basePath.c_str()));
source->setDeviceType(it->deviceType);
source->setHasMediaFile(it->hasMediaFile);
switch(it->deviceType) {
case MediaLib::DeviceType::DEVICE_TYPE_USB:
source->setObjectImage("selectSourceItemUsb");
break;
case MediaLib::DeviceType::DEVICE_TYPE_MTP:
source->setObjectImage("selectSourceItemPhone");
break;
case MediaLib::DeviceType::DEVICE_TYPE_IPOD:
source->setObjectImage("selectSourceItemUsb");//selectSourceItemPhone
break;
case MediaLib::DeviceType::DEVICE_TYPE_IAP2:
source->setObjectImage("selectSourceItemUsb");//selectSourceItemPhone
break;
case MediaLib::DeviceType::DEVICE_TYPE_LOCALDRIVE:
source->setObjectImage("selectSourceItemPhone");
break;
default:
source->setObjectImage("selectSourceItemPhone");
break;
}
return source;
}
void SelectSourceInterface::getConnectedMediaDeviceListSync()
{
MTLOG_I(TAG , " ==== \n");
std::list<MediaLib::mediaDevice> mediaDeviceList;
// Request media service to get data detail connect
bool bRet = m_hmiMediaService->MediaSvc_GetConnectedMediaDeviceList_Sync(mediaDeviceList);
if (true != bRet) {
MTLOG_E(TAG, "request HmiMedia Get Device Connect return false\n");
}
else {
// Set name of list
std::list<MediaLib::mediaDevice>::iterator it = mediaDeviceList.begin();
for (; it != mediaDeviceList.end(); ++it) {
bool check = false;
SourceElementPtr source = this->convertSourceUSBFromMediaDevice(it);
for(int i = 0 ; i < m_fullList.size() ; i++){
if(m_fullList.at(i)->deviceId() == source->deviceId()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(source);
}
}
}
}
void SelectSourceInterface::getOnlineMediaList()
{
if(m_listOnline.size() > 0){
for(int i = 0 ; i < m_listOnline.size() ; i++){
bool check2 = false;
for(int j = 0 ; j < m_fullList.size() ; j++){
if(m_listOnline.at(i)->name() == m_fullList.at(j)->name()){
check2 = true;
break;
}
}
if(check2 == false){
m_fullList.append(m_listOnline.at(i));
}
}
}
}
void SelectSourceInterface::onResponseGetAvailableAudioSources(const S_RES_AUDIO_SOURCE_ID_LIST_T& availableSourceIds)
{
m_fullList.clear();
m_fullList.append(SourceElementPtr(new SourceElement(E_RES_AUDIO_SOURCE_ID::E_RES_DEFAULT_AUDIO_SOURCE,
"ADD", "selectSourceItemAdd")));
if(m_lastFullList.size() > 1 && m_fullList.size() > 0){
for(int i = 0 ; i < m_lastFullList.size() ; i++)
{
bool check = false;
for(int j = 0 ; j < m_fullList.size() ; j++){
if(m_lastFullList.at(i)->name() == m_fullList.at(j)->name()){
check = true;
break;
}
}
if(check == false){
m_fullList.append(m_lastFullList.at(i));
}
}
}
this->getAvailableRadioSources(availableSourceIds);
this->getAvailableAdditionalDevices(availableSourceIds);
this->getPairedBluetoothDevices();
for(int i = 0 ; i < m_fullList.count() ; i++){
if ((m_fullList[i]->deviceType() == static_cast<int>(MediaLib::DeviceType::DEVICE_TYPE_IAP2))||(m_fullList[i]->deviceType() == static_cast<int>(MediaLib::DeviceType::DEVICE_TYPE_IPOD))) {
m_mappingIndexUSBIphoneConnected.insert(m_fullList[i]->name(), i);
// m_indexUSBIphoneConnected = i;
m_isAppleExist = true;
MTLOG_I(TAG , "m_mappingIndexUSBIphoneConnected: %d \n" ,i);
break;
}
else {
m_isAppleExist = false;
}
}
if (m_isAppleExist == true) {
QMap<QString, int>::iterator i;
for(i = m_mappingIndexUSBIphoneConnected.begin(); i != m_mappingIndexUSBIphoneConnected.end(); ++i){
QString temPoSourceName = m_fullList.at(i.value())->name();
int idxBluetooth = -1;
MTLOG_I(TAG, "temPoSourceName %s \n", temPoSourceName.toStdString().c_str());
for(int i = 0; i < m_fullList.count(); i++){
if ((m_fullList.at(i)->name() == temPoSourceName)
&& ((m_fullList.at(i)->sourceId() == E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP0)
|| (m_fullList.at(i)->sourceId() == E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP1))) {
idxBluetooth = i;
m_lastSourceName = m_fullList.at(i)->name();
MTLOG_I(TAG, "index Bluetooh %d \n", idxBluetooth);
break;
}
}
if((i.value() > idxBluetooth) && (idxBluetooth != -1)) {
m_fullList.replace(idxBluetooth, m_fullList.at(i.value()));
m_fullList.removeAt(i.value());
m_mappingIndexUSBIphoneConnected.insert(m_lastSourceName, idxBluetooth);
// m_indexUSBIphoneConnected = idxBluetooth;
}
else {
if(idxBluetooth != -1){
m_fullList.removeAt(idxBluetooth);
}
}
idxBluetooth = -1;
}
}
else if((m_isAppleExist == false) ) { //&& (m_lastSourceName != "") && (m_indexUSBIphoneConnected > -1)
int idxBluetooth = -1;
QMap<QString, int>::iterator i;
for(i = m_mappingIndexUSBIphoneConnected.begin(); i != m_mappingIndexUSBIphoneConnected.end(); ++i){
QString temPoSourceName = m_fullList.at(i.value())->name();
for(int i = 0; i < m_fullList.count(); i++) {
if((temPoSourceName == m_fullList.at(i)->name())
&& ((m_fullList.at(i)->sourceId() == E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP0)
|| (m_fullList.at(i)->sourceId() == E_RES_AUDIO_SOURCE_ID::E_RES_BT_A2DP1))) {
idxBluetooth = i;
MTLOG_I(TAG, " isUsbExist index Bluetooh disconect %d \n", idxBluetooth);
break;
}
}
if(idxBluetooth > -1 && (idxBluetooth < m_fullList.count())) {
m_fullList.swap(i.value(), idxBluetooth);
}
}
m_mappingIndexUSBIphoneConnected.clear();
}
m_offlineList = m_fullList;
m_lastFullList = m_fullList;
if(m_getMore.size() > 0){
m_fullList.append(m_getMore);
}
emit getResourceList(m_fullList, m_currentSource); // Upload Gui
}
#endif
void SelectSourceInterface::MediaSvc_onGetProviders(QString rcvDataStr)
{
/// TODO: check return data changed or not
if (rcvDataStr != m_lastReceivedProvider) {
MTLOG_I(TAG, "=== online source changed ===\n");
m_lastReceivedProvider = rcvDataStr;
m_listOnline.clear();
m_listGetMore.clear();
m_getMore.clear();
QJsonObject jsonObject = JsonObject::objectFromString(rcvDataStr);
QJsonArray jsonArray = jsonObject["data"].toArray();
foreach (const QJsonValue & value, jsonArray) {
QJsonObject obj = value.toObject();
QString providerId = obj["providerId"].toString();
QString providerName = obj["providerName"].toString();
QString providerArtwork = obj["providerArtwork"].toString();
bool supportAnonymous = obj["supportAnonymous"].toBool();
bool supportFreemium = obj["supportFreemium"].toBool();
bool supportPremium = obj["supportPremium"].toBool();
bool isSelected = obj["isSelected"].toBool();
bool isAuthorized = obj["isAuthorized"].toBool();
int sourceId = m_mappingAudioSource.key(providerId);
SourceElementPtr onlineMediaSource = SourceElementPtr(new SourceElement(0));
onlineMediaSource->setSourceId(sourceId);
onlineMediaSource->setDeviceId(providerId.toUpper());
onlineMediaSource->setObjectImage("urlImage");
onlineMediaSource->setOnlineMediaInfo(providerId, providerName, providerArtwork, supportAnonymous,
supportFreemium, supportPremium, isSelected, isAuthorized);
if (supportAnonymous || isAuthorized) {
if (true == isSelected) {
m_listOnline.push_back(onlineMediaSource);
}
else {
m_listGetMore.push_back(onlineMediaSource);
}
}
else {
m_listGetMore.push_back(onlineMediaSource);
MTLOG_E(TAG, "SORRY, DOES NOT SUPPORT: %s\n", providerId.toStdString().c_str());
}
}
if (m_listGetMore.count() > 0) {
SourceElementPtr getMoreSource = SourceElementPtr(new SourceElement(E_RES_DEFAULT_AUDIO_SOURCE,
"", ""));
getMoreSource->setGetMore(m_listGetMore.count());
m_getMore.push_back(getMoreSource);
}
#ifdef APP_ON_DESKTOP
if(m_listOnline.count() > 0){
m_fullList = m_offlineList;
m_fullList.append(m_listOnline);
m_fullList.append(m_getMore);
emit getResourceList(m_fullList , m_currentSource);
}
#endif
} else {
MTLOG_I(TAG, "=== online source not changed ===\n");
}
}
void SelectSourceInterface::requestGetMoreSource()
{
MTLOG_I(TAG, "m_currentSource %s \n", m_currentSource.toStdString().c_str());
emit getSourceMore(m_listGetMore, m_currentSource);
}
void SelectSourceInterface::setLastSourceQML(QString lastSourceQML)
{
if (m_lastSourceQML != lastSourceQML) {
m_lastSourceQML = lastSourceQML;
}
}
void SelectSourceInterface::setCurrentSourceQML(QString currentSourceQML)
{
MTLOG_I(TAG, "Source %s \n", currentSourceQML.toStdString().c_str());