Esempio n. 1
0
ZTuple ZTBQueryNode_First::AsTuple()
	{
	ZTuple theTuple;
	theTuple.SetString("Kind", "First");
	theTuple.SetString("PropName", fPropName.AsString());
	if (fSourceNode)
		theTuple.SetTuple("SourceNode", fSourceNode->AsTuple());
	return theTuple;
	}
Esempio n. 2
0
ZTuple ZTBQueryNode_ID_FromSource::AsTuple()
	{
	ZTuple theTuple;
	theTuple.SetString("Kind", "ID_FromSource");
	theTuple.SetString("SourcePropName", fSourcePropName.AsString());
	if (fSourceNode)
		theTuple.SetTuple("SourceNode", fSourceNode->AsTuple());
	return theTuple;
	}
Esempio n. 3
0
ZTuple ZTBSpec::Criterion::Rep::AsTuple() const
	{
	ZTuple result;
	result.SetString("PropName", fPropName.AsString());
	result.SetString("Rel", sStringFromRel(fComparator.fRel));
	if (fComparator.fStrength)
		result.SetInt32("Strength", fComparator.fStrength);
	if (fTupleValue)
		result.SetValue("Value", fTupleValue);
	return result;
	}
Esempio n. 4
0
static ZTuple sGetProp(const ZNode& iNode, const string& iPropName)
 	{
 	ZTuple propT;

	if (iPropName == "D:resourcetype")
		{
		if (iNode.CanHaveChildren())
			propT.SetTuple(iPropName, ZTuple().SetNull("D:collection"));
		else
			propT.SetNull(iPropName);
		}
	else if (iPropName == "D:getcontenttype")
		{
		ZTupleValue theValue;
		if (iNode.GetProp("MIMEType", theValue))
			{
			string theMIMEType;
			if (theValue.GetString(theMIMEType))
				propT.SetString(iPropName, theMIMEType);
			}
		}
	else if (iPropName == "D:creationdate")
		{
		ZTupleValue theValue;
		if (iNode.GetProp("TimeCreated", theValue))
			{
			if (ZTime theTime = theValue.GetTime())
				propT.SetString(iPropName, sAsString_WebDAV(theTime));
			}
		}
	else if (iPropName == "D:getlastmodified")
		{
		ZTupleValue theValue;
		if (iNode.GetProp("TimeModified", theValue))
			{
			if (ZTime theTime = theValue.GetTime())
				propT.SetString(iPropName, sAsString_WebDAV(theTime));
			}
		}
	else if (iPropName == "D:getcontentlength")
		{
		ZTupleValue theValue;
		if (iNode.GetProp("ContentLength", theValue))
			{
			int64 theLength;
			if (theValue.GetInt64(theLength))
	 			propT.SetString(iPropName, ZString::sFromUInt64(theLength));
			}
		}

 	return propT;
 	}
Esempio n. 5
0
static void sHandle_PROPFIND_All(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, int iDepth, ZTuple& ioTuple)
	{
	vector<string> thePropNames;
	thePropNames.push_back("D:resourcetype");
	thePropNames.push_back("D:getcontenttype");
	thePropNames.push_back("D:creationdate");
	thePropNames.push_back("D:getlastmodified");
	thePropNames.push_back("D:getcontentlength");

	for (DAVIter i = DAVIter(iNode, iDepth); i; i.Advance())
		{
		ZNode theNode = i.Current();
		if (theNode.Exists())
			{
			ZTuple goodT, badT;
			sGetProperties(theNode, thePropNames, goodT, badT);

			ZTuple responseT;
			responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, theNode));

			if (goodT)
				{
				goodT.SetString("D:status", "HTTP/1.1 200 OK");
				responseT.AppendTuple("D:propstat", goodT);
				}
			
			ioTuple.AppendTuple("D:response", responseT);
			}
		}
	}
Esempio n. 6
0
static void sHandle_PROPFIND_Some(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, int iDepth, const vector<string>& iPropNames, ZTuple& ioTuple)
	{
	for (DAVIter i = DAVIter(iNode, iDepth); i; i.Advance())
		{
		ZNode theNode = i.Current();
		if (theNode.Exists())
			{
			ZTuple goodT, badT;
			sGetProperties(theNode, iPropNames, goodT, badT);

			ZTuple responseT;
			responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, theNode));

			if (goodT)
				{
				goodT.SetString("D:status", "HTTP/1.1 200 OK");
				responseT.AppendTuple("D:propstat", goodT);
				}

			if (badT)
				{
				badT.SetString("D:status", "HTTP/1.1 404 Not Found");
				responseT.AppendTuple("D:propstat", badT);
				}
			
			ioTuple.AppendTuple("D:response", responseT);
			}
		}
	}
Esempio n. 7
0
ZTuple ZTBQueryNode_ID_Constant::AsTuple()
	{
	ZTuple theTuple;
	theTuple.SetString("Kind", "ID_Constant");
	theTuple.SetVector_T("IDs", fIDs.begin(), fIDs.end());
	return theTuple;
	}
Esempio n. 8
0
ZTuple ZTBQueryNode_Difference::AsTuple()
	{
	ZTuple theTuple;
	theTuple.SetString("Kind", "Difference");
	if (fLeftNode)
		theTuple.SetTuple("LeftNode", fLeftNode->AsTuple());
	if (fRightNode)
		theTuple.SetTuple("RightNode", fRightNode->AsTuple());
	return theTuple;
	}
Esempio n. 9
0
void ZApp::InvalidateAllMenuBars()
	{
	// We don't need to be locked to broadcast this message
	ZTuple theTuple;
	theTuple.SetString("what", "zoolib:InvalidateAllMenuBars");

	ZMessage envelope;
	envelope.SetString("what", "zoolib:Owner");
	envelope.SetTuple("message", theTuple);

	fOSApp->BroadcastMessageToAllWindows(envelope);
	}
Esempio n. 10
0
static bool sDelete(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, ZTuple& ioT)
	{
	bool allOkay = true;
	// Delete any descendants of iNode.
	for (ZNodeIter i = iNode; i; i.Advance())
		{
		if (!sDelete(iPrefix, iRoot, i.Current(), ioT))
			allOkay = false;
		}

	if (allOkay)
		{
		if (iNode.Delete())
			return true;

		ZTuple responseT;
		responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, iNode));
		responseT.SetString("D:status", "HTTP/1.1 404");
		ioT.AppendTuple("D:response", responseT);
		}
	return false;
	}
Esempio n. 11
0
ZTuple ZTBQueryNode_Combo::AsTuple()
	{
	ZTuple result;
	result.SetString("Kind", "Combo");

	if (!fSort.empty())
		{
		vector<ZTupleValue>& sortVector = result.SetMutableVector("Sort");
		for (vector<ZTBQuery::SortSpec>::iterator i = fSort.begin(); i != fSort.end(); ++i)
			{
			ZTuple theTuple;
			theTuple.SetString("PropName", (*i).fPropName.AsString());
			theTuple.SetBool("Ascending", (*i).fAscending);
			theTuple.SetInt32("Strength", (*i).fStrength);
			sortVector.push_back(theTuple);
			}
		}

	vector<ZTupleValue>& sectVector = result.SetMutableVector("Intersections");
	for (vector<Intersection>::iterator i = fIntersections.begin(); i != fIntersections.end(); ++i)
		sectVector.push_back((*i).AsTuple());

	return result;
	}
Esempio n. 12
0
ZTuple ZDragClip_Win_DataObject::sAsTuple(IDataObject* iIDataObject)
	{
	ZTuple theTuple;
	ZDragClip_Win_DataObject* theDataObject;
	if (SUCCEEDED(iIDataObject->QueryInterface(ZDragClip_Win_DataObject::sIID, (void**)&theDataObject)))
		{
		theTuple = *theDataObject->GetTuple();
		theDataObject->Release();
		}
	else
		{
		vector<FORMATETC> filteredVector;
		::sFilterNonHGLOBAL(iIDataObject, filteredVector);

		for (vector<FORMATETC>::const_iterator i = filteredVector.begin();i != filteredVector.end(); ++i)
			{
			bool isString;
			string thePropertyName;
			if (ZDragClipManager::sGet()->LookupCLIPFORMAT((*i).cfFormat, thePropertyName, isString))
				{
				ZAssertStop(1, !thePropertyName.empty());
				FORMATETC theFORMATETC = *i;
				STGMEDIUM theSTGMEDIUM;
				HRESULT theHRESULT = iIDataObject->GetData(&theFORMATETC, &theSTGMEDIUM);
				if (SUCCEEDED(theHRESULT))
					{
					if (theSTGMEDIUM.tymed & TYMED_HGLOBAL)
						{
						void* globalPtr = ::GlobalLock(theSTGMEDIUM.hGlobal);
						// Special case text, to find and ignore the zero terminator, and to store a string.
						if (theFORMATETC.cfFormat == CF_TEXT)
							theTuple.SetString(thePropertyName, string(reinterpret_cast<char*>(globalPtr)));
						else
							theTuple.SetRaw(thePropertyName, globalPtr, ::GlobalSize(theSTGMEDIUM.hGlobal));

						::GlobalUnlock(theSTGMEDIUM.hGlobal);
						}
					::ReleaseStgMedium(&theSTGMEDIUM);
					}
				}
			}
		}
	return theTuple;
	}
Esempio n. 13
0
ZTuple ZTBQueryNode_All::AsTuple()
	{
	ZTuple theTuple;
	theTuple.SetString("Kind", "All");
	return theTuple;
	}
Esempio n. 14
0
ZTuple ZUITextEngine::GetTuple(size_t inOffset, size_t inLength)
	{
	ZTuple theTuple;
	theTuple.SetString("text/plain", this->GetText(inOffset, inLength));
	return theTuple;
	}