Ejemplo n.º 1
0
void DocBookReader::handleSeparatorField() {
	static const std::string HYPERLINK = "HYPERLINK";
	static const std::string SEQUENCE = "SEQ";
//	static const std::string PAGE = "PAGE";
//	static const std::string PAGEREF = "PAGEREF";
//	static const std::string SHAPE = "SHAPE";
	static const std::string SPACE_DELIMETER = " ";
	static const std::string LOCAL_LINK = "\\l";
	static const std::string QUOTE = "\"";
	myReadFieldState = READ_FIELD_TEXT;
	myHyperlinkTypeState = NO_HYPERLINK;
	ZLUnicodeUtil::Ucs2String buffer = myFieldInfoBuffer;
	myFieldInfoBuffer.clear();
	std::string utf8String;
	ZLUnicodeUtil::ucs2ToUtf8(utf8String, buffer);
	ZLStringUtil::stripWhiteSpaces(utf8String);
	if (utf8String.empty()) {
		return;
	}
	std::vector<std::string> result = ZLStringUtil::split(utf8String, SPACE_DELIMETER);
	//TODO split function can returns empty string, maybe fix it
	std::vector<std::string> splitted;
	for (size_t i = 0; i < result.size(); ++i) {
		if (!result.at(i).empty()) {
			splitted.push_back(result.at(i));
		}
	}

	if (!splitted.empty() && splitted.at(0) == SEQUENCE) {
		myReadFieldState = READ_FIELD_TEXT;
		myHyperlinkTypeState = NO_HYPERLINK;
		return;
	}

	if (splitted.size() < 2 || splitted.at(0) != HYPERLINK) {
		myReadFieldState = DONT_READ_FIELD_TEXT;
		//to remove pagination from TOC and not hyperlink fields
		return;
	}

	if (splitted.at(1) == LOCAL_LINK) {
		std::string link = parseLink(buffer);
		if (!link.empty()) {
			myModelReader.addHyperlinkControl(INTERNAL_HYPERLINK, link);
			myHyperlinkTypeState = INT_HYPERLINK_INSERTED;
		}
	} else {
		std::string link = parseLink(buffer, true);
		if (!link.empty()) {
			myModelReader.addHyperlinkControl(EXTERNAL_HYPERLINK, link);
			myHyperlinkTypeState = EXT_HYPERLINK_INSERTED;
		}
	}
}
Ejemplo n.º 2
0
static void
parseStyle (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb)
{
  xmlChar *content;
  xmlChar *prop;
  int start = fb->utf8_current_index;

  prop = xmlGetProp(cur, (const xmlChar *)"name");

  cur = cur->children;

  while (cur != NULL) {

    if (xmlNodeIsText(cur)) {
      content = xmlNodeGetContent(cur);
      if (content)
	bufferAppend(content, xmlStrlen(content), fb);
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) {
      parseStyle(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int st = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(st, fb->utf8_current_index, STRONG_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int st = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(st, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"a")) {
      parseLink(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) {
      parseImage(doc, cur, fb);

    }

    cur = cur->next;
  }

  if (prop && (!xmlStrcmp(prop, (const xmlChar *)"italic"))) {
    addMark(start, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb);
    xmlFree(prop);
  }

  return;
}
void AISUpdate::parseEmbeddedLinks(const LLSD& links)
{
	for(LLSD::map_const_iterator linkit = links.beginMap(),
			linkend = links.endMap();
		linkit != linkend; ++linkit)
	{
		const LLUUID link_id((*linkit).first);
		const LLSD& link_map = (*linkit).second;
		if (mItemIds.end() == mItemIds.find(link_id))
		{
			LL_DEBUGS("Inventory") << "Ignoring link not in items list " << link_id << LL_ENDL;
		}
		else
		{
			parseLink(link_map);
		}
	}
}
Ejemplo n.º 4
0
bool QGeoRouteXmlParser::parseLeg()
{
    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Leg");

    m_reader->readNext();
    bool succeeded = true;
    while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Leg")) {
        if (m_reader->tokenType() == QXmlStreamReader::StartElement && succeeded) {
            if (m_reader->name() == "Maneuver") {
                succeeded = parseManeuver();
            } else if (m_reader->name() == "Link") {
                succeeded = parseLink();
            } else {
                m_reader->skipCurrentElement();
            }
        }
        m_reader->readNext();
    }

    return succeeded;
}
void AISUpdate::parseContent(const LLSD& update)
{
	if (update.has("linked_id"))
	{
		parseLink(update);
	}
	else if (update.has("item_id"))
	{
		parseItem(update);
	}

	if (update.has("category_id"))
	{
		parseCategory(update);
	}
	else
	{
		if (update.has("_embedded"))
		{
			parseEmbedded(update["_embedded"]);
		}
	}
}
Ejemplo n.º 6
0
MainWindow::MainWindow( QWidget *parent )
:	QWidget( parent )
,	cardsGroup( new QActionGroup( this ) )
,	quitOnClose( false )
{
	setWindowFlags( Qt::Window|Qt::CustomizeWindowHint|Qt::WindowMinimizeButtonHint|Qt::WindowCloseButtonHint );
	setAttribute( Qt::WA_DeleteOnClose, true );
	setupUi( this );

	cards->hide();
	cards->hack();
	languages->hack();

	Settings s;
	// Mobile
	infoMobileCode->setValidator( new IKValidator( infoMobileCode ) );
	infoMobileCode->setText( s.value( "Client/MobileCode" ).toString() );
	infoMobileCell->setText( s.value( "Client/MobileNumber", "+372" ).toString() );
	connect( infoMobileCode, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoMobileCell, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoSignMobile, SIGNAL(toggled(bool)), SLOT(showCardStatus()) );

	// Buttons
	QButtonGroup *buttonGroup = new QButtonGroup( this );

	buttonGroup->addButton( settings, HeadSettings );
	buttonGroup->addButton( help, HeadHelp );
	buttonGroup->addButton( about, HeadAbout );

	buttonGroup->addButton( homeSign, HomeSign );
	buttonGroup->addButton( homeView, HomeView );
	buttonGroup->addButton( homeCrypt, HomeCrypt );

	introNext = introButtons->addButton( tr( "Next" ), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( introNext, IntroNext );
	buttonGroup->addButton( introButtons->button( QDialogButtonBox::Cancel ), IntroBack );

	signButton = signButtons->addButton( tr("Sign"), QDialogButtonBox::AcceptRole );
	buttonGroup->addButton( signButton, SignSign );
	buttonGroup->addButton( signButtons->button( QDialogButtonBox::Cancel ), SignCancel );

	viewAddSignature = viewButtons->addButton( tr("Add signature"), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( viewAddSignature, ViewAddSignature );
	buttonGroup->addButton( viewButtons->button( QDialogButtonBox::Close ), ViewClose );
	connect( buttonGroup, SIGNAL(buttonClicked(int)),
		SLOT(buttonClicked(int)) );

	connect( infoCard, SIGNAL(linkActivated(QString)), SLOT(parseLink(QString)) );
	connect( cards, SIGNAL(activated(QString)), qApp->signer(), SLOT(selectCard(QString)), Qt::QueuedConnection );
	connect( qApp->signer(), SIGNAL(dataChanged()), SLOT(showCardStatus()) );

	// Digidoc
	doc = new DigiDoc( this );

	// Translations
	lang << "et" << "en" << "ru";
	retranslate();
	QActionGroup *langGroup = new QActionGroup( this );
	for( int i = 0; i < lang.size(); ++i )
	{
		QAction *a = langGroup->addAction( new QAction( langGroup ) );
		a->setData( lang[i] );
		a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_0 + i );
	}
	addActions( langGroup->actions() );
	connect( langGroup, SIGNAL(triggered(QAction*)), SLOT(changeLang(QAction*)) );
	connect( cardsGroup, SIGNAL(triggered(QAction*)), SLOT(changeCard(QAction*)) );

	// Views
	signContentView->setColumnHidden( 2, true );
	viewContentView->setColumnHidden( 3, true );
	connect( signContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );
	connect( viewContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );
}
Ejemplo n.º 7
0
bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
{
    
    TiXmlDocument xml_doc;
    xml_doc.Parse(sdfText);
    if (xml_doc.Error())
    {
        logger->reportError(xml_doc.ErrorDesc());
        xml_doc.ClearError();
        return false;
    }

    TiXmlElement *sdf_xml = xml_doc.FirstChildElement("sdf");
    if (!sdf_xml)
    {
        logger->reportError("expected an sdf element");
        return false;
    }
    
    TiXmlElement *world_xml = sdf_xml->FirstChildElement("world");
    if (!world_xml)
    {
        logger->reportError("expected a world element");
        return false;
    }
    
    // Get all model (robot) elements
    for (TiXmlElement* robot_xml = world_xml->FirstChildElement("model"); robot_xml; robot_xml = robot_xml->NextSiblingElement("model"))
    {
        UrdfModel* localModel = new UrdfModel;
        m_tmpModels.push_back(localModel);
        
        
        // Get robot name
        const char *name = robot_xml->Attribute("name");
        if (!name)
        {
            logger->reportError("Expected a name for robot");
            return false;
        }
        localModel->m_name = name;
        
        TiXmlElement* pose_xml = robot_xml->FirstChildElement("pose");
        if (0==pose_xml)
        {
            localModel->m_rootTransformInWorld.setIdentity();
        }
        else
        {
            parseTransform(localModel->m_rootTransformInWorld,pose_xml,logger,m_parseSDF);
        }

        // Get all Material elements
        for (TiXmlElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
        {
            UrdfMaterial* material = new UrdfMaterial;
            
            parseMaterial(*material, material_xml, logger);
            
            
            UrdfMaterial** mat =localModel->m_materials.find(material->m_name.c_str());
            if (mat)
            {
                logger->reportWarning("Duplicate material");
            } else
            {
                localModel->m_materials.insert(material->m_name.c_str(),material);
            }
        }
        
        
        //	char msg[1024];
        //	sprintf(msg,"Num materials=%d", m_model.m_materials.size());
        //	logger->printMessage(msg);
        
        
        for (TiXmlElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
        {
            UrdfLink* link = new UrdfLink;
            
            if (parseLink(*localModel, *link, link_xml,logger))
            {
                if (localModel->m_links.find(link->m_name.c_str()))
                {
                    logger->reportError("Link name is not unique, link names in the same model have to be unique");
                    logger->reportError(link->m_name.c_str());
                    return false;
                } else
                {
                    //copy model material into link material, if link has no local material
                    for (int i=0;i<link->m_visualArray.size();i++)
                    {
                        UrdfVisual& vis = link->m_visualArray.at(i);
                        if (!vis.m_hasLocalMaterial && vis.m_materialName.c_str())
                        {
                            UrdfMaterial** mat = localModel->m_materials.find(vis.m_materialName.c_str());
                            if (mat && *mat)
                            {
                                vis.m_localMaterial = **mat;
                            } else
                            {
                                //logger->reportError("Cannot find material with name:");
                                //logger->reportError(vis.m_materialName.c_str());
                            }
                        }
                    }
                    
                    localModel->m_links.insert(link->m_name.c_str(),link);
                }
            } else
            {
                logger->reportError("failed to parse link");
                delete link;
                return false;
            }
            
        }
        if (localModel->m_links.size() == 0)
        {
            logger->reportWarning("No links found in URDF file");
            return false;
        }
        
        // Get all Joint elements
        for (TiXmlElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
        {
            UrdfJoint* joint = new UrdfJoint;
            
            if (parseJoint(*joint, joint_xml,logger))
            {
                if (localModel->m_joints.find(joint->m_name.c_str()))
                {
                    logger->reportError("joint '%s' is not unique.");
                    logger->reportError(joint->m_name.c_str());
                    return false;
                }
                else
                {
                    localModel->m_joints.insert(joint->m_name.c_str(),joint);
                }
            }
            else
            {
                logger->reportError("joint xml is not initialized correctly");
                return false;
            }
        }
        
        bool ok(initTreeAndRoot(*localModel,logger));
        if (!ok)
        {
            return false;
        }
        m_sdfModels.push_back(localModel);
    }
    
    return true;
}
Ejemplo n.º 8
0
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase)
{
	
	TiXmlDocument xml_doc;
	xml_doc.Parse(urdfText);
	if (xml_doc.Error())
	{
		logger->reportError(xml_doc.ErrorDesc());
		xml_doc.ClearError();
		return false;
	}

	TiXmlElement *robot_xml = xml_doc.FirstChildElement("robot");
	if (!robot_xml)
	{
		logger->reportError("expected a robot element");
		return false;
	}
	
	// Get robot name
	const char *name = robot_xml->Attribute("name");
	if (!name)
	{
		logger->reportError("Expected a name for robot");
		return false;
	}
	m_urdf2Model.m_name = name;
	
	
	
	// Get all Material elements
	for (TiXmlElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
	{
		UrdfMaterial* material = new UrdfMaterial;
		
		parseMaterial(*material, material_xml, logger);


		UrdfMaterial** mat =m_urdf2Model.m_materials.find(material->m_name.c_str());
		if (mat)
		{
			logger->reportWarning("Duplicate material");
		} else
		{
			m_urdf2Model.m_materials.insert(material->m_name.c_str(),material);
		}
	}


//	char msg[1024];
//	sprintf(msg,"Num materials=%d", m_model.m_materials.size());
//	logger->printMessage(msg);

	
	for (TiXmlElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
	{
		UrdfLink* link = new UrdfLink;
		
		if (parseLink(m_urdf2Model,*link, link_xml,logger))
		{
			if (m_urdf2Model.m_links.find(link->m_name.c_str()))
			{
				logger->reportError("Link name is not unique, link names in the same model have to be unique");
				logger->reportError(link->m_name.c_str());
				return false;
			} else
			{
				//copy model material into link material, if link has no local material
				for (int i=0;i<link->m_visualArray.size();i++)
				{
					UrdfVisual& vis = link->m_visualArray.at(i);
					if (!vis.m_hasLocalMaterial && vis.m_materialName.c_str())
					{
						UrdfMaterial** mat = m_urdf2Model.m_materials.find(vis.m_materialName.c_str());
						if (mat && *mat)
						{
							vis.m_localMaterial = **mat;
						} else
						{
							//logger->reportError("Cannot find material with name:");
							//logger->reportError(vis.m_materialName.c_str());
						}
					}
				}
				
				m_urdf2Model.m_links.insert(link->m_name.c_str(),link);
			}
		} else
		{
			logger->reportError("failed to parse link");
			delete link;
			return false;
		}
		
	}
	if (m_urdf2Model.m_links.size() == 0)
	{
		logger->reportWarning("No links found in URDF file");
		return false;
	}
	
	// Get all Joint elements
	for (TiXmlElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
	{
		UrdfJoint* joint = new UrdfJoint;
		
		if (parseJoint(*joint, joint_xml,logger))
		{
			if (m_urdf2Model.m_joints.find(joint->m_name.c_str()))
			{
				logger->reportError("joint '%s' is not unique.");
				logger->reportError(joint->m_name.c_str());
				return false;
			}
			else
			{
				m_urdf2Model.m_joints.insert(joint->m_name.c_str(),joint);
			}
		}
		else
		{
			logger->reportError("joint xml is not initialized correctly");
			return false;
		}
	}

	bool ok(initTreeAndRoot(m_urdf2Model,logger));
	if (!ok)
	{
		return false;
	}
	
	if (forceFixedBase)
	{
		for (int i=0;i<m_urdf2Model.m_rootLinks.size();i++)
		{
			UrdfLink* link(m_urdf2Model.m_rootLinks.at(i));
			link->m_inertia.m_mass = 0.0;
			link->m_inertia.m_ixx = 0.0;
			link->m_inertia.m_ixy = 0.0;
			link->m_inertia.m_ixz = 0.0;
			link->m_inertia.m_iyy = 0.0;
			link->m_inertia.m_iyz = 0.0;
			link->m_inertia.m_izz = 0.0;
		}
	}
	
	return true;
}
Ejemplo n.º 9
0
ModelInterfaceSharedPtr  parseURDF(const std::string &xml_string)
{
  ModelInterfaceSharedPtr model(new ModelInterface);
  model->clear();

  TiXmlDocument xml_doc;
  xml_doc.Parse(xml_string.c_str());
  if (xml_doc.Error())
  {
    CONSOLE_BRIDGE_logError(xml_doc.ErrorDesc());
    xml_doc.ClearError();
    model.reset();
    return model;
  }

  TiXmlElement *robot_xml = xml_doc.FirstChildElement("robot");
  if (!robot_xml)
  {
    CONSOLE_BRIDGE_logError("Could not find the 'robot' element in the xml file");
    model.reset();
    return model;
  }

  // Get robot name
  const char *name = robot_xml->Attribute("name");
  if (!name)
  {
    CONSOLE_BRIDGE_logError("No name given for the robot.");
    model.reset();
    return model;
  }
  model->name_ = std::string(name);

  // Get all Material elements
  for (TiXmlElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
  {
    MaterialSharedPtr material;
    material.reset(new Material);

    try {
      parseMaterial(*material, material_xml, false); // material needs to be fully defined here
      if (model->getMaterial(material->name))
      {
        CONSOLE_BRIDGE_logError("material '%s' is not unique.", material->name.c_str());
        material.reset();
        model.reset();
        return model;
      }
      else
      {
        model->materials_.insert(make_pair(material->name,material));
        CONSOLE_BRIDGE_logDebug("urdfdom: successfully added a new material '%s'", material->name.c_str());
      }
    }
    catch (ParseError &/*e*/) {
      CONSOLE_BRIDGE_logError("material xml is not initialized correctly");
      material.reset();
      model.reset();
      return model;
    }
  }

  // Get all Link elements
  for (TiXmlElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
  {
    LinkSharedPtr link;
    link.reset(new Link);

    try {
      parseLink(*link, link_xml);
      if (model->getLink(link->name))
      {
        CONSOLE_BRIDGE_logError("link '%s' is not unique.", link->name.c_str());
        model.reset();
        return model;
      }
      else
      {
        // set link visual(s) material
        CONSOLE_BRIDGE_logDebug("urdfdom: setting link '%s' material", link->name.c_str());
        if (link->visual)
        {
          assignMaterial(link->visual, model, link->name.c_str());
        }
        for (const auto& visual : link->visual_array)
        {
          assignMaterial(visual, model, link->name.c_str());
        }

        model->links_.insert(make_pair(link->name,link));
        CONSOLE_BRIDGE_logDebug("urdfdom: successfully added a new link '%s'", link->name.c_str());
      }
    }
    catch (ParseError &/*e*/) {
      CONSOLE_BRIDGE_logError("link xml is not initialized correctly");
      model.reset();
      return model;
    }
  }
  if (model->links_.empty()){
    CONSOLE_BRIDGE_logError("No link elements found in urdf file");
    model.reset();
    return model;
  }

  // Get all Joint elements
  for (TiXmlElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
  {
    JointSharedPtr joint;
    joint.reset(new Joint);

    if (parseJoint(*joint, joint_xml))
    {
      if (model->getJoint(joint->name))
      {
        CONSOLE_BRIDGE_logError("joint '%s' is not unique.", joint->name.c_str());
        model.reset();
        return model;
      }
      else
      {
        model->joints_.insert(make_pair(joint->name,joint));
        CONSOLE_BRIDGE_logDebug("urdfdom: successfully added a new joint '%s'", joint->name.c_str());
      }
    }
    else
    {
      CONSOLE_BRIDGE_logError("joint xml is not initialized correctly");
      model.reset();
      return model;
    }
  }


  // every link has children links and joints, but no parents, so we create a
  // local convenience data structure for keeping child->parent relations
  std::map<std::string, std::string> parent_link_tree;
  parent_link_tree.clear();

  // building tree: name mapping
  try 
  {
    model->initTree(parent_link_tree);
  }
  catch(ParseError &e)
  {
    CONSOLE_BRIDGE_logError("Failed to build tree: %s", e.what());
    model.reset();
    return model;
  }

  // find the root link
  try
  {
    model->initRoot(parent_link_tree);
  }
  catch(ParseError &e)
  {
    CONSOLE_BRIDGE_logError("Failed to find root link: %s", e.what());
    model.reset();
    return model;
  }
  
  return model;
}
Ejemplo n.º 10
0
ParsedElement
Animxmlparser::parseNext ()
{
  ParsedElement parsedElement;
  parsedElement.type = XML_INVALID;
  parsedElement.version = m_version;
  parsedElement.isWpacket = false;

  if (m_reader->atEnd () || m_reader->hasError ())
    {
      m_parsingComplete = true;
      m_traceFile->close ();
      return parsedElement;
    }



  QXmlStreamReader::TokenType token =  m_reader->readNext ();
  if (token == QXmlStreamReader::StartDocument)
    return parsedElement;

  if (token == QXmlStreamReader::StartElement)
    {
      if (m_reader->name () == "anim")
        {
          parsedElement = parseAnim ();
        }
      if (m_reader->name () == "topology")
        {
          parsedElement = parseTopology ();
        }
      if (m_reader->name () == "node")
        {
          parsedElement = parseNode ();
        }
      if (m_reader->name () == "packet")
        {
          parsedElement = parsePacket ();
        }
      if (m_reader->name () == "p")
        {
          parsedElement = parseP ();
        }
      if (m_reader->name () == "wp")
        {
          parsedElement = parseWp ();
        }
      if (m_reader->name () == "wpacket")
        {
          parsedElement = parseWPacket ();
        }
      if (m_reader->name () == "link")
        {
          parsedElement = parseLink ();
        }
      if (m_reader->name () == "nonp2plinkproperties")
        {
          parsedElement = parseNonP2pLink ();
        }
      if (m_reader->name () == "linkupdate")
        {
          parsedElement = parseLinkUpdate ();
        }
      if (m_reader->name () == "nu")
        {
          parsedElement = parseNodeUpdate ();
        }
      if (m_reader->name () == "res")
        {
          parsedElement = parseResource ();
        }
      if (m_reader->name () == "bg")
        {
          parsedElement = parseBackground ();
        }
      if (m_reader->name () == "ncs")
        {
          parsedElement = parseCreateNodeCounter ();
        }
      if (m_reader->name () == "nc")
        {
          parsedElement = parseNodeCounterUpdate ();
        }
      if (m_reader->name () == "pr")
        {
          parsedElement = parsePacketTxRef ();
        }
      if (m_reader->name () == "wpr")
        {
          parsedElement = parseWPacketRxRef ();
        }
      //qDebug (m_reader->name ().toString ());
    }

  if (m_reader->atEnd ())
    {
      m_parsingComplete = true;
      m_traceFile->close ();
    }
  return parsedElement;
}
Ejemplo n.º 11
0
MainWindow::MainWindow( QWidget *parent )
:	QWidget( parent )
,	cardsGroup( new QActionGroup( this ) )
,	m_loaded( false )
,	quitOnClose( false )
{
	qRegisterMetaType<QSslCertificate>("QSslCertificate");

	setupUi( this );

	cards->hide();
	cards->hack();
	languages->hack();

	setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowTitleHint );
#if QT_VERSION >= 0x040500
	setWindowFlags( windowFlags() | Qt::WindowCloseButtonHint );
#else
	setWindowFlags( windowFlags() | Qt::WindowSystemMenuHint );
#endif

	QApplication::instance()->installEventFilter( this );

	Common *common = new Common( this );
	QDesktopServices::setUrlHandler( "browse", common, "browse" );
	QDesktopServices::setUrlHandler( "mailto", common, "mailTo" );

	Settings s;
	// Mobile
	infoMobileCode->setValidator( new IKValidator( infoMobileCode ) );
	infoMobileCode->setText( s.value( "Client/MobileCode" ).toString() );
	infoMobileCell->setText( s.value( "Client/MobileNumber", "+372" ).toString() );
	connect( infoMobileCode, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoMobileCell, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoSignMobile, SIGNAL(toggled(bool)), SLOT(showCardStatus()) );

	// Buttons
	QButtonGroup *buttonGroup = new QButtonGroup( this );

	buttonGroup->addButton( settings, HeadSettings );
	buttonGroup->addButton( help, HeadHelp );

	buttonGroup->addButton( homeSign, HomeSign );
	buttonGroup->addButton( homeView, HomeView );
	buttonGroup->addButton( homeCrypt, HomeCrypt );

	introNext = introButtons->addButton( tr( "Next" ), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( introNext, IntroNext );
	buttonGroup->addButton( introButtons->button( QDialogButtonBox::Cancel ), IntroBack );

	signButton = signButtons->addButton( tr("Sign"), QDialogButtonBox::AcceptRole );
	buttonGroup->addButton( signButton, SignSign );
	buttonGroup->addButton( signButtons->button( QDialogButtonBox::Cancel ), SignCancel );

	viewAddSignature = viewButtons->addButton( tr("Add signature"), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( viewAddSignature, ViewAddSignature );
	buttonGroup->addButton( viewButtons->button( QDialogButtonBox::Close ), ViewClose );
	connect( buttonGroup, SIGNAL(buttonClicked(int)),
		SLOT(buttonClicked(int)) );

	connect( infoCard, SIGNAL(linkActivated(QString)), SLOT(parseLink(QString)) );

	// Digidoc
	doc = new DigiDoc( this );
	connect( cards, SIGNAL(activated(QString)), doc, SLOT(selectCard(QString)) );
	connect( doc, SIGNAL(error(QString)), SLOT(showWarning(QString)) );
	connect( doc, SIGNAL(dataChanged()), SLOT(showCardStatus()) );
	m_loaded = doc->init();

	// Translations
	appTranslator = new QTranslator( this );
	commonTranslator = new QTranslator( this );
	qtTranslator = new QTranslator( this );
	QApplication::instance()->installTranslator( appTranslator );
	QApplication::instance()->installTranslator( commonTranslator );
	QApplication::instance()->installTranslator( qtTranslator );
	lang << "et" << "en" << "ru";
	QString deflang;
	switch( QLocale().language() )
	{
	case QLocale::English: deflang = "en"; break;
	case QLocale::Russian: deflang = "ru"; break;
	case QLocale::Estonian:
	default: deflang = "et"; break;
	}
	on_languages_activated( lang.indexOf(
		s.value( "Main/Language", deflang ).toString() ) );
	QActionGroup *langGroup = new QActionGroup( this );
	QAction *etAction = langGroup->addAction( new QAction( langGroup ) );
	QAction *enAction = langGroup->addAction( new QAction( langGroup ) );
	QAction *ruAction = langGroup->addAction( new QAction( langGroup ) );
	etAction->setData( 0 );
	enAction->setData( 1 );
	ruAction->setData( 2 );
	etAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_1 );
	enAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_2 );
	ruAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_3 );
	addAction( etAction );
	addAction( enAction );
	addAction( ruAction );
	connect( langGroup, SIGNAL(triggered(QAction*)), SLOT(changeLang(QAction*)) );
	connect( cardsGroup, SIGNAL(triggered(QAction*)), SLOT(changeCard(QAction*)) );

	// Views
	signContentView->setColumnHidden( 2, true );
	viewContentView->setColumnHidden( 3, true );
	connect( signContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );
	connect( viewContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );

	// Actions
	closeAction = new QAction( tr("Close"), this );
	closeAction->setShortcut( Qt::CTRL + Qt::Key_W );
	connect( closeAction, SIGNAL(triggered()), this, SLOT(closeDoc()) );
	addAction( closeAction );
#if defined(Q_OS_MAC)
	QMenuBar *bar = new QMenuBar;
	QMenu *menu = bar->addMenu( tr("&File") );
	QAction *pref = menu->addAction( tr("Settings"), this, SLOT(showSettings()) );
	pref->setMenuRole( QAction::PreferencesRole );
	menu->addAction( closeAction );
#endif

	// Arguments
	QStringList args = qApp->arguments();
	if( args.size() > 1 )
	{
		quitOnClose = true;
		args.removeAt( 0 );
		params = args;
		buttonClicked( HomeSign );
	}
}
Ejemplo n.º 12
0
MainWindow::MainWindow( const QStringList &_params )
:	QWidget()
,	cardsGroup( new QActionGroup( this ) )
,	quitOnClose( false )
{
	setAttribute( Qt::WA_DeleteOnClose, true );
	setupUi( this );

	cards->hide();
	cards->hack();
	languages->hack();

	setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint );
#if QT_VERSION >= 0x040500
	setWindowFlags( windowFlags() | Qt::WindowCloseButtonHint );
#else
	setWindowFlags( windowFlags() | Qt::WindowSystemMenuHint );
#endif

	Settings s;
	// Mobile
	infoMobileCode->setValidator( new IKValidator( infoMobileCode ) );
	infoMobileCode->setText( s.value( "Client/MobileCode" ).toString() );
	infoMobileCell->setText( s.value( "Client/MobileNumber", "+372" ).toString() );
	connect( infoMobileCode, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoMobileCell, SIGNAL(textEdited(QString)), SLOT(enableSign()) );
	connect( infoSignMobile, SIGNAL(toggled(bool)), SLOT(showCardStatus()) );

	// Buttons
	QButtonGroup *buttonGroup = new QButtonGroup( this );

	buttonGroup->addButton( settings, HeadSettings );
	buttonGroup->addButton( help, HeadHelp );
	buttonGroup->addButton( about, HeadAbout );

	buttonGroup->addButton( homeSign, HomeSign );
	buttonGroup->addButton( homeView, HomeView );
	buttonGroup->addButton( homeCrypt, HomeCrypt );

	introNext = introButtons->addButton( tr( "Next" ), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( introNext, IntroNext );
	buttonGroup->addButton( introButtons->button( QDialogButtonBox::Cancel ), IntroBack );

	signButton = signButtons->addButton( tr("Sign"), QDialogButtonBox::AcceptRole );
	buttonGroup->addButton( signButton, SignSign );
	buttonGroup->addButton( signButtons->button( QDialogButtonBox::Cancel ), SignCancel );

	viewAddSignature = viewButtons->addButton( tr("Add signature"), QDialogButtonBox::ActionRole );
	buttonGroup->addButton( viewAddSignature, ViewAddSignature );
	buttonGroup->addButton( viewButtons->button( QDialogButtonBox::Close ), ViewClose );
	connect( buttonGroup, SIGNAL(buttonClicked(int)),
		SLOT(buttonClicked(int)) );

	connect( infoCard, SIGNAL(linkActivated(QString)), SLOT(parseLink(QString)) );
	connect( cards, SIGNAL(activated(QString)), qApp->signer(), SLOT(selectCard(QString)), Qt::QueuedConnection );
	connect( qApp, SIGNAL(dataChanged()), SLOT(showCardStatus()) );

	// Digidoc
	doc = new DigiDoc( this );

	// Translations
	lang << "et" << "en" << "ru";
	QString deflang;
	switch( QLocale().language() )
	{
	case QLocale::English: deflang = "en"; break;
	case QLocale::Russian: deflang = "ru"; break;
	case QLocale::Estonian:
	default: deflang = "et"; break;
	}
	on_languages_activated( lang.indexOf(
		s.value( "Main/Language", deflang ).toString() ) );
	QActionGroup *langGroup = new QActionGroup( this );
	QAction *etAction = langGroup->addAction( new QAction( langGroup ) );
	QAction *enAction = langGroup->addAction( new QAction( langGroup ) );
	QAction *ruAction = langGroup->addAction( new QAction( langGroup ) );
	etAction->setData( 0 );
	enAction->setData( 1 );
	ruAction->setData( 2 );
	etAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_1 );
	enAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_2 );
	ruAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_3 );
	addAction( etAction );
	addAction( enAction );
	addAction( ruAction );
	connect( langGroup, SIGNAL(triggered(QAction*)), SLOT(changeLang(QAction*)) );
	connect( cardsGroup, SIGNAL(triggered(QAction*)), SLOT(changeCard(QAction*)) );

	// Views
	signContentView->setColumnHidden( 2, true );
	viewContentView->setColumnHidden( 3, true );
	connect( signContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );
	connect( viewContentView, SIGNAL(remove(unsigned int)),
		SLOT(removeDocument(unsigned int)) );

	if( !_params.empty() )
	{
		quitOnClose = true;
		params = _params;
		buttonClicked( HomeSign );
	}
}
Ejemplo n.º 13
0
static void
parseP (xmlDocPtr doc, xmlNodePtr cur, int add_tab, FB2Content *fb)
{
  xmlChar *content;
  FB2Mark *mark;

  mark = getLink(cur, fb);

  cur = cur->children;

  if (add_tab)
    bufferAppend("\t", 1, fb);

  while (cur != NULL) {

    if (xmlNodeIsText(cur)) {
      content = xmlNodeGetContent(cur);
      if (content) {
	/*
	int len;
	len = removeSpaces(content, xmlStrlen(content));
	bufferAppend(content, len, fb);
	*/
	bufferAppend(content, xmlStrlen(content), fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"style")) {
      parseStyle(doc, cur, fb);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"strong")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int start = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(start, fb->utf8_current_index, STRONG_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"emphasis")) {
      content = xmlNodeGetContent(cur->children);
      if (content) {
	int start = fb->utf8_current_index;
	bufferAppend(content, xmlStrlen(content), fb);
	addMark(start, fb->utf8_current_index, EMPHASIS_TYPE, NULL, fb);
      }
      xmlFree(content);

    } else if (!xmlStrcmp(cur->name, (const xmlChar *)"a")) {
      parseLink(doc, cur, fb);

    }

    cur = cur->next;
  }

  bufferAppend("\n", 1, fb);

  if (mark)
    mark->link_end = fb->text_current_index;

  return;
}