Ejemplo n.º 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;
}