src/messaging/win32wce/qmailnamespace.h
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 #ifndef QMAILNAMESPACE_H
       
    43 #define QMAILNAMESPACE_H
       
    44 
       
    45 #include "qmailglobal.h"
       
    46 #include <QDate>
       
    47 #include <QPair>
       
    48 #include <QString>
       
    49 #include <QTime>
       
    50 
       
    51 #if !defined(Q_OS_WIN) || !defined(_WIN32_WCE)
       
    52 class QSqlDatabase;
       
    53 #endif
       
    54 
       
    55 namespace QMail
       
    56 {
       
    57     QTOPIAMAIL_EXPORT QString lastSystemErrorMessage();
       
    58     QTOPIAMAIL_EXPORT void usleep(unsigned long usecs);
       
    59     QTOPIAMAIL_EXPORT QString dataPath();
       
    60     QTOPIAMAIL_EXPORT QString tempPath();
       
    61     QTOPIAMAIL_EXPORT QString pluginsPath();
       
    62     QTOPIAMAIL_EXPORT QString sslCertsPath();
       
    63     QTOPIAMAIL_EXPORT QString messageServerPath();
       
    64     QTOPIAMAIL_EXPORT QString messageSettingsPath();
       
    65     QTOPIAMAIL_EXPORT QString mimeTypeFromFileName(const QString& filename);
       
    66     QTOPIAMAIL_EXPORT QStringList extensionsForMimeType(const QString& mimeType);
       
    67 
       
    68 #if !defined(Q_OS_WIN) || !defined(_WIN32_WCE)
       
    69     QTOPIAMAIL_EXPORT int fileLock(const QString& filePath);
       
    70     QTOPIAMAIL_EXPORT bool fileUnlock(int id);
       
    71 
       
    72     QTOPIAMAIL_EXPORT QSqlDatabase createDatabase();
       
    73 #endif
       
    74 
       
    75     QTOPIAMAIL_EXPORT QString baseSubject(const QString& subject, bool *replyOrForward);
       
    76     QTOPIAMAIL_EXPORT QStringList messageIdentifiers(const QString& str);
       
    77 
       
    78     template<typename StringType>
       
    79     StringType unquoteString(const StringType& src)
       
    80     {
       
    81         // If a string has double-quote as the first and last characters, return the string
       
    82         // between those characters
       
    83         int length = src.length();
       
    84         if (length)
       
    85         {
       
    86             typename StringType::const_iterator const begin = src.constData();
       
    87             typename StringType::const_iterator const last = begin + length - 1;
       
    88 
       
    89             if ((last > begin) && (*begin == '"' && *last == '"'))
       
    90                 return src.mid(1, length - 2);
       
    91         }
       
    92 
       
    93         return src;
       
    94     }
       
    95 
       
    96     template<typename StringType>
       
    97     StringType quoteString(const StringType& src)
       
    98     {
       
    99         StringType result("\"\"");
       
   100 
       
   101         // Return the input string surrounded by double-quotes, which are added if not present
       
   102         int length = src.length();
       
   103         if (length)
       
   104         {
       
   105             result.reserve(length + 2);
       
   106 
       
   107             typename StringType::const_iterator begin = src.constData();
       
   108             typename StringType::const_iterator last = begin + length - 1;
       
   109 
       
   110             if (*begin == '"')
       
   111                 begin += 1;
       
   112 
       
   113             if ((last >= begin) && (*last == '"'))
       
   114                 last -= 1;
       
   115 
       
   116             if (last >= begin)
       
   117                 result.insert(1, StringType(begin, (last - begin + 1)));
       
   118         }
       
   119 
       
   120         return result;
       
   121     }
       
   122 
       
   123 }
       
   124 
       
   125 #endif