src/messaging/win32wce/qmailid.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qmailid.h"
       
    43 
       
    44 class MailIdPrivate : public QSharedData
       
    45 {
       
    46 public:
       
    47     MailIdPrivate():QSharedData(){};
       
    48 
       
    49     quint64 id;
       
    50 };
       
    51 
       
    52 Q_IMPLEMENT_USER_METATYPE(MailId);
       
    53 
       
    54 MailId::MailId()
       
    55 {
       
    56     d = new MailIdPrivate();
       
    57     d->id = 0;
       
    58 }
       
    59 
       
    60 MailId::MailId(quint64 value)
       
    61 {
       
    62     d = new MailIdPrivate();
       
    63     d->id = value;  
       
    64 }
       
    65 
       
    66 MailId::MailId(const MailId& other)
       
    67 {
       
    68     d = other.d;
       
    69 }
       
    70 
       
    71 MailId::~MailId()
       
    72 {
       
    73 }
       
    74 
       
    75 MailId& MailId::operator=(const MailId& other) 
       
    76 {
       
    77     d = other.d;
       
    78     return *this;
       
    79 }
       
    80 
       
    81 bool MailId::isValid() const
       
    82 {
       
    83     return d->id != 0;
       
    84 }
       
    85 
       
    86 quint64 MailId::toULongLong() const
       
    87 {
       
    88     return d->id;
       
    89 }
       
    90 
       
    91 bool MailId::operator!= (const MailId & other) const
       
    92 {
       
    93     return d->id != other.d->id;
       
    94 }
       
    95 
       
    96 bool MailId::operator== (const MailId& other) const
       
    97 {
       
    98     return d->id == other.d->id;
       
    99 }
       
   100 
       
   101 bool MailId::operator< (const MailId& other) const
       
   102 {
       
   103     return d->id < other.d->id;
       
   104 }
       
   105 
       
   106 template <typename Stream> void MailId::serialize(Stream &stream) const
       
   107 {
       
   108     stream << d->id;
       
   109 }
       
   110 
       
   111 template <typename Stream> void MailId::deserialize(Stream &stream)
       
   112 {
       
   113     stream >> d->id;
       
   114 }
       
   115 
       
   116 
       
   117 QDebug& operator<< (QDebug& debug, const MailId &id)
       
   118 {
       
   119     return debug << id.toULongLong();
       
   120 }
       
   121 
       
   122 QTextStream& operator<< (QTextStream& s, const MailId &id)
       
   123 {
       
   124     return s << id.toULongLong();
       
   125 }
       
   126 
       
   127 /*!
       
   128     \class QMailAccountId
       
   129     \ingroup messaginglibrary
       
   130 
       
   131     \brief The QMailAccountId class is used to identify accounts stored by QMailStore.
       
   132 
       
   133     QMailAccountId is a class used to represent accounts stored by the QMailStore, identified
       
   134     by their unique numeric internal indentifer.
       
   135 
       
   136     A QMailAccountId instance can be tested for validity, and compared to other instances
       
   137     for equality.  The numeric value of the identifier is not intrinsically meaningful 
       
   138     and cannot be modified.
       
   139     
       
   140     \sa QMailAccount, QMailStore::account()
       
   141 */
       
   142 
       
   143 /*!
       
   144     \typedef QMailAccountIdList
       
   145     \relates QMailAccountId
       
   146 */
       
   147 
       
   148 Q_IMPLEMENT_USER_METATYPE(QMailAccountId);
       
   149 
       
   150 /*! 
       
   151     Construct an uninitialized QMailAccountId, for which isValid() returns false.
       
   152 */
       
   153 QMailAccountId::QMailAccountId()
       
   154     : MailId()
       
   155 {
       
   156 }
       
   157 
       
   158 /*! 
       
   159     Construct a QMailAccountId with the supplied numeric identifier \a value.
       
   160 */
       
   161 QMailAccountId::QMailAccountId(quint64 value)
       
   162     : MailId(value)
       
   163 {
       
   164 }
       
   165 
       
   166 /*! \internal */
       
   167 QMailAccountId::QMailAccountId(const QMailAccountId& other)
       
   168     : MailId(other)
       
   169 {
       
   170 }
       
   171 
       
   172 /*! \internal */
       
   173 QMailAccountId::~QMailAccountId()
       
   174 {
       
   175 }
       
   176 
       
   177 /*! \internal */
       
   178 QMailAccountId& QMailAccountId::operator=(const QMailAccountId& other) 
       
   179 {
       
   180     MailId::operator=(other);
       
   181     return *this;
       
   182 }
       
   183 
       
   184 /*!
       
   185     Returns true if this object has been initialized with the identifier of an
       
   186     existing message contained by QMailStore.
       
   187 */
       
   188 bool QMailAccountId::isValid() const
       
   189 {
       
   190     return MailId::isValid();
       
   191 }
       
   192 
       
   193 /*! \internal */
       
   194 quint64 QMailAccountId::toULongLong() const
       
   195 {
       
   196     return MailId::toULongLong();
       
   197 }
       
   198 
       
   199 /*!
       
   200     Returns a QVariant containing the value of this account identfier.
       
   201 */
       
   202 QMailAccountId::operator QVariant() const
       
   203 {
       
   204     return QVariant::fromValue(*this);
       
   205 }
       
   206 
       
   207 /*!
       
   208     Returns true if this object's identifier value differs from that of \a other.
       
   209 */
       
   210 bool QMailAccountId::operator!= (const QMailAccountId& other) const
       
   211 {
       
   212     return MailId::operator!=(other);
       
   213 }
       
   214 
       
   215 /*!
       
   216     Returns true if this object's identifier value is equal to that of \a other.
       
   217 */
       
   218 bool QMailAccountId::operator== (const QMailAccountId& other) const
       
   219 {
       
   220     return MailId::operator==(other);
       
   221 }
       
   222 
       
   223 /*!
       
   224     Returns true if this object's identifier value is less than that of \a other.
       
   225 */
       
   226 bool QMailAccountId::operator< (const QMailAccountId& other) const
       
   227 {
       
   228     return MailId::operator<(other);
       
   229 }
       
   230 
       
   231 /*! 
       
   232     \fn QMailAccountId::serialize(Stream&) const
       
   233     \internal 
       
   234 */
       
   235 template <typename Stream> void QMailAccountId::serialize(Stream &stream) const
       
   236 {
       
   237     MailId::serialize(stream);
       
   238 }
       
   239 
       
   240 /*! 
       
   241     \fn QMailAccountId::deserialize(Stream&)
       
   242     \internal 
       
   243 */
       
   244 template <typename Stream> void QMailAccountId::deserialize(Stream &stream)
       
   245 {
       
   246     MailId::deserialize(stream);
       
   247 }
       
   248 
       
   249 /*! \internal */
       
   250 QDebug& operator<< (QDebug& debug, const QMailAccountId &id)
       
   251 {
       
   252     return debug << static_cast<const MailId&>(id);
       
   253 }
       
   254 
       
   255 /*! \internal */
       
   256 QTextStream& operator<< (QTextStream& s, const QMailAccountId &id)
       
   257 {
       
   258     return s << static_cast<const MailId&>(id);
       
   259 }
       
   260 
       
   261 
       
   262 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailAccountIdList, QMailAccountIdList)
       
   263 
       
   264 /*!
       
   265     \class QMailFolderId
       
   266     \ingroup messaginglibrary
       
   267 
       
   268     \brief The QMailFolderId class is used to identify folders stored by QMailStore.
       
   269 
       
   270     QMailFolderId is a class used to represent folders stored by the QMailStore, identified
       
   271     by their unique numeric internal indentifer.
       
   272 
       
   273     A QMailFolderId instance can be tested for validity, and compared to other instances
       
   274     for equality.  The numeric value of the identifier is not intrinsically meaningful 
       
   275     and cannot be modified.
       
   276     
       
   277     \sa QMailFolder, QMailStore::folder()
       
   278 */
       
   279 
       
   280 /*!
       
   281     \typedef QMailFolderIdList
       
   282     \relates QMailFolderId
       
   283 */
       
   284 
       
   285 Q_IMPLEMENT_USER_METATYPE(QMailFolderId);
       
   286 
       
   287 /*! 
       
   288     Construct an uninitialized QMailFolderId, for which isValid() returns false.
       
   289 */
       
   290 QMailFolderId::QMailFolderId()
       
   291     : MailId()
       
   292 {
       
   293 }
       
   294 
       
   295 /*! 
       
   296     Construct a QMailFolderId corresponding to the predefined folder identifier \a id.
       
   297 */
       
   298 QMailFolderId::QMailFolderId(QMailFolderFwd::PredefinedFolderId id)
       
   299     : MailId(static_cast<quint64>(id))
       
   300 {
       
   301 }
       
   302 
       
   303 /*! 
       
   304     Construct a QMailFolderId with the supplied numeric identifier \a value.
       
   305 */
       
   306 QMailFolderId::QMailFolderId(quint64 value)
       
   307     : MailId(value)
       
   308 {
       
   309 }
       
   310 
       
   311 /*! \internal */
       
   312 QMailFolderId::QMailFolderId(const QMailFolderId& other)
       
   313     : MailId(other)
       
   314 {
       
   315 }
       
   316 
       
   317 /*! \internal */
       
   318 QMailFolderId::~QMailFolderId()
       
   319 {
       
   320 }
       
   321 
       
   322 /*! \internal */
       
   323 QMailFolderId& QMailFolderId::operator=(const QMailFolderId& other) 
       
   324 {
       
   325     MailId::operator=(other);
       
   326     return *this;
       
   327 }
       
   328 
       
   329 /*!
       
   330     Returns true if this object has been initialized with the identifier of an
       
   331     existing message contained by QMailStore.
       
   332 */
       
   333 bool QMailFolderId::isValid() const
       
   334 {
       
   335     return MailId::isValid();
       
   336 }
       
   337 
       
   338 /*! \internal */
       
   339 quint64 QMailFolderId::toULongLong() const
       
   340 {
       
   341     return MailId::toULongLong();
       
   342 }
       
   343 
       
   344 /*!
       
   345     Returns a QVariant containing the value of this folder identfier.
       
   346 */
       
   347 QMailFolderId::operator QVariant() const
       
   348 {
       
   349     return QVariant::fromValue(*this);
       
   350 }
       
   351 
       
   352 /*!
       
   353     Returns true if this object's identifier value differs from that of \a other.
       
   354 */
       
   355 bool QMailFolderId::operator!= (const QMailFolderId& other) const
       
   356 {
       
   357     return MailId::operator!=(other);
       
   358 }
       
   359 
       
   360 /*!
       
   361     Returns true if this object's identifier value is equal to that of \a other.
       
   362 */
       
   363 bool QMailFolderId::operator== (const QMailFolderId& other) const
       
   364 {
       
   365     return MailId::operator==(other);
       
   366 }
       
   367 
       
   368 /*!
       
   369     Returns true if this object's identifier value is less than that of \a other.
       
   370 */
       
   371 bool QMailFolderId::operator< (const QMailFolderId& other) const
       
   372 {
       
   373     return MailId::operator<(other);
       
   374 }
       
   375 
       
   376 /*! 
       
   377     \fn QMailFolderId::serialize(Stream&) const
       
   378     \internal 
       
   379 */
       
   380 template <typename Stream> void QMailFolderId::serialize(Stream &stream) const
       
   381 {
       
   382     MailId::serialize(stream);
       
   383 }
       
   384 
       
   385 /*! 
       
   386     \fn QMailFolderId::deserialize(Stream&)
       
   387     \internal 
       
   388 */
       
   389 template <typename Stream> void QMailFolderId::deserialize(Stream &stream)
       
   390 {
       
   391     MailId::deserialize(stream);
       
   392 }
       
   393 
       
   394 /*! \internal */
       
   395 QDebug& operator<< (QDebug& debug, const QMailFolderId &id)
       
   396 {
       
   397     return debug << static_cast<const MailId&>(id);
       
   398 }
       
   399 
       
   400 /*! \internal */
       
   401 QTextStream& operator<< (QTextStream& s, const QMailFolderId &id)
       
   402 {
       
   403     return s << static_cast<const MailId&>(id);
       
   404 }
       
   405 
       
   406 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailFolderIdList, QMailFolderIdList)
       
   407 
       
   408 
       
   409 /*!
       
   410     \class QMailMessageId
       
   411     \ingroup messaginglibrary
       
   412 
       
   413     \brief The QMailMessageId class is used to identify messages stored by QMailStore.
       
   414 
       
   415     QMailMessageId is a class used to represent messages stored by the QMailStore, identified
       
   416     by their unique numeric internal indentifer.
       
   417 
       
   418     A QMailMessageId instance can be tested for validity, and compared to other instances
       
   419     for equality.  The numeric value of the identifier is not intrinsically meaningful 
       
   420     and cannot be modified.
       
   421     
       
   422     \sa QMailMessage, QMailStore::message()
       
   423 */
       
   424 
       
   425 /*!
       
   426     \typedef QMailMessageIdList
       
   427     \relates QMailMessageId
       
   428 */
       
   429 
       
   430 Q_IMPLEMENT_USER_METATYPE(QMailMessageId);
       
   431 
       
   432 /*! 
       
   433     Construct an uninitialized QMailMessageId, for which isValid() returns false.
       
   434 */
       
   435 QMailMessageId::QMailMessageId()
       
   436     : MailId()
       
   437 {
       
   438 }
       
   439 
       
   440 /*! 
       
   441     Construct a QMailMessageId with the supplied numeric identifier \a value.
       
   442 */
       
   443 QMailMessageId::QMailMessageId(quint64 value)
       
   444     : MailId(value)
       
   445 {
       
   446 }
       
   447 
       
   448 /*! \internal */
       
   449 QMailMessageId::QMailMessageId(const QMailMessageId& other)
       
   450     : MailId(other)
       
   451 {
       
   452 }
       
   453 
       
   454 /*! \internal */
       
   455 QMailMessageId::~QMailMessageId()
       
   456 {
       
   457 }
       
   458 
       
   459 /*! \internal */
       
   460 QMailMessageId& QMailMessageId::operator=(const QMailMessageId& other) 
       
   461 {
       
   462     MailId::operator=(other);
       
   463     return *this;
       
   464 }
       
   465 
       
   466 /*!
       
   467     Returns true if this object has been initialized with the identifier of an
       
   468     existing message contained by QMailStore.
       
   469 */
       
   470 bool QMailMessageId::isValid() const
       
   471 {
       
   472     return MailId::isValid();
       
   473 }
       
   474 
       
   475 /*! \internal */
       
   476 quint64 QMailMessageId::toULongLong() const
       
   477 {
       
   478     return MailId::toULongLong();
       
   479 }
       
   480 
       
   481 /*!
       
   482     Returns a QVariant containing the value of this message identfier.
       
   483 */
       
   484 QMailMessageId::operator QVariant() const
       
   485 {
       
   486     return QVariant::fromValue(*this);
       
   487 }
       
   488 
       
   489 /*!
       
   490     Returns true if this object's identifier value differs from that of \a other.
       
   491 */
       
   492 bool QMailMessageId::operator!= (const QMailMessageId& other) const
       
   493 {
       
   494     return MailId::operator!=(other);
       
   495 }
       
   496 
       
   497 /*!
       
   498     Returns true if this object's identifier value is equal to that of \a other.
       
   499 */
       
   500 bool QMailMessageId::operator== (const QMailMessageId& other) const
       
   501 {
       
   502     return MailId::operator==(other);
       
   503 }
       
   504 
       
   505 /*!
       
   506     Returns true if this object's identifier value is less than that of \a other.
       
   507 */
       
   508 bool QMailMessageId::operator< (const QMailMessageId& other) const
       
   509 {
       
   510     return MailId::operator<(other);
       
   511 }
       
   512 
       
   513 /*! 
       
   514     \fn QMailMessageId::serialize(Stream&) const
       
   515     \internal 
       
   516 */
       
   517 template <typename Stream> void QMailMessageId::serialize(Stream &stream) const
       
   518 {
       
   519     MailId::serialize(stream);
       
   520 }
       
   521 
       
   522 /*! 
       
   523     \fn QMailMessageId::deserialize(Stream&)
       
   524     \internal 
       
   525 */
       
   526 template <typename Stream> void QMailMessageId::deserialize(Stream &stream)
       
   527 {
       
   528     MailId::deserialize(stream);
       
   529 }
       
   530 
       
   531 /*! \internal */
       
   532 QDebug& operator<< (QDebug& debug, const QMailMessageId &id)
       
   533 {
       
   534     return debug << static_cast<const MailId&>(id);
       
   535 }
       
   536 
       
   537 /*! \internal */
       
   538 QTextStream& operator<< (QTextStream& s, const QMailMessageId &id)
       
   539 {
       
   540     return s << static_cast<const MailId&>(id);
       
   541 }
       
   542 
       
   543 Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailMessageIdList, QMailMessageIdList)
       
   544 
       
   545 /*! \internal */
       
   546 uint qHash(const QMailAccountId &id)
       
   547 {
       
   548     return qHash(id.toULongLong());
       
   549 }
       
   550 
       
   551 /*! \internal */
       
   552 uint qHash(const QMailFolderId &id)
       
   553 {
       
   554     return qHash(id.toULongLong());
       
   555 }
       
   556 
       
   557 /*! \internal */
       
   558 uint qHash(const QMailMessageId &id)
       
   559 {
       
   560     return qHash(id.toULongLong());
       
   561 }
       
   562 
       
   563