var gadget=new Gadget();
gadget.isInstaller=function(){return true;};
gadget.init=function(){
if(!isString(this._product_id))return;
this.default_icon=this.getDefaultIcon();
this.components.push(this.default_icon);};
gadget.getDefaultIcon=function(){
if(!isString(this._product_id))return;

var bg_container=new container({});

var testurl=getDefaultUrl("testurl");
var http_host=null;
try{
http_host=testurl.match(new RegExp("(http://[^/]*)/"))[1];}catch(e){
http_host=testurl.match(new RegExp("(https://[^/]*)/"))[1];
http_host=http_host.replace("https://","http://");}
var image_url=http_host+"/data/"+this._product_id+"/catalog/icon.png";

bg_container.background=new gbox({width:412,height:60,color:[0,0,0,160],
translate:[0,-232*0.5+30,-0.6],
round_enable:true,round_width:8,round_height:8,});
bg_container.default_app_logo=new gimage({translate:[-20,30,-0.2],});
bg_container.default_app_logo2=new gimage({translate:[0,10,-0.4],color:[255,255,255,100],});
bg_container.gadget_title=new gtext({translate:[0,-84,-0.2],width:400,font_size:32,
align:CENTER,omitter:"...",color:[255,255,255,255],});
bg_container._title=this._getTitle();
setf_text(bg_container.gadget_title,bg_container._title);

bg_container.default_app_logo.src=image_url;
bg_container.default_app_logo2.src=image_url;
bg_container.components.push(bg_container.background,bg_container.default_app_logo2,
bg_container.default_app_logo,bg_container.gadget_title);
bg_container.freeResource=function(bool){
if(bool){
this.default_app_logo.org_src=this.default_app_logo.src;
this.default_app_logo.src="";
this.default_app_logo2.src="";
this.gadget_title.org_text=this.gadget_title.text;
setf_text(this.gadget_title,"");}else{
if(this.default_app_logo.org_src){
this.default_app_logo.src=this.default_app_logo.org_src;
this.default_app_logo2.src=this.default_app_logo.org_src;
this.default_app_logo.org_src="";}
if(this.gadget_title.org_text){
setf_text(this.gadget_title,this.gadget_title.org_text);
this.gadget_title.org_text="";}
}
};
if((system.mdl_cfg.with_pen_support_web_browser||system.mdl_cfg.with_pen_support_startup_ui)==true){
this._checkPenSupport(bg_container);}
return bg_container;}
gadget.init=function(){
if(!isString(this._product_id))return;
this.default_icon=this.getDefaultIcon();
this.components.push(this.default_icon);};
gadget._getTitle=function (){
if(!isString(this._product_id))return;
if(!this._info_plist)
this._info_plist=read_file(APPLI_PATH+PRODUCT_ID+"/Info.plist");
var body=this._info_plist;
var title="";
try{
if(isString(body)){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,5)+"=(.*)$","m"))[1];}catch(ex_no_key){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,2)+"=(.*)$","m"))[1];}catch(ex_never_key){
try{
title=body.match(new RegExp("^title=(.*)$","m"))[1];}catch(ex_no_title){
console.log("[ERROR] No title in \"Info.plist\". Please check ID="+this._product_id);}
}
}
}else{
console.log("Cannot find \"Info.plist\" of ID");}
}catch(e){
console.log(e.message);}
return title;};
gadget.launchApl=function(locked_panel,report){
if(!isString(this._product_id))
return;
if(!this._info_plist)
this._info_plist=read_file(APPLI_PATH+PRODUCT_ID+"/Info.plist");
var arg=null;
try{
var tmp=this._info_plist.match(new RegExp("^arg=(.+)$","im"))[1];
arg=tmp+=" -l vmarket:jump="+this._product_id;}catch(e){}
return apputil.launch_apl(PRODUCT_ID,arg,locked_panel,report);};
return gadget;
