Ejemplo n.º 1
0
void VT100Parser::decodeParameters(uchar character)
{
    switch (character) {
    case 0x30:
    case 0x31:
    case 0x32:
    case 0x33:
    case 0x34:
    case 0x35:
    case 0x36:
    case 0x37:
    case 0x38:
    case 0x39:
        parameterString.append(character);
        break;
    case 0x3a:
        qDebug() << "Encountered special delimiter in parameterbyte";
        break;
    case 0x3b:
        appendParameter();
        break;
    case 0x3c:
    case 0x3d:
    case 0x3e:
    case 0x3f:
        appendParameter();
        parameters.append(-character);
        break;
    default:
        //this is undefined for now
        qDebug() << "Encountered undefined parameter byte";
        break;
    }
}
Ejemplo n.º 2
0
ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
{
	const string name = utility::stringUtils::toLower(paramName);

	// Find the first parameter that matches the specified name
	std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
	const std::vector <ref <parameter> >::const_iterator end = m_params.end();

	for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}

	// If no parameter with this name can be found, create a new one
	if (pos == end)
	{
		ref <parameter> param = vmime::create <parameter>(paramName);

		appendParameter(param);

		// Return a reference to the new parameter
		return (param);
	}
	// Else, return a reference to the existing parameter
	else
	{
		return (*pos);
	}
}
Ejemplo n.º 3
0
 my_Descriptor()
 : h_Descriptor()
   {
     m_Name        = "event horizon";
     m_Author      = "sstillwell";
     m_Product     = "holos port";
     m_Version     = 2;
     m_UniqueId    = H_MAGIC + 0xf001;
     m_Flags       = df_None;
     m_NumInputs   = 2;
     m_NumOutputs  = 2;
     appendParameter( new h_ParFloat("threshold", "",   PF_DEFAULT,  0.0, -30.0,  0.0, 0.1  ) );
     appendParameter( new h_ParFloat("ceiling",   "",   PF_DEFAULT, -0.1, -20.0,  0.0, 0.1  ) );
     appendParameter( new h_ParFloat("soft clip", "db", PF_DEFAULT,  2.0,   0.0,  6.0, 0.01 ) );
     //appendParameter( new parFloat(this,"soft clip ratio","",   10.0,   3.0, 20.0, 0.1  ) );
   }
Ejemplo n.º 4
0
 myPlugin(axContext* aContext)
 : axFormat(aContext, pf_None/*HasEditor*/)
   {
     m_Gain = 0;
     describe("test_buttons","ccernn","axonlib example",0,AX_MAGIC+0x0000);
     setupAudio(2,2,false);
     setupEditor(320,240);
     appendParameter( p_Gain = new axParameter(this,"gain","") );
     setupParameters();
   }
Ejemplo n.º 5
0
void ofxOscSender::appendParameter( ofxOscBundle & _bundle, const ofAbstractParameter & parameter, string address){
	if(parameter.type()==typeid(ofParameterGroup).name()){
		ofxOscBundle bundle;
		const ofParameterGroup & group = static_cast<const ofParameterGroup &>(parameter);
		for(std::size_t i=0;i<group.size();i++){
			const ofAbstractParameter & p = group[i];
			if(p.isSerializable()){
				appendParameter(bundle,p,address+group.getEscapedName()+"/");
			}
		}
		_bundle.addBundle(bundle);
	}else{
		if(parameter.isSerializable()){
			ofxOscMessage msg;
			appendParameter(msg,parameter,address);
			_bundle.addMessage(msg);
		}
	}
}
Ejemplo n.º 6
0
void ofxOscSender::sendParameter( const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	if(parameter.type()==typeid(ofParameterGroup).name()){
		string address = "/";
		const vector<string> hierarchy = parameter.getGroupHierarchyNames();
		for(int i=0;i<(int)hierarchy.size()-1;i++){
			address+=hierarchy[i] + "/";
		}
		ofxOscBundle bundle;
		appendParameter(bundle,parameter,address);
		sendBundle(bundle);
	}else{
		string address = "";
		const vector<string> hierarchy = parameter.getGroupHierarchyNames();
		for(int i=0;i<(int)hierarchy.size()-1;i++){
			address+= "/" + hierarchy[i];
		}
		if(address.length()) address += "/";
		ofxOscMessage msg;
		appendParameter(msg,parameter,address);
		sendMessage(msg, false);
	}
}
Ejemplo n.º 7
0
void parameterizedHeaderField::copyFrom(const component& other)
{
	headerField::copyFrom(other);

	const parameterizedHeaderField& source = dynamic_cast<const parameterizedHeaderField&>(other);

	removeAllParameters();

	for (std::vector <ref <parameter> >::const_iterator i = source.m_params.begin() ;
	     i != source.m_params.end() ; ++i)
	{
		appendParameter((*i)->clone().dynamicCast <parameter>());
	}
}
Ejemplo n.º 8
0
 myInstance(axBase* aBase) : AX_INSTANCE(aBase)
   {
     //describe("fx_distortion","ccernn","axonlib example",2,AX_MAGIC+0x1003);
     //setupAudio(2,2,false);
     appendParameter( p_Type = new parInteger( this,"type",      "", 0, 0,5, str_type) );
     appendParameter( p_Thr  = new parFloatPow(this,"threshold", "", 1, 0,1,0, 3 ) );
     appendParameter( p_Pre  = new parFloatPow(this,"pre gain",  "", 1, 1,2,0, 3 ) );
     appendParameter( p_Post = new parFloatPow(this,"post gain", "", 1, 0,2,0, 3 ) );
     appendParameter( p_Flt  = new parFloatPow(this,"filter",    "", 1, 0,1,0, 3 ) );
     appendParameter( p_Vol  = new parFloatPow(this,"volume",    "", 1, 0,1,0, 3 ) );
     setupParameters();
   }
Ejemplo n.º 9
0
 my_Descriptor()
 : h_Descriptor()
   {
     m_Name   = "fx_freeze";
     m_Author = "ccernn";
     appendParameter( new h_ParFloat("buffer","ms",PF_DEFAULT,1000,1,1000) );
     appendParameter( new h_ParFloat("size",  "",  PF_DEFAULT,1,   0,1) );
     appendParameter( new h_ParFloat("speed", "",  PF_DEFAULT,1,   0,2) );
     appendParameter( new h_ParFloat("start", "",  PF_DEFAULT,0,   0,1) );
     appendParameter( new h_ParText ("freeze","",  PF_DEFAULT,0,   2, str_freeze) );
     appendParameter( new h_ParText ("mode","",    PF_DEFAULT,1,   2, str_loopmode) );
     initPrograms(10,&m_Parameters);
   }
Ejemplo n.º 10
0
 myPlugin(axContext* aContext, int aFlags)
 : axFormat(aContext)
   {
     w_Editor = NULL;
     w_Painter = NULL;
     describe("test_gain_gui","ccernn","axonlib example",0,AX_MAGIC+0x0000);
     setupAudio(2,2);
     setupEditor(640,480);
     appendParameter( new parInteger(this,"type1","", 0,   0, NUMTYPES-1, str_type ) );
     appendParameter( new parInteger(this,"type2","", 0,   0, NUMTYPES-1, str_type ) );
     appendParameter( new parFloat(  this,"min x","",-10, -10,10 ) );
     appendParameter( new parFloat(  this,"max x","", 10, -10,10 ) );
     appendParameter( new parFloat(  this,"min y","",-10, -10,10 ) );
     appendParameter( new parFloat(  this,"max y","", 10, -10,10 ) );
     appendParameter( new parFloat(  this,"n",    "", 0,  -10,10  ) );
     //setupParameters();
     prepareParameters();
   }
Ejemplo n.º 11
0
    my_Descriptor()
    : h_Descriptor()
      {
        m_Name        = "test_ladspa";
        m_Author      = "ccernn";
        m_Product     = "holos test plugin";
        m_Version     = 0;
        m_UniqueId    = H_MAGIC;
        m_Flags       = df_None;
        m_NumInputs   = 2;    // inputs
        m_NumOutputs  = 2; // outputs
        //m_EditorRect  = h_Rect(0,0,640,480);

        appendParameter( new h_Parameter("param",   "", PF_DEFAULT, 0 ) );
        appendParameter( new h_ParFloat( "float",   "", PF_DEFAULT, 1.5, 0,5, 0.25 ) );
        appendParameter( new h_ParInt(   "int",     "", PF_DEFAULT, 3,   1,   10 ) );

        appendParameter( new h_ParFloat("parFloat", "", PF_DEFAULT, 440, 1, 44100, 0, &p2, &inv_p2 )); // 16
        appendParameter( new h_ParInt(  "parInt",   "", PF_DEFAULT, 256, 1,1024, &p2, &inv_p2 )); // 16
        appendParameter( new h_ParText( "parText",  "", PF_DEFAULT, 2,   4, strings));
      }
Ejemplo n.º 12
0
void VT100Parser::decodeOSC(uchar character)
{

    if (!parameters.size() &&
            character >= 0x30 && character <= 0x3f) {

        decodeParameters(character);
    }
    else
    {
        if (decodeOscState ==  None) {
            appendParameter();
            if (parameters.size() != 1) {
                tokenFinished();
                return;
            }
            oscData.clear();
            switch (parameters.at(0)) {
            case 0:
                decodeOscState = ChangeWindowAndIconName;
                break;
            case 1:
                decodeOscState = ChangeIconTitle;
                break;
            case 2:
                decodeOscState = ChangeWindowTitle;
                break;
            case 4:
                // TODO: set 256-color palette
                decodeOscState = Other;
                break;
            case 105:
                decodeOscState = ExTermBlock;
                break;
            default:
                qDebug() << parameters;

                decodeOscState = Other;
            }
            oscData.append(QChar(character));
        }
        else if (character == 0x07 || (decodeOscState == Other && character == 0x5c)) {
            if (decodeOscState == ChangeWindowAndIconName || decodeOscState == ChangeWindowTitle) {
                //m_screen->setTitle(title);
            }
            else if(decodeOscState == ExTermBlock) {
                int index = oscData.indexOf(QChar(';'));
                QStringRef type = oscData.leftRef(index);
                QStringRef data = oscData.midRef(index+1);
                if(type.compare("HTML") == 0) {
                    int argIndexes[2] = {0,};
                    int argN = 0;
                    for(int i = 0; i < data.length(); ++i) {
                        if(data.at(i) == QChar(';')) {
                            argIndexes[argN++] = i;
                        }
                        if(argN == 2)
                            break;
                    }
                    QStringRef objectId = oscData.midRef(index + 1, argIndexes[0]);
                    QStringRef numLines = oscData.midRef(index + 1 + argIndexes[0] + 1,  argIndexes[1] - argIndexes[0] - 1);
                    QStringRef actualData = oscData.midRef(index + 1 + argIndexes[1] + 1);
                    int lines = numLines.toString().toInt();
                    for(int i = 0; i < lines-1; ++i)
                        screen.lineFeed();
                    emit htmlBlock(objectId.toString(), lines, actualData.toString());
                }
                else if(type.compare("JS")) {

                }
            }
            tokenFinished();
        }
        else {
            oscData.append(QChar(character));
        }
    }
}
Ejemplo n.º 13
0
void VT100Parser::decodeCSI(uchar character)
{
    if (character >= 0x30 && character <= 0x3f) {
        decodeParameters(character);
    } else {
        if (character >= 0x20 && character <= 0x2f) {
            if (intermediateChar.unicode())
                qDebug() << "Warning!: double intermediate bytes found in CSI";
            intermediateChar = character;
        } else if (character >= 0x40 && character <= 0x7d) {
            if (intermediateChar.unicode()) {
                switch (character) {
                case FinalBytesSingleIntermediate::SL:
                case FinalBytesSingleIntermediate::SR:
                case FinalBytesSingleIntermediate::GSM:
                case FinalBytesSingleIntermediate::GSS:
                case FinalBytesSingleIntermediate::FNT:
                case FinalBytesSingleIntermediate::TSS:
                case FinalBytesSingleIntermediate::JFY:
                case FinalBytesSingleIntermediate::SPI:
                case FinalBytesSingleIntermediate::QUAD:
                case FinalBytesSingleIntermediate::SSU:
                case FinalBytesSingleIntermediate::PFS:
                case FinalBytesSingleIntermediate::SHS:
                case FinalBytesSingleIntermediate::SVS:
                case FinalBytesSingleIntermediate::IGS:
                case FinalBytesSingleIntermediate::IDCS:
                case FinalBytesSingleIntermediate::PPA:
                case FinalBytesSingleIntermediate::PPR:
                case FinalBytesSingleIntermediate::PPB:
                case FinalBytesSingleIntermediate::SPD:
                case FinalBytesSingleIntermediate::DTA:
                case FinalBytesSingleIntermediate::SHL:
                case FinalBytesSingleIntermediate::SLL:
                case FinalBytesSingleIntermediate::FNK:
                case FinalBytesSingleIntermediate::SPQR:
                case FinalBytesSingleIntermediate::SEF:
                case FinalBytesSingleIntermediate::PEC:
                case FinalBytesSingleIntermediate::SSW:
                case FinalBytesSingleIntermediate::SACS:
                case FinalBytesSingleIntermediate::SAPV:
                case FinalBytesSingleIntermediate::STAB:
                case FinalBytesSingleIntermediate::GCC:
                case FinalBytesSingleIntermediate::TATE:
                case FinalBytesSingleIntermediate::TALE:
                case FinalBytesSingleIntermediate::TAC:
                case FinalBytesSingleIntermediate::TCC:
                case FinalBytesSingleIntermediate::TSR:
                case FinalBytesSingleIntermediate::SCO:
                case FinalBytesSingleIntermediate::SRCS:
                case FinalBytesSingleIntermediate::SCS:
                case FinalBytesSingleIntermediate::SLS:
                case FinalBytesSingleIntermediate::SCP:
                default:
                    qDebug() << "unhandled CSI FinalBytesSingleIntermediate sequence" << character;
                    tokenFinished();
                    break;
                }
            } else {
                switch (character) {
                case FinalBytesNoIntermediate::ICH:
                    qDebug() << "ICH" << parameters;
                    tokenFinished();
                    //qDebug() << parameters[0];
                    //qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    break;
                case FinalBytesNoIntermediate::CUU: // Cursor Up PS Times
                    appendParameter();
                    if(parameters.size())
                        screen.moveCursorUp(parameters[0]);
                    else
                        screen.moveCursorUp();
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::CUD:
                    tokenFinished();
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    break;
                case FinalBytesNoIntermediate::CUF: {
                    //qDebug() << "CUF";
                    appendParameter();
                    Q_ASSERT(parameters.size() < 2);
                    int count = parameters.size() ? parameters.at(0) : 1;
                    screen.moveCursorRight(count);
                    tokenFinished();
                }
                break;
                case FinalBytesNoIntermediate::CUB:
                case FinalBytesNoIntermediate::CNL:
                case FinalBytesNoIntermediate::CPL:
                case FinalBytesNoIntermediate::CHA:
                    tokenFinished();
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    break;
                case FinalBytesNoIntermediate::CUP:
                    appendParameter();
                    if (!parameters.size()) {
                        //screen.moveCursorUp();
                        //screen.moveCursorHome();
                        screen.moveCursorTo(QPoint(1, 1));
                    }
                    else if (parameters.size() == 2) {
                        screen.moveCursorTo(QPoint(parameters[1], parameters[0]));
                    }
                    else {
                        qDebug() << "CUP bad parameters" << parameters;
                    }


                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::CHT:
                    tokenFinished();
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    break;
                case FinalBytesNoIntermediate::ED:
//                        qDebug() << "ED unimplemented";
                    appendParameter();
                    if (!parameters.size()) {
                        //m_screen->eraseFromCurrentLineToEndOfScreen();
                        screen.clearToEndOfScreen();
                    } else {
                        switch (parameters.at(0)) {
                        case 1:
                            //m_screen->eraseFromCurrentLineToBeginningOfScreen();

                            screen.clearToBeginningOfScreen();
                            break;
                        case 2:
                            screen.clearScreen();
                            break;
                        default:
                            qDebug() << "Invalid parameter value for FinalBytesNoIntermediate::ED";
                        }
                    }

                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::EL:
                    appendParameter();
                    if (!parameters.size() || parameters.at(0) == 0) {
                        screen.eraseFromCursor();
                    } else if (parameters.at(0) == 1) {
                        qDebug() << "Unimplemented erase cursor to position";
                        //m_screen->eraseToCursorPosition();
                    } else if (parameters.at(0) == 2) {
                        qDebug() << "Unimplemented eraseLine";
                        //m_screen->eraseLine();
                    } else {
                        qDebug() << "Fault when processing FinalBytesNoIntermediate::EL";
                    }
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::IL: {
                    appendParameter();
                    int count = 1;
                    if (parameters.size()) {
                        count = parameters.at(0);
                    }
                    qDebug() << "Unimplemented insertLines";
                    //m_screen->insertLines(count);
                    tokenFinished();
                }
                break;
                case FinalBytesNoIntermediate::DL: {
                    appendParameter();
                    int count = 1;
                    if (parameters.size()) {
                        count = parameters.at(0);
                    }
                    qDebug() << "Unimplemented deleteLines";
                    //m_screen->deleteLines(count);
                    tokenFinished();
                }
                break;
                case FinalBytesNoIntermediate::EF:
                case FinalBytesNoIntermediate::EA:
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::DCH:
                {
                    appendParameter();
                    int count = 1;
                    if(parameters.size())
                        count = parameters[0];
                    screen.deleteRight(count);
                    tokenFinished();
                    break;
                }
                case FinalBytesNoIntermediate::SSE:
                case FinalBytesNoIntermediate::CPR:
                case FinalBytesNoIntermediate::SU:
                case FinalBytesNoIntermediate::SD:
                case FinalBytesNoIntermediate::NP:
                case FinalBytesNoIntermediate::PP:
                case FinalBytesNoIntermediate::CTC:
                case FinalBytesNoIntermediate::ECH:
                case FinalBytesNoIntermediate::CVT:
                case FinalBytesNoIntermediate::CBT:
                case FinalBytesNoIntermediate::SRS:
                case FinalBytesNoIntermediate::PTX:
                case FinalBytesNoIntermediate::SDS:
                case FinalBytesNoIntermediate::SIMD:
                case FinalBytesNoIntermediate::HPA:
                case FinalBytesNoIntermediate::HPR:
                case FinalBytesNoIntermediate::REP:
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::DA:
                    appendParameter();
                    if (parameters.size()) {
                        switch (parameters.at(0)) {
                        case -'>':
                            //m_screen->sendSecondaryDA();
                            break;
                        case -'?':
                            qDebug() << "WHAT!!!";
                            break; //ignore
                        case 0:
                        default:
                            ;//m_screen->sendPrimaryDA();
                        }
                    } else {
                        //m_screen->sendPrimaryDA();
                    }
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::VPA:
                case FinalBytesNoIntermediate::VPR:
                case FinalBytesNoIntermediate::HVP:
                case FinalBytesNoIntermediate::TBC:
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::SM:
                    appendParameter();
                    if (parameters.size() && parameters.at(0) == -'?') {
                        if (parameters.size() > 1) {
                            switch (parameters.at(1)) {
                            case 1:
                                m_cursorKeyMode =  true;
                                emit cursorKeyModeChanged(true);
                                break;
                            case 12:
                                screen.setCursorBlinking(true);
                                break;
                            case 25:
                                screen.setCursorVisible(true);
                                break;
                            case 1034:
                                //I don't know what this sequence is
                                break;
                            case 1049:
                                qDebug() << "Unimplemented save cursor and save screen data";
                                //m_screen->saveCursor();
                                //m_screen->saveScreenData();
                                break;
                            default:
                                qDebug() << "unhandled CSI FinalBytesNoIntermediate::SM ? with parameter:" << parameters.at(1);
                            }
                        } else {
                            qDebug() << "unhandled CSI FinalBytesNoIntermediate::SM ?";
                        }
                    } else {
                        qDebug() << "unhandled CSI FinalBytesNoIntermediate::SM";
                    }
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::MC:
                case FinalBytesNoIntermediate::HPB:
                case FinalBytesNoIntermediate::VPB:
                    qDebug() << "unhandled CSI FinalBytesNoIntermediate sequence" << character;
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::RM:
                    appendParameter();
                    if (parameters.size()) {
                        qDebug() << parameters;
                        switch(parameters.at(0)) {
                        case -'?':
                            if (parameters.size() > 1) {
                                switch(parameters.at(1)) {
                                case 1:
                                    m_cursorKeyMode =  false;
                                    emit cursorKeyModeChanged(true);
                                    break;
                                case 12:
                                    screen.setCursorBlinking(false);
                                    break;
                                case 25:
                                    screen.setCursorVisible(false);
                                    break;
                                case 1049:
                                    qDebug() << "Unimplemented restore cursor and restore screen data";
                                    //m_screen->restoreCursor();
                                    //m_screen->restoreScreenData();
                                    break;
                                default:
                                    qDebug() << "unhandled CSI FinalBytesNoIntermediate::RM? with "
                                             "parameter " << parameters.at(1);
                                }
                            } else {
                                qDebug() << "unhandled CSI FinalBytesNoIntermediate::RM";
                            }
                            break;
                        case 4:
                            qDebug() << "REPLACE MODE!";
                        default:
                            qDebug() << "unhandled CSI FinalBytesNoIntermediate::RM";
                            break;
                        }
                    }
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::SGR: {
                    appendParameter();

                    if (!parameters.size())
                        parameters << 0;

                    for (int i = 0; i < parameters.size(); i++) {
                        switch(parameters.at(i)) {
                        case 0:
                            screen.style().reset();
                            break;
                        case 1:
                            screen.style().setFlag(ScreenStyle::Bold);
                            break;
                        case 5:
                            screen.style().setFlag(ScreenStyle::Blinking);
                            break;
                        case 4:
                            qDebug() << "Set palette!!";
                            tokenFinished();
                            break;
                        case 7:
                            screen.style().setFlag(ScreenStyle::Inverse);
                            break;
                        case 8:
                        {
                            QColor c = screen.style().fgColor();
                            c.setAlpha(0);
                            screen.style().setFgColor(c);
                            break;
                        }
                        case 22:
                            screen.style().clearFlag(ScreenStyle::Bold);
                            break;
                        case 24:
                            screen.style().clearFlag(ScreenStyle::Underline);
                            break;
                        case 25:
                            screen.style().clearFlag(ScreenStyle::Blinking);
                            break;
                        case 27:
                            screen.style().clearFlag(ScreenStyle::Inverse);
                            break;
                        case 28:
                        {
                            QColor c = screen.style().fgColor();
                            c.setAlpha(255);
                            screen.style().setFgColor(c);
                            break;
                        }
                        case 39:
                            screen.style().setFlag(ScreenStyle::DefaultFg);
                            break;
                        case 49:
                            screen.style().setFlag(ScreenStyle::DefaultBg);
                            break;
                        case 30:
                        case 31:
                        case 32:
                        case 33:
                        case 34:
                        case 35:
                        case 36:
                        case 37:
                            //screen.setFgColor(palette[parameters[i] - 30]);
                            //qDebug() << "Set fg color";
                            if(screen.style().hasFlag(ScreenStyle::Bold))
                                screen.style().setFgColor(brightPalette8[parameters[i] - 30]);
                            else
                                screen.style().setFgColor(darkPalette8[parameters[i] - 30]);
                            break;
                        case 40:
                        case 41:
                        case 42:
                        case 43:
                        case 44:
                        case 45:
                        case 46:
                        case 47:
                            //m_screen->setTextStyleColor(parameters.at(i));
                            //qDebug() << "Set bg color" << parameters[i];
                            screen.style().setBgColor(darkPalette8[parameters[i] - 40]);
                            break;
                        // below is 16-colors xterm support - http://www.xfree86.org/current/ctlseqs.html
                        case 90:
                        case 91:
                        case 92:
                        case 93:
                        case 94:
                        case 95:
                        case 96:
                        case 97:
                            screen.style().setFgColor(brightPalette8[parameters[i] - 90]);
                            break;
                        case 100:
                        case 101:
                        case 102:
                        case 103:
                        case 104:
                        case 105:
                        case 106:
                        case 107:
                            screen.style().setBgColor(brightPalette8[parameters[i] - 100]);
                            break;
                        case 38:
                            appendParameter();
                            qDebug() << "256 colors support fg" << parameters;
                            screen.style().setFgColor(color256(parameters[2]));
                            i = parameters.size();
                            tokenFinished();
                            break;
                        case 48:
                            appendParameter();
                            screen.style().setBgColor(color256(parameters[2]));
                            i = parameters.size();
                            tokenFinished();
                            break;
                        default:
                            qDebug() << "Unknown SGR" << parameters.at(i);
                        }
                    }

                    tokenFinished();
                }
                break;
                case FinalBytesNoIntermediate::DSR:
                    qDebug() << "report";
                case FinalBytesNoIntermediate::DAQ:
                case FinalBytesNoIntermediate::Reserved0:
                case FinalBytesNoIntermediate::Reserved1:
                    qDebug() << "Unhandeled CSI FinalBytesNoIntermediate squence" << character;
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::Reserved2:
                    appendParameter();
                    if (parameters.size() == 2) {
                        if (parameters.at(0) >= 0) {
                            qDebug() << "Unimplemented setScrollArea";
                            //m_screen->setScrollArea(parameters.at(0),parameters.at(1));
                        } else {
                            qDebug() << "Unknown value for scrollRegion";
                        }
                    } else {
                        qDebug() << "Unknown parameterset for scrollRegion";
                    }
                    tokenFinished();
                    break;
                case FinalBytesNoIntermediate::Reserved3:
                case FinalBytesNoIntermediate::Reserved4:
                case FinalBytesNoIntermediate::Reserved5:
                case FinalBytesNoIntermediate::Reserved6:
                case FinalBytesNoIntermediate::Reserved7:
                case FinalBytesNoIntermediate::Reserved8:
                case FinalBytesNoIntermediate::Reserved9:
                case FinalBytesNoIntermediate::Reserveda:
                case FinalBytesNoIntermediate::Reservedb:
                case FinalBytesNoIntermediate::Reservedc:
                case FinalBytesNoIntermediate::Reservedd:
                case FinalBytesNoIntermediate::Reservede:
                case FinalBytesNoIntermediate::Reservedf:
                default:
                    qDebug() << "Unhandeled CSI FinalBytesNoIntermediate squence" << character;
                    tokenFinished();
                    break;
                }
            }
        }
    }
}
void GoogleAnalyticsUrlStrategy::appendParameter( const String& name, const String& val, String& builder )
{
	appendParameter( name, val, true, builder );
}
Ejemplo n.º 15
0
void parameterizedHeaderField::parse(const string& buffer, const string::size_type position,
	const string::size_type end, string::size_type* newPosition)
{
	const string::value_type* const pend = buffer.data() + end;
	const string::value_type* const pstart = buffer.data() + position;
	const string::value_type* p = pstart;

	// Skip non-significant whitespaces
	string::size_type valueStart = position;

	while (p < pend && parserHelpers::isSpace(*p))
	{
		++p;
		++valueStart;
	}

	// Advance up to ';', if any
	string::size_type valueLength = 0;

	while (p < pend && *p != ';')  // FIXME: support ";" inside quoted or RFC-2047-encoded text
	{
		++p;
		++valueLength;
	}

	// Trim whitespaces at the end of the value
	while (valueLength > 0 && parserHelpers::isSpace(buffer[valueStart + valueLength - 1]))
		--valueLength;

	// Parse value
	getValue()->parse(buffer, valueStart, valueStart + valueLength);

	// Reset parameters
	removeAllParameters();

	// If there is one or more parameters following...
	if (p < pend)
	{
		std::map <string, paramInfo> params;

		while (*p == ';')
		{
			// Skip ';'
			++p;

			while (p < pend && parserHelpers::isSpace(*p)) ++p;

			const string::size_type attrStart = position + (p - pstart);

			while (p < pend && !(*p == ';' || *p == '='))
				++p;

			if (p >= pend || *p == ';')
			{
				// Hmmmm... we didn't found an '=' sign.
				// This parameter may not be valid so try to advance
				// to the next one, if there is one.
				while (p < pend && *p != ';')
					++p;
			}
			else
			{
				// Extract the attribute name
				string::size_type attrEnd = position + (p - pstart);

				while (attrEnd != attrStart && parserHelpers::isSpace(buffer[attrEnd - 1]))
					--attrEnd;

				// Skip '='
				++p;

				// Skip white-spaces between '=' and the value
				while (p < pend && parserHelpers::isSpace(*p)) ++p;

				// Extract the value
				string value;

				// -- this is a quoted-string
				if (*p == '"')
				{
					// Skip '"'
					++p;

					// Extract quoted-string
					bool escape = false;
					bool stop = false;

					std::ostringstream ss;
					string::size_type start = position + (p - pstart);

					for ( ; p < pend && !stop ; ++p)
					{
						if (escape)
						{
							escape = false;
							start = position + (p - pstart);
						}
						else
						{
							switch (*p)
							{
							case '"':
							{
								ss << string(buffer.begin() + start,
								             buffer.begin() + position + (p - pstart));

								stop = true;
								break;
							}
							case '\\':
							{
								ss << string(buffer.begin() + start,
								             buffer.begin() + position + (p - pstart));

								escape = true;
								break;
							}

							}
						}
					}

					if (!stop)
					{
						ss << string(buffer.begin() + start,
						             buffer.begin() + position + (p - pstart));
					}

					value = ss.str();
				}
				// -- the value is a simple token
				else
				{
					const string::size_type valStart = position + (p - pstart);

					while (p < pend && *p != ';')
						++p;

					string::size_type valEnd = position + (p - pstart);

					while (valEnd != valStart && parserHelpers::isSpace(buffer[valEnd - 1]))
						--valEnd;

					value = string(buffer.begin() + valStart,
					               buffer.begin() + valEnd);
				}

				// Don't allow ill-formed parameters
				if (attrStart != attrEnd && value.length())
				{
					string name(buffer.begin() + attrStart, buffer.begin() + attrEnd);

					// Check for RFC-2231 extended parameters
					bool extended = false;
					bool encoded = false;

					if (name[name.length() - 1] == '*')
					{
						name.erase(name.end() - 1, name.end());

						extended = true;
						encoded = true;
					}

					// Check for RFC-2231 multi-section parameters
					const string::size_type star = name.find_last_of('*');

					if (star != string::npos)
					{
						bool allDigits = true;

						for (string::size_type i = star + 1 ; allDigits && (i < name.length()) ; ++i)
							allDigits = parserHelpers::isDigit(name[i]);

						if (allDigits)
						{
							name.erase(name.begin() + star, name.end());
							extended = true;
						}

						// NOTE: we ignore section number, and we suppose that
						// the sequence is correct (ie. the sections appear
						// in order: param*0, param*1...)
					}

					// Add/replace/modify the parameter
					const std::map <string, paramInfo>::iterator it = params.find(name);

					if (it != params.end())
					{
						paramInfo& info = (*it).second;

						// An extended parameter replaces a normal one
						if (!info.extended)
						{
							info.extended = extended;
							info.value.clear();
							info.start = attrStart;
						}

						// Append a new section for a multi-section parameter
						parameter::valueChunk chunk;
						chunk.encoded = encoded;
						chunk.data = value;

						info.value.push_back(chunk);
						info.end = position + (p - pstart);
					}
					else
					{
						parameter::valueChunk chunk;
						chunk.encoded = encoded;
						chunk.data = value;

						paramInfo info;
						info.extended = extended;
						info.value.push_back(chunk);
						info.start = attrStart;
						info.end = position + (p - pstart);

						// Insert a new parameter
						params.insert(std::map <string, paramInfo>::value_type(name, info));
					}
				}

				// Skip white-spaces after this parameter
				while (p < pend && parserHelpers::isSpace(*p)) ++p;
			}
		}

		for (std::map <string, paramInfo>::const_iterator it = params.begin() ;
		     it != params.end() ; ++it)
		{
			const paramInfo& info = (*it).second;

			// Append this parameter to the list
			ref <parameter> param = vmime::create <parameter>((*it).first);

			param->parse(info.value);
			param->setParsedBounds(info.start, info.end);

			appendParameter(param);
		}
	}

	if (newPosition)
		*newPosition = end;
}
String GoogleAnalyticsUrlStrategy::build( IFocusPoint* focusPoint )
{
	String builder( TRACKING_URL );
	builder += IGoogleAnalyticsParameters::URL_PARAM_DELIMITER;
	appendParameter( IGoogleAnalyticsParameters::PARAM_TRACKING_CODE_VERSION,
		IGoogleAnalyticsParameters::VALUE_TRACKING_CODE_VERSION, builder) ;
	appendParameter( IGoogleAnalyticsParameters::PARAM_UNIQUE_TRACKING_NUMBER, getRandomNumber(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_HOST_NAME, m_pGoogleParameters->getHostname(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_LANGUAGE_ENCODING,
		IGoogleAnalyticsParameters::VALUE_ENCODING_UTF8, builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_SCREEN_RESOLUTION, m_pGoogleParameters->getScreenResolution(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_SCREEN_COLOR_DEPTH, m_pGoogleParameters->getScreenColorDepth(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_BROWSER_LANGUAGE, m_pGoogleParameters->getBrowserLanguage(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_PAGE_TITLE, focusPoint->getTitle(), builder );
	//appendParameter( IGoogleAnalyticsParameters::PARAM_HID, getRandomNumber(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_FLASH_VERSION, m_pGoogleParameters->getFlashVersion(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_REFERRAL, m_pGoogleParameters->getReferral(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_PAGE_REQUEST, focusPoint->getURI(), builder );

	appendParameter( IGoogleAnalyticsParameters::PARAM_ACCOUNT_NAME, m_pGoogleParameters->getAccountName(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_COOKIES, getCookies(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_GAQ, _T("1"), false, builder );

	// update visit timestamps and count
	m_pGoogleParameters->visit();

	return builder;
}