Пример #1
0
QList<QJsonObject> *UsrData::retrieveUnreadMessage()
{
  unread_message_buffer_list = unread_message_list;
  recordMessage(unread_message_list);
  unread_message_list.clear();
  return &unread_message_buffer_list;
}
Пример #2
0
Log::Logger::Message::~Message()
{
    if (--refCount == 0)
    {
        delete &refCount;
        recordMessage(message.str(), lineInfo);
    }
}
Пример #3
0
static void parse( Translator *tor )
{
    QString text;
    QString com;
    QString extracomment;

    yyCh = getChar();

    yyTok = getToken();
    while ( yyTok != Tok_Eof ) {
        switch ( yyTok ) {
        case Tok_class:
            yyTok = getToken();
            if(yyTok == Tok_Ident) {
                yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo));
            }
            else {
                yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n"));
                break;
            }
            while (!match(Tok_LeftBrace)) {
                yyTok = getToken();
            }
            break;

        case Tok_tr:
            yyTok = getToken();
            if ( match(Tok_LeftParen) && matchString(text) ) {
                com.clear();
                bool plural = false;

                if ( match(Tok_RightParen) ) {
                    // no comment
                } else if (match(Tok_Comma) && matchStringOrNull(com)) {   //comment
                    if ( match(Tok_RightParen)) {
                        // ok,
                    } else if (match(Tok_Comma)) {
                        plural = true;
                    }
                }
                if (!text.isEmpty())
                    recordMessage(tor, context(), text, com, extracomment, plural);
            }
            break;
        case Tok_translate:
        {
            QString contextOverride;
            yyTok = getToken();
            if ( match(Tok_LeftParen) &&
                    matchString(contextOverride) &&
                    match(Tok_Comma) &&
                    matchString(text) ) {

                com.clear();
                bool plural = false;
                if (!match(Tok_RightParen)) {
                    // look for comment
                    if ( match(Tok_Comma) && matchStringOrNull(com)) {
                        if (!match(Tok_RightParen)) {
                            if (match(Tok_Comma) && matchExpression() && match(Tok_RightParen)) {
                                plural = true;
                            } else {
                                break;
                            }
                        }
                    } else {
                        break;
                    }
                }
                if (!text.isEmpty())
                    recordMessage(tor, contextOverride, text, com, extracomment, plural);
            }
        }
        break;

        case Tok_Ident:
            yyTok = getToken();
            break;

        case Tok_Comment:
            if (yyComment.startsWith(QLatin1Char(':'))) {
                yyComment.remove(0, 1);
                extracomment.append(yyComment);
            }
            yyTok = getToken();
            break;

        case Tok_RightBrace:
            if ( yyScope.isEmpty() ) {
                yyMsg() << qPrintable(LU::tr("Excess closing brace.\n"));
            }
            else
                delete (yyScope.pop());
            extracomment.clear();
            yyTok = getToken();
            break;

        case Tok_LeftBrace:
            yyScope.push(new Scope(QString(), Scope::Other, yyLineNo));
            yyTok = getToken();
            break;

        case Tok_Semicolon:
            extracomment.clear();
            yyTok = getToken();
            break;

        case Tok_Package:
            yyTok = getToken();
            while(!match(Tok_Semicolon)) {
                switch(yyTok) {
                case Tok_Ident:
                    yyPackage.append(yyIdent);
                    break;
                case Tok_Dot:
                    yyPackage.append(QLatin1String("."));
                    break;
                default:
                    yyMsg() << qPrintable(LU::tr("'package' must be followed by package name.\n"));
                    break;
                }
                yyTok = getToken();
            }
            break;

        default:
            yyTok = getToken();
        }
    }

    if ( !yyScope.isEmpty() )
        yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n"));
    else if ( yyParenDepth != 0 )
        yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n"));
}
Пример #4
0
static void parse( Translator *tor, const QString &filename )
{
    QRegExp i18nRE( "\\|[ \t\r\n]*[xi]18n[ \t\r\n]*\\(" );
    QString content = stream.readAll();
    QString context, source, comment, extracomment;
    int startpos, pos = 0;
    int endpos;

    while ( pos >= 0 )
    {
        source = QString::null;
        context = QString::null;
        comment = QString::null;
        startpos = i18nRE.indexIn( content, pos );
        pos = startpos + i18nRE.matchedLength();
        if ( pos < 0 )
            return;

        source = getString( content, startpos - 1, true, endpos );
        if ( source.isNull() )
        {
            qWarning( "%s:error: Found non-quoted source, skipping translation", qPrintable(filename) );
            exit( 1 );
//             continue;
        }

        if ( content[startpos+1] == 'x' )
        {
            QString ext = getString( content, pos, false, endpos );
            if ( endpos < 0 )
                continue;
            pos = endpos;
            skipComma( content, pos, endpos );
            if ( endpos < 0 )
                continue;
            pos = endpos;
        }
        context = getString( content, pos, false, endpos );
        if ( endpos < 0 )
        {
            qWarning( "%s:error: Found non-quoted context, skipping translation", qPrintable(filename) );
            exit( 1 );
//             continue;
        }
        if ( context.indexOf( '\n' ) != -1 )
        {
            qWarning( "%s:error: The context contains newlines, please correct the template.\nThe context was:\n%s", qPrintable(filename), qPrintable(context) );
            exit( 1 );
        }
        pos = endpos;
        skipComma( content, pos, endpos );
        if ( endpos >= 0 )
        {
            pos = endpos;

            comment = getString( content, pos, false, endpos );
            if ( endpos >= 0 &&
                 comment.length() == 0 )
                comment = QString::null;
        }

        if ( context.isNull() )
            continue;

        int line = 0; // We don't support line numbers yet
        bool plural = false; // We don't support plural yet
        bool utf8 = false; // We don't support autodetection yet
        recordMessage(tor, line, context, source, comment, extracomment, utf8, plural);
    }
}
Пример #5
0
void Writer::recordMessage(const protocol::MessagePtr msg)
{
	recordMessage(*msg);
}
Пример #6
0
UsrData::~UsrData()
{
  recordMessage(unread_message_list);
}