1f8e2c85aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e2c85aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e2c85aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e2c85aSAndrew Rist * distributed with this work for additional information 6f8e2c85aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e2c85aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e2c85aSAndrew Rist * "License"); you may not use this file except in compliance 9f8e2c85aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f8e2c85aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f8e2c85aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e2c85aSAndrew Rist * software distributed under the License is distributed on an 15f8e2c85aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e2c85aSAndrew Rist * KIND, either express or implied. See the License for the 17f8e2c85aSAndrew Rist * specific language governing permissions and limitations 18f8e2c85aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f8e2c85aSAndrew Rist *************************************************************/ 21f8e2c85aSAndrew Rist 22f8e2c85aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_shell.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "cmdmailmsg.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir using com::sun::star::lang::IllegalArgumentException; 30cdf0e10cSrcweir using com::sun::star::lang::WrappedTargetException; 31cdf0e10cSrcweir using com::sun::star::container::NoSuchElementException; 32cdf0e10cSrcweir using com::sun::star::container::XNameAccess; 33cdf0e10cSrcweir using rtl::OUString; 34cdf0e10cSrcweir using osl::MutexGuard; 35cdf0e10cSrcweir 36cdf0e10cSrcweir using namespace cppu; 37cdf0e10cSrcweir using namespace com::sun::star::uno; 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40*33bc51b9SAriel Constenla-Haile void SAL_CALL CmdMailMsg::setBody( const OUString& aBody ) 41*33bc51b9SAriel Constenla-Haile throw (RuntimeException) 42*33bc51b9SAriel Constenla-Haile { 43*33bc51b9SAriel Constenla-Haile MutexGuard aGuard( m_aMutex ); 44*33bc51b9SAriel Constenla-Haile m_aBody = aBody; 45*33bc51b9SAriel Constenla-Haile } 46cdf0e10cSrcweir 47*33bc51b9SAriel Constenla-Haile OUString SAL_CALL CmdMailMsg::getBody( ) 48*33bc51b9SAriel Constenla-Haile throw (RuntimeException) 49*33bc51b9SAriel Constenla-Haile { 50*33bc51b9SAriel Constenla-Haile MutexGuard aGuard( m_aMutex ); 51*33bc51b9SAriel Constenla-Haile return m_aBody; 52*33bc51b9SAriel Constenla-Haile } 53*33bc51b9SAriel Constenla-Haile 54*33bc51b9SAriel Constenla-Haile void SAL_CALL CmdMailMsg::setRecipient( const OUString& aRecipient ) 55cdf0e10cSrcweir throw (RuntimeException) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 58cdf0e10cSrcweir m_aRecipient = aRecipient; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61*33bc51b9SAriel Constenla-Haile OUString SAL_CALL CmdMailMsg::getRecipient( ) 62cdf0e10cSrcweir throw (RuntimeException) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 65cdf0e10cSrcweir return m_aRecipient; 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir void SAL_CALL CmdMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient ) 69cdf0e10cSrcweir throw (RuntimeException) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 72cdf0e10cSrcweir m_CcRecipients = aCcRecipient; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir Sequence< OUString > SAL_CALL CmdMailMsg::getCcRecipient( ) 76cdf0e10cSrcweir throw (RuntimeException) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 79cdf0e10cSrcweir return m_CcRecipients; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir void SAL_CALL CmdMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient ) 83cdf0e10cSrcweir throw (RuntimeException) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 86cdf0e10cSrcweir m_BccRecipients = aBccRecipient; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir Sequence< OUString > SAL_CALL CmdMailMsg::getBccRecipient( ) 90cdf0e10cSrcweir throw (RuntimeException) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 93cdf0e10cSrcweir return m_BccRecipients; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir void SAL_CALL CmdMailMsg::setOriginator( const OUString& aOriginator ) 97cdf0e10cSrcweir throw (RuntimeException) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 100cdf0e10cSrcweir m_aOriginator = aOriginator; 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir OUString SAL_CALL CmdMailMsg::getOriginator( ) 104cdf0e10cSrcweir throw (RuntimeException) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 107cdf0e10cSrcweir return m_aOriginator; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir void SAL_CALL CmdMailMsg::setSubject( const OUString& aSubject ) 111cdf0e10cSrcweir throw (RuntimeException) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 114cdf0e10cSrcweir m_aSubject = aSubject; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir OUString SAL_CALL CmdMailMsg::getSubject( ) 118cdf0e10cSrcweir throw (RuntimeException) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 121cdf0e10cSrcweir return m_aSubject; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124*33bc51b9SAriel Constenla-Haile void SAL_CALL CmdMailMsg::setAttachement( const Sequence< OUString >& aAttachment ) 125cdf0e10cSrcweir throw (IllegalArgumentException, RuntimeException) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 128cdf0e10cSrcweir m_Attachments = aAttachment; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( ) 132cdf0e10cSrcweir throw (RuntimeException) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 135cdf0e10cSrcweir return m_Attachments; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir Any SAL_CALL CmdMailMsg::getByName( const OUString& aName ) 139cdf0e10cSrcweir throw (NoSuchElementException, WrappedTargetException, RuntimeException) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 142cdf0e10cSrcweir 143*33bc51b9SAriel Constenla-Haile if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "body" )) && m_aBody.getLength() ) 144*33bc51b9SAriel Constenla-Haile return makeAny( m_aBody ); 145*33bc51b9SAriel Constenla-Haile 146*33bc51b9SAriel Constenla-Haile if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "from" )) && m_aOriginator.getLength() ) 147cdf0e10cSrcweir return makeAny( m_aOriginator ); 148cdf0e10cSrcweir 149*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "to" )) && m_aRecipient.getLength() ) 150cdf0e10cSrcweir return makeAny( m_aRecipient ); 151cdf0e10cSrcweir 152*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "cc" )) && m_CcRecipients.getLength() ) 153cdf0e10cSrcweir return makeAny( m_CcRecipients ); 154cdf0e10cSrcweir 155*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "bcc" )) && m_BccRecipients.getLength() ) 156cdf0e10cSrcweir return makeAny( m_BccRecipients ); 157cdf0e10cSrcweir 158*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "subject" )) && m_aSubject.getLength() ) 159cdf0e10cSrcweir return makeAny( m_aSubject ); 160cdf0e10cSrcweir 161*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "attachment" )) && m_Attachments.getLength() ) 162cdf0e10cSrcweir return makeAny( m_Attachments ); 163cdf0e10cSrcweir 164*33bc51b9SAriel Constenla-Haile throw NoSuchElementException( OUString(RTL_CONSTASCII_USTRINGPARAM( "key not found: ")) + aName, 165cdf0e10cSrcweir static_cast < XNameAccess * > (this) ); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( ) 169cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir sal_Int32 nItems = 0; 174*33bc51b9SAriel Constenla-Haile Sequence< OUString > aRet( 7 ); 175*33bc51b9SAriel Constenla-Haile 176*33bc51b9SAriel Constenla-Haile if( m_aBody.getLength() ) 177*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "body" )); 178cdf0e10cSrcweir 179cdf0e10cSrcweir if( m_aOriginator.getLength() ) 180*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "from" )); 181cdf0e10cSrcweir 182cdf0e10cSrcweir if( m_aRecipient.getLength() ) 183*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "to" )); 184cdf0e10cSrcweir 185cdf0e10cSrcweir if( m_CcRecipients.getLength() ) 186*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "cc" )); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if( m_BccRecipients.getLength() ) 189*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "bcc" )); 190cdf0e10cSrcweir 191cdf0e10cSrcweir if( m_aSubject.getLength() ) 192*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "subject" )); 193cdf0e10cSrcweir 194cdf0e10cSrcweir if( m_Attachments.getLength() ) 195*33bc51b9SAriel Constenla-Haile aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "attachment" )); 196cdf0e10cSrcweir 197cdf0e10cSrcweir aRet.realloc( nItems ); 198cdf0e10cSrcweir return aRet; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201*33bc51b9SAriel Constenla-Haile sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName ) 202cdf0e10cSrcweir throw (RuntimeException) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 205cdf0e10cSrcweir 206*33bc51b9SAriel Constenla-Haile if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "body" )) && m_aBody.getLength() ) 207cdf0e10cSrcweir return sal_True; 208cdf0e10cSrcweir 209*33bc51b9SAriel Constenla-Haile if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "from" )) && m_aOriginator.getLength() ) 210cdf0e10cSrcweir return sal_True; 211cdf0e10cSrcweir 212*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "to" )) && m_aRecipient.getLength() ) 213cdf0e10cSrcweir return sal_True; 214cdf0e10cSrcweir 215*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "cc" )) && m_CcRecipients.getLength() ) 216cdf0e10cSrcweir return sal_True; 217cdf0e10cSrcweir 218*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "bcc" )) && m_BccRecipients.getLength() ) 219cdf0e10cSrcweir return sal_True; 220cdf0e10cSrcweir 221*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "subject" )) && m_aSubject.getLength() ) 222*33bc51b9SAriel Constenla-Haile return sal_True; 223*33bc51b9SAriel Constenla-Haile 224*33bc51b9SAriel Constenla-Haile else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "attachment" )) && m_Attachments.getLength() ) 225cdf0e10cSrcweir return sal_True; 226cdf0e10cSrcweir 227cdf0e10cSrcweir return sal_False; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir Type SAL_CALL CmdMailMsg::getElementType( ) 231cdf0e10cSrcweir throw (RuntimeException) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir // returning void for multi type container 234cdf0e10cSrcweir return Type(); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir sal_Bool SAL_CALL CmdMailMsg::hasElements( ) 238cdf0e10cSrcweir throw (RuntimeException) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir return 0 != getElementNames().getLength(); 241cdf0e10cSrcweir } 242