void MTD_FLASHMEM HTTPTemplateResponse::processFileRequest() {
  FlashFileSystem::Item file;
  if (m_filename && FlashFileSystem::find(m_filename, &file)) {
    // found
    setStatus(STR_200_OK);
    addHeader(STR_Content_Type, FSTR("text/html; charset=UTF-8"));

    // replace parameters
    m_replacer.start((char const *)file.data, (char const *)file.data + file.datalength, &m_params, NULL);

    // is this a specialized file (contains {%..%} blocks)?
    if (m_replacer.getBlocks()->getItemsCount() > 0 && m_replacer.getTemplateFilename() != NULL) {
      // this is a specialized file
      // load template file
      file.reset();
      if (FlashFileSystem::find(m_replacer.getTemplateFilename(), &file)) {
        // replace parameters and blocks of template file
        m_templateReplacer.start((char const *)file.data, (char const *)file.data + file.datalength, &m_params,
                                 m_replacer.getBlocks());
        // flush resulting content
        addContent(m_templateReplacer.getResult());
        return;
      }
    } else {
      // just flush this file (contains only {{...}} blocks)
      addContent(m_replacer.getResult());
      return;
    }
  }
  // not found
  setStatus(STR_404_Not_Found);
}
CruiseControlDialog::CruiseControlDialog(AbstractDiagInterface *diagInterface, QString language) : ControlUnitDialog(controlUnitName(), diagInterface, language)
{
	// Add information widget:
	setInfoWidget( new CUinfo_simple() );
	// Add content:
	addContent(ContentSelection::DCsMode);
	addContent(ContentSelection::MBsSWsMode);
}
void AdaptiveSkinFilter::setup() 
{
	ColorFilter::setup();

	bgrInput.allocate(videoSize.x, videoSize.y);
	grayOutput.allocate(videoSize.x, videoSize.y);

	addContent("Output", &output);
	addContent("BGR Input", &bgrInput);
	addSlider("Morphing Method",
			  &settings.morphing_mode, 0, 3);
}
Beispiel #4
0
void Chest::receiveChestInfo(int chestType){
    clearContent();
    if (chestType == 1){
        Item item1("Mace of destruction","mace","none",12,2);
        Item item2("Small health potion","health potion","none",50,1);
        addContent(item1);
        addContent(item2);
    }
    else if (chestType == 2){
        Item item1("Savage axe","axe","none",18,4);
        Item item2("Small health potion","health potion","none",50,1);
        addContent(item1);
        addContent(item2);
    }
}
 MTD_FLASHMEM HTTPResponse::HTTPResponse(HTTPHandler* httpHandler, char const* status, char const* content)
     : m_httpHandler(httpHandler), m_status(status)
 {
     // content (if present, otherwise use addContent())
     if (content)
         addContent(content);
 }
    void MTD_FLASHMEM HTTPGPIOResponseHTML::flush()
    {
        setStatus(STR_200_OK);
        addHeader(STR_Content_Type, STR_TEXTHTML);

        char const* cmd = getRequest().query[FSTR("cmd")];
        if (cmd && f_strcmp(cmd, FSTR("set")) == 0)
        {
            // set gpio
            HTTPHelperConfiguration::GPIOSetValue(this);
        }
        else if (cmd && f_strcmp(cmd, FSTR("conf")) == 0)
        {
            // conf gpio
            HTTPHelperConfiguration::GPIOConf(this);
        }
        
        char const* gpio = getRequest().query[STR_gpio];
        if (gpio)
        {
            uint8_t gpion = strtol(gpio, NULL, 10);
            addContent(GPIO(gpion).read()? STR_1 : STR_0);
        }
        
        HTTPResponse::flush();
    }
/**
	Importe l'element decrit dans un document XML. Si une position est
	precisee, les elements importes sont positionnes de maniere a ce que le
	coin superieur gauche du plus petit rectangle pouvant les entourant tous
	(le bounding rect) soit a cette position.
	@param xml_document un document XML decrivant l'element
	@param position La position des parties importees
	@param consider_informations Si vrai, les informations complementaires
	(dimensions, hotspot, etc.) seront prises en compte
	@param content_ptr si ce pointeur vers un ElementContent est different de 0,
	il sera rempli avec le contenu ajoute a l'element par le fromXml
	@return true si l'import a reussi, false sinon
*/
void ElementScene::fromXml(
	const QDomDocument &xml_document,
	const QPointF &position,
	bool consider_informations,
	ElementContent *content_ptr
) {
	QString error_message;
	bool state = true;
	
	// prend en compte les informations de l'element
	if (consider_informations) {
		state = applyInformations(xml_document, &error_message);
	}
	
	// parcours des enfants de la definition : parties de l'element
	if (state) {
		ElementContent loaded_content = loadContent(xml_document, &error_message);
		if (position != QPointF()) {
			addContentAtPos(loaded_content, position, &error_message);
		} else {
			addContent(loaded_content, &error_message);
		}
		
		// renvoie le contenu ajoute a l'element
		if (content_ptr) {
			*content_ptr = loaded_content;
		}
	}
}
void SobelFilterOcl::setup()
{
	ColorFilter::setup();

	rgbaInput.allocate(videoSize.x, videoSize.y);
	grayOutput.allocate(videoSize.x, videoSize.y);

	oclSobelFilter.input = rgbaInput.getCvImage()->imageData;
	oclSobelFilter.output = grayOutput.getCvImage()->imageData;

	addContent("RGBA", rgbaInput);
	addContent("Output", output);
	addSlider("Threshold", oclSobelFilter.threshold, 0.0, 255.0);

	oclSobelFilter.loadFromFile("sobelFilter.cl");
	clScheduler->initKernel(oclSobelFilter);
}
void ContourFindingFilter::setup() 
{
	GrayscaleFilter::setup();

	addContent("Output", output);
	addSlider("Blobs", settings.num_blobs, 1, 10);
	addToggle("Find Holes", settings.find_holes);
}
void CalibrationFilter::setup() 
{
	ColorFilter::setup();

	grayInput.allocate(videoSize.x, videoSize.y);
	tempImage.allocate(videoSize.x, videoSize.y);
	shownCapture.allocate(videoSize.x, videoSize.y);
	
	addContent("Output", &output);
	showCapturesSlider = addSlider("Previous Captures", &settings.show_capture, 0, settings.min_captures);
	addContent("Selected Capture", &shownCapture);
	addButton("Capture", &settings.capture);
//	addToggle("Once", &settings.once);
//	addSlider2d("Chessboard Corners", &targetCorners, 2.0, 7.0, 2.0, 7.0);
	addToggle("Interpolate", &settings.do_interpolate);
	addButton("Calculate", &settings.calc_undistort);
	addToggle("Undistort Stream", &settings.do_undistort);
	addToggle("Guess Lens Intrinsics", &settings.guess_intrinsics);
}
void ThresholdingFilter::setup() 
{
	GrayscaleFilter::setup();

	addContent("Output", output);
	addSlider("Threshold", settings.threshold, 0, 255);
	addSlider("Max Value", settings.max_value, 0, 255);
	addSlider("Mode", settings.mode, 0, 4);
	addToggle("Use Otsu", settings.use_otsu);
}
Beispiel #12
0
SlotInspectorSection::SlotInspectorSection(
        const QString& name,
        const SlotModel& slot,
        RackInspectorSection* parentRack) :
    InspectorSectionWidget {name, false, parentRack},
    m_model {slot},
    m_parent{parentRack->constraintInspector()}
{
    auto framewidg = new QFrame;
    auto lay = new iscore::MarginLess<QVBoxLayout>(framewidg);
    framewidg->setFrameShape(QFrame::StyledPanel);
    addContent(framewidg);

    this->showMenu(true);
    auto del = this->menu()->addAction(tr("Remove Slot"));
    connect(del, &QAction::triggered, this, [=] ()
    {
        auto cmd = new Command::RemoveSlotFromRack{m_model};
        emit m_parent.commandDispatcher()->submitCommand(cmd);
    });

    // View model list
    m_lmSection = new InspectorSectionWidget{"Process View Models", false, this};
    m_lmSection->setObjectName("LayerModels");

    m_model.layers.added.connect<SlotInspectorSection, &SlotInspectorSection::on_layerModelCreated>(this);
    m_model.layers.removed.connect<SlotInspectorSection, &SlotInspectorSection::on_layerModelRemoved>(this);


    // add indention in section
    auto indentWidg = new QWidget{this};
    auto indentLay = new iscore::MarginLess<QHBoxLayout>{indentWidg};

    indentLay->addWidget(new Inspector::VSeparator{this});
    indentLay->addWidget(m_lmSection);
    indentLay->setStretchFactor(m_lmSection, 10);

    m_addLmWidget = new AddLayerModelWidget{this};
    lay->addWidget(indentWidg);
    lay->addWidget(m_addLmWidget);

    auto frame = new QFrame{this};
    m_lmGridLayout = new iscore::MarginLess<QGridLayout>{frame};
    frame->setFrameShape(QFrame::StyledPanel);
    m_lmSection->addContent(frame);


    connect(this, &InspectorSectionWidget::nameChanged,
            this, &SlotInspectorSection::ask_changeName);

    for(const auto& lm : m_model.layers)
    {
        displayLayerModel(lm);
    }
}
Beispiel #13
0
void wyToast::setContent(wyNode* c) {
	// remove old content node
	removeContent();

	// save new content node
	m_content = c;
	addContent();

	// set flag
	m_dirty = true;
}
Beispiel #14
0
AXmlElement *AXmlElement::_createAndAppend(LIST_AString& xparts, AXmlElement *pParent, bool insertIntoFront)
{
  AString& strName = xparts.front();
  AXmlElement *p = new AXmlElement(strName, pParent);
  addContent(p, AConstant::ASTRING_EMPTY, insertIntoFront);
  xparts.pop_front();
  if (xparts.size() > 0)
    return p->_createAndAppend(xparts, this, insertIntoFront);
  else
    return p;
}
Beispiel #15
0
MessageDialog::MessageDialog(const QString &title, const QString &content, Buttons f, QWidget *parent) : Dialog(parent) {
	_mainLayout.setContentsMargins(24, 24, 24, 8);
	_mainLayout.setSpacing(24);
	_mainLayout.addLayout(&_titleLayout);
	_mainLayout.addLayout(&_contentLayout);
	_mainLayout.addLayout(&_actionLayout);
	setLayout(&_mainLayout);

	addTitle(title);
	addButtons(f);
	addContent(content);
}
Beispiel #16
0
RackInspectorSection::RackInspectorSection(
    const QString& name,
    const RackModel& rack,
    const ConstraintInspectorWidget& parentConstraint,
    QWidget* parent) :
    InspectorSectionWidget {name, false, parent},
    m_parent{parentConstraint},
    m_model {rack}
{
    auto framewidg = new QFrame;
    auto lay = new iscore::MarginLess<QVBoxLayout> {framewidg};
    framewidg->setFrameShape(QFrame::StyledPanel);
    addContent(framewidg);

    this->showMenu(true);
    auto del = this->menu()->addAction(tr("Remove Rack"));
    del->setIcon(genIconFromPixmaps(QString(":/icons/delete_on.png"), QString(":/icons/delete_off.png")));
    connect(del, &QAction::triggered, this, [=] ()
    {
        auto cmd = new Command::RemoveRackFromConstraint{
            m_parent.model(),
            m_model.id()};
        emit m_parent.commandDispatcher()->submitCommand(cmd);
    });

    // Slots
    m_slotSection = new InspectorSectionWidget{"Slots", false, this};  // TODO Make a custom widget.
    m_slotSection->setObjectName("Slots");

    m_model.slotmodels.added.connect<RackInspectorSection, &RackInspectorSection::on_slotCreated>(this);
    m_model.slotmodels.removed.connect<RackInspectorSection, &RackInspectorSection::on_slotRemoved>(this);

    for(const auto& slot : m_model.slotmodels)
    {
        addSlotInspectorSection(slot);
    }

    // add indention in section
    auto indentWidg = new QWidget{this};
    auto indentLay = new iscore::MarginLess<QHBoxLayout> {indentWidg};

    indentLay->addWidget(new Inspector::VSeparator{this});
    indentLay->addWidget(m_slotSection);
    indentLay->setStretchFactor(m_slotSection, 10);

    m_slotWidget = new AddSlotWidget{this};
    lay->addWidget(indentWidg);
    lay->addWidget(m_slotWidget);

    connect(this, &InspectorSectionWidget::nameChanged,
            this, &RackInspectorSection::ask_changeName);
}
void UserSharePasswordSettingDialog::initUI()
{
    QStringList buttonTexts;
    buttonTexts << tr("Cancel") << tr("Confirm");
    addButton(buttonTexts[0], false);
    addButton(buttonTexts[1], false, DDialog::ButtonRecommend);
    setDefaultButton(1);
    m_passwordEdit = new DPasswordEdit(this);
    m_passwordEdit->setFixedSize(240,24);
    m_passwordEdit->setFocus();
    addContent(m_passwordEdit);
    setContentsMargins(0,0,0,0);
}
void MTD_FLASHMEM HTTPStaticFileResponse::flush() {
  FlashFileSystem::Item file;
  if (FlashFileSystem::find(m_filename.get(), &file)) {
    // found
    setStatus(STR_200_OK);
    addHeader(STR_Content_Type, file.mimetype);
    addContent(file.data, file.datalength);
  } else {
    // not found
    setStatus(STR_404_Not_Found);
  }
  HTTPResponse::flush();
}
 void MTD_FLASHMEM HTTPTemplateResponse::processFileRequest()
 {
     char const* mimetype;
     void const* data;
     uint16_t dataLength;
     if (m_filename && FlashFileSystem::find(m_filename, &mimetype, &data, &dataLength))
     {
         // found
         setStatus(STR_200_OK);
         addHeader(STR_Content_Type, FSTR("text/html"));
         
         // replace parameters
         ParameterReplacer replacer((char const*)data, (char const*)data + dataLength, &m_params);
         
         // is this a specialized file (contains {%..%} blocks)?
         if (replacer.getBlocks()->getItemsCount() > 0 && replacer.getTemplateFilename() != NULL)
         {
             // this is a specialized file, add blocks as parameters
             addParams(replacer.getBlocks());
             // load template file
             if (FlashFileSystem::find(replacer.getTemplateFilename(), &mimetype, &data, &dataLength))
             {
                 // replace parameters and blocks of template file
                 ParameterReplacer templateReplacer((char const*)data, (char const*)data + dataLength, &m_params);
                 // flush resulting content
                 addContent(templateReplacer.getResult());
                 return;
             }
         }
         else
         {
             // just flush this file (contains only {{...}} blocks)
             addContent(replacer.getResult());
             return;
         }
     }
     // not found
     setStatus(STR_404_Not_Fount);
 }
    void MTD_FLASHMEM HTTPWiFiScanResponseHTMLRows::flush()
    {
        setStatus(STR_200_OK);
        addHeader(STR_Content_Type, STR_TEXTHTML);
        
        uint32_t count = 0;
        WiFi::APInfo* infos = WiFi::getAPList(&count, true);

        addContent(FSTR("<tr> <th>SSID</th> <th>Address</th> <th>Channel</th> <th>RSSI</th> <th>Security</th> </tr>"));
        for (uint32_t i = 0; i != count; ++i)
        {
            addContent(f_printf(FSTR("<tr> <td><input type='radio' name='selssid' value='%s' onclick='SelSSID(this)'>%s</td> <td>%02X:%02X:%02X:%02X:%02X:%02X</td> <td>%d</td> <td>%d</td> <td>%s</td> </tr>"), 
                                infos[i].SSID,
                                infos[i].SSID,
                                infos[i].BSSID[0], infos[i].BSSID[1], infos[i].BSSID[2], infos[i].BSSID[3], infos[i].BSSID[4], infos[i].BSSID[5],
                                infos[i].Channel,
                                infos[i].RSSI,
                                WiFi::convSecurityProtocolToString(infos[i].AuthMode)),
                       true);
        }						

        HTTPResponse::flush();
    }
Beispiel #21
0
IntervalSummaryWidget::IntervalSummaryWidget(
    const IntervalModel& object,
    const score::DocumentContext& doc,
    QWidget* parent)
    : QWidget(parent)
    , interval{object}
    , m_selectionDispatcher{doc.selectionStack}
{
  auto eventBtn
      = SelectionButton::make("", &object, m_selectionDispatcher, this);

  auto l1 = new TextLabel{object.metadata().getName()};
  auto l2 = new TextLabel{tr("Start : ") + object.date().toString()};
  m_lay.addWidget(l1, 0, 0, 1, 3);
  m_lay.addWidget(l2, 0, 3, 1, 3);
  m_lay.addWidget(eventBtn, 0, 6, 1, 1);

  if (object.duration.isRigid())
  {
    auto l3 = new TextLabel{object.duration.defaultDuration().toString()};
    m_lay.addWidget(l3, 1, 1, 1, 4);
  }
  else
  {
    QString text = tr("Flexible : ")
                   % (object.duration.minDuration().isZero()
                          ? QStringLiteral("0")
                          : object.duration.minDuration().toString())
                   % tr(" to ")
                   % (object.duration.maxDuration().isInfinite()
                          ? QStringLiteral("inf")
                          : object.duration.maxDuration().toString());
    auto l4 = new TextLabel{text};
    m_lay.addWidget(l4, 1, 1, 1, 4);
  }

  if (!object.processes.empty())
  {
    auto processList
        = new Inspector::InspectorSectionWidget{tr("Processes"), false, this};
    for (const auto& p : object.processes)
    {
      auto lab = new TextLabel{p.prettyName()};
      processList->addContent(lab);
    }
    m_lay.addWidget(processList, 2, 1, 1, 6);
  }

  this->setLayout(&m_lay);
}
SummaryInspectorWidget::SummaryInspectorWidget(const IdentifiedObjectAbstract* obj,
        std::set<const ConstraintModel*> constraints,
        std::set<const TimeNodeModel*> timenodes,
        std::set<const EventModel*> events,
        std::set<const StateModel*> states,
        const iscore::DocumentContext& context,
        QWidget* parent):
    InspectorWidgetBase {*obj, context, parent}
{
    setObjectName("SummaryInspectorWidget");
    setParent(parent);

    auto cSection = new Inspector::InspectorSectionWidget{tr("Constraints"), false, this};
    m_properties.push_back(cSection);

    for(auto c : constraints)
    {
        cSection->addContent(new ConstraintSummaryWidget{*c, context, this});
    }

    auto tnSection = new Inspector::InspectorSectionWidget{tr("TimeNodes"), false, this};
    m_properties.push_back(tnSection);
    for(auto t : timenodes)
    {
        tnSection->addContent(new TimeNodeSummaryWidget{*t, context, this});
    }

    auto evSection = new Inspector::InspectorSectionWidget{tr("Events"), false, this};
    m_properties.push_back(evSection);
    for(auto ev : events)
    {
        evSection->addContent(new EventSummaryWidget{*ev, context, this});
    }

    updateAreaLayout(m_properties);
}
void FiducialTrackingFilter::setup() 
{
	GrayscaleFilter::setup();
	fidFinder.detectFinger		= true;
	fidFinder.maxFingerSize		= 25;
	fidFinder.minFingerSize		= 5;
	fidFinder.fingerSensitivity	= 0.05f; //from 0 to 2.0f

	addContent("Output", output);
	addToggle("Detect Fingers", fidFinder.detectFinger);
	addSlider("Min Finger Size", fidFinder.minFingerSize, 0, 50);
	addSlider("Max Finger Size", fidFinder.maxFingerSize, 0, 50);
	addSlider("Finger Sensitivity", fidFinder.fingerSensitivity, 0.0, 2.0);
	
	output.set(0);
}
void SvgBasicShapeWriter::writeShapes(const char *filePath, SvgBasicShape **shapes, const int size) {
	delete[] content;
	content = new char[MAX_XML_LEN];
	content[0] = '\0';

	writeXmlTemplate();

	for(int i = 0; i < size; i ++) {
		strcat(content, "\t");
		addContent(shapes[i]->toXmlElement());
		strcat(content, "\n");
	}

	strcat(content, "</svg");
	writeContentToFile(filePath);
}
ConstraintSummaryWidget::ConstraintSummaryWidget(const ConstraintModel& object,
                         const iscore::DocumentContext& doc,
                         QWidget *parent) :
    QWidget(parent),
    m_selectionDispatcher{new iscore::SelectionDispatcher{doc.selectionStack}}
{
    auto mainLay = new iscore::MarginLess<QGridLayout>{this};

    auto eventBtn = SelectionButton::make("", &object, *m_selectionDispatcher.get() , this);

    mainLay->addWidget(new QLabel{object.metadata.name()},
                       0, 0, 1, 3);
    mainLay->addWidget(new QLabel{tr("start : ") + object.startDate().toString()},
                       0, 3, 1, 3);
    mainLay->addWidget(eventBtn,
                       0, 6, 1, 1);


    if(object.duration.isRigid())
    {
        mainLay->addWidget(new QLabel{object.duration.defaultDuration().toString()},
                           1, 1, 1, 4);
    }
    else
    {
        QString max = object.duration.maxDuration().isInfinite() ? "inf" : object.duration.maxDuration().toString();
        QString min = object.duration.minDuration().isZero() ? "0" : object.duration.minDuration().toString();
        mainLay->addWidget(new QLabel{tr("Flexible : ")
                                      + min
                                      + " to "
                                      + max},
                           1, 1, 1, 4);

    }


    if(!object.processes.empty())
    {
        auto processList = new Inspector::InspectorSectionWidget{tr("processes"), false, this};
        for(const auto& p : object.processes)
        {
            processList->addContent(new QLabel{p.prettyName()});
        }
        mainLay->addWidget(processList, 2, 1, 1, 6);
    }

}
Beispiel #26
0
AXmlElement *AXmlElement::_getOrCreate(LIST_AString& xparts, AXmlElement* pParent, bool insertIntoFront)
{
  AString& strName = xparts.front();
  CONTAINER::iterator it = m_Content.begin();
  while (it != m_Content.end())
  {
    if ((*it)->isNameEquals(strName))
    {
      AXmlElement *p = dynamic_cast<AXmlElement *>(*it);
      if (!xparts.size())
      {
        return p;
      }
      else
      {
        if (p)
        {
          xparts.pop_front();
          if (!xparts.size())
            return p;
          else
            return p->_getOrCreate(xparts, this, insertIntoFront);
        }
        else
          ATHROW_EX(this, AException::DataConflict, strName);  //a_ Not AXmlElement type
      }
    }
    ++it;
  }
  
  //a_strName not found, create it
  AXmlElement *p = new AXmlElement(strName, pParent);
  addContent(p, AConstant::ASTRING_EMPTY, insertIntoFront);
  xparts.pop_front();
  if (xparts.size() == 0)
  {
    return p;
  }
  else
  {
    return p->_getOrCreate(xparts, this, insertIntoFront);
  }
}
Beispiel #27
0
bool PopChoiceDlg::init()
{
	if (!LayerColor::initWithColor(ccc4(25, 25, 25, 125))) 
		return false;

	auto visibleSize = Director::getInstance()->getVisibleSize();
	//auto origin = Director::getInstance()->getVisibleOrigin();

	addBgImg();

	//获得背景sprite的大小
	m_size = m_bgSprite->getContentSize();
	auto yesItem = MenuItemImage::create(
		"popdlg/popy.png",
		"popdlg/popy.png",
		CC_CALLBACK_1(PopChoiceDlg::yesButton, this));

	auto noItem = MenuItemImage::create(
		"popdlg/popn.png",
		"popdlg/popn.png",
		CC_CALLBACK_1(PopChoiceDlg::noButton, this));

	// create menu, it's an autorelease object
	auto menu = Menu::create(yesItem, noItem, NULL);
	menu->alignItemsHorizontallyWithPadding(5);
	menu->setPosition(ccp(visibleSize.width / 2, visibleSize.height * 0.42));

	this->addChild(menu, 1);

	addTitle();
	addContent();

	//保证是模态对话框
	auto touchlistenter = EventListenerTouchOneByOne::create();
	touchlistenter->setSwallowTouches(true);
	touchlistenter->onTouchBegan = CC_CALLBACK_2(PopChoiceDlg::onTouchBegan, this);
	_eventDispatcher->addEventListenerWithSceneGraphPriority(touchlistenter, this);

	return true;
}
JingleSession::JingleSession(const JingleStanza &AStanza):
    FValid(false),FOutgoing(false),FThisParty(AStanza.to()),FOtherParty(AStanza.from()),FActionId(),FAction(IJingle::NoAction)
{
    QDomElement jingle=AStanza.firstElement("jingle", NS_JINGLE);
    if (!jingle.isNull())
    {
        QString action=jingle.attribute("action");
        if (action=="session-initiate")
        {
            FSid=jingle.attribute("sid");
            for (QDomElement content=jingle.firstChildElement("content"); !content.isNull(); content=content.nextSiblingElement("content"))
            {
                QDomElement description=content.firstChildElement("description");
                if (!description.isNull())
                {
                    FApplicationNamespace = description.namespaceURI();
                    QDomElement transport=content.firstChildElement("transport");
                    if (!transport.isNull())
                    {
                        setParent(FJingle->appByNS(FApplicationNamespace)->instance());
                        if (!addContent(content.attribute("name"), description, transport, content.attribute("initiator")==QString("responder")))
                            qWarning() << "addContent() failed!";
                        FValid=true;
                        connect(this,SIGNAL(sessionAccepted(Jid,QString)),parent(), SLOT(onSessionAccepted(Jid,QString)));
                        connect(this,SIGNAL(sessionTerminated(Jid,QString,IJingle::SessionStatus,IJingle::Reason)),parent(),SLOT(onSessionTerminated(Jid,QString,IJingle::SessionStatus,IJingle::Reason)));                        
                        connect(this,SIGNAL(sessionInformed(QDomElement)),parent(),SLOT(onSessionInformed(QDomElement)));                        
                        connect(this,SIGNAL(receivingData(Jid,QString)),parent(),SLOT(onDataReceived(Jid,QString)));
                        connect(this,SIGNAL(actionAcknowledged(Jid,QString,IJingle::Action,IJingle::CommandRespond,IJingle::SessionStatus,Jid,IJingle::Reason)),parent(),SLOT(onActionAcknowledged(Jid,QString,IJingle::Action,IJingle::CommandRespond,IJingle::SessionStatus,Jid,IJingle::Reason)));
                    }
                }
            }
            if (!FSessions.contains(FThisParty) || !FSessions[FThisParty].contains(FSid))
                FSessions[FThisParty].insert(FSid, this);
            else
                qWarning() << "Session exists!";
        }
    }
}
Beispiel #29
0
/**
 * Launch the dialog to edit (or copy) a particular row of the database.
 *
 * @param subject The database being modified
 * @param rowId The ID of the row to edit
 * @param copy True if the row should be copied rather than edited
 * @return The ID of the added or edited row, -1 if no changes made in the
 *         dialog were committed
 */
int RowEditor::edit(Database *subject, int rowId, bool copy)
{
    db = subject;
    addContent(rowId);
    bool finished = false;
    bool aborted = false;
    while (!finished) {
        if (!exec()) {
            finished = true;
            aborted = true;
        }
        else {
            finished = isValid();
        }
    }
    if (!aborted) {
        QStringList values = getRow();
        int id;
        if (rowId == -1 || copy) {
            db->addRow(values, &id);
        }
        else {
            db->updateRow(rowId, values);
            id = rowId;
        }
        int count = imageSelectors.count();
        for (int i = 0; i < count; i++) {
            ImageSelector *widget = imageSelectors[i];
            widget->saveImage(id);
        }
        return id;
    }
    else {
        return -1;
    }
}
void BulletMLParserTinyXML::translateNode(TiXmlNode* node) {
    TiXmlElement* elem = node->ToElement();
    assert(elem != 0);

    BulletMLNode* xmlNode = addContent(elem->Value());

    if (xmlNode->getName() == BulletMLNode::bulletml) {
        TiXmlAttribute* attr;
        for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) {
            if (attr->Value() == "horizontal") setHorizontal();
        }
    }
    else {
        MyAttributes mattr;
        TiXmlAttribute* attr;
        for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) {
            mattr.push_back(attr->Name());
            mattr.push_back(attr->Value());
        }
        addAttribute(mattr, xmlNode);
        if (curNode_ != 0) curNode_->addChild(xmlNode);
    }
    curNode_ = xmlNode;
}