1 /* 2 Bacula(R) - The Network Backup Solution 3 4 Copyright (C) 2000-2020 Kern Sibbald 5 6 The original author of Bacula is Kern Sibbald, with contributions 7 from many others, a complete list can be found in the file AUTHORS. 8 9 You may use this file and others of this release according to the 10 license defined in the LICENSE file, which includes the Affero General 11 Public License, v3.0 ("AGPLv3") and some additional permissions and 12 terms pursuant to its AGPLv3 Section 7. 13 14 This notice must be preserved when any source code is 15 conveyed and/or propagated. 16 17 Bacula(R) is a registered trademark of Kern Sibbald. 18 */ 19 20 #include "respanel-ui-controller.h" 21 ResPanelUiController(QObject * parent)22ResPanelUiController::ResPanelUiController(QObject *parent): 23 QObject(parent) 24 { 25 m_storage = &ConfigStorage::getInstance(); 26 } 27 saveChanges()28void ResPanelUiController::saveChanges() { 29 const char *error_msg = NULL; 30 QByteArray resNameBytes = m_resourceName.toUtf8(); 31 QByteArray resAddressBytes = m_resourceAddress.toUtf8(); 32 QByteArray resPasswordBytes = m_resourcePassword.toUtf8(); 33 34 RESMON *newRes = new RESMON(); 35 newRes->code = m_resCode; 36 newRes->hdr.name = resNameBytes.data(); 37 newRes->address = resAddressBytes.data(); 38 newRes->password = resPasswordBytes.data(); 39 newRes->port = m_resourcePort.toUInt(); 40 newRes->use_remote = m_remoteClient; 41 42 if(m_res == NULL) { 43 error_msg = m_storage->addResource(newRes, m_resCode); 44 } else { 45 error_msg = m_storage->editResource(m_res, newRes, m_resCode); 46 } 47 48 if(error_msg == NULL) { 49 setSuccessMessage("Changes Saved"); 50 } else { 51 setErrorMessage(error_msg); 52 } 53 54 m_res = m_storage->getResourceByName(newRes->code, newRes->hdr.name); 55 delete newRes; 56 } 57 ~ResPanelUiController()58ResPanelUiController::~ResPanelUiController() {} 59