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