int main(int argc, char **argv)
{
    Q_UNUSED(argc);
    Q_UNUSED(argv);
    KConfigRawEditor conf("testconfig");

    if( conf.load() )
    {
        qDebug() << "Is mutable" << conf.group("General")->isMutable;
        qDebug() << "Normal value" << conf.group("General")->data["widgetStyle"].value
            << conf.group("General")->data["widgetStyle"].type;
	qDebug() << "Immutable value" << conf.group("NormalGroup")->data["ImmutableValue"].value
	    << conf.group("NormalGroup")->data["ImmutableValue"].type;
	qDebug() << "ShellExpanded value" << conf.group("NormalGroup")->data["ShellExpandedValue"].value
	    << conf.group("NormalGroup")->data["ShellExpandedValue"].type;
	qDebug() << "ShellExpandedAndImmutable value" << conf.group("NormalGroup")->data["ShellExpandedAndImmutableValue"].value
	    << conf.group("NormalGroup")->data["ShellExpandedAndImmutableValue"].type;

	qDebug() << "Is not mutable" << conf.group("ImutableGroup")->isMutable;
		qDebug() << "Normal value" << conf.group("ImutableGroup")->data["NormalValue"].value
	    << conf.group("ImutableGroup")->data["NormalValue"].type;
	qDebug() << "ShellExpanded value" << conf.group("ImutableGroup")->data["ShellExpandedValue"].value
	    << conf.group("ImutableGroup")->data["ShellExpandedValue"].type;
    }

     KConfigRawEditor conf2("testconfig-out");
     conf2.group("General")->isMutable = true;
     conf2.group("General")->data["Normal Value"] = KConfigRawEditor::KConfigEntryData( "Normal Value", KConfigRawEditor::KConfigEntryData::Normal );
     conf2.group("General")->data["Nother Value"] = KConfigRawEditor::KConfigEntryData( "Nother Normal Value", KConfigRawEditor::KConfigEntryData::Normal );

     conf2.save();

    return 0;
}
int main(int argc, char** argv)
{
	ZApplication *a = new ZApplication(argc, argv);
	ZConfig conf("/ezxlocal/download/appwrite/setup/ezx_theme.cfg");
	QString skinpath = conf.readEntry("THEME_GROUP_LOG", "CurrentTheme");
	qDebug(skinpath);

	ZConfig conf2(skinpath);
	QString oriwallpaper = conf2.readEntry("THEME_CONFIG_TABLE", "WallPaper");
	qDebug(oriwallpaper);
	
	QPixmap *ori_pixmap = new QPixmap(oriwallpaper);//QWallpaper::sysWallpaper();//new QPixmap(wallpaper);
	if(ori_pixmap->isNull())
	{
	qDebug("DEBUG::  wallpaper is null");
	return 0;
	}
	QWallpaper::setSysWallpaper(ori_pixmap);
	ori_pixmap = QWallpaper::sysWallpaper();
	
	ZConfig setupconf(SETUPPATH);
	QString cityid = setupconf.readEntry("SETUP", "cityid");
	QString curskin = setupconf.readEntry("SETUP", "skin");
	QPixmap *wppanel = new QPixmap(getAppDir()+"skins/"+curskin+"/wp/wpweather.png");
	QPixmap *alarmpanel = new QPixmap(getAppDir()+"skins/"+curskin+"/wp/wpalarm.png");	
	QString alarmtext = setupconf.readEntry("WP", "text");
	int panel_x = setupconf.readNumEntry("WP", "panel_x"); 
	int panel_y = setupconf.readNumEntry("WP", "panel_y");
	int alarmpanel_x = setupconf.readNumEntry("WP", "alarmpanel_x");
	int alarmpanel_y = setupconf.readNumEntry("WP", "alarmpanel_y");
	bool showwp = setupconf.readBoolEntry("SETUP", "showweather");
	bool showalarm = setupconf.readBoolEntry("SETUP", "showwpalarm");
	
	ZConfig wsconf(getAppDir()+"skins/"+curskin+"/skin.ini");
	QString weatherpath = wsconf.readEntry("panel1", "weathericon");
	

	int weather_x = wsconf.readNumEntry("WP", "weather_x"); 
	int weather_y = wsconf.readNumEntry("WP", "weather_y"); 
	int city_x = wsconf.readNumEntry("WP", "city_x"); 
	int city_y = wsconf.readNumEntry("WP", "city_y"); 
	int weathertext_x = wsconf.readNumEntry("WP", "weathertext_x"); 
	int weathertext_y = wsconf.readNumEntry("WP", "weathertext_y"); 
	int size_city = wsconf.readUIntEntry("WP", "size_city");
	int size_weather = wsconf.readUIntEntry("WP", "size_weather");
	QColor textcolor(wsconf.readUIntEntry("WP", "text_R"),wsconf.readUIntEntry("WP", "text_G"),wsconf.readUIntEntry("WP", "text_B"));
	
	

	int alarmtext_x = wsconf.readNumEntry("WPALARM", "alarmtext_x");
	int alarmtext_y = wsconf.readNumEntry("WPALARM", "alarmtext_y");
	QColor alarmcolor(wsconf.readUIntEntry("WPALARM", "alarm_R"),wsconf.readUIntEntry("WPALARM", "alarm_G"),wsconf.readUIntEntry("WPALARM", "alarm_B"));
	int size_alarm = wsconf.readUIntEntry("WPALARM", "size_alarmtext");
	
	ZConfig infoconf(INFOPATH);
	int img1 = infoconf.readUIntEntry(cityid, "img1");
	QString city = infoconf.readEntry(cityid,"city");
	QString weathertext = infoconf.readEntry(cityid, "weather1")+infoconf.readEntry(cityid, "temp1");
	QPixmap *weather;
	if(img1<10)
	weather = new QPixmap(QString(getAppDir()+"weathericon/"+weatherpath+"/smallicon/"+"s000%1"+".png").arg(img1));
	else
	weather = new QPixmap(QString(getAppDir()+"weathericon/"+weatherpath+"/smallicon/"+"s00%1"+".png").arg(img1));

	
	
	
	QPainter painter;
	painter.begin(ori_pixmap);
	if(showwp)
	{
	painter.drawPixmap(panel_x, panel_y, *wppanel);
	painter.drawPixmap(weather_x+panel_x, weather_y+panel_y, *weather);
	painter.setFont(QFont("AMSCL", size_city, QFont::Bold));
	painter.setPen(textcolor);
	painter.drawText(city_x+panel_x, city_y+panel_y, city);
	painter.setFont(QFont("AMSCL", size_weather, QFont::Normal));
	painter.drawText(weathertext_x+panel_x, weathertext_y+panel_y, weathertext);
	}
	if(showalarm)
	{
	painter.drawPixmap(alarmpanel_x, alarmpanel_y, *alarmpanel);
	painter.setFont(QFont("AMSCL", size_alarm, QFont::Bold));
	painter.setPen(alarmcolor);
	painter.drawText(alarmpanel_x+alarmtext_x, alarmpanel_y+alarmtext_y, alarmtext);
	}
	
	
	painter.end();
	QWallpaper::setSysWallpaper(ori_pixmap);
	//int i = a->exec();
	delete ori_pixmap;
	delete wppanel;
	delete weather;
	delete a;
	delete alarmpanel;
	//return i;
	//qApp->quit();
	
}
void cSemaineEmmaSender::sendInterestC( cComponentMessage *_msg )
{
  char strtmp[50];
  sprintf(strtmp,"%.2f",_msg->floatData[0]);
  std::string interestStr(strtmp);

  // Create and fill a simple EMMA EmotionML document
  XERCESC_NS::DOMDocument * document = XMLTool::newDocument(EMMA::E_EMMA, EMMA::namespaceURI, EMMA::version);

  sprintf(strtmp,"%ld",smileTimeToSemaineTime(_msg->userTime1));
  std::string startTm(strtmp);
  sprintf(strtmp,"%ld",(long long)round((_msg->userTime2 - _msg->userTime1)*1000.0));
  std::string duration(strtmp);

  XERCESC_NS::DOMElement * oneof = XMLTool::appendChildElement(document->getDocumentElement(), EMMA::E_ONEOF);
  XMLTool::setAttribute(oneof, EMMA::A_OFFSET_TO_START, startTm);
  XMLTool::setAttribute(oneof, EMMA::A_DURATION, duration);
  XMLTool::setPrefix(oneof, "emma");

  XERCESC_NS::DOMElement * interpretation0 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);
  sprintf(strtmp,"%.3f",((double*)(_msg->custData))[0]);
  std::string conf0(strtmp);
  XMLTool::setAttribute(interpretation0, EMMA::A_CONFIDENCE, conf0);
  XMLTool::setPrefix(interpretation0, "emma");

  XERCESC_NS::DOMElement * emotion0 = XMLTool::appendChildElement(interpretation0, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setPrefix(emotion0, "emotion");
  XERCESC_NS::DOMElement * category0 = XMLTool::appendChildElement(emotion0, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category0, EmotionML::A_SET, "interestLevels");
  XMLTool::setAttribute(category0, EmotionML::A_NAME, "bored");
  XMLTool::setPrefix(category0, "emotion");

  XERCESC_NS::DOMElement * interpretation1 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);
  sprintf(strtmp,"%.3f",((double*)(_msg->custData))[1]);
  std::string conf1(strtmp);
  XMLTool::setAttribute(interpretation1, EMMA::A_CONFIDENCE, conf1);
  XMLTool::setPrefix(interpretation1, "emma");

  XERCESC_NS::DOMElement * emotion1 = XMLTool::appendChildElement(interpretation1, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setPrefix(emotion1, "emotion");
  XERCESC_NS::DOMElement * category1 = XMLTool::appendChildElement(emotion1, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category1, EmotionML::A_SET, "interestLevels");
  XMLTool::setAttribute(category1, EmotionML::A_NAME, "neutral");
  XMLTool::setPrefix(category1, "emotion");
  
  XERCESC_NS::DOMElement * interpretation2 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);
  sprintf(strtmp,"%.3f",((double*)(_msg->custData))[2]);
  std::string conf2(strtmp);
  XMLTool::setAttribute(interpretation2, EMMA::A_CONFIDENCE, conf2);
  XMLTool::setPrefix(interpretation2, "emma");

  XERCESC_NS::DOMElement * emotion2 = XMLTool::appendChildElement(interpretation2, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setPrefix(emotion2, "emotion");
  XERCESC_NS::DOMElement * category2 = XMLTool::appendChildElement(emotion2, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category2, EmotionML::A_SET, "interestLevels");
  XMLTool::setAttribute(category2, EmotionML::A_NAME, "interested");
  XMLTool::setPrefix(category2, "emotion");

  // Now send it
  sendDocument(document);
}
void cSemaineEmotionSender::sendInterestC( cComponentMessage *_msg )
{
  char strtmp[50];
  sprintf(strtmp,"%.2f",_msg->floatData[0]);
  std::string interestStr(strtmp);

  // Create and fill a simple EMMA EmotionML document
  XERCESC_NS::DOMDocument * document = XMLTool::newDocument(EMMA::E_EMMA, EMMA::namespaceURI, EMMA::version);
  XMLTool::setPrefix(document->getDocumentElement(), "emma");

  sprintf(strtmp,"%ld",smileTimeToSemaineTime(_msg->userTime1));
  std::string startTm(strtmp);
  sprintf(strtmp,"%ld",(long long)round((_msg->userTime2 - _msg->userTime1)*1000.0));
  std::string duration(strtmp);

  XERCESC_NS::DOMElement * oneof = XMLTool::appendChildElement(document->getDocumentElement(), EMMA::E_ONEOF);
  XMLTool::setAttribute(oneof, EMMA::A_OFFSET_TO_START, startTm);
  XMLTool::setAttribute(oneof, EMMA::A_DURATION, duration);
  XMLTool::setPrefix(oneof, "emma");

  double v = 0.0;
  //TODO: update this to new classification result message!  check that probEstim is not NULL....!
  XERCESC_NS::DOMElement * interpretation0 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);

  if (_msg->custData != NULL) v = ((double*)(_msg->custData))[0];
  sprintf(strtmp,"%.3f",v);
  std::string conf0(strtmp);
  XMLTool::setAttribute(interpretation0, EMMA::A_CONFIDENCE, conf0);
  XMLTool::setPrefix(interpretation0, "emma");

  XERCESC_NS::DOMElement * emotion0 = XMLTool::appendChildElement(interpretation0, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setAttribute(emotion0, EmotionML::A_CATEGORY_VOCABULARY , EmotionML::VOC_SEMAINE_INTEREST_CATEGORY_DEFINITION);
  XMLTool::setPrefix(emotion0, "emotion");
  
  XERCESC_NS::DOMElement * category0 = XMLTool::appendChildElement(emotion0, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category0, EmotionML::A_NAME, "bored");
  XMLTool::setPrefix(category0, "emotion");

  XERCESC_NS::DOMElement * interpretation1 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);
  if (_msg->custData != NULL) v = ((double*)(_msg->custData))[1];
  else v = 0;
  sprintf(strtmp,"%.3f",v);
  std::string conf1(strtmp);
  XMLTool::setAttribute(interpretation1, EMMA::A_CONFIDENCE, conf1);
  XMLTool::setPrefix(interpretation1, "emma");

  XERCESC_NS::DOMElement * emotion1 = XMLTool::appendChildElement(interpretation1, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setAttribute(emotion1, EmotionML::A_CATEGORY_VOCABULARY , EmotionML::VOC_SEMAINE_INTEREST_CATEGORY_DEFINITION);
  XMLTool::setPrefix(emotion1, "emotion");
  XERCESC_NS::DOMElement * category1 = XMLTool::appendChildElement(emotion1, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category1, EmotionML::A_NAME, "neutral");
  XMLTool::setPrefix(category1, "emotion");
  
  XERCESC_NS::DOMElement * interpretation2 = XMLTool::appendChildElement(oneof, EMMA::E_INTERPRETATION);
  if (_msg->custData != NULL) v = ((double*)(_msg->custData))[2];
  else v = 0;
  sprintf(strtmp,"%.3f",v);
  std::string conf2(strtmp);
  XMLTool::setAttribute(interpretation2, EMMA::A_CONFIDENCE, conf2);
  XMLTool::setPrefix(interpretation2, "emma");

  XERCESC_NS::DOMElement * emotion2 = XMLTool::appendChildElement(interpretation2, EmotionML::E_EMOTION, EmotionML::namespaceURI);
  XMLTool::setAttribute(emotion2, EmotionML::A_CATEGORY_VOCABULARY , EmotionML::VOC_SEMAINE_INTEREST_CATEGORY_DEFINITION);
  XMLTool::setPrefix(emotion2, "emotion");
  XERCESC_NS::DOMElement * category2 = XMLTool::appendChildElement(emotion2, EmotionML::E_CATEGORY, EmotionML::namespaceURI);
  XMLTool::setAttribute(category2, EmotionML::A_NAME, "interested");
  XMLTool::setPrefix(category2, "emotion");

  // Now send it
  sendDocument(document);
}