bool RouteAddress::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("RouteAddress")); pNode->AppendAttr(_T("Name"), m_sAddress); return true; }
bool PropertySet::XMLStore(XNode *pBackupNode) { XNode *pPropertiesNode = pBackupNode->AppendChild(_T("Properties")); std::map<String, std::shared_ptr<Property> >::iterator iterProperty = items_.begin(); while (iterProperty != items_.end()) { std::shared_ptr<Property> oProperty = (*iterProperty).second; XNode *pNode = pPropertiesNode->AppendChild(String(oProperty->GetName())); pNode->AppendAttr(_T("LongValue"), StringParser::IntToString(oProperty->GetLongValue())); pNode->AppendAttr(_T("StringValue"), oProperty->GetStringValue()); iterProperty++; } return true; }
bool IMAPFolder::XMLStore(XNode *pParentNode, int iBackupOptions) { XNode *pNode = pParentNode->AppendChild(_T("Folder")); pNode->AppendAttr(_T("Name"), String(folder_name_)); pNode->AppendAttr(_T("Subscribed"), folder_is_subscribed_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("CreateTime"), String(Time::GetTimeStampFromDateTime(create_time_))); pNode->AppendAttr(_T("CurrentUID"), StringParser::IntToString(current_uid_)); if (!GetMessages()->XMLStore(pNode, iBackupOptions)) return false; if (!GetSubFolders()->XMLStore(pNode, iBackupOptions)) return false; if (IsPublicFolder()) { if (!GetPermissions()->XMLStore(pNode, iBackupOptions)) return false; } return true; }
bool Message::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("Message")); String sFilename = filename_; sFilename.Replace(IniFileSettings::Instance()->GetDataDirectory() + _T("\\"), _T("")); pNode->AppendAttr(_T("CreateTime"), String(create_time_)); pNode->AppendAttr(_T("Filename"), FileUtilities::GetFileNameFromFullPath(sFilename)); pNode->AppendAttr(_T("FromAddress"), String(from_address_)); pNode->AppendAttr(_T("State"), StringParser::IntToString(message_state_)); pNode->AppendAttr(_T("Size"), StringParser::IntToString(message_size_)); pNode->AppendAttr(_T("NoOfRetries"), StringParser::IntToString(no_of_retries_)); pNode->AppendAttr(_T("Flags"), StringParser::IntToString(flags_)); pNode->AppendAttr(_T("ID"), StringParser::IntToString(id_)); pNode->AppendAttr(_T("UID"), StringParser::IntToString(uid_)); return true; }
bool Message::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("Message")); String sFilename = m_sFilename; sFilename.Replace(IniFileSettings::Instance()->GetDataDirectory() + _T("\\"), _T("")); pNode->AppendAttr(_T("CreateTime"), String(m_sCreateTime)); pNode->AppendAttr(_T("Filename"), FileUtilities::GetFileNameFromFullPath(sFilename)); pNode->AppendAttr(_T("FromAddress"), String(m_sFromAddress)); pNode->AppendAttr(_T("State"), StringParser::IntToString(m_iMessageState)); pNode->AppendAttr(_T("Size"), StringParser::IntToString(m_iMessageSize)); pNode->AppendAttr(_T("NoOfRetries"), StringParser::IntToString(m_iNoOfRetries)); pNode->AppendAttr(_T("Flags"), StringParser::IntToString(m_iFlags)); pNode->AppendAttr(_T("ID"), StringParser::IntToString(m_iID)); pNode->AppendAttr(_T("UID"), StringParser::IntToString(_uid)); return true; }
bool FetchAccount::XMLStore(XNode *pRuleNode, int iOptions) { XNode *pNode = pRuleNode->AppendChild(_T("FetchAccount")); pNode->AppendAttr(_T("Name"), name_); pNode->AppendAttr(_T("ServerAddress"), server_address_); pNode->AppendAttr(_T("ServerType"), StringParser::IntToString(server_type_)); pNode->AppendAttr(_T("Port"), StringParser::IntToString(port_)); pNode->AppendAttr(_T("Username"), username_); pNode->AppendAttr(_T("Password"), Crypt::Instance()->EnCrypt(password_, Crypt::ETBlowFish)); pNode->AppendAttr(_T("Minutes"), StringParser::IntToString(minutes_)); pNode->AppendAttr(_T("DaysToKeep"), StringParser::IntToString(days_to_keep_)); pNode->AppendAttr(_T("Active"), is_active_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("ProcessMIMERecipients"), process_mimerecipients_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("ProcessMIMEDate"), process_mimedate_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("UseAntiSpam"), use_anti_spam_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("UseAntiVirus"), use_anti_virus_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("EnableRouteRecipients"), enable_route_recipients_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("ConnectionSecurity"), StringParser::IntToString(connection_security_)); if (!GetUIDs()->XMLStore(pNode, iOptions)) return false; return true; }
bool BackupExecuter::StartBackup() { Logger::Instance()->LogBackup("Loading backup settings...."); _LoadSettings(); // Special temp setting to skip files during backup/restore while still storing/restoring db file/message info. bool bMessagesDBOnly = IniFileSettings::Instance()->GetBackupMessagesDBOnly(); if (m_iBackupMode & Backup::BOMessages) { if (!PersistentMessage::GetAllMessageFilesAreInDataFolder()) { Application::Instance()->GetBackupManager()->OnBackupFailed("All messages are not located in the data folder."); return false; } // Skip size check if DB only if (!bMessagesDBOnly) { // Check size of data directory and LOG it. if (PersistentMessage::GetTotalMessageSize() > 1500) { Logger::Instance()->LogBackup("The size of the data directory exceeds the maximum RECOMMENDED size for the built in backup (1.5GB) so LOGGING. Please consult the backup documentation"); // Check size of data directory and STOP it. if (PersistentMessage::GetTotalMessageSize() > 30000) { Application::Instance()->GetBackupManager()->OnBackupFailed("The size of the data directory exceeds the maximum size for the built in backup (30GB) so ABORTING. Please consult the backup documentation."); return false; } } } } if (!FileUtilities::Exists(m_sDestination)) { Application::Instance()->GetBackupManager()->OnBackupFailed("The specified backup directory is not accessible: " + m_sDestination); return false; } String sTime = Time::GetCurrentDateTime(); sTime.Replace(_T(":"), _T("")); // Generate name for zip file. We always create zip // file String sZipFile; sZipFile.Format(_T("%s\\HMBackup %s.7z"), m_sDestination, sTime); String sXMLFile; sXMLFile.Format(_T("%s\\hMailServerBackup.xml"), m_sDestination); // The name of the backup directory that // contains all the data files. String sDataBackupDir = m_sDestination + "\\DataBackup"; // Backup all properties. XDoc oDoc; XNode *pBackupNode = oDoc.AppendChild(_T("Backup")); XNode *pBackupInfoNode = pBackupNode->AppendChild(_T("BackupInformation")); // Store backup mode pBackupInfoNode->AppendAttr(_T("Mode"), StringParser::IntToString(m_iBackupMode)); pBackupInfoNode->AppendAttr(_T("Version"), Application::Instance()->GetVersion()); // Backup business objects if (m_iBackupMode & Backup::BODomains) { Logger::Instance()->LogBackup("Backing up domains..."); if (!_BackupDomains(pBackupNode)) { Application::Instance()->GetBackupManager()->OnBackupFailed("Could not backup domains."); return false; } // Backup message files if (m_iBackupMode & Backup::BOMessages && !bMessagesDBOnly) { Logger::Instance()->LogBackup("Backing up data directory..."); if (!_BackupDataDirectory(sDataBackupDir)) { Application::Instance()->GetBackupManager()->OnBackupFailed("Could not backup data directory."); return false; } } } // Save information in the XML file where messages can be found. if (m_iBackupMode & Backup::BOMessages) { XNode *pMessageFile = pBackupInfoNode->AppendChild(_T("DataFiles")); if (m_iBackupMode & Backup::BOCompression) { pMessageFile->AppendAttr(_T("Format"), _T("7z")); pMessageFile->AppendAttr(_T("Size"), StringParser::IntToString(FileUtilities::FileSize(sZipFile))); } else { pMessageFile->AppendAttr(_T("Format"), _T("Raw")); pMessageFile->AppendAttr(_T("FolderName"), _T("DataBackup")); } } if (m_iBackupMode & Backup::BOSettings) { Logger::Instance()->LogBackup("Backing up settings..."); Configuration::Instance()->XMLStore(pBackupNode); } Logger::Instance()->LogBackup(_T("Writing XML file...")); String sXMLData = oDoc.GetXML(); if (!FileUtilities::WriteToFile(sXMLFile, sXMLData, true)) { Application::Instance()->GetBackupManager()->OnBackupFailed("Could not write to the XML file."); return false; } // Compress the XML file Compression oComp; oComp.AddFile(sZipFile, sXMLFile); // Delete the XML file FileUtilities::DeleteFile(sXMLFile); // Should we compress the message files? if (m_iBackupMode & Backup::BOMessages && m_iBackupMode & Backup::BOCompression && !bMessagesDBOnly) { Logger::Instance()->LogBackup("Compressing message files..."); if (m_iBackupMode & Backup::BOMessages) oComp.AddDirectory(sZipFile, sDataBackupDir + "\\"); // Since the files are now compressed, we can deleted // the data backup directory if (!FileUtilities::DeleteDirectory(sDataBackupDir)) { Application::Instance()->GetBackupManager()->OnBackupFailed("Could not delete files from the destination directory."); return false; } } Application::Instance()->GetBackupManager()->OnBackupCompleted(); return true; }
// NOTE: This function can return NULL if the actor should not be displayed. // Callers should be aware of this and handle it appropriately. Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor ) { RString sPath( sPath_ ); FileType ft = GetFileType( sPath ); switch( ft ) { case FT_Lua: { auto_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) ); if( pNode.get() == NULL ) { // XNode will warn about the error return new Actor; } Actor *pRet = ActorUtil::LoadFromNode( pNode.get(), pParentActor ); return pRet; } case FT_Xml: { // Legacy actors; only supported in quirks mode if ( !PREFSMAN->m_bQuirksMode ) return new Actor; XNode xml; if ( !XmlFileUtil::LoadFromFileShowErrors(xml, sPath) ) return new Actor; XmlFileUtil::CompileXNodeTree( &xml, sPath ); XmlFileUtil::AnnotateXNodeTree( &xml, sPath ); return LoadFromNode( &xml, pParentActor ); } case FT_Directory: { if( sPath.Right(1) != "/" ) sPath += '/'; RString sXml = sPath + "default.xml"; if (DoesFileExist(sXml)) return MakeActor(sXml, pParentActor); XNode xml; xml.AppendAttr( "Class", "BGAnimation" ); xml.AppendAttr( "AniDir", sPath ); return ActorUtil::LoadFromNode( &xml, pParentActor ); } case FT_Bitmap: case FT_Movie: { XNode xml; xml.AppendAttr( "Class", "Sprite" ); xml.AppendAttr( "Texture", sPath ); return ActorUtil::LoadFromNode( &xml, pParentActor ); } case FT_Sprite: { // Legacy actor; only supported in quirks mode if( !PREFSMAN->m_bQuirksMode ) return new Actor; IniFile ini; ini.ReadFile( sPath ); XmlFileUtil::AnnotateXNodeTree( &ini, sPath ); return ActorUtil::LoadFromNode( ini.GetChild("Sprite"), pParentActor ); } case FT_Model: { XNode xml; xml.AppendAttr( "Class", "Model" ); xml.AppendAttr( "Meshes", sPath ); xml.AppendAttr( "Materials", sPath ); xml.AppendAttr( "Bones", sPath ); return ActorUtil::LoadFromNode( &xml, pParentActor ); } default: { LOG->Warn( "File \"%s\" has unknown type, \"%s\".", sPath.c_str(), FileTypeToString(ft).c_str() ); XNode xml; xml.AppendAttr( "Class", "Actor" ); return ActorUtil::LoadFromNode( &xml, pParentActor ); } } }
bool FetchAccount::XMLStore(XNode *pRuleNode, int iOptions) { XNode *pNode = pRuleNode->AppendChild(_T("FetchAccount")); pNode->AppendAttr(_T("Name"), m_sName); pNode->AppendAttr(_T("ServerAddress"), m_sServerAddress); pNode->AppendAttr(_T("ServerType"), StringParser::IntToString(m_iServerType)); pNode->AppendAttr(_T("Port"), StringParser::IntToString(m_iPort)); pNode->AppendAttr(_T("Username"), m_sUsername); pNode->AppendAttr(_T("Password"), Crypt::Instance()->EnCrypt(m_sPassword, Crypt::ETBlowFish)); pNode->AppendAttr(_T("Minutes"), StringParser::IntToString(m_iMinutes)); pNode->AppendAttr(_T("DaysToKeep"), StringParser::IntToString(m_iDaysToKeep)); pNode->AppendAttr(_T("Active"), m_bIsActive ? _T("1") : _T("0")); pNode->AppendAttr(_T("ProcessMIMERecipients"), m_bProcessMIMERecipients ? _T("1") : _T("0")); pNode->AppendAttr(_T("ProcessMIMEDate"), m_bProcessMIMEDate ? _T("1") : _T("0")); pNode->AppendAttr(_T("UseSSL"), m_bUseSSL ? _T("1") : _T("0")); pNode->AppendAttr(_T("UseAntiSpam"), _useAntiSpam ? _T("1") : _T("0")); pNode->AppendAttr(_T("UseAntiVirus"), _useAntiVirus ? _T("1") : _T("0")); pNode->AppendAttr(_T("EnableRouteRecipients"), _enableRouteRecipients ? _T("1") : _T("0")); if (!GetUIDs()->XMLStore(pNode, iOptions)) return false; return true; }
bool Domain::XMLStore(XNode *pParentNode, int iBackupOptions) { XNode *pNode = pParentNode->AppendChild(_T("Domain")); pNode->AppendAttr(_T("Name"), name_); pNode->AppendAttr(_T("Postmaster"), postmaster_); pNode->AppendAttr(_T("ADDomainName"), addomain_name_); pNode->AppendAttr(_T("Active"), StringParser::IntToString(active_)); pNode->AppendAttr(_T("MaxMessageSize"), StringParser::IntToString(max_message_size_)); pNode->AppendAttr(_T("MaxSize"), StringParser::IntToString(max_size_mb_)); pNode->AppendAttr(_T("MaxAccountSize"), StringParser::IntToString(max_account_size_)); pNode->AppendAttr(_T("UsePlusAddressing"), use_plus_addressing_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("PlusAddressingChar"), plus_addressing_char_); pNode->AppendAttr(_T("AntiSpamOptions"), StringParser::IntToString(anti_spam_options_)); pNode->AppendAttr(_T("EnableSignature"), enable_signature_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("SignatureMethod"), StringParser::IntToString(signature_method_)); pNode->AppendAttr(_T("SignaturePlainText"), signature_plain_text_); pNode->AppendAttr(_T("SignatureHTML"), signature_html_); pNode->AppendAttr(_T("AddSignaturesToLocalMail"), add_signatures_to_local_mail_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("AddSignaturesToReplies"), add_signatures_to_replies_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("MaxNoOfAccounts"), StringParser::IntToString(max_no_of_accounts_)); pNode->AppendAttr(_T("MaxNoOfAliases"), StringParser::IntToString(max_no_of_aliases_)); pNode->AppendAttr(_T("MaxNoOfLists"), StringParser::IntToString(max_no_of_distribution_lists_)); pNode->AppendAttr(_T("LimitationsEnabled"), StringParser::IntToString(limitations_enabled_)); pNode->AppendAttr(_T("DKIMSelector"), dkim_selector_); pNode->AppendAttr(_T("DKIMPrivateKeyFile"), dkim_private_key_file_); if (!GetDomainAliases()->XMLStore(pNode, iBackupOptions)) return false; // Accounts if (!GetAccounts()->XMLStore(pNode, iBackupOptions)) return false; if (!GetAliases()->XMLStore(pNode, iBackupOptions)) return false; if (!GetDistributionLists()->XMLStore(pNode, iBackupOptions)) return false; return true; }
bool Route::XMLStore(XNode *pRoutesNode, int iOptions) { XNode *pNode = pRoutesNode->AppendChild(_T("Route")); pNode->AppendAttr(_T("Name"), domain_name_); pNode->AppendAttr(_T("Description"), description_); pNode->AppendAttr(_T("TargetHost"), target_smtphost_); pNode->AppendAttr(_T("TargetPort"), StringParser::IntToString(target_smtpport_)); pNode->AppendAttr(_T("NumberOfTries"), StringParser::IntToString(number_of_tries_)); pNode->AppendAttr(_T("MinutesBetweenTry"), StringParser::IntToString(minutes_between_try_)); pNode->AppendAttr(_T("ToAllAddresses"), to_all_addresses_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("RequiresAuthentication"), relayer_requires_authentication_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("Username"), relayer_auth_username_); pNode->AppendAttr(_T("Password"), Crypt::Instance()->EnCrypt(relayer_auth_password_, Crypt::ETBlowFish)); pNode->AppendAttr(_T("TreatRecipientAsLocalDomain"), treat_recipient_as_local_domain_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("TreatSenderAsLocalDomain"), treat_sender_as_local_domain_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("ConnectionSecurity"), StringParser::IntToString(connection_security_)); return GetAddresses()->XMLStore(pNode, iOptions); }