[Qt-qmf] How does QMailAccount::setStatus(quint64 mask, bool set) API work?

1 view
Skip to first unread message

Apollo Xue

unread,
Mar 4, 2011, 11:37:29 AM3/4/11
to qt-...@qt.nokia.com
Hi All,
    I am trying add an new email account, but I found that QMailAccount::setStatus(quint64 mask, bool set) API did not work, I am not sure if I was using this API correctly. here is my code piece:
    m_pAccount = new QMailAccount();
    m_pAccount->setMessageType(QMailMessage::Email);
    m_pAccount->setStatus(QMailAccount::UserEditable, true);
    m_pAccount->setStatus(QMailAccount::UserRemovable, true);
    m_pAccount->setStatus(QMailAccount::Enabled, true);
    m_pAccount->setStatus(QMailAccount::MessageSource, true);
    m_pAccount->setStatus(QMailAccount::MessageSink, true);
    m_pAccount->setStatus(QMailAccount::CanTransmit, true);
    m_pAccount->setStatus(QMailAccount::CanRetrieve, true);

    quint64 test = m_pAccount->status();

    I found the value return by m_pAccount->status() is always 0, then I checked the souce code of QMailAccount:::setStatus(quint64 mask, bool set), and debugged again, I found that QMailAccount::MessageSource and otherQMailAccount variables are all 0 when I call setStatus() API. why? how to use this API?

Best Regards
Apolloxue

Apollo Xue

unread,
Mar 4, 2011, 9:39:15 PM3/4/11
to Eric Springer, qt-...@qt.nokia.com
thanks, Eric, it works now.

2011/3/5 Eric Springer <eric.s...@nokia.com>
Hi Appoloxue,

It's a bit unideal, but the status variables are "uninitialized", and only are done when the database is loaded (as it gets its values from there). So assuming you're using QMailStore, just make sure at the start of your app just write: "QMailStore::instance();" and it will create a singleton QMailStore (and initialize status flags).

If you plan on using the API without QMailStore, you will need to do something something like this:
const_cast<quint64 *>(&QMailAccount::SynchronizationEnabled) = (1 << 1);
const_cast<quint64 *>(&QMailAccount::Synchronized) = (1 << 2);
const_cast<quint64 *>(&QMailAccount::AppendSignature) = (1 << 3);

For all the status flags (and for both folders and messages)


Hope that helps,
/Eric

Eric Springer

unread,
Mar 4, 2011, 8:59:10 PM3/4/11
to ext Apollo Xue, qt-...@qt.nokia.com
Hi Appoloxue,

It's a bit unideal, but the status variables are "uninitialized", and only are done when the database is loaded (as it gets its values from there). So assuming you're using QMailStore, just make sure at the start of your app just write: "QMailStore::instance();" and it will create a singleton QMailStore (and initialize status flags).

If you plan on using the API without QMailStore, you will need to do something something like this:
const_cast<quint64 *>(&QMailAccount::SynchronizationEnabled) = (1 << 1);
const_cast<quint64 *>(&QMailAccount::Synchronized) = (1 << 2);
const_cast<quint64 *>(&QMailAccount::AppendSignature) = (1 << 3);

For all the status flags (and for both folders and messages)


Hope that helps,
/Eric


On 03/05/2011 02:37 AM, ext Apollo Xue wrote:
Reply all
Reply to author
Forward
0 new messages