libemailfunctions

KPIM Namespace Reference

Classes

class  IdMapper
 
class  NetworkStatus
 

Enumerations

enum  EmailParseResult {
  AddressOk , AddressEmpty , UnexpectedEnd , UnbalancedParens ,
  MissingDomainPart , UnclosedAngleAddr , UnopenedAngleAddr , TooManyAts ,
  UnexpectedComma , TooFewAts , MissingLocalPart , UnbalancedQuote ,
  NoAddressSpec , DisallowedChar , InvalidDisplayName
}
 

Functions

TDE_EXPORT TQStringList splitEmailAddrList (const TQString &aStr)
 
TDE_EXPORT EmailParseResult splitAddress (const TQCString &address, TQCString &displayName, TQCString &addrSpec, TQCString &comment)
 
TDE_EXPORT EmailParseResult splitAddress (const TQString &address, TQString &displayName, TQString &addrSpec, TQString &comment)
 
TDE_EXPORT EmailParseResult isValidEmailAddress (const TQString &aStr)
 
TDE_EXPORT TQString emailParseResultToString (EmailParseResult errorCode)
 
TDE_EXPORT bool isValidSimpleEmailAddress (const TQString &aStr)
 
TDE_EXPORT TQString simpleEmailAddressErrorMsg ()
 
TDE_EXPORT TQCString getEmailAddress (const TQCString &address)
 
TDE_EXPORT TQString getEmailAddress (const TQString &address)
 
TDE_EXPORT TQCString getFirstEmailAddress (const TQCString &addresses)
 
TDE_EXPORT TQString getFirstEmailAddress (const TQString &addresses)
 
TDE_EXPORT bool getNameAndMail (const TQString &aStr, TQString &name, TQString &mail)
 
TDE_EXPORT bool compareEmail (const TQString &email1, const TQString &email2, bool matchName)
 
TDE_EXPORT TQString normalizedAddress (const TQString &displayName, const TQString &addrSpec, const TQString &comment)
 
TDE_EXPORT TQString decodeIDN (const TQString &addrSpec)
 
TDE_EXPORT TQString encodeIDN (const TQString &addrSpec)
 
TDE_EXPORT TQString normalizeAddressesAndDecodeIDNs (const TQString &addresses)
 
TDE_EXPORT TQString normalizeAddressesAndEncodeIDNs (const TQString &str)
 
TDE_EXPORT TQString quoteNameIfNecessary (const TQString &str)
 

Detailed Description

KPIM holds all kinds of functions specific to KDE PIM.

The KPIM namespace hides away functions, enums, and other things that are KDE PIM specific and that we don't want to have polluting the global namespace.

Enumeration Type Documentation

◆ EmailParseResult

Result type for splitAddress, isValidEmailAddress.

Definition at line 43 of file email.h.

Function Documentation

◆ compareEmail()

TDE_EXPORT bool KPIM::compareEmail ( const TQString &  email1,
const TQString &  email2,
bool  matchName 
)

Compare two email addresses.

If matchName is false, it just checks the email address, and returns true if this matches. If matchName is true, both the name and the email must be the same.

◆ decodeIDN()

TDE_EXPORT TQString KPIM::decodeIDN ( const TQString &  addrSpec)

Decodes the punycode domain part of the given addr-spec if it's an IDN.

Parameters
addrSpeca pure 7-bit email address (addr-spec in RFC2822)
Returns
the email address with Unicode domain

◆ emailParseResultToString()

TQString KPIM::emailParseResultToString ( EmailParseResult  errorCode)

Translate the enum errorcodes from emailParseResult into i18n'd strings that can be used for msg boxes.

Parameters
errorCodethe errorCode from isValidEmailEmailAddress().
Returns
An i18n ready string for use in msgboxes.

Definition at line 460 of file email.cpp.

◆ encodeIDN()

TDE_EXPORT TQString KPIM::encodeIDN ( const TQString &  addrSpec)

Encodes the domain part of the given addr-spec in punycode if it's an IDN.

Parameters
addrSpeca pure email address with Unicode domain
Returns
the email address with domain in punycode

◆ getEmailAddress() [1/2]

TDE_EXPORT TQCString KPIM::getEmailAddress ( const TQCString &  address)

Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).

Parameters
addressan email address, e.g. "Joe User <joe.user@example.org>"
Returns
the addr-spec of address, i.e. joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg in the example

◆ getEmailAddress() [2/2]

TDE_EXPORT TQString KPIM::getEmailAddress ( const TQString &  address)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).

Parameters
addressan email address, e.g. "Joe User <joe.user@example.org>"
Returns
the addr-spec of address, i.e. joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg in the example

◆ getFirstEmailAddress() [1/2]

TDE_EXPORT TQCString KPIM::getFirstEmailAddress ( const TQCString &  addresses)

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <joe.user@example.org>"
Returns
the addr-spec of addresses, i.e. joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg in the example

◆ getFirstEmailAddress() [2/2]

TDE_EXPORT TQString KPIM::getFirstEmailAddress ( const TQString &  addresses)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <joe.user@example.org>"
Returns
the addr-spec of addresses, i.e. joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg in the example

◆ getNameAndMail()

TDE_EXPORT bool KPIM::getNameAndMail ( const TQString &  aStr,
TQString &  name,
TQString &  mail 
)

Return email address and name from string.

Examples: "Stefan Taferner <taferner@example.org>" returns "taferner@example.org" and "Stefan Taferner". "joe@example.com" returns "joe@example.com" and "". Note that this only returns the first address. Also note that the return value is TRUE if both the name and the mail are not empty: this does NOT tell you if mail contains a valid email address or just some rubbish.

◆ isValidEmailAddress()

KPIM::EmailParseResult KPIM::isValidEmailAddress ( const TQString &  aStr)

Validates an email address in the form of "Joe User" joe@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g.

Returns AddressOk if no error was encountered. Otherwise an appropriate error code is returned.

Parameters
aStra single email address, example: Joe User (comment1) joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg
Returns
AddressOk if no error was encountered. Otherwise an appropriate error code is returned.

Definition at line 285 of file email.cpp.

◆ isValidSimpleEmailAddress()

bool KPIM::isValidSimpleEmailAddress ( const TQString &  aStr)

Validates an email address in the form of joe@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g.

Returns true if no error was encountered. This method should be used when the input field should not allow a "full" email address with comments and other special cases that normally are valid in an email address.

Parameters
aStra single email address, example: joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg
Returns
true if no error was encountered.

Definition at line 518 of file email.cpp.

◆ normalizeAddressesAndDecodeIDNs()

TDE_EXPORT TQString KPIM::normalizeAddressesAndDecodeIDNs ( const TQString &  addresses)

Normalizes all email addresses in the given list and decodes all IDNs.

Parameters
addressesa list of email addresses with punycoded IDNs
Returns
the email addresses in normalized form with Unicode IDNs

◆ normalizeAddressesAndEncodeIDNs()

TDE_EXPORT TQString KPIM::normalizeAddressesAndEncodeIDNs ( const TQString &  str)

Normalizes all email addresses in the given list and encodes all IDNs in punycode.

◆ normalizedAddress()

TDE_EXPORT TQString KPIM::normalizedAddress ( const TQString &  displayName,
const TQString &  addrSpec,
const TQString &  comment 
)

Returns a normalized address built from the given parts.

The normalized address is of one the following forms:

  • displayName (comment) <addrSpec>
  • displayName <addrSpec>
  • comment <addrSpec>
  • addrSpec
Parameters
displayNamethe display name of the address
addrSpecthe actual email address (addr-spec in RFC 2822)
commenta comment
Returns
a normalized address built from the given parts

◆ quoteNameIfNecessary()

TDE_EXPORT TQString KPIM::quoteNameIfNecessary ( const TQString &  str)

Add quote characters around the given string if it contains a character that makes that necessary, in an email name, such as ",".

◆ simpleEmailAddressErrorMsg()

TDE_EXPORT TQString KPIM::simpleEmailAddressErrorMsg ( )

Returns a i18n string to be used in msgboxes this allows for error messages to be the same across the board.

Returns
An i18n ready string for use in msgboxes.

◆ splitAddress() [1/2]

KPIM::EmailParseResult KPIM::splitAddress ( const TQCString &  address,
TQCString &  displayName,
TQCString &  addrSpec,
TQCString &  comment 
)

Splits the given address into display name, email address and comment.

Returns AddressOk if no error was encountered. Otherwise an appropriate error code is returned. In case of an error the values of displayName, addrSpec and comment are undefined.

Parameters
addressa single email address, example: Joe User (comment1) joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg (comment2)
displayNameonly out: the display-name of the email address, i.e. "Joe User" in the example; in case of an error the return value is undefined
addrSpeconly out: the addr-spec, i.e. "joe.user@example.org" in the example; in case of an error the return value is undefined
commentonly out: the space-separated comments, i.e. "comment1 comment2" in the example; in case of an error the return value is undefined
Returns
AddressOk if no error was encountered. Otherwise an appropriate error code is returned.

Definition at line 257 of file email.cpp.

◆ splitAddress() [2/2]

KPIM::EmailParseResult KPIM::splitAddress ( const TQString &  address,
TQString &  displayName,
TQString &  addrSpec,
TQString &  comment 
)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Splits the given address into display name, email address and comment. Returns AddressOk if no error was encountered. Otherwise an appropriate error code is returned. In case of an error the values of displayName, addrSpec and comment are undefined.

Parameters
addressa single email address, example: Joe User (comment1) joe.u.nosp@m.ser@.nosp@m.examp.nosp@m.le.o.nosp@m.rg (comment2)
displayNameonly out: the display-name of the email address, i.e. "Joe User" in the example; in case of an error the return value is undefined
addrSpeconly out: the addr-spec, i.e. "joe.user@example.org" in the example; in case of an error the return value is undefined
commentonly out: the space-separated comments, i.e. "comment1 comment2" in the example; in case of an error the return value is undefined
Returns
AddressOk if no error was encountered. Otherwise an appropriate error code is returned.

Definition at line 268 of file email.cpp.

◆ splitEmailAddrList()

TQStringList KPIM::splitEmailAddrList ( const TQString &  aStr)

Split a comma separated list of email addresses.

Definition at line 30 of file email.cpp.