//************************************************************************************************
//*************************************** class ZSearch ******************************************
//************************************************************************************************
ZSearch::ZSearch(const QString &curPath, const QString &originName)
  :MyBaseDlg()
{
  QString ProgDir =  QString ( qApp->argv() [0] );
  int i = ProgDir.findRev ( "/" );
  ProgDir.remove ( i+1, ProgDir.length() - i );

  ZConfig readlang("/ezxlocal/download/appwrite/setup/ezx_system.cfg", true);
  Idioma = ProgDir + "/languages/" + readlang.readEntry(QString("SYS_SYSTEM_SET"), QString("LanguageType"), "en-us");
  if ( ! QFileInfo(Idioma).isFile() ) Idioma = ProgDir + "/languages/en-us";
  ZConfig lang (Idioma,false); 

  this->setMainWidgetTitle("zTextViewer");
  
  QWidget *myWidget = new ZWidget ( this, NULL, 0);
  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  myWidget->setFixedWidth(240);
  ZAppInfoArea* pAIA = new ZAppInfoArea(myWidget, NULL, 0);
  pAIA->setActArea(ZAppInfoArea::no_progress_meter);
  pAIA->appendText(ZAppInfoArea::activity, lang.readEntry(QString("TEXTVIEWER"), "IDS_SAVE", ""), "name");
  setAppInfoArea(pAIA);
  myVBoxLayout->addWidget ( pAIA, 1, 1 );

    ZFormContainer* fc = new ZFormContainer(this);
    setContentWidget(fc);

    lineEdit = new ZLineEdit(this, NULL);
    lineEdit->setTitle(lang.readEntry(QString("TEXTVIEWER"), "IDS_ENTER_FILE_NAME", ""));
    lineEdit->setTitlePosition(ZLineEdit::TitleTop);
    lineEdit->setMaxLength(50);
	lineEdit->setText(originName);
    fc->addChild(lineEdit);

 	buttonDir = new myButton(this, "ZPressButton");
	buttonDir->setTitle(lang.readEntry(QString("TEXTVIEWER"), "IDS_LOCATION", ""));
	QString direc = curPath;
	if ( direc == "" ) direc = "/mmc/mmca1";
	if ( direc[direc.length()-1] == QChar('/') ) 
	  {	direc.remove( direc.length()-1, 1 ); }
    buttonDir->setText(direc); 
	FStext=direc;
	buttonDir->setPixmap(QPixmap(ProgDir+"/img/folder.png"));
    fc->addChild(buttonDir);
	

  ZSoftKey *softKey = new ZSoftKey ( "CST_2A", this, this );
  softKey->setText ( ZSoftKey::RIGHT, lang.readEntry(QString("TEXTVIEWER"), "IDS_CANCEL", ""), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::LEFT, lang.readEntry(QString("TEXTVIEWER"), "IDS_SAVE", ""), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( slot_cancel() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( slot_search() ) );


  this->setCSTWidget( softKey );

}
Exemple #2
0
void ListRegisteredAppsInMenu()
{
    LoadAllRegisteredApp();

    DBG_OUT("List Applications registered in Menu");
    DBG_OUT("[List START]");

    ZConfig* umt = new ZConfig("/ezxlocal/download/appwrite/am/UserMenuTree");
    QString appUID = QString::null;
    QString items = umt->readEntry(appMenuUUID,"Items","");
    QStringList itemsList = QStringList::split(";", items,false);
    delete umt;

    for (uint i = 0; i<itemsList.count();i++)
    {
        appUID = itemsList[i];
        if (appRegList.contains( appUID ) )
        {
            printf("\tAPP OBJECT{ Name: %s, Type: %d, Icon: %s}\n",
                appRegList[appUID]->Name.ascii(),
                appRegList[appUID]->eType,
                appRegList[appUID]->SimpleIcon.ascii() );
        }
    }
    DBG_OUT("[List END]");
}
CitySelectDlg::CitySelectDlg(QString str1,QString str2,QString str3):ZPopup()
{
    setTitle(str1);
    listBox = new ZListBox("%I%M",this);
    
    // insert menu items with images from SysRegistry
    ZConfig config ( getAppDir() + "cities.ini", false );
    QStringList grouplist;
    config.getGroupsKeyList ( grouplist );
    QString cityCode = "";
    
    for ( QStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) 
    {
        cityCode = config.readEntry(*it, "Code", "");
        City *city = new City(listBox);
        qDebug(*it);
        qDebug(cityCode);
        city->setName(*it);
        city->setCode(cityCode);
        
        listBox->insertItem(city);
        city->appendSubItem(1,ctr(city->getName()));
        
    }
    
    insertChild(listBox);
    setSoftkeyText(str2,str3);
    connect(this,SIGNAL(leftSoftkeyClicked()),this,SLOT(slotSelected()));
    connect(listBox,SIGNAL(returnPressed(ZSettingItem *)),this,SLOT(slotItemClicked(ZSettingItem *)));
    
}
//************************************************************************************************
//************************************** class ZFolderSelect2 ***********************************
//************************************************************************************************
ZFolderSelect2::ZFolderSelect2(bool onlyDirs, QString path)
  :MyBaseDlg()
{
  QString ProgDir =  QString ( qApp->argv() [0] );
  int i = ProgDir.findRev ( "/" );
  ProgDir.remove ( i+1, ProgDir.length() - i );

  ZConfig readlang("/ezxlocal/download/appwrite/setup/ezx_system.cfg", true);
  Idioma = ProgDir + "/languages/" + readlang.readEntry(QString("SYS_SYSTEM_SET"), QString("LanguageType"), "en-us");
  if ( ! QFileInfo(Idioma).isFile() ) Idioma = ProgDir + "/languages/en-us";
  ZConfig lang (Idioma,false); 

  this->setMainWidgetTitle("zFileManager");
  
  QWidget *myWidget = new ZWidget ( this, NULL, 0);
  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  myWidget->setFixedWidth(240);
  ZAppInfoArea* pAIA = new ZAppInfoArea(myWidget, NULL, 0);
  pAIA->setActArea(ZAppInfoArea::no_progress_meter);
  QPixmap pixmap; pixmap.load(ProgDir+"/img/folder.png");
  pAIA->appendIcon(ZAppInfoArea::activity,pixmap,"");
  pAIA->appendText(ZAppInfoArea::activity, lang.readEntry(QString("LANGUAGE"), "SEARCH_IN", ""), "name");
  setAppInfoArea(pAIA);
  myVBoxLayout->insertWidget (0, pAIA );

  fb = new FileBrowser2("*", onlyDirs, QString ( "%I%M" ), myWidget, 0);
  fb->setDir(path);
  QObject::connect(fb, SIGNAL(isFilePicked(bool)), SLOT(filePicked(bool)));

  
  fb->ProgramDir = ProgDir;
  setContentWidget ( fb );
  
  ZSoftKey *softKey = new ZSoftKey ( "CST_2A", this, this );
  
  softKey->setText ( ZSoftKey::RIGHT, lang.readEntry(QString("LANGUAGE"), "CANCEL", ""), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::LEFT, lang.readEntry(QString("LANGUAGE"), "CHOISE", ""), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( slot_cancel() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) );
   
  this->setCSTWidget( softKey );

}
//************************************************************************************************
//************************************** class ZFileOpenDialog ***********************************
//************************************************************************************************
ZFileOpenDialog::ZFileOpenDialog()
  :MyBaseDlg()
{
  
  QString ProgDir =  QString ( qApp->argv() [0] );
  int i = ProgDir.findRev ( "/" );
  ProgDir.remove ( i+1, ProgDir.length() - i );

  ZConfig readlang("/ezxlocal/download/appwrite/setup/ezx_system.cfg", true);
  Idioma = ProgDir + "/languages/" + readlang.readEntry(QString("SYS_SYSTEM_SET"), QString("LanguageType"), "en-us");
  if ( ! QFileInfo(Idioma).isFile() ) Idioma = ProgDir + "/languages/en-us";
  ZConfig lang (Idioma,false); 

  this->setMainWidgetTitle("zTextViewer");

  QWidget *myWidget = new ZWidget ( this, NULL, 0);
  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  myWidget->setFixedWidth(240);
  ZAppInfoArea* pAIA = new ZAppInfoArea(myWidget, NULL, 0);
  pAIA->setActArea(ZAppInfoArea::no_progress_meter);
  pAIA->appendText(ZAppInfoArea::activity, lang.readEntry(QString("TEXTVIEWER"), "IDS_OPEN", "Open"), "name");
  setAppInfoArea(pAIA);
  myVBoxLayout->addWidget ( pAIA, 1, 1 );

  fb = new FileBrowser("*", QString ( "%I%M" ), myWidget, 0);
  fb->setDir("/");
  QObject::connect(fb, SIGNAL(isFilePicked(bool)), SLOT(filePicked(bool)));

 // myVBoxLayout->addWidget ( fb, 1 );
  
  setContentWidget ( fb );
  
  ZSoftKey *softKey = new ZSoftKey ( NULL, this, this );
  softKey->setText ( ZSoftKey::LEFT, lang.readEntry(QString("TEXTVIEWER"), "IDS_OPEN", "Open"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::RIGHT, lang.readEntry(QString("TEXTVIEWER"), "IDS_CANCEL", "Cancel"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) );
  setCSTWidget ( softKey );
}
void ZAddAppDlg::procReg(QString FileRegistry)
{
	QString id;
	QString name;
	QString ico;
	static int i=0;
	
	ZConfig confReg ( FileRegistry, false );
	QStringList grouplist;
	confReg.getGroupsKeyList ( grouplist );
	for ( QStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) 
	{	 
		name = confReg.readEntry ( *it, "Name", "" );
		id = confReg.readEntry ( *it, "AppID", "" );
		ico = confReg.readEntry ( *it, ICON_NAME, "" );
		#ifdef NEW_PLATFORM
		if (ico=="")
		{
			ico = confReg.readEntry ( *it, "Icon", "" );
		}		
		#endif		
		if (ico=="")
		{
			ico = confReg.readEntry ( *it, "BigIcon", "" );
		}		
		if ( (id!="")&&(name!=""))
		{
			AppRegistry app;
			app.setId(id);
			app.setName(name);
			#ifndef NEW_PLATFORM
			if ( ico.find(".g") == -1 && !QFile::exists(ico) )
			#else
			if ( ico.find(".g") == -1 && ico.find(".k") == -1 &&!QFile::exists(ico) )
			#endif
			{
					ico = confReg.readEntry ( *it, "Directory", "" ) + "/" + ico;
			}	
			app.setIcon(ico);
			mapApp[ i ] = app;
			addApp(name, ico, i);
			++i;
		}
	}	
}
ZSettingsDlg::ZSettingsDlg()
    :MyBaseDlg()
{
	setMainWidgetTitle(LNG_SETTINGS);

	myWidget = new ZWidget ();

	tabWidget = new ZNavTabWidget( myWidget );
	setContentWidget ( tabWidget );

	QPixmap pm;

	ZConfig cfg ( ProgDir+"/zMessanger.cfg");
	//##################################   1   ############################################
	net = new ZListBox( tabWidget );
	pm.load( ProgDir+ "/image/tab_net.png");
	tabWidget->addTab(net, QIconSet(pm), "");
	//#####################################################################################
	optInetLink = new ZOptionItem(net, ZOptionItem::EDIT_INTERNET_PROFILE);
	optInetLink->setText( cfg.readEntry(QString("Inet"), QString("ProfileName"), "") );
	optInetLink->setTitle(LNG_INETPROF);
	net->insertItem(optInetLink);
	
	optICQServer = new ZOptionItem(net, ZOptionItem::EDIT_TEXT);
	optICQServer->setText( cfg.readEntry(QString("Inet"), QString("Server"), "login.icq.com") );
	optICQServer->setTitle(LNG_ICQSERV);
	net->insertItem(optICQServer);
	
	optICQPort = new ZOptionItem(net, ZOptionItem::EDIT_TEXT_NUM);
	optICQPort->setText( cfg.readEntry(QString("Inet"), QString("Port"), "5190") );
	optICQPort->setTitle(LNG_PORT);
	net->insertItem(optICQPort);
	
	optICQKeepTime = new ZOptionItem(net, ZOptionItem::EDIT_TEXT_NUM);
	optICQKeepTime->setText( cfg.readEntry(QString("Inet"), QString("TimeKeepConnect"), "500") );
	optICQKeepTime->setTitle(LNG_KEEPCONNECTTIME);
	net->insertItem(optICQKeepTime);
	
	optICQdelayReadSnec = new ZOptionItem(net, ZOptionItem::EDIT_TEXT_NUM);
	optICQdelayReadSnec->setText( cfg.readEntry(QString("Inet"), QString("delayReadSnec"), "2000") );
	optICQdelayReadSnec->setTitle(LNG_DELAYNEWSOCKREAD);
	net->insertItem(optICQdelayReadSnec);
	
	#ifndef _NoUSBNetOption
	optUSBNet = new ZOptionItem(net, ZOptionItem::EDIT_BOOL_ONOFF);
	optUSBNet->setTitle( "Internet on USB" );
	optUSBNet->setNum( cfg.readBoolEntry("Inet", "inetOnUSB", false) );
	net->insertItem(optUSBNet);
	#endif
	//#######################################  2  #########################################
	alert = new ZListBox( tabWidget );
	pm.load( ProgDir + "/image/tab_alert.png");
	tabWidget->addTab(alert, QIconSet(pm), "");
	//#####################################################################################
	
	optVibrate = new ZOptionItem(alert, ZOptionItem::EDIT_BOOL_ONOFF);
	optVibrate->setTitle( LNG_VIBRATE );
	optVibrate->setNum( cfg.readBoolEntry("Alert", "Vibrate", true) );
	alert->insertItem(optVibrate);
	
	optTone = new ZOptionItem(alert, ZOptionItem::EDIT_BOOL_ONOFF);
	optTone->setTitle( LNG_RINGTONE );
	optTone->setNum( cfg.readBoolEntry("Alert", "Ring", false) );
	alert->insertItem(optTone);
	
	optToneVol = new ZOptionItem(alert, ZOptionItem::EDIT_NUM);
	optToneVol->setTitle( LNG_RINGTONEVOL );
	optToneVol->setNum( cfg.readNumEntry("Alert", "Volume", 2) );
	optToneVol->setMaxMin(10, 0);
	alert->insertItem(optToneVol);	
	
	optTonePath = new ZOptionItem(alert, ZOptionItem::EDIT_ONE_OF_LIST);
	optTonePath->setTitle( LNG_RINGTONEPATH );
	
	QDir dirTone ( ProgDir+"/alert/", QString("*.mp3 *.wav") );
	dirTone.setFilter ( QDir::Files | QDir::Hidden );
	toneList = new QStringList( dirTone.entryList() );
	toneList->sort();

	int sel=0, i=0;
	QString text = cfg.readEntry(QString("Alert"), QString("Path"), "msn.mp3");
	for ( QStringList::Iterator it = toneList->begin(); it != toneList->end(); ++it )
		if ( *it == text )
		{
			sel=i;
			break;
		} else
			i++;
	
	optTonePath->setList( toneList );
	optTonePath->setNum( sel );
	
	alert->insertItem(optTonePath);

	//#########################################  3  #######################################
	CL = new ZListBox( tabWidget );
	pm.load( ProgDir+ "/image/tab_CL.png");
	tabWidget->addTab(CL, QIconSet(pm), "");
	//#####################################################################################
	optJampNewMes = new ZOptionItem(CL, ZOptionItem::EDIT_BOOL_YESNO);
	optJampNewMes->setTitle( LNG_AUTO_JAMP_NEW_MESSAGE );
	optJampNewMes->setNum( cfg.readBoolEntry(QString("ContactList"), QString("jampNewMes"), true) );
	CL->insertItem(optJampNewMes);	
	
	optShowOffLine = new ZOptionItem(CL, ZOptionItem::EDIT_BOOL_YESNO);
	optShowOffLine->setTitle( LNG_SHOWOFFCONT );
	optShowOffLine->setNum( !cfg.readBoolEntry(QString("ContactList"), QString("dontShowOffLine"), true) );
	CL->insertItem(optShowOffLine);
	
	optShowGroup = new ZOptionItem(CL, ZOptionItem::EDIT_BOOL_YESNO);
	optShowGroup->setTitle( LNG_SHOWGROUP );
	optShowGroup->setNum( !cfg.readBoolEntry(QString("ContactList"), QString("dontShowGroup"), false) );
	CL->insertItem(optShowGroup);
	
	optRigthXStatus = new ZOptionItem(CL, ZOptionItem::EDIT_BOOL_YESNO);
	optRigthXStatus->setTitle( LNG_XSTATUSRIGTH );
	optRigthXStatus->setNum( cfg.readBoolEntry(QString("ContactList"), QString("rigthAlignXStatus"), true) );
	CL->insertItem(optRigthXStatus);
	
	QStringList * modes = new QStringList();
	modes->append(LNG_NO_SORTCONTACT);
	modes->append(LNG_STATUS_SORTCONTACT);
	modes->append(LNG_STATUS_NICK_SORTCONTACT);
	
	optSortType = new ZOptionItem(CL, ZOptionItem::EDIT_ONE_OF_LIST);
	optSortType->setTitle(LNG_SORTCONTACT);
	optSortType->setList( modes );
	optSortType->setNum( cfg.readNumEntry(QString("ContactList"), QString("sortType"), 2) );
	CL->insertItem(optSortType);

	//#######################################  4  ##########################################
	Chat = new ZListBox( tabWidget );
	pm.load( ProgDir+ "/image/tab_chat.png");
	tabWidget->addTab(Chat, QIconSet(pm), "");
	//#####################################################################################
	
	optSmilePack = new ZOptionItem(Chat, ZOptionItem::EDIT_ONE_OF_LIST);
	optSmilePack->setTitle( LNG_SMILE_PACK );
	
	smileList = zSmile->getSmilePackList();
	
	optSmilePack->setList( smileList );
	
	sel=0; i=0;
	text = cfg.readEntry(QString("Chat"), QString("smilePack"), "kolobok");
	for ( QStringList::Iterator it = smileList->begin(); it != smileList->end(); ++it )
		if ( *it == text )
		{
			sel=i;
			break;
		} else
			i++;	
	
	optSmilePack->setNum( sel );
	Chat->insertItem(optSmilePack);	
	
	optChatFontSize = new ZOptionItem(Chat, ZOptionItem::EDIT_NUM);
	optChatFontSize->setMaxMin(35, 2);
	optChatFontSize->setNum( cfg.readNumEntry(QString("Chat"), QString("chatFontSize"), 11) );
	optChatFontSize->setTitle( LNG_FONTSIZECHAT );
	Chat->insertItem(optChatFontSize);
	
	optMesFontSize = new ZOptionItem(Chat, ZOptionItem::EDIT_NUM);
	optMesFontSize->setMaxMin(35, 2);
	optMesFontSize->setNum( cfg.readNumEntry(QString("Chat"), QString("writeMesFontSize"), 11) );
	optMesFontSize->setTitle( LNG_FONTSIZEMES );
	Chat->insertItem(optMesFontSize);
	
	optMaxNumLine = new ZOptionItem(Chat, ZOptionItem::EDIT_NUM);
	optMaxNumLine->setMaxMin(500, 3);
	optMaxNumLine->setNum( cfg.readNumEntry(QString("Chat"), QString("maxNumLines"), 40) );
	optMaxNumLine->setTitle( LNG_MAXNUMLINESCHAT );
	Chat->insertItem(optMaxNumLine);	
	
	optNoShowStatusBarInChat = new ZOptionItem(Chat, ZOptionItem::EDIT_BOOL_ONOFF);
	optNoShowStatusBarInChat->setTitle( LNG_NO_SHOW_STATUS_BAR_IN_CHAT );
	optNoShowStatusBarInChat->setNum( !cfg.readBoolEntry(QString("Chat"), QString("noShowStatusBarInChat"), false) );
	Chat->insertItem(optNoShowStatusBarInChat);	
	
	optSendByCenter = new ZOptionItem(Chat, ZOptionItem::EDIT_BOOL_YESNO);
	optSendByCenter->setTitle( LNG_SEND_BY_CENTER );
	optSendByCenter->setNum( cfg.readBoolEntry(QString("Chat"), QString("sendByCenter"), false) );
	Chat->insertItem(optSendByCenter);

	optSendTypeMes = new ZOptionItem(Chat, ZOptionItem::EDIT_BOOL_YESNO);
	optSendTypeMes->setTitle( LNG_SENDTYPEMES );
	optSendTypeMes->setNum( !cfg.readBoolEntry(QString("Chat"), QString("notSendTypeMes"), false) );
	Chat->insertItem(optSendTypeMes);
	
	//#####################################  5  ###########################################
	othe = new ZListBox( tabWidget );
	pm.load( ProgDir+ "/image/tab_othe.png");
	tabWidget->addTab(othe, QIconSet(pm), "");
	//#####################################################################################
	
	codec = new QStringList();
	codec->append( "KOI8-R" );
	codec->append( "KOI8-U" );
	codec->append( "ISO8859-2" );
	codec->append( "ISO8859-3" );
	codec->append( "ISO8859-4" );
	codec->append( "ISO8859-5" );
	codec->append( "ISO8859-6-I" );
	codec->append( "ISO8859-7" );
	codec->append( "ISO8859-8-I" );
	codec->append( "ISO8859-9" );
	codec->append( "ISO8859-10" );
	codec->append( "ISO8859-11" );		
	codec->append( "ISO8859-13" );
	codec->append( "ISO8859-14" );
	codec->append( "ISO8859-15" );
	codec->append( "PT154" );
	codec->append( "CP874" );
	codec->append( "CP1250" );
	codec->append( "CP1251" );
	codec->append( "CP1252" );
	codec->append( "CP1253" );
	codec->append( "CP1254" );
	codec->append( "CP1255" );
	codec->append( "CP1256" );	
	codec->append( "CP1257" );	
	codec->append( "CP1258" );

	sel=0, i=0;
	text = cfg.readEntry(QString("Message"), QString("CodePage"), "CP1251");
	for ( QStringList::Iterator it = codec->begin(); it != codec->end(); ++it )
		if ( *it == text )
		{
			sel=i;
			break;
		} else
			i++;
	optCodePage = new ZOptionItem(othe, ZOptionItem::EDIT_ONE_OF_LIST);
	optCodePage->setTitle( LNG_DEFCP );	
	optCodePage->setList( codec );
	optCodePage->setNum( sel );
	othe->insertItem(optCodePage);
	
	optXTrazRequest = new ZOptionItem(othe, ZOptionItem::EDIT_BOOL_YESNO);
	optXTrazRequest->setTitle( LNG_XSTATUSAUTOREQUEST );
	optXTrazRequest->setNum( !cfg.readBoolEntry(QString("Message"), QString("noAutoXTrazRequest"), true) );
	othe->insertItem(optXTrazRequest);
	
	optAutoMsgRequest = new ZOptionItem(othe, ZOptionItem::EDIT_BOOL_YESNO);
	optAutoMsgRequest->setTitle( LNG_STATUSAUTOREQUEST );
	optAutoMsgRequest->setNum( !cfg.readBoolEntry(QString("Message"), QString("noAutoMsgRequest"), true) );
	othe->insertItem(optAutoMsgRequest);
		
	optSaveStusWithExit = new ZOptionItem(othe, ZOptionItem::EDIT_BOOL_ONOFF);
	optSaveStusWithExit->setTitle( LNG_SAVE_STATUS_WITH_EXIT );
	optSaveStusWithExit->setNum( cfg.readBoolEntry(QString("Status"), QString("saveStausCanDisconect"), true) );
	othe->insertItem(optSaveStusWithExit);

	optEye = new ZOptionItem(othe, ZOptionItem::EDIT_BOOL_ONOFF);
	optEye->setTitle( LNG_EYE );
	optEye->setNum(cfg.readBoolEntry(QString("Othe"), QString("enabledEye"), true));
	othe->insertItem(optEye);
	//#####################################################################################
	
	net->setFocus(); // set focus to widget in first tab
	
	ZSoftKey *softKey = new ZSoftKey ( NULL, this, this );
	softKey->setText ( ZSoftKey::LEFT, LNG_OK, ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setText ( ZSoftKey::RIGHT, LNG_CANCEL, ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) );
	softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( saveSetting() ) );
	setCSTWidget ( softKey );
}
bool xInstaller::run( QString sPakgPath )
{
	QCopChannel::send( "zPkgInstaller", "proc_show()" );
	qApp->processEvents();
	qApp->processEvents();
	//unpack pack
	{
		createTmpDir(sTemp);
		system( QString(PATH_7Z).arg( sPakgPath ).arg( sTemp ).utf8() );
		
		QString tarName = sPakgPath.right( sPakgPath.length() - sPakgPath.findRev('/') );
		tarName = tarName.left( tarName.findRev('.') );
		toLog( "Check tar: " + sTemp+tarName );
		if ( QFile::exists( sTemp+tarName ) )
		{
			system( QString(PATH_7Z).arg( sTemp+tarName ).arg( sTemp ).utf8() );	
			system( QString("rm %1").arg( sTemp+tarName ).utf8() );	
		}
		tarName = tarName +".tar";
		toLog( "Check tar: " + sTemp+tarName );
		if ( QFile::exists( sTemp+tarName ) )
		{
			system( QString(PATH_7Z).arg( sTemp+tarName ).arg( sTemp ).utf8() );	
			system( QString("rm %1").arg( sTemp+tarName ).utf8() );	
		}		
	}
	QCopChannel::send( "zPkgInstaller", "proc_hide()" );	
	
	//detect pak type
	PAK_TYPE type = PAK_UNKNOWN;
	QString sFolder;
	if ( QFile::exists( sTemp + "/description.ini" ) )
		type = PAK_PEP;
	else
	{
		QDir dir ( sTemp, "*" );
		dir.setFilter ( QDir::Dirs | QDir::Hidden );
		QStringList entries = dir.entryList();
		entries.sort();	

		QStringList::ConstIterator it = entries.begin();
		while ( it != entries.end() )
		{
			if ( *it != "." && *it != ".." )
			{
				sFolder = *it;
				toLog( QString( "Maybe pak folder:" ) + sFolder );
				if ( QFile::exists( sTemp + "/"+sFolder+"/"+sFolder+".cfg" ) )
					type = PAK_MGX;
			}
			it++;
		}
	}
	if ( type == PAK_UNKNOWN || bCancel )
	{
		toLog("Error: not detected pak type!");
		uiDlg->corruptFileDlg();
		cancelInstall();
		return 0;
	}
	
	toLog("Create discription app");
	AppEntry installedApp;
	installedApp.uid = AM_Global::createUuid();
	installedApp.appId = QString(installedApp.uid).right(37).left(36);
    installedApp.isLockEnabled = false;
    installedApp.isShared = false;
    installedApp.isErasable = true;
    installedApp.parentFolderUid = "abc9ddaa-6643-429b-9844-8dc429829417";
    installedApp.position = -1;
    installedApp.m_type = AM_AppLnk::NativeApp;
    
    #define toUTF8(a) QString::fromUtf8((a).utf8())
    switch ( type )
    {
		case PAK_PEP:
		{
			ZConfig cfg( sTemp + "/description.ini" );
			
			if ( cfg.readBoolEntry ( "Actions", "InstallApp", false ) )
			{
				installedApp.directory = fixDirectoryName( toUTF8(cfg.readEntry("InstallApp", "InstallPath", "")) );
				installedApp.bigIcon = fixIconName( toUTF8(cfg.readEntry("InstallApp", "BigIcon", "")), sTemp+"/app");
				installedApp.smallIcon = fixIconToSmall(fixIconName( toUTF8(cfg.readEntry("InstallApp", "Icon", "")), sTemp+"/app"), sTemp+"/app");
				installedApp.aniIcon = fixIconName( toUTF8(cfg.readEntry("InstallApp", "AniIcon", "" )), sTemp+"/app");
				installedApp.simpleIcon = toUTF8(installedApp.smallIcon);
				installedApp.name = toUTF8(cfg.readEntry("InstallApp", "Name", ""));
				installedApp.vendor = toUTF8(cfg.readEntry("InstallApp", "Author", ""));
				installedApp.nameResourceId = "";
				installedApp.version = toUTF8(cfg.readEntry ("InstallApp", "Version", ""));
				installedApp.exec = toUTF8(cfg.readEntry("InstallApp", "Exec", ""));
				installedApp.device = (installedApp.directory.find("/mmc/")==-1)?AM_Global::Flash2:AM_Global::Card1;
			} else
			if ( cfg.readBoolEntry ( "Actions", "UpdatePak", false ) )
			{
				installedApp.directory = fixDirectoryName( toUTF8(cfg.readEntry("UpdatePak", "InstallPath", "")) );
				installedApp.name = toUTF8(cfg.readEntry("UpdatePak", "Name", ""));
				installedApp.vendor = toUTF8(cfg.readEntry("UpdatePak", "Author", ""));
				installedApp.version = cfg.readEntry ( "UpdatePak", "Version", "" );
				installedApp.device = (installedApp.directory.find("/mmc/")==-1)?AM_Global::Flash2:AM_Global::Card1;
				type = PAK_PEP_UPDATE;
			}			
			break;
		}
		case PAK_MGX:
		{
			QString cfg = sTemp + "/"+sFolder+"/"+sFolder+".cfg";
			installedApp.directory = "";
			installedApp.name = toUTF8(getMgxReadConfig(cfg, "Name", ""));
			installedApp.vendor = toUTF8(getMgxReadConfig(cfg, "Author", ""));
			installedApp.nameResourceId = "";
			installedApp.version = toUTF8(getMgxReadConfig(cfg, "Version", ""));
			installedApp.exec = toUTF8(getMgxReadConfig(cfg, "Exec", ""));
			installedApp.bigIcon = fixIconName( toUTF8(getMgxReadConfig(cfg, "Icon", "")), sTemp + "/"+sFolder);
			installedApp.aniIcon = installedApp.bigIcon;
			installedApp.smallIcon = fixIconToSmall(installedApp.bigIcon, sTemp + "/"+sFolder);
			installedApp.simpleIcon = installedApp.smallIcon;
			break;
		}
		default:
			break;		
	}
    installedApp.appSize = STUFF_Global::getSize(sTemp);
    
    toLog("Check installed");
    bool bUpdateApp=false;
    QString sOldVersion="";
    
    if ( type == PAK_MGX || type == PAK_PEP )
    {
		ZConfig PhoneRegistry ( "/ezxlocal/download/appwrite/am/InstalledDB" );
		QStringList grouplist;
		PhoneRegistry.getGroupsKeyList( grouplist );
        for ( QStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) 
        {
			if ( PhoneRegistry.readEntry( *it, "Name", "" ) == installedApp.name )
			{
				sOldVersion = PhoneRegistry.readEntry( *it, "Version", "" );
				installedApp.uid = QUuid(PhoneRegistry.readEntry( *it, "AppID", "" ));
				installedApp.appId = *it;
				installedApp.directory = PhoneRegistry.readEntry( *it, "Directory", "" );
				installedApp.device = AM_Global::Flash2;
				bUpdateApp=true;
				break;
			}
        }	
        if ( !bUpdateApp && uiDlg->isCardMounted() )
        {
			ZConfig CardRegistry ( "/mmc/mmca1/.system/java/CardRegistry" );
			CardRegistry.getGroupsKeyList( grouplist );
			for ( QStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) 
			{
				if ( CardRegistry.readEntry( *it, "Name", "" ) == installedApp.name )
				{
					sOldVersion = CardRegistry.readEntry( *it, "Version", "" );
					installedApp.uid = QUuid(CardRegistry.readEntry( *it, "AppID", "" ));
					installedApp.appId = *it;
					installedApp.directory = CardRegistry.readEntry( *it, "Directory", "" );
					installedApp.device = AM_Global::Card1;
					bUpdateApp=true;
					break;
				}
			}				
		}
	} else
		sOldVersion="-";
	
    toLog("Show discription app");
    if ( bUpdateApp || type == PAK_PEP_UPDATE )
		bCancel = uiDlg->updateDlg(installedApp.name, sOldVersion, installedApp.version );
    else
		bCancel = uiDlg->appDetailsCardDlg("", installedApp.name, installedApp.vendor, installedApp.version, QString::number(installedApp.appSize) );
	
	if ( bCancel )
	{
		cancelInstall();
		return 0;
	}   
	
	if ( type == PAK_MGX && !bUpdateApp )
	{
		toLog("Get location app");
		uiDlg->installLocationDlg( installedApp.name, 0, installedApp.device );		
		toLog("Device id: "+QString::number( installedApp.device ) );
				
		toLog("Set directory for MGX");
		installedApp.directory = getPathByDevice(installedApp.device)+"/"+sFolder;
	}

	toLog("Check free space");	
	if ( getFileSystemFreeSize(installedApp.device) < installedApp.appSize && !bUpdateApp )
	{
		uiDlg->memFullDlg(installedApp.device, installedApp.appSize);
		cancelInstall();
		return 0;		
	}
	
	toLog("Show process dlg");
	uiDlg->initProgressBar( "", installedApp.name, "Install" );
	uiDlg->disableProgressCancel();
	
	if ( installedApp.directory.isEmpty() ||  bCancel )
	{
		uiDlg->invalidPkgDlg();
		cancelInstall();
		return 0;			
	}
	
	uiDlg->setProgressBar( 5 );
	qApp->processEvents();	
	
	toLog("Move folder");
    switch ( type )
    {
		case PAK_PEP:
		case PAK_PEP_UPDATE:
		{
			ZConfig cfg( sTemp + "/description.ini" );
			//if no need add app to menu => this pakege = update pakege
			if ( !cfg.readBoolEntry( "Actions", "AddAppToMenu", true ) ) 
				type = PAK_PEP_UPDATE;
			if ( cfg.readBoolEntry( "Actions", "PreInstall", false ) )
				system( (sTemp+"/scripts/"+cfg.readEntry( "PreInstall", "Name", "" )).utf8() );		
			
			QDir dir;
			if ( dir.exists ( installedApp.directory ) )
			{			
				system( QString ( "cp -rf %1/app/* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );	
				system( QString ( "cp -rf %1/app/.[!.]* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );
			} else
			{
				system( QString( "mkdir -p %1" ).arg( installedApp.directory ).utf8() );
				system( QString ( "mv -f %1/app/* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );	
				system( QString ( "mv -f %1/app/.[!.]* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );				
			}			
			//system( QString ( "mv -f %1/app/* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );	
			//system( QString ( "mv -f %1/app/.[!.]* %2" ).arg( sTemp ).arg( installedApp.directory ).utf8() );
			//system( QString ( "cd %1; mkdir -p `find -type d | sed -e 's|\\./|%2/|'`; busybox_full find . -type f -exec mv -f '{}' '%3/{}' \\;" ).arg( sTemp+"/app" ).arg( installedApp.directory ).arg( installedApp.directory ).utf8() );
			//toLog( QString ( "cd %1; mkdir -p `find -type d | sed -e 's|\\./|%2/|'`; busybox_full find . -type f -exec mv -f '{}' '%3/{}' \\;" ).arg( sTemp+"/app" ).arg( installedApp.directory ).arg( installedApp.directory ).utf8() );
			if ( type != PAK_PEP_UPDATE )
			{
				if ( !installedApp.bigIcon.isEmpty() ) system( QString ( "mv -f %1/%2 %3/%4" ).arg( sTemp ).arg( installedApp.bigIcon ).arg( installedApp.directory ).arg( installedApp.bigIcon ).utf8() );
				if ( !installedApp.smallIcon.isEmpty() ) system( QString ( "mv -f %1/%2 %3/%4" ).arg( sTemp ).arg( installedApp.smallIcon ).arg( installedApp.directory ).arg( installedApp.smallIcon ).utf8() );
				if ( !installedApp.aniIcon.isEmpty() ) system( QString ( "mv -f %1/%2 %3/%4" ).arg( sTemp ).arg( installedApp.aniIcon ).arg( installedApp.directory ).arg( installedApp.aniIcon ).utf8() );
			}
			
			if ( cfg.readBoolEntry( "Actions", "AssignExt", false ) )
				extAssign( &installedApp, QStringList::split(";", cfg.readEntry("AssignExt", "Ext", "")) );
			break;
		}
		
		case PAK_MGX:
		{
			QDir dir;
			if ( dir.exists ( installedApp.directory ) )
			{
				system( QString ( "cp -rf %1/%2/* %3/" ).arg( sTemp ).arg( sFolder ).arg( installedApp.directory ).utf8() );
				system( QString ( "cp -rf %1/%2/.[!.]* %3/" ).arg( sTemp ).arg( sFolder ).arg( installedApp.directory ).utf8() );	
			} else
			{
				system( QString( "mkdir -p %1" ).arg( installedApp.directory ).utf8() );
				system( QString ( "mv -f %1/%2/* %3/" ).arg( sTemp ).arg( sFolder ).arg( installedApp.directory ).utf8() );
				system( QString ( "mv -f %1/%2/.[!.]* %3/" ).arg( sTemp ).arg( sFolder ).arg( installedApp.directory ).utf8() );					
			}
			
			//system( QString ( "cd %1; mkdir -p `find -type d | sed -e 's|\\./|%2/|'`; busybox_full find . -type f -exec mv -f '{}' '%3/{}' \\;" ).arg( sFolder ).arg( installedApp.directory ).arg( installedApp.directory ).utf8() );
			//toLog( QString ( "cd %1; mkdir -p `find -type d | sed -e 's|\\./|%2/|'`; busybox_full find . -type f -exec mv -f '{}' '%3/{}' \\;" ).arg( sFolder ).arg( installedApp.directory ).arg( installedApp.directory ).utf8() );
			break;
		}
		default:
			break;	
	}
	
	uiDlg->setProgressBar( 50 );
	qApp->processEvents();

	toLog(QString("Set chmod: ")+installedApp.directory+"/"+installedApp.exec );
	system ( QString( "chmod a+x %1/%2" ).arg( installedApp.directory ).arg( installedApp.exec ).utf8() );
	
	//Fix bad chinese script
	if ( installedApp.exec.endsWith(".sh") || installedApp.exec.endsWith(".lin") )
	{
		FILE * f = fopen( installedApp.directory+"/"+installedApp.exec, "rt" );
		if ( f )
		{
			fseek(f, 0, SEEK_END);
			int iFileSize = ftell(f);
			char * text = (char *)malloc(sizeof(char)*iFileSize);
			fseek(f, 0, SEEK_SET);		
			fread(text, sizeof(char), iFileSize, f);
			fclose(f);		
			int startId=0;
			while ( startId<iFileSize && *(text+startId) != '#' ) 
			{
				if ( *(text+startId) == 0x0A )
				{
					startId=-1;
					break;
				}
				startId++;
			}
			if ( startId > 0 )
			{
				f = fopen( installedApp.directory+"/"+installedApp.exec, "wt" );
				fwrite(text+3, sizeof(char), iFileSize-3, f); // 3 ??? maybe need change 3 to startId ???
				fclose(f);
			}
			free(text);
		}
	}
	
	uiDlg->setProgressBar( 55 );
	qApp->processEvents();
	
	if ( type != PAK_PEP_UPDATE )
	{
		toLog("Write info about program to registry");
		writeToRegistry( &installedApp );
	}
	
	toLog("Run post install script");
    switch ( type )
    {
		case PAK_PEP:
		case PAK_PEP_UPDATE:
		{
			ZConfig cfg( sTemp + "/description.ini" );
			if ( cfg.readBoolEntry( "Actions", "PostInstall", false ) )
				system( sTemp+"/scripts/"+cfg.readEntry( "PostInstall", "Name", "" )+"&" );			
			break;
		}
		default:
			break;	
	}
	
	uiDlg->setProgressBar( 90 );
	qApp->processEvents();	
	
	clearTmpDir(sTemp, false);
	
	uiDlg->setProgressBar( 100 );
	qApp->processEvents();	
	
	toLog("Close process dlg");
	uiDlg->close();
	
	toLog("Show dlg installed sucessful");
	uiDlg->appInstalledNoLaunchDlg( installedApp.name );
	
	return 1;
}
void xInstaller::writeToRegistry( AppEntry * app )
{
	QString cfgFile;
	
	switch ( app->device )
	{
		case AM_Global::Flash2:
			cfgFile = "/ezxlocal/download/appwrite/am/InstalledDB";
			break;
		case AM_Global::Card1:
			cfgFile = "/mmc/mmca1/.system/java/CardRegistry";
			break;
		default:
			break;			
	}	
	
	ZConfig registry( cfgFile );
	registry.writeEntry(app->appId, "Name",        app->name);
	registry.writeEntry(app->appId, "ObjectType",  2);
	registry.writeEntry(app->appId, "AniIcon",     app->directory+"/"+app->aniIcon);	
	registry.writeEntry(app->appId, "AppID",       app->uid);
	registry.writeEntry(app->appId, "AppType",     app->m_type);
	registry.writeEntry(app->appId, "Args",        "");
	registry.writeEntry(app->appId, "Attribute",   1);
	registry.writeEntry(app->appId, "Directory",   app->directory);
	registry.writeEntry(app->appId, "BigIcon",     app->directory+"/"+app->bigIcon);
	registry.writeEntry(app->appId, "SimpleIcon",  app->directory+"/"+app->simpleIcon);
	registry.writeEntry(app->appId, "SVGIcon",     app->directory+"/"+app->simpleIcon);
	registry.writeEntry(app->appId, "Icon",        app->directory+"/"+app->simpleIcon);
	registry.writeEntry(app->appId, "Daemon",      1);
	registry.writeEntry(app->appId, "ExecId",      app->exec);
	registry.writeEntry(app->appId, "GroupID",     "root");
	registry.writeEntry(app->appId, "UserID",      "root");
	registry.writeEntry(app->appId, "LockEnabled", 0);	
	registry.writeEntry(app->appId, "Erasable",    app->isErasable);
	registry.writeEntry(app->appId, "Shared",      app->isShared);
	registry.writeEntry(app->appId, "Vendor",      app->vendor);
	registry.writeEntry(app->appId, "Version",     app->version);
	registry.writeEntry(app->appId, "Size",        app->appSize);
	
	QDate d = QDateTime::currentDateTime().date();
	QString sDate;
	sDate.sprintf("%.4d/%.2d/%.2d",d.year(),d.month(),d.day());
	
	registry.writeEntry ( app->appId, "InstalledDate", sDate );

	if ( app->device == AM_Global::Card1 )
	{
		QString imei = getIMEI();
		registry.writeEntry ( app->appId, "IMEI", imei );
		
		ZConfig regconf("/mmc/mmca1/.system/java/MemoryCardConfig");
		regconf.writeEntry ( app->appId, "IMEI", imei );
		regconf.writeEntry ( app->appId, "Folder", app->parentFolderUid);
		regconf.flush();
	}
	registry.flush();
	
	ZConfig userMenuTree ( "/ezxlocal/download/appwrite/am/UserMenuTree" );
	QString list = userMenuTree.readEntry(app->parentFolderUid, "Items", "");
	if ( !list.endsWith(";") )
		list=list+";";
	if ( list.find(app->appId+";")==-1 )
	{
		//write change
		userMenuTree.writeEntry(app->parentFolderUid, "Items", list+app->appId+";");
		userMenuTree.flush();
		//update menu
		QByteArray data;
		QDataStream stream(data, IO_WriteOnly);
		stream << getpid() << app->appId << app->parentFolderUid << app->position << false;
		QCopChannel::send("AM/AppRegistry/Channel", "appApplicatonObject()", data);	
	}
}