libemailfunctions

email.h
Go to the documentation of this file.
1 /*
2  This file is part of tdepim.
3  Copyright (c) 2004 TDEPIM developers
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef EMAIL_H
22 #define EMAIL_H
23 
24 #include <tqstringlist.h>
25 #include <tqcstring.h>
26 
27 #include <tdemacros.h>
28 
38 namespace KPIM {
39 
43 enum EmailParseResult { AddressOk, AddressEmpty, UnexpectedEnd,
44  UnbalancedParens, MissingDomainPart,
45  UnclosedAngleAddr, UnopenedAngleAddr,
46  TooManyAts, UnexpectedComma,
47  TooFewAts, MissingLocalPart,
48  UnbalancedQuote, NoAddressSpec,
49  DisallowedChar, InvalidDisplayName };
50 
51 // Helper functions
53 TDE_EXPORT TQStringList splitEmailAddrList(const TQString& aStr);
54 
74 TDE_EXPORT EmailParseResult splitAddress( const TQCString & address,
75  TQCString & displayName,
76  TQCString & addrSpec,
77  TQCString & comment );
78 
101 TDE_EXPORT EmailParseResult splitAddress( const TQString & address,
102  TQString & displayName,
103  TQString & addrSpec,
104  TQString & comment );
105 
115 TDE_EXPORT EmailParseResult isValidEmailAddress( const TQString& aStr );
116 
124 TDE_EXPORT TQString emailParseResultToString( EmailParseResult errorCode );
125 
136 TDE_EXPORT bool isValidSimpleEmailAddress( const TQString& aStr );
137 
145 TDE_EXPORT TQString simpleEmailAddressErrorMsg();
146 
154 TDE_EXPORT TQCString getEmailAddress( const TQCString & address );
155 
166 TDE_EXPORT TQString getEmailAddress( const TQString & address );
167 
175 TDE_EXPORT TQCString getFirstEmailAddress( const TQCString & addresses );
176 
187 TDE_EXPORT TQString getFirstEmailAddress( const TQString & addresses );
188 
197 TDE_EXPORT bool getNameAndMail(const TQString& aStr, TQString& name, TQString& mail);
198 
204 TDE_EXPORT bool compareEmail( const TQString& email1, const TQString& email2,
205  bool matchName );
206 
219 TDE_EXPORT TQString normalizedAddress( const TQString & displayName,
220  const TQString & addrSpec,
221  const TQString & comment );
222 
228 TDE_EXPORT TQString decodeIDN( const TQString & addrSpec );
229 
236 TDE_EXPORT TQString encodeIDN( const TQString & addrSpec );
237 
244 TDE_EXPORT TQString normalizeAddressesAndDecodeIDNs( const TQString & addresses );
245 
249 TDE_EXPORT TQString normalizeAddressesAndEncodeIDNs( const TQString & str );
250 
254 TDE_EXPORT TQString quoteNameIfNecessary( const TQString& str );
255 
256 } // namespace
257 
258 #endif /* EMAIL_H */
259 
KPIM holds all kinds of functions specific to KDE PIM.
Definition: email.h:38
TDE_EXPORT TQString simpleEmailAddressErrorMsg()
Returns a i18n string to be used in msgboxes this allows for error messages to be the same across the...
TDE_EXPORT bool getNameAndMail(const TQString &aStr, TQString &name, TQString &mail)
Return email address and name from string.
TDE_EXPORT TQString normalizeAddressesAndEncodeIDNs(const TQString &str)
Normalizes all email addresses in the given list and encodes all IDNs in punycode.
TDE_EXPORT bool compareEmail(const TQString &email1, const TQString &email2, bool matchName)
Compare two email addresses.
TDE_EXPORT TQStringList splitEmailAddrList(const TQString &aStr)
Split a comma separated list of email addresses.
Definition: email.cpp:30
TDE_EXPORT TQCString getEmailAddress(const TQCString &address)
Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).
TDE_EXPORT EmailParseResult splitAddress(const TQCString &address, TQCString &displayName, TQCString &addrSpec, TQCString &comment)
Splits the given address into display name, email address and comment.
Definition: email.cpp:257
TDE_EXPORT TQString decodeIDN(const TQString &addrSpec)
Decodes the punycode domain part of the given addr-spec if it's an IDN.
TDE_EXPORT TQString quoteNameIfNecessary(const TQString &str)
Add quote characters around the given string if it contains a character that makes that necessary,...
TDE_EXPORT TQString normalizeAddressesAndDecodeIDNs(const TQString &addresses)
Normalizes all email addresses in the given list and decodes all IDNs.
TDE_EXPORT TQString encodeIDN(const TQString &addrSpec)
Encodes the domain part of the given addr-spec in punycode if it's an IDN.
TDE_EXPORT TQString emailParseResultToString(EmailParseResult errorCode)
Translate the enum errorcodes from emailParseResult into i18n'd strings that can be used for msg boxe...
Definition: email.cpp:460
TDE_EXPORT bool isValidSimpleEmailAddress(const TQString &aStr)
Validates an email address in the form of joe@example.org.
Definition: email.cpp:518
TDE_EXPORT TQCString getFirstEmailAddress(const TQCString &addresses)
Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of address...
EmailParseResult
Result type for splitAddress, isValidEmailAddress.
Definition: email.h:43
TDE_EXPORT TQString normalizedAddress(const TQString &displayName, const TQString &addrSpec, const TQString &comment)
Returns a normalized address built from the given parts.
TDE_EXPORT EmailParseResult isValidEmailAddress(const TQString &aStr)
Validates an email address in the form of "Joe User" joe@example.org.
Definition: email.cpp:285