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
|
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file task_manifest_file.cpp
* @author Pawel Sikorski (p.sikorski@samgsung.com)
* @version
* @brief
*/
//SYSTEM INCLUDES
#include <string>
#include <dpl/assert.h>
#include <dirent.h>
#include <fstream>
#include <ail.h>
//WRT INCLUDES
#include <widget_install/task_manifest_file.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/log/log.h>
#include <dpl/file_input.h>
#include <dpl/file_output.h>
#include <dpl/copy.h>
#include <dpl/exception.h>
#include <dpl/foreach.h>
#include <dpl/sstream.h>
#include <dpl/string.h>
#include <dpl/optional.h>
#include <dpl/utils/wrt_utility.h>
#include <map>
#include <libxml_utils.h>
#include <pkgmgr/pkgmgr_parser.h>
#define DEFAULT_ICON_NAME "icon.png"
using namespace WrtDB;
namespace {
typedef std::map<DPL::String, DPL::String> LanguageTagMap;
LanguageTagMap getLanguageTagMap()
{
LanguageTagMap map;
#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag));
#include "languages.def"
#undef ADD
return map;
}
DPL::OptionalString getLangTag(const DPL::String& tag)
{
static LanguageTagMap TagsMap =
getLanguageTagMap();
DPL::String langTag = tag;
LogDebug("Trying to map language tag: " << langTag);
size_t pos = langTag.find_first_of(L'_');
if (pos != DPL::String::npos) {
langTag.erase(pos);
}
DPL::OptionalString ret;
LanguageTagMap::iterator it = TagsMap.find(langTag);
if (it != TagsMap.end()) {
ret = it->second;
}
LogDebug("Mapping IANA Language tag to language tag: " <<
langTag << " -> " << ret);
return ret;
}
}
namespace Jobs {
namespace WidgetInstall {
const char * TaskManifestFile::encoding = "UTF-8";
TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
DPL::TaskDecl<TaskManifestFile>(this),
m_context(inCont)
{
if (false == m_context.existingWidgetInfo.isExist) {
AddStep(&TaskManifestFile::stepCopyIconFiles);
AddStep(&TaskManifestFile::stepCreateExecFile);
AddStep(&TaskManifestFile::stepGenerateManifest);
AddStep(&TaskManifestFile::stepParseManifest);
AddStep(&TaskManifestFile::stepFinalize);
} else {
// for widget update.
AddStep(&TaskManifestFile::stepBackupIconFiles);
AddStep(&TaskManifestFile::stepCopyIconFiles);
AddStep(&TaskManifestFile::stepGenerateManifest);
AddStep(&TaskManifestFile::stepParseUpgradedManifest);
AddStep(&TaskManifestFile::stepUpdateFinalize);
AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
}
}
TaskManifestFile::~TaskManifestFile()
{
}
void TaskManifestFile::stepCreateExecFile()
{
//ln -s /usr/bin/wrt-client {widget-handle}
std::ostringstream real_path;
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if (pkgname.IsNull()) {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
real_path << m_context.locations->getBinaryDir() << "/" << m_context.widgetHandle;
std::string clientExeStr = GlobalConfig::GetWrtClientExec();
LogInfo("link -s " << clientExeStr << " " << real_path.str());
symlink(clientExeStr.c_str(), real_path.str().c_str());
m_context.job->UpdateProgress(
InstallerContext::INSTALL_CREATE_EXECFILE,
"Widget execfile creation Finished");
}
void TaskManifestFile::stepCopyIconFiles()
{
LogDebug("CopyIconFiles");
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if (pkgname.IsNull()) {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
Assert(!!m_context.widgetHandle);
WidgetDAOReadOnly dao(*m_context.widgetHandle);
WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
FOREACH(it, locList)
{
DPL::String i = it->widgetLocale;
DPL::OptionalString src;
FOREACH(icon, list)
{
if (icon->iconId == it->iconId) {
src = icon->iconSrc;
}
}
LogDebug("Icon for locale: " << i << "is : " << src);
std::ostringstream sourceFile;
std::ostringstream targetFile;
if (!!src) {
sourceFile << m_context.locations->getSourceDir() << "/";
if (!i.empty()) {
sourceFile << "locales/" << i << "/";
}
sourceFile << *src;
targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
targetFile << getIconTargetFilename(i);
if (m_context.locations->browserRequest())
{
m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
}
} else {
//Use WRT default (not from the widget) only if widget default (not
// localized) doesn't exist.
if (i.empty()) {
LogError("Using Default Icon for widget");
sourceFile << GlobalConfig::GetUserWidgetDefaultIconFile();
} else {
continue;
}
}
LogDebug("Copying icon: " << sourceFile.str() <<
" -> " << targetFile.str());
icon_list.push_back(targetFile.str());
Try
{
DPL::FileInput input(sourceFile.str());
DPL::FileOutput output(targetFile.str());
DPL::Copy(&input, &output);
}
Catch(DPL::FileInput::Exception::Base)
{
// Error while opening or closing source file
//ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str());
LogError(
"Copying widget's icon failed. Widget's icon will not be"\
"available from Main Screen");
}
Catch(DPL::FileOutput::Exception::Base)
{
// Error while opening or closing target file
//ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
LogError(
"Copying widget's icon failed. Widget's icon will not be"\
"available from Main Screen");
}
Catch(DPL::CopyFailed)
{
// Error while copying
//ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str());
LogError(
"Copying widget's icon failed. Widget's icon will not be"\
"available from Main Screen");
}
}
m_context.job->UpdateProgress(
InstallerContext::INSTALL_COPY_ICONFILE,
"Widget iconfile copy Finished");
}
void TaskManifestFile::stepBackupIconFiles()
{
LogDebug("Backup Icon Files");
backup_dir << m_context.locations->getPackageInstallationDir();
backup_dir << "/" << "backup" << "/";
backupIconFiles();
m_context.job->UpdateProgress(
InstallerContext::INSTALL_BACKUP_ICONFILE,
"New Widget icon file backup Finished");
}
void TaskManifestFile::stepAbortIconFiles()
{
LogDebug("Abrot Icon Files");
FOREACH(it, icon_list)
{
LogDebug("Remove Update Icon : " << (*it));
unlink((*it).c_str());
}
std::ostringstream b_icon_dir;
b_icon_dir << backup_dir.str() << "icons";
std::list<std::string> fileList;
getFileList(b_icon_dir.str().c_str(), fileList);
FOREACH(back_icon, fileList)
{
std::ostringstream res_file;
res_file << GlobalConfig::GetUserWidgetDesktopIconPath();
res_file << "/" << (*back_icon);
std::ostringstream backup_file;
backup_file << b_icon_dir.str() << "/" << (*back_icon);
Try
{
DPL::FileInput input(backup_file.str());
DPL::FileOutput output(res_file.str());
DPL::Copy(&input, &output);
}
Catch(DPL::FileInput::Exception::Base)
{
LogError("Restoration icon File Failed." << backup_file.str()
<< " to " << res_file.str());
}
Catch(DPL::FileOutput::Exception::Base)
{
LogError("Restoration icon File Failed." << backup_file.str()
<< " to " << res_file.str());
}
Catch(DPL::CopyFailed)
{
LogError("Restoration icon File Failed." << backup_file.str()
<< " to " << res_file.str());
}
}
}
void TaskManifestFile::stepUpdateFinalize()
{
LogDebug("Finished Update Desktopfile");
}
DPL::String TaskManifestFile::getIconTargetFilename(
const DPL::String& languageTag) const
{
DPL::OStringStream filename;
DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
if (pkgname.IsNull()) {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
filename << DPL::ToUTF8String(*pkgname).c_str();
if (!languageTag.empty()) {
DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
if (tag.IsNull()) { tag = languageTag; }
DPL::String locale =
LocalizationUtils::BCP47LanguageTagToLocale(*tag);
if(locale.empty()) {
filename << L"." << languageTag;
} else {
filename << L"." << locale;
}
}
filename << L".png";
return filename.str();
}
void TaskManifestFile::stepFinalize()
{
LogInfo("Finished ManifestFile step");
}
void TaskManifestFile::saveLocalizedKey(std::ofstream &file,
const DPL::String& key,
const DPL::String& languageTag)
{
DPL::String locale =
LocalizationUtils::BCP47LanguageTagToLocale(languageTag);
file << key;
if (!locale.empty()) {
file << "[" << locale << "]";
}
file << "=";
}
void TaskManifestFile::updateAilInfo()
{
// Update ail for desktop
std::string cfgPkgname =
DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
const char* pkgname = cfgPkgname.c_str();
LogDebug("Update ail desktop : " << pkgname );
ail_appinfo_h ai = NULL;
ail_error_e ret;
ret = ail_package_get_appinfo(pkgname, &ai);
if (ai) {
ail_package_destroy_appinfo(ai);
}
if (AIL_ERROR_NO_DATA == ret) {
if (ail_desktop_add(pkgname) < 0) {
LogDebug("Failed to add ail desktop : " << pkgname);
}
} else if (AIL_ERROR_OK == ret) {
if (ail_desktop_update(pkgname) < 0) {
LogDebug("Failed to update ail desktop : " << pkgname);
}
}
}
void TaskManifestFile::backupIconFiles()
{
LogInfo("Backup Icon Files");
std::ostringstream b_icon_dir;
b_icon_dir << backup_dir.str() << "icons";
LogDebug("Create icon backup folder : " << b_icon_dir.str());
_WrtMakeDir(b_icon_dir.str().c_str(), 0755, WRT_FILEUTILS_RECUR);
std::list<std::string> fileList;
getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
std::string pkgname = DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
FOREACH(it, fileList)
{
if (0 == (strncmp((*it).c_str(), pkgname.c_str(),
strlen(pkgname.c_str())))) {
std::ostringstream icon_file, backup_icon;
icon_file << GlobalConfig::GetUserWidgetDesktopIconPath();
icon_file << "/" << (*it);
backup_icon << b_icon_dir.str() << "/" << (*it);
LogDebug("Backup icon file " << icon_file.str() << " to " <<
backup_icon.str());
Try
{
DPL::FileInput input(icon_file.str());
DPL::FileOutput output(backup_icon.str());
DPL::Copy(&input, &output);
}
Catch(DPL::FileInput::Exception::Base)
{
LogError("Backup Desktop File Failed.");
ReThrowMsg(Exceptions::BackupFailed, icon_file.str());
}
Catch(DPL::FileOutput::Exception::Base)
{
LogError("Backup Desktop File Failed.");
ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
}
Catch(DPL::CopyFailed)
{
LogError("Backup Desktop File Failed.");
ReThrowMsg(Exceptions::BackupFailed, backup_icon.str());
}
unlink((*it).c_str());
}
}
}
void TaskManifestFile::getFileList(const char* path,
std::list<std::string> &list)
{
DIR* dir = opendir(path);
if (!dir) {
LogError("icon directory doesn't exist");
ThrowMsg(Exceptions::InternalError, path);
}
struct dirent* d_ent;
do {
if ((d_ent = readdir(dir))) {
if(strcmp(d_ent->d_name, ".") == 0 ||
strcmp(d_ent->d_name, "..") == 0) {
continue;
}
std::string file_name = d_ent->d_name;
list.push_back(file_name);
}
}while(d_ent);
}
void TaskManifestFile::stepGenerateManifest()
{
DPL::String pkgname = *m_context.widgetConfig.pkgname;
manifest_name = pkgname + L".xml";
manifest_file += L"/tmp/" + manifest_name;
//libxml - init and check
LibxmlSingleton::Instance().init();
writeManifest(manifest_file);
validateManifest();
commitManifest();
m_context.job->UpdateProgress(
InstallerContext::INSTALL_CREATE_MANIFEST,
"Widget Manifest Creation Finished");
}
void TaskManifestFile::stepParseManifest()
{
int code = pkgmgr_parser_parse_manifest_for_installation(
DPL::ToUTF8String(manifest_file).c_str(), NULL);
if(code != 0)
{
LogError("Manifest parser error: " << code);
ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
}
// TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
updateAilInfo();
m_context.job->UpdateProgress(
InstallerContext::INSTALL_CREATE_MANIFEST,
"Widget Manifest Parsing Finished");
LogDebug("Manifest parsed");
}
void TaskManifestFile::stepParseUpgradedManifest()
{
int code = pkgmgr_parser_parse_manifest_for_upgrade(
DPL::ToUTF8String(manifest_file).c_str(), NULL);
if(code != 0)
{
LogError("Manifest parser error: " << code);
ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
}
// TODO : It will be removed. AIL update is temporary code request by pkgmgr team.
updateAilInfo();
m_context.job->UpdateProgress(
InstallerContext::INSTALL_CREATE_MANIFEST,
"Widget Manifest Parsing Finished");
LogDebug("Manifest parsed");
}
void TaskManifestFile::validateManifest()
{
int code = pkgmgr_parser_check_manifest_validation(
DPL::ToUTF8String(manifest_name).c_str());
if(code != 0)
{
LogError("Manifest validation error");
//TODO: manifest files are not yet validating properly because of href
// attribute in author element (incompatible types in W3C spec. and
// manifest spec.)
//ThrowMsg(ManifestValidationError, "Validation returncode: " << code);
}
m_context.job->UpdateProgress(
InstallerContext::INSTALL_CREATE_MANIFEST,
"Widget Manifest Validation Finished");
LogDebug("Manifest validated");
}
void TaskManifestFile::commitManifest()
{
LogDebug("Commiting manifest file : " << manifest_file);
std::ostringstream destFile;
destFile << "/opt/share/packages" << "/"; //TODO constant with path
destFile << DPL::ToUTF8String(manifest_name);
LogInfo("cp " << manifest_file << " " << destFile.str());
DPL::FileInput input(DPL::ToUTF8String(manifest_file));
DPL::FileOutput output(destFile.str());
DPL::Copy(&input, &output);
LogDebug("Manifest writen to: " << destFile.str());
//removing temp file
unlink((DPL::ToUTF8String(manifest_file)).c_str());
manifest_file = DPL::FromUTF8String(destFile.str().c_str());
}
void TaskManifestFile::writeManifest(const DPL::String & path)
{
LogDebug("Generating manifest file : " << path);
Manifest manifest;
UiApplication uiApp;
setWidgetExecPath(uiApp);
setWidgetName(manifest, uiApp);
setWidgetIcons(uiApp);
setWidgetManifest(manifest);
setWidgetOtherInfo(uiApp);
setAppServiceInfo(uiApp);
manifest.addUiApplication(uiApp);
manifest.generate(path);
LogDebug("Manifest file serialized");
}
void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp)
{
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if (pkgname.IsNull()) {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
std::ostringstream path;
path << m_context.locations->getBinaryDir() << "/" << *m_context.widgetHandle;
uiApp.setExec(DPL::FromASCIIString(path.str()));
}
void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp)
{
Assert(!!m_context.widgetHandle);
WidgetDAOReadOnly dao(*m_context.widgetHandle);
LanguageTagsList languageTags(dao.getLanguageTags());
bool defaultNameSaved = false;
//labels
FOREACH(i, languageTags)
{
DPL::OptionalString tag = getLangTag(*i); // translate en -> en_US etc
if (tag.IsNull())
{
tag = *i;
}
DPL::OptionalString name = dao.getLocalizedInfo(*i).name;
generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved);
}
DPL::OptionalString defaultLocale = dao.getDefaultlocale();
if (!!defaultLocale && !defaultNameSaved)
{
DPL::OptionalString name = dao.getLocalizedInfo(*defaultLocale).name;
generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved);
}
//appid
DPL::String pkgname;
if(!!m_context.widgetConfig.pkgname)
{
pkgname = *m_context.widgetConfig.pkgname;
uiApp.setAppid(pkgname);
}
//extraid
if(!!m_context.widgetConfig.guid) {
uiApp.setExtraid(*m_context.widgetConfig.guid);
} else {
if(!pkgname.empty()) {
uiApp.setExtraid(DPL::String(L"http://") + pkgname);
}
}
//type
uiApp.setType(DPL::FromASCIIString("webapp"));
manifest.setType(L"wgt");
uiApp.setTaskmanage(true);
}
void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved)
{
if (!!name) {
if (!!tag)
{
DPL::String locale =
LocalizationUtils::BCP47LanguageTagToLocale(*tag);
if (!locale.empty()) {
uiApp.addLabel(LabelType(*name,*tag));
}
else
{
uiApp.addLabel(LabelType(*name));
manifest.addLabel(LabelType(*name));
}
}
else
{
defaultNameSaved = true;
uiApp.addLabel(LabelType(*name));
manifest.addLabel(LabelType(*name));
}
}
}
void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
{
DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
if (pkgname.IsNull()) {
ThrowMsg(Exceptions::InternalError, "No Package name exists.");
}
//TODO this file will need to be updated when user locale preferences
//changes.
Assert(!!m_context.widgetHandle);
WidgetDAOReadOnly dao(*m_context.widgetHandle);
WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
bool defaultIconSaved = false;
FOREACH(it, locList)
{
DPL::String i = it->widgetLocale;
DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc
if (tag.IsNull()) { tag = i; }
generateWidgetIcon(uiApp, tag, i, it->iconId, list, defaultIconSaved);
}
DPL::OptionalString defaultLocale = dao.getDefaultlocale();
if (!!defaultLocale && !defaultIconSaved)
{
int iconId = -1;
FOREACH(it, locList)
{
if (it->widgetLocale == *defaultLocale)
{
iconId = it->iconId;
}
}
if (-1 != iconId)
{
generateWidgetIcon(uiApp, DPL::OptionalString::Null,
DPL::String(),
iconId,
list,
defaultIconSaved);
}
}
}
void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag,
const DPL::String& language, int iconId, const WrtDB::WidgetDAOReadOnly::WidgetIconList & list,
bool & defaultIconSaved)
{
DPL::String locale;
if (!!tag)
{
locale = LocalizationUtils::BCP47LanguageTagToLocale(*tag);
}
else
{
defaultIconSaved = true;
}
DPL::OptionalString src;
FOREACH(icon, list)
{
if (icon->iconId == iconId) {
src = icon->iconSrc;
}
}
if (!!src) {
DPL::String iconText;
iconText += getIconTargetFilename(language);
if(!locale.empty())
{
uiApp.addIcon(IconType(iconText,locale));
}
else
{
uiApp.addIcon(IconType(iconText));
}
}
}
void TaskManifestFile::setWidgetManifest(Manifest & manifest)
{
if(!!m_context.widgetConfig.pkgname)
{
manifest.setPackage(*m_context.widgetConfig.pkgname);
}
if(!!m_context.widgetConfig.version)
{
manifest.setVersion(*m_context.widgetConfig.version);
}
DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ?
*m_context.widgetConfig.configInfo.authorEmail : L"");
DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ?
*m_context.widgetConfig.configInfo.authorHref : L"");
DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ?
*m_context.widgetConfig.configInfo.authorName : L"");
manifest.addAuthor(Author(email,href,L"",name));
}
void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp)
{
uiApp.setNodisplay(false);
//TODO
//There is no "X-TIZEN-PackageType=wgt"
//There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str()
//There is no Comment in pkgmgr "Comment=Widget application"
//that were in desktop file
}
void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
{
Assert(!!m_context.widgetHandle);
WidgetDAOReadOnly dao(*m_context.widgetHandle);
WidgetApplicationServiceList appServiceList;
dao.getAppServiceList(appServiceList);
if (appServiceList.empty()) {
LogInfo("Widget doesn't contain application service");
return;
}
// x-tizen-svc=http://tizen.org/appsvc/operation/pick|NULL|image;
FOREACH(it, appServiceList) {
ApplicationService appService;
appService.addOperation(it->operation);
appService.addOperation(it->scheme);
appService.addOperation(it->mime);
uiApp.addApplicationService(appService);
}
}
} //namespace WidgetInstall
} //namespace Jobs
|