STDMETHODIMP InterfaceDistributionListRecipient::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      if (!m_pObject)
         return S_FALSE;
   
      HM::String sErrorMessage;
      if (HM::PersistentDistributionListRecipient::SaveObject(m_pObject, sErrorMessage))
      {
         AddToParentCollection();
   
         return S_OK;
      }
   
      return COMError::GenerateError(sErrorMessage);
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP InterfaceSecurityRange::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      if (!m_pAuthentication->GetIsServerAdmin())
         return m_pAuthentication->GetAccessDenied();
   
      HM::String result;
      if (HM::PersistentSecurityRange::SaveObject(m_pObject, result))
      {
         // Add to parent collection
         AddToParentCollection();
   
         return S_OK;
      }
   
      return COMError::GenerateError(result);
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP 
InterfaceSURBLServer::Save()
{
   try
   {
      if (!object_)
         return GetAccessDenied();

      if (!authentication_->GetIsServerAdmin())
         return authentication_->GetAccessDenied();
   
      if (HM::PersistentSURBLServer::SaveObject(object_))
      {
         // Add to parent collection
         AddToParentCollection();
   
         return S_OK;
      }
   
      return COMError::GenerateError("Failed to save object. See hMailServer error log.");
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 4
0
STDMETHODIMP 
InterfaceMessage::_SaveNewMessageToIMAPFolder()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      // Check which account this message belongs to.
      shared_ptr<const HM::Account> pAccount = HM::CacheContainer::Instance()->GetAccount(m_pObject->GetAccountID());
   
      // Save the message to the database
      if (!HM::PersistentMessage::SaveObject(m_pObject))
         return S_FALSE;
   
      // Add to parent collection
      AddToParentCollection();
   
      // Notify...
      shared_ptr<HM::ChangeNotification> pNotification = 
         shared_ptr<HM::ChangeNotification>(new HM::ChangeNotification(m_pObject->GetAccountID(), m_pObject->GetFolderID(), HM::ChangeNotification::NotificationMessageAdded));
   
      HM::Application::Instance()->GetNotificationServer()->SendNotification(pNotification);
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 5
0
STDMETHODIMP InterfaceDomain::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      if (!m_pAuthentication->GetIsDomainAdmin())
         return m_pAuthentication->GetAccessDenied();
   
      // Save object in the database.
      HM::String sErrorMessage;
      if (HM::PersistentDomain::SaveObject(m_pObject, sErrorMessage))
      {
         // Add to parent collection
         AddToParentCollection();
         return S_OK;
      }
   
      return COMError::GenerateError(sErrorMessage);
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP InterfaceIMAPFolderPermission::Save()
{
   try
   {
      if (!object_)
         return GetAccessDenied();

      if (HM::PersistentACLPermission::SaveObject(object_))
      {
         // Add to parent collection
         AddToParentCollection();
         return S_OK;
      }
   
      return COMError::GenerateError("Failed to save object. See hMailServer error log.");
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP 
InterfaceGroupMember::Save()
{
   try
   {
      if (!object_)
         return GetAccessDenied();

      if (HM::PersistentGroupMember::SaveObject(object_))
      {
         // Add to parent collection
         AddToParentCollection();
      }
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 8
0
STDMETHODIMP InterfaceRuleAction::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      // Set the sort order of the rule.
      if (m_pObject->GetID() == 0 && m_pObject->GetSortOrder() == 0)
      {
         std::vector<boost::shared_ptr<HM::RuleAction> > vecExistingRuleActions = m_pParentCollection->GetVector();
   
         // Determine the highest SortOrder.
         if (vecExistingRuleActions.size() == 0)
            m_pObject->SetSortOrder(1);
         else
         {
            boost::shared_ptr<HM::RuleAction> pLastRuleAction = vecExistingRuleActions[vecExistingRuleActions.size() -1];
            m_pObject->SetSortOrder(pLastRuleAction->GetSortOrder() +1);
         }
      }
   
      if (m_pParentCollection->GetRuleID() > 0)
      {
         if (!HM::PersistentRuleAction::SaveObject(m_pObject))
         {
            // Saving failed.
            return COMError::GenerateError("Failed to save object. See hMailServer error log.");
         }
      }
   
      AddToParentCollection();   
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 9
0
STDMETHODIMP InterfaceAlias::Save()
{
   try
   {
      if (!object_)
         return GetAccessDenied();

      HM::String sErrorMessage;
      if (HM::PersistentAlias::SaveObject(object_, sErrorMessage, HM::PersistenceModeNormal))
      {
         // Add to parent collection
         AddToParentCollection();
         return S_OK;
      }
   
      return COMError::GenerateError("Failed to save object. " +  sErrorMessage);
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 10
0
STDMETHODIMP 
InterfaceRouteAddress::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      if (HM::PersistentRouteAddress::SaveObject(m_pObject))
      {
         // Add to parent collection
         AddToParentCollection();
   
         return S_OK;
      }
   
      return COMError::GenerateError("Failed to save object. See hMailServer error log.");
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Exemplo n.º 11
0
STDMETHODIMP InterfaceRoute::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      HM::String sErrorMessage;
      if (HM::PersistentRoute::SaveObject(m_pObject, sErrorMessage))
      {
         // Add to parent collection
         AddToParentCollection();
   
         return S_OK;
      }
   
      return COMError::GenerateError(sErrorMessage);
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP 
InterfaceWhiteListAddress::Save()
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      if (!m_pAuthentication->GetIsServerAdmin())
         return m_pAuthentication->GetAccessDenied();
   
      if (HM::PersistentWhiteListAddress::SaveObject(m_pObject))
      {
         // Add to parent collection
         AddToParentCollection();
      }
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
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();
    }
}