Ejemplo n.º 1
0
String generateHTMLContent(unsigned contentLength)
{
    String baseString("abcdefghijklmnopqrstuvwxyz0123457890");
    unsigned baseLength = baseString.length();

    StringBuilder builder;
    builder.append("<html><body>");

    if (contentLength <= baseLength)
        builder.append(baseString, 0, contentLength);
    else {
        unsigned currentLength = 0;
        while (currentLength < contentLength) {
            if ((currentLength + baseLength) <= contentLength)
                builder.append(baseString);
            else
                builder.append(baseString, 0, contentLength - currentLength);

            // Account for the 12 characters of the '<html><body>' prefix.
            currentLength = builder.length() - 12;
        }
    }
    builder.append("</body></html>");

    return builder.toString();
}
Ejemplo n.º 2
0
/*
 * Generates a image/video file name based on the given parameters:
 *  * Type (image or video)
 *  * Base (either absolute or relative file name of type QString)
 *  * File type
 */
QString S60FileNameGenerator::generateFileNameFromString(const FileNameType nameType,
                                                         const QString base,
                                                         const QString postfix)
{
    QString baseString(base);
    return generateFileName(nameType, baseString, postfix);
}
Ejemplo n.º 3
0
/*
 * Generates a image/video file name based on the given parameters:
 *   * Type (image or video)
 *   * Base (either absolute or relative file name of type QUrl)
 *   * File type
 */
QString S60FileNameGenerator::generateFileNameFromUrl(const FileNameType nameType,
                                                      const QUrl base,
                                                      const QString postfix)
{

    QString baseString(base.toLocalFile());
    return generateFileName(nameType, baseString, postfix);
}
Ejemplo n.º 4
0
Archivo: chord.cpp Proyecto: Pfeil/CAN2
QString Chord::toString(MinorPolicy mpolicy, EnharmonicPolicy epolicy) const
{
    QString text = baseString(epolicy);

    if (isMinor())
    {
        switch (mpolicy)
        {
        case LowerCase:
            text = text.toLower();
            break;
        case FollowingM:
            text += "m";
            break;
        }
    }

    return m_before + text + attachment() + m_after;
}
Ejemplo n.º 5
0
QString OAuthPrivate::buildAuthHeader(const QString & method, const QString & url, const Params & data, const QString & verifier)
{
    QMap<QString, QString> params;

    params.insert("oauth_consumer_key", consumerKey.toAscii());
    params.insert("oauth_nonce", Helper::identifier(42));
    params.insert("oauth_signature_method", "HMAC-SHA1");
    params.insert("oauth_timestamp", QString("%1").arg(Helper::timestamp()));
    params.insert("oauth_version", "1.0");

    if(!verifier.isEmpty())
        params.insert("oauth_verifier", verifier);

    if(!oauthToken.isEmpty())
        params.insert("oauth_token", oauthToken.toAscii());

    params.unite(data);

    QString authStr;
    Params::const_iterator i = params.constBegin();

    params.insert("oauth_signature", signature(signingKey(consumerSecret, oauthTokenSecret), baseString(method, url, paramsString(params))));

    while (i != params.constEnd()){
        authStr += QUrl::toPercentEncoding(i.key()) + "=\"" + QUrl::toPercentEncoding(i.value()) + "\", ";
        ++i;
    }

    return authStr.mid(0, authStr.length() - 2);
}