// Copyright (c) 2010 Martin Knafve / hMailServer.com. // http://www.hmailserver.com #include "stdafx.h" #include "COMError.h" #include "..\COM\InterfaceBlockedAttachment.h" #include "..\Common\Persistence\PersistentBlockedAttachment.h" #include "..\Common\BO\BlockedAttachment.h" // InterfaceBlockedAttachment STDMETHODIMP InterfaceBlockedAttachment::Save() { try { if (!object_) return GetAccessDenied(); if (!authentication_->GetIsServerAdmin()) return authentication_->GetAccessDenied(); if (HM::PersistentBlockedAttachment::SaveObject(object_)) { // Add to parent collection AddToParentCollection(); } return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::get_ID(long *pVal) { try { if (!object_) return GetAccessDenied(); *pVal = (long) object_->GetID(); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::put_Wildcard(BSTR newVal) { try { if (!object_) return GetAccessDenied(); object_->SetWildcard(newVal); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::get_Wildcard(BSTR *pVal) { try { if (!object_) return GetAccessDenied(); *pVal = object_->GetWildcard().AllocSysString(); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::put_Description(BSTR newVal) { try { if (!object_) return GetAccessDenied(); object_->SetDescription(newVal); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::get_Description(BSTR *pVal) { try { if (!object_) return GetAccessDenied(); *pVal = object_->GetDescription().AllocSysString(); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } } STDMETHODIMP InterfaceBlockedAttachment::Delete() { try { if (!object_) return GetAccessDenied(); if (!authentication_->GetIsServerAdmin()) return authentication_->GetAccessDenied(); if (!parent_collection_) return HM::PersistentBlockedAttachment::DeleteObject(object_) ? S_OK : S_FALSE; parent_collection_->DeleteItemByDBID(object_->GetID()); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } }