void KRegExpEditorPrivate::maybeVerify() { if ( _autoVerify ) doVerify(); else _verifyButtons->setMatchCount(-1); }
void KRegExpEditorPrivate::setAutoVerify( bool on ) { _autoVerify = on; if ( !_autoVerify ) _verifier->clearRegexp(); else doVerify(); }
void VerificationThread::run() { if (m_type == Nothing) { return; } if (m_type == Verify) { doVerify(); } else if (m_type == BrokenPieces) { doBrokenPieces(); } }
KRegExpEditorPrivate::KRegExpEditorPrivate(TQWidget *parent, const char *name) : TQWidget(parent, name), _updating( false ), _autoVerify( true ) { setMinimumSize(730,300); TQDockArea* area = new TQDockArea(Qt::Horizontal, TQDockArea::Normal, this ); area->setMinimumSize(2,2); TQDockArea* verArea1 = new TQDockArea(Qt::Vertical, TQDockArea::Normal, this ); verArea1->setMinimumSize(2,2); TQDockArea* verArea2 = new TQDockArea(Qt::Vertical, TQDockArea::Reverse, this ); verArea2->setMinimumSize(2,2); // The DockWindows. _regExpButtons = new RegExpButtons( area, "KRegExpEditorPrivate::regExpButton" ); _verifyButtons = new VerifyButtons( area, "KRegExpEditorPrivate::VerifyButtons" ); _auxButtons = new AuxButtons( area, "KRegExpEditorPrivate::AuxButtons" ); _userRegExps = new UserDefinedRegExps( verArea1, "KRegExpEditorPrivate::userRegExps" ); _userRegExps->setResizeEnabled( true ); TQWhatsThis::add( _userRegExps, i18n( "In this window you will find predefined regular expressions. Both regular expressions " "you have developed and saved, and regular expressions shipped with the system." )); // Editor window _editor = new TQSplitter(Qt::Vertical, this, "KRegExpEditorPrivate::_editor" ); _scrolledEditorWindow = new RegExpScrolledEditorWindow( _editor, "KRegExpEditorPrivate::_scrolledEditorWindow" ); TQWhatsThis::add( _scrolledEditorWindow, i18n( "In this window you will develop your regular expressions. " "Select one of the actions from the action buttons above, and click the mouse in this " "window to insert the given action.")); _info = new InfoPage( this, "_info" ); _verifier = new Verifier( _editor, "KRegExpEditorPrivate::_verifier" ); connect( _verifier, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( maybeVerify() ) ); TQWhatsThis::add( _verifier, i18n("Type in some text in this window, and see what the regular expression you have developed matches.<p>" "Each second match will be colored in red and each other match will be colored blue, simply so you " "can distinguish them from each other.<p>" "If you select part of the regular expression in the editor window, then this part will be " "highlighted - This allows you to <i>debug</i> your regular expressions") ); _editor->hide(); _editor->setSizes( TQValueList<int>() << _editor->height()/2 << _editor->height()/2 ); TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, 6, "KRegExpEditorPrivate::topLayout" ); topLayout->addWidget( area ); TQHBoxLayout* rows = new TQHBoxLayout; // I need to cal addLayout explicit to get stretching right. topLayout->addLayout( rows, 1 ); rows->addWidget( verArea1 ); rows->addWidget( _editor, 1 ); rows->addWidget( _info, 1 ); rows->addWidget( verArea2 ); // Connect the buttons connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ), _scrolledEditorWindow, TQT_SLOT( slotInsertRegExp( int ) ) ); connect( _regExpButtons, TQT_SIGNAL( doSelect() ), _scrolledEditorWindow, TQT_SLOT( slotDoSelect() ) ); connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ), _scrolledEditorWindow, TQT_SLOT( slotInsertRegExp( RegExp* ) ) ); connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ), _userRegExps, TQT_SLOT( slotUnSelect() ) ); connect( _regExpButtons, TQT_SIGNAL( doSelect() ), _userRegExps, TQT_SLOT( slotUnSelect() ) ); connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ), _regExpButtons, TQT_SLOT( slotUnSelect() ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( doneEditing() ), _regExpButtons, TQT_SLOT( slotSelectNewAction() ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( doneEditing() ), _userRegExps, TQT_SLOT( slotSelectNewAction() ) ); connect( _regExpButtons, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotShowEditor() ) ); connect( _userRegExps, TQT_SIGNAL( load( RegExp* ) ), this, TQT_SLOT( slotShowEditor() ) ); connect( _regExpButtons, TQT_SIGNAL( doSelect() ), this, TQT_SLOT( slotShowEditor() ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( savedRegexp() ), _userRegExps, TQT_SLOT( slotPopulateUserRegexps() ) ); connect( _auxButtons, TQT_SIGNAL( undo() ), this, TQT_SLOT( slotUndo() ) ); connect( _auxButtons, TQT_SIGNAL( redo() ), this, TQT_SLOT( slotRedo() ) ); connect( _auxButtons, TQT_SIGNAL( cut() ), _scrolledEditorWindow, TQT_SLOT( slotCut() ) ); connect( _auxButtons, TQT_SIGNAL( copy() ), _scrolledEditorWindow, TQT_SLOT( slotCopy() ) ); connect( _auxButtons, TQT_SIGNAL( paste() ), _scrolledEditorWindow, TQT_SLOT( slotPaste() ) ); connect( _auxButtons, TQT_SIGNAL( save() ), _scrolledEditorWindow, TQT_SLOT( slotSave() ) ); connect( _verifyButtons, TQT_SIGNAL( autoVerify( bool ) ), this, TQT_SLOT( setAutoVerify( bool ) ) ); connect( _verifyButtons, TQT_SIGNAL( verify() ), this, TQT_SLOT( doVerify() ) ); connect( _verifyButtons, TQT_SIGNAL( changeSyntax( const TQString& ) ), this, TQT_SLOT( setSyntax( const TQString& ) ) ); connect( this, TQT_SIGNAL( canUndo( bool ) ), _auxButtons, TQT_SLOT( slotCanUndo( bool ) ) ); connect( this, TQT_SIGNAL( canRedo( bool ) ), _auxButtons, TQT_SLOT( slotCanRedo( bool ) ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( anythingSelected( bool ) ), _auxButtons, TQT_SLOT( slotCanCut( bool ) ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( anythingSelected( bool ) ), _auxButtons, TQT_SLOT( slotCanCopy( bool ) ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( anythingOnClipboard( bool ) ), _auxButtons, TQT_SLOT( slotCanPaste( bool ) ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( canSave( bool ) ), _auxButtons, TQT_SLOT( slotCanSave( bool ) ) ); connect( _scrolledEditorWindow, TQT_SIGNAL( verifyRegExp() ), this, TQT_SLOT( maybeVerify() ) ); connect( _verifyButtons, TQT_SIGNAL( loadVerifyText( const TQString& ) ), this, TQT_SLOT( setVerifyText( const TQString& ) ) ); // connect( _verifier, TQT_SIGNAL( countChanged( int ) ), _verifyButtons, TQT_SLOT( setMatchCount( int ) ) ); // TQt anchors do not work for <pre>...</pre>, thefore scrolling to next/prev match // do not work. Enable this when they work. // connect( _verifyButtons, TQT_SIGNAL( gotoFirst() ), _verifier, TQT_SLOT( gotoFirst() ) ); // connect( _verifyButtons, TQT_SIGNAL( gotoPrev() ), _verifier, TQT_SLOT( gotoPrev() ) ); // connect( _verifyButtons, TQT_SIGNAL( gotoNext() ), _verifier, TQT_SLOT( gotoNext() ) ); // connect( _verifyButtons, TQT_SIGNAL( gotoLast() ), _verifier, TQT_SLOT( gotoLast() ) ); // connect( _verifier, TQT_SIGNAL( goForwardPossible( bool ) ), _verifyButtons, TQT_SLOT( enableForwardButtons( bool ) ) ); // connect( _verifier, TQT_SIGNAL( goBackwardPossible( bool ) ), _verifyButtons, TQT_SLOT( enableBackwardButtons( bool ) ) ); _auxButtons->slotCanPaste( false ); _auxButtons->slotCanCut( false ); _auxButtons->slotCanCopy( false ); _auxButtons->slotCanSave( false ); // Line Edit TQHBoxLayout* layout = new TQHBoxLayout( topLayout, 6 ); TQLabel* label = new TQLabel( i18n("ASCII syntax:"), this ); layout->addWidget( label ); clearButton = new TQToolButton( this ); const TQString icon( TQString::fromLatin1( TQApplication::reverseLayout() ? "clear_left" : "locationbar_erase" ) ); TQIconSet clearIcon = SmallIconSet( icon ); clearButton->setIconSet( clearIcon ); layout->addWidget( clearButton ); TQToolTip::add( clearButton, i18n("Clear expression") ); _regexpEdit = new TQLineEdit( this ); layout->addWidget( _regexpEdit ); TQWhatsThis::add( _regexpEdit, i18n( "This is the regular expression in ASCII syntax. You are likely only " "to be interested in this if you are a programmer, and need to " "develop a regular expression using TQRegExp.<p>" "You may develop your regular expression both by using the graphical " "editor, and by typing the regular expression in this line edit.") ); #ifdef TQT_ONLY TQPixmap pix( "icons/error.png" ); #else TQPixmap pix = TDEGlobal::iconLoader()->loadIcon(locate("data", TQString::fromLatin1("kregexpeditor/pics/error.png") ), TDEIcon::Toolbar ); #endif _error = new TQLabel( this ); _error->setPixmap( pix ); layout->addWidget( _error ); _error->hide(); _timer = new TQTimer(this); connect( _scrolledEditorWindow, TQT_SIGNAL( change() ), this, TQT_SLOT( slotUpdateLineEdit() ) ); connect( _regexpEdit, TQT_SIGNAL(textChanged( const TQString& ) ), this, TQT_SLOT( slotTriggerUpdate() ) ); connect( _timer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( slotTimeout() ) ); connect( clearButton, TQT_SIGNAL( clicked() ), _regexpEdit, TQT_SLOT( clear() ) ); // Push an initial empty element on the stack. _undoStack.push( _scrolledEditorWindow->regExp() ); _redoStack.setAutoDelete( true ); TQAccel* accel = new TQAccel( this ); accel->connectItem( accel->insertItem( CTRL+Key_Z ), this, TQT_SLOT( slotUndo() ) ); accel->connectItem( accel->insertItem( CTRL+Key_R ), this, TQT_SLOT( slotRedo() ) ); setSyntax( TQString::fromLatin1( "TQt" ) ); }
int doAsymTests( CSSM_CSP_HANDLE cspHand, privAlg palg, CSSM_BOOL refKeys, CSSM_BOOL quiet) { CSSM_ALGORITHMS keyAlg; CSSM_ALGORITHMS sigAlg; CSSM_ALGORITHMS encrAlg; CSSM_ENCRYPT_MODE encrMode; CSSM_PADDING encrPad; uint32 keySizeInBits; const char *keyAlgStr; privAlgToCssm(palg, &keyAlg, &sigAlg, &encrAlg, &encrMode, &encrPad, &keySizeInBits, &keyAlgStr); CSSM_KEY pubKey; CSSM_KEY privKey; int irtn; CSSM_KEYATTR_FLAGS pubKeyAttr = CSSM_KEYATTR_EXTRACTABLE; CSSM_KEYATTR_FLAGS privKeyAttr = CSSM_KEYATTR_EXTRACTABLE; if(refKeys) { pubKeyAttr |= CSSM_KEYATTR_RETURN_REF; privKeyAttr |= CSSM_KEYATTR_RETURN_REF; } else { pubKeyAttr |= CSSM_KEYATTR_RETURN_DATA; privKeyAttr |= CSSM_KEYATTR_RETURN_DATA; } if(!quiet) { printf("...testing %s with %s keys\n", keyAlgStr, refKeys ? "Ref" : "Raw"); printf(" ...verifying empty Dates\n"); } irtn = genKeyPair(cspHand, keyAlg, keyAlgStr, keySizeInBits, &pubKey, pubKeyAttr, CSSM_KEYUSE_ANY, &privKey, privKeyAttr, CSSM_KEYUSE_ANY, quiet, CSSM_FALSE, 0, // no StartDate CSSM_FALSE, 0); // no EndDate if(irtn) { return irtn; } irtn = doEncrypt(cspHand, keyAlgStr, &pubKey, encrAlg, encrMode, encrPad, CSSM_OK, quiet); if(irtn) { printf("***Failure on encrypting with empty Key Dates\n"); return irtn; } irtn = doDecrypt(cspHand, keyAlgStr, &privKey, encrAlg, encrMode, encrPad, DR_BadData, quiet); if(irtn) { printf("***Failure on decrypting with empty Key Dates\n"); return irtn; } irtn = doSign(cspHand, keyAlgStr, &privKey, sigAlg, CSSM_OK, quiet); if(irtn) { printf("***Failure on signing with empty Key Dates\n"); return irtn; } irtn = doVerify(cspHand, keyAlgStr, &pubKey, sigAlg, KD_VERIFY_FAIL_ERR, quiet); if(irtn) { printf("***Failure on verifying with empty Key Dates\n"); return irtn; } cspFreeKey(cspHand, &pubKey); cspFreeKey(cspHand, &privKey); if(!quiet) { printf(" ...verifying Good Dates\n"); } irtn = genKeyPair(cspHand, keyAlg, keyAlgStr, keySizeInBits, &pubKey, pubKeyAttr, CSSM_KEYUSE_ANY, &privKey, privKeyAttr, CSSM_KEYUSE_ANY, quiet, CSSM_TRUE, 0, // StartDate = today CSSM_TRUE, 1); // EndDate = tomorrow if(irtn) { return irtn; } irtn = doEncrypt(cspHand, keyAlgStr, &pubKey, encrAlg, encrMode, encrPad, CSSM_OK, quiet); if(irtn) { printf("***Failure on encrypting with good Key Dates\n"); return irtn; } irtn = doDecrypt(cspHand, keyAlgStr, &privKey, encrAlg, encrMode, encrPad, DR_BadData, quiet); if(irtn) { printf("***Failure on decrypting with Good Key Dates\n"); return irtn; } irtn = doSign(cspHand, keyAlgStr, &privKey, sigAlg, CSSM_OK, quiet); if(irtn) { printf("***Failure on signing with Good Key Dates\n"); return irtn; } irtn = doVerify(cspHand, keyAlgStr, &pubKey, sigAlg, KD_VERIFY_FAIL_ERR, quiet); if(irtn) { printf("***Failure on verifying with Good Key Dates\n"); return irtn; } cspFreeKey(cspHand, &pubKey); cspFreeKey(cspHand, &privKey); if(!quiet) { printf(" ...verifying Bad StartDate\n"); } irtn = genKeyPair(cspHand, keyAlg, keyAlgStr, keySizeInBits, &pubKey, pubKeyAttr, CSSM_KEYUSE_ANY, &privKey, privKeyAttr, CSSM_KEYUSE_ANY, quiet, CSSM_TRUE, 1, // StartDate = tomorrow CSSM_TRUE, 1); // EndDate = tomorrow if(irtn) { return irtn; } irtn = doEncrypt(cspHand, keyAlgStr, &pubKey, encrAlg, encrMode, encrPad, CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE, quiet); if(irtn) { printf("***Failure on encrypting with bad StartDate\n"); return irtn; } irtn = doDecrypt(cspHand, keyAlgStr, &privKey, encrAlg, encrMode, encrPad, DR_BadStartDate, quiet); if(irtn) { printf("***Failure on decrypting with bad StartDate\n"); return irtn; } irtn = doSign(cspHand, keyAlgStr, &privKey, sigAlg, CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE, quiet); if(irtn) { printf("***Failure on signing with bad StartDate\n"); return irtn; } irtn = doVerify(cspHand, keyAlgStr, &pubKey, sigAlg, CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE, quiet); if(irtn) { printf("***Failure on verifying with bad StartDate\n"); return irtn; } cspFreeKey(cspHand, &pubKey); cspFreeKey(cspHand, &privKey); if(!quiet) { printf(" ...verifying Bad EndDate\n"); } irtn = genKeyPair(cspHand, keyAlg, keyAlgStr, keySizeInBits, &pubKey, pubKeyAttr, CSSM_KEYUSE_ANY, &privKey, privKeyAttr, CSSM_KEYUSE_ANY, quiet, CSSM_TRUE, 0, // StartDate = today CSSM_TRUE, -1); // EndDate = yesterday if(irtn) { return irtn; } irtn = doEncrypt(cspHand, keyAlgStr, &pubKey, encrAlg, encrMode, encrPad, CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE, quiet); if(irtn) { printf("***Failure on encrypting with bad EndDate\n"); return irtn; } irtn = doDecrypt(cspHand, keyAlgStr, &privKey, encrAlg, encrMode, encrPad, DR_BadEndDate, quiet); if(irtn) { printf("***Failure on decrypting with bad EndDate\n"); return irtn; } irtn = doSign(cspHand, keyAlgStr, &privKey, sigAlg, CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE, quiet); if(irtn) { printf("***Failure on signing with bad EndDate\n"); return irtn; } irtn = doVerify(cspHand, keyAlgStr, &pubKey, sigAlg, CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE, quiet); if(irtn) { printf("***Failure on verifying with bad EndDate\n"); return irtn; } cspFreeKey(cspHand, &pubKey); cspFreeKey(cspHand, &privKey); return 0; }