Esempio n. 1
0
bool CXMLEngineMI::SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePtr& pNode)const
{
	CXMLNodeMI* pXML = dynamic_cast<CXMLNodeMI*>(pNode.get());
	if(pXML)
	{
		tofstream file(rsFileName.c_str());
		if(file.good())
		{
			IXMLNode::TXMLNodePtr pRoot(create_node(_T("xml"),tstring(),true));
			if(pRoot)
			{
				pRoot->AddAttribute(_T("version"),_T("1.0"));
				pRoot->AddAttribute(_T("encoding"),_T("UTF-8"));
				file << *pRoot;
			}

			if(file.good())
			{
				file << *pNode;
			}
		}

		return file.good();
	}

	return false;
}
Esempio n. 2
0
void KernelStartup::arg_root(const char *arg)
{
	//ensure it exists
	//also ensure that the kernel starts from this directory
	if(!SetCurrentDirectory(arg))
	{
		ktrace("root dir does not exist");
		halt();
	}

	char root[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, root);
	g_pKernelTable->m_FilesystemRoot = root;
	Path pRoot("/", false);
	g_pKernelTable->m_pRootMountPoint = MountPoint::Mount(pRoot, g_pKernelTable->m_FilesystemRoot, new FilesystemKeow(), 0,0,0);

	ktrace("Using %s as filesystem root\n", g_pKernelTable->m_FilesystemRoot.c_str());
}
Esempio n. 3
0
void ExporterConfig::save (void)
{
	std::string configFile = getFileName ();
	ATOM_TiXmlDocument doc (configFile.c_str());
	ATOM_TiXmlDeclaration decl ("1.0", "gb2312", "");
	doc.InsertEndChild (decl);

	ATOM_TiXmlElement pRoot("config");

	ATOM_TiXmlElement pElementShare("sharedDir");
	pElementShare.SetAttribute ("path", shareDirectory.c_str());
	pRoot.InsertEndChild (pElementShare);

	ATOM_TiXmlElement pElementRoot("rootDir");
	pElementRoot.SetAttribute ("path", rootDirectory.c_str());
	pRoot.InsertEndChild (pElementRoot);

	doc.InsertEndChild (pRoot);
	doc.SaveFile ();
}
Esempio n. 4
0
int CVkProto::PollServer()
{
	debugLogA("CVkProto::PollServer");

	NETLIBHTTPREQUEST req = { sizeof(req) };
	req.requestType = REQUEST_GET;
	req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken));
	req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
	req.timeout = 30000;
	req.nlc = m_pollingConn;

	NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
	if (reply == NULL) {
		m_pollingConn = NULL;
		return 0;
	}

	int retVal = 0;
	if (reply->resultCode == 200) {
		JSONROOT pRoot(reply->pData);
		JSONNODE *pFailed = json_get(pRoot, "failed");
		if (pFailed != NULL && json_as_int(pFailed) == 2) {
			RetrievePollingInfo();
			retVal = -1;
			debugLogA("Polling key expired, restarting polling thread");
		}
		else if (CheckJsonResult(NULL, reply, pRoot)) {
			m_pollingTs = mir_t2a(ptrT(json_as_string(json_get(pRoot, "ts"))));
			JSONNODE *pUpdates = json_get(pRoot, "updates");
			if (pUpdates != NULL)
				PollUpdates(pUpdates);
			retVal = 1;
		}
	}

	m_pollingConn = reply->nlc;

	CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
	return retVal;
}
Esempio n. 5
0
bool GetSessionItemBase<T>::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   StepResource pStep("Execute Wizard Item", "app", "{234E6866-C61D-4ca8-9152-8CA3DCEFC3C0}");
   pStep->addProperty("Item", getName());
   mpStep = pStep.get();
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      reportError("Invalid arguments.", "{0012BA62-EE8E-451e-B725-26D7335436AC}");
      return false;
   }

   if (extractInputArgs(pInArgList) == false)
   {
      reportError("Unable to extract input arguments.", "{365B8383-651C-421f-87D4-01238F4E3398}");
      return false;
   }

   // Create the dialog.
   QDialog dialog(Service<DesktopServices>()->getMainWidget());

   // Tree view containing available session items.
   QStringList columnNames;
   columnNames << "Name" << "Type";

   QTreeWidget* pTree = new QTreeWidget(&dialog);
   pTree->setColumnCount(columnNames.count());
   pTree->setHeaderLabels(columnNames);

   std::auto_ptr<QTreeWidgetItem> pRoot(new QTreeWidgetItem);
   pRoot->setFlags(Qt::NoItemFlags);
   pRoot->setText(GetSessionItemBase<T>::NameColumn, "No items available");
   pRoot->setData(GetSessionItemBase<T>::NameColumn,
      GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(NULL));
   populateTreeWidgetItem(pRoot.get());

   if (pRoot->childCount() > 0)
   {
      pTree->addTopLevelItems(pRoot->takeChildren());
   }
   else
   {
      pTree->addTopLevelItem(pRoot.release());
   }

   pTree->expandAll();
   pTree->resizeColumnToContents(0);

   // Buttons.
   QFrame* pLine = new QFrame(&dialog);
   pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
   QDialogButtonBox* pButtonBox = new QDialogButtonBox(
      QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);

   // Layout.
   QVBoxLayout* pLayout = new QVBoxLayout(&dialog);
   pLayout->setMargin(10);
   pLayout->setSpacing(10);
   pLayout->addWidget(pTree);
   pLayout->addWidget(pLine);
   pLayout->addWidget(pButtonBox);
   dialog.setWindowTitle(QString::fromStdString(mDialogCaption));
   dialog.resize(400, 400);

   // Connections.
   VERIFY(QObject::connect(pButtonBox, SIGNAL(accepted()), &dialog, SLOT(accept())));
   VERIFY(QObject::connect(pButtonBox, SIGNAL(rejected()), &dialog, SLOT(reject())));
   if (dialog.exec() != QDialog::Accepted)
   {
      reportError("User cancelled.", "{27E33A95-0DFB-486b-ABAE-BFC849418201}");
      return false;
   }

   QTreeWidgetItem* pItem = pTree->currentItem();
   if (pItem == NULL)
   {
      reportError("No item selected.", "{27B21666-19BB-4932-BF08-A81E340F1A54}");
      return false;
   }

   QVariant value = pItem->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
   SessionItem* pSessionItem = reinterpret_cast<SessionItem*>(value.value<void*>());
   mpSessionItem = dynamic_cast<T*>(pSessionItem);
   if (mpSessionItem == NULL)
   {
      reportError("Wrong item type selected.", "{E6D3E131-4E71-4989-9D34-BC9A1157AB8E}");
      return false;
   }

   if (populateOutputArgs(pOutArgList) == false)
   {
      reportError("Unable to populate the output argument list.", "{C3AB6771-50C4-4091-BA39-3D44C82C93A8}");
      return false;
   }

   reportComplete();
   return true;
}