~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to src/versit/qvcard21writer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
**
9
9
** $QT_BEGIN_LICENSE:LGPL$
10
10
** Commercial Usage
11
 
** Licensees holding valid Qt Commercial licenses may use this file in
12
 
** accordance with the Qt Solutions Commercial License Agreement provided
13
 
** with the Software or, alternatively, in accordance with the terms
 
11
** Licensees holding valid Qt Commercial licenses may use this file in 
 
12
** accordance with the Qt Commercial License Agreement provided with
 
13
** the Software or, alternatively, in accordance with the terms
14
14
** contained in a written agreement between you and Nokia.
15
15
**
16
16
** GNU Lesser General Public License Usage
33
33
** ensure the GNU General Public License version 3.0 requirements will be
34
34
** met: http://www.gnu.org/copyleft/gpl.html.
35
35
**
36
 
** Please note Third Party Software included with Qt Solutions may impose
37
 
** additional restrictions and it is the user's responsibility to ensure
38
 
** that they have met the licensing requirements of the GPL, LGPL, or Qt
39
 
** Solutions Commercial license and the relevant license of the Third
40
 
** Party Software they are using.
41
 
**
42
36
** If you are unsure which license is appropriate for your use, please
43
37
** contact the sales department at qt-sales@nokia.com.
44
38
** $QT_END_LICENSE$
54
48
QTM_USE_NAMESPACE
55
49
 
56
50
/*! Constructs a writer. */
57
 
QVCard21Writer::QVCard21Writer() : QVersitDocumentWriter()
 
51
QVCard21Writer::QVCard21Writer(QVersitDocument::VersitType type) : QVersitDocumentWriter(type)
58
52
{
59
53
}
60
54
 
73
67
    QVariant variant(property.variantValue());
74
68
 
75
69
    QString renderedValue;
 
70
    QByteArray renderedBytes;
76
71
    bool useUtf8 = false;
77
72
 
78
73
    /* Structured values need to have their components backslash-escaped (in vCard 2.1, semicolons
108
103
        useUtf8 = encodeVersitValue(parameters, renderedValue);
109
104
    } else if (variant.type() == QVariant::ByteArray) {
110
105
        parameters.insert(QLatin1String("ENCODING"), QLatin1String("BASE64"));
111
 
        renderedValue = QLatin1String(variant.toByteArray().toBase64().data());
 
106
        if (mCodecIsAsciiCompatible) // optimize by not converting to unicode
 
107
            renderedBytes = variant.toByteArray().toBase64();
 
108
        else
 
109
            renderedValue = QLatin1String(variant.toByteArray().toBase64().data());
112
110
    }
113
111
 
114
112
    // Encode parameters
127
125
        // one extra line break after the value are needed in vCard 2.1
128
126
        writeCrlf();
129
127
        writeString(QLatin1String(" "));
130
 
        writeString(renderedValue, useUtf8);
 
128
        if (renderedBytes.isEmpty())
 
129
            writeString(renderedValue, useUtf8);
 
130
        else
 
131
            writeBytes(renderedBytes);
131
132
        writeCrlf();
132
133
    }
133
134
    writeCrlf();