예제 #1
0
std::map<std::string, Status*> Status::GetAllStatusses()
{
	if (s_allStatusses.size() == 0)
	{	
		IImageManager* imageManager = PlatformSpecific::GetImageManager();
		//otherwise open status XML file
		typedef vector<XMLNode*>::const_iterator SI;
		vector<XMLNode*> statusNodes = BmeClient::GetPreferences()->GetIconPrefs()->GetStatusNodes();
		
		for (SI s = statusNodes.begin(); s != statusNodes.end(); ++s)
		{
			XMLNode* statusNode = *s;
			if (statusNode->Name() == "status")
			{
				vector<XMLNode*> children = statusNode->Children();
				Status* status = new Status();
				for (SI c = children.begin(); c != children.end(); ++c)
				{
					
					XMLNode* statusChild = *c;
					if (statusChild->Name() == "icon")
					{						
						std::string iconPath = statusChild->StringValue();
						IPath* iconFullPath = PlatformSpecific::GetPathManager()->GetIconPrefsPath()->Append(iconPath);
						
						Image* statusIcon = imageManager->GetImageFromFile(iconFullPath->ToString());
						status->AddIcon(statusIcon);
						delete iconFullPath;
					}
					else if (statusChild->Name() == "message")
					{
						status->SetStatusName(statusChild->StringValue());
					}
					else if (statusChild->Name() == "protocol")
					{
						status->SetAbbreviation(statusChild->StringValue());
					}
					else if (statusChild->Name() == "visible")
					{
						bool userChoice = atoi(statusChild->StringValue().c_str());
						status->SetUserChoice(userChoice);
					}
					else if (statusChild->Name() == "color")
					{
					}
				}
				s_allStatusses[status->GetAbbreviation()] = (status);
			}
		}
		delete imageManager;
	}
	return s_allStatusses;
}
예제 #2
0
XMLNode*
resource_to_xmb_msg(const StringResource& res)
{
    // the msg element
    vector<XMLAttribute> attrs;
    string name = res.pos.file;
    name += ":";
    name += res.TypedID();
    attrs.push_back(XMLAttribute("", "name", name));
    attrs.push_back(XMLAttribute("", "desc", strip_newlines(res.comment)));
    attrs.push_back(XMLAttribute(XMLNS_XMLNS, "space", "preserve"));
    XMLNode* msg = XMLNode::NewElement(res.pos, "", "msg", attrs, XMLNode::EXACT);

    // the contents are in xliff/html, convert it to xliff
    int err = 0;
    XMLNode* value = res.value;
    string tag = value->Name();
    int phID = 0;
    for (vector<XMLNode*>::const_iterator it=value->Children().begin();
            it!=value->Children().end(); it++) {
        err |= convert_html_to_xliff(*it, tag, msg, &phID);
    }

    if (err != 0) {
        return NULL;
    }

    // and then convert that to xmb
    for (vector<XMLNode*>::iterator it=msg->EditChildren().begin();
            it!=msg->EditChildren().end(); it++) {
        err |= convert_xliff_to_ph(*it, &phID);
    }

    if (err == 0) {
        return msg;
    } else {
        return NULL;
    }
}