void CGraphPlugIn::MouseDown(BPoint where) { long clicks; fParent->Window()->CurrentMessage()->FindInt32("clicks", &clicks); if (clicks == 2) DisplayOptions(); else CGraphic::MouseDown(where); } /* CGraphPlugIn::MouseDown */
void WorldWindow::CreateMenu(void) { QMenu *menu = menuBar()->addMenu(tr("&Tools")); QAction *lad_action = menu->addAction(tr("&Life and Death...")); connect(lad_action, SIGNAL(triggered()), this, SLOT(LifeAndDeathOptions())); QAction *agent_action = menu->addAction(tr("&Agent Options...")); connect(agent_action, SIGNAL(triggered()), this, SLOT(AgentOptions())); QAction *display_action = menu->addAction(tr("&Display Properties...")); connect(display_action, SIGNAL(triggered()), this, SLOT(DisplayOptions())); }
int main(int argc, char **argv) { DisplayOptions disopt = DisplayOptions(); for (int i = 1; i < argc; i++) { std::string x = argv[i]; if (x.compare("-help") == 0) { std::cout << "ALLOWED ARGUMENTS:" << std::endl; std::cout << "-atend bool - do not display map while exploring" << std::endl; std::cout << "-objects bool - displays recognised objects in different color" << std::endl; std::cout << "-objectsh bool - displays circles around recognised objects" << std::endl; std::cout << "-robsize int - displays a robot of given size, -1 to disable" << std::endl; std::cout << "-footprints - displays robot's footprints" << std::endl; std::cout << "-path - displays robot's current path" << std::endl; std::cout << "-margin - displays path finder's margin from the walls" << std::endl; std::cout << "-walls int - displays walls bolded by given amount of pixels" << std::endl; std::cout << "-penalties - displays path finder's penalties from the walls" << std::endl; exit(0); } else if (x.compare("-atend") == 0) { std::stringstream ss(argv[++i]); ss >> disopt.atEndOnly; } else if (x.compare("-objects") == 0) {
BOOL CALLBACK pgpKeyPassphraseDlgProc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CPGPKeyPassphraseDialogOptions *options; GPP *gpp; INT i; DWORD Common; Common=DoCommonCalls (hDlg,uMsg,wParam,lParam); if(Common) return Common; switch (uMsg) { case WM_INITDIALOG: { RECT rc; int iTextWidth; HDC hdc; char szNameFinal[kPGPMaxUserIDSize]; gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPKeyPassphraseDialogOptions *) gpp->options; gpp->iNextTabControl = IDOK; gpp->wpOrigPhrase1Proc = (WNDPROC) SetWindowLong( GetDlgItem(hDlg, IDC_PHRASE1), GWL_WNDPROC, (LONG) PhraseSubclassProc); GetClientRect(GetDlgItem(hDlg,IDC_KEYNAME), &rc); iTextWidth = rc.right-rc.left; hdc = GetDC (GetDlgItem(hDlg,IDC_KEYNAME)); GetKeyString(hdc,iTextWidth,options->mDefaultKey,szNameFinal); SetWindowText(GetDlgItem(hDlg,IDC_KEYNAME),szNameFinal); ReleaseDC (GetDlgItem (hDlg, IDC_KEYNAME), hdc); gpp->hwndOptionsControl=DisplayOptions(hDlg,options->mDialogOptions,130); return FALSE; } case WM_COMMAND: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPKeyPassphraseDialogOptions *) gpp->options; switch (LOWORD (wParam)) { case IDOK: { PGPBoolean PassValid; FreePassphrases(gpp); i = SendDlgItemMessage (hDlg, IDC_PHRASE1, WM_GETTEXTLENGTH, 0, 0) +1; gpp->szDummy = (char *)secAlloc (gpp->context, i); if(gpp->szDummy) { gpp->pszPassPhrase = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhrase) { GetDlgItemText (hDlg, IDC_PHRASE1, gpp->szDummy, i); if(PassphraseLengthAndQualityOK(hDlg,options,gpp->pszPassPhrase)) { if(!options->mVerifyPassphrase) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } PassValid=PGPPassphraseIsValid (options->mDefaultKey, PGPOPassphrase (gpp->context, gpp->pszPassPhrase), PGPOLastOption (gpp->context)); if(PassValid) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } else { PGPsdkUIMessageBox (hDlg, IDS_PGPERROR,IDS_BADPASSREENTER, MB_OK|MB_ICONSTOP); } } // Bad passphrase/quality ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); break; } } // Couldn't allocate passphrases ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); EndDialog (hDlg, kPGPError_OutOfMemory); break; } } } break; } return FALSE; }
BOOL CALLBACK pgpConfirmationDlgProc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CPGPConfirmationPassphraseDialogOptions *options; GPP *gpp; INT i; DWORD Common; Common=DoCommonCalls (hDlg,uMsg,wParam,lParam); if(Common) return Common; switch (uMsg) { case WM_INITDIALOG: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPConfirmationPassphraseDialogOptions *) gpp->options; gpp->iNextTabControl = IDC_PHRASE2; gpp->hwndQuality = GetDlgItem (hDlg, IDC_PHRASEQUALITY); gpp->hwndMinQuality = GetDlgItem (hDlg, IDC_MINQUALITY); gpp->wpOrigPhrase1Proc = (WNDPROC) SetWindowLong ( GetDlgItem (hDlg, IDC_PHRASE1), GWL_WNDPROC, (LONG) PhraseSubclassProc); gpp->wpOrigPhrase2Proc = (WNDPROC) SetWindowLong ( GetDlgItem (hDlg, IDC_PHRASE2), GWL_WNDPROC, (LONG) PhraseConfirmSubclassProc); gpp->hwndOptionsControl=DisplayOptions(hDlg,options->mDialogOptions,215); // If we aren't showing quality, don't show either bar if(!options->mShowPassphraseQuality) { EnableWindow (GetDlgItem (hDlg, IDC_STATICPASSQUAL), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_STATICPASSQUAL), SW_HIDE); EnableWindow (GetDlgItem (hDlg, IDC_STATICMINQUAL), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_STATICMINQUAL), SW_HIDE); EnableWindow (GetDlgItem (hDlg, IDC_MINQUALITY), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_MINQUALITY), SW_HIDE); EnableWindow (GetDlgItem (hDlg, IDC_PHRASEQUALITY), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_PHRASEQUALITY), SW_HIDE); } // If we don't give a min quality, don't show bar if(options->mMinPassphraseQuality==0) { EnableWindow (GetDlgItem (hDlg, IDC_STATICMINQUAL), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_STATICMINQUAL), SW_HIDE); EnableWindow (GetDlgItem (hDlg, IDC_MINQUALITY), FALSE); ShowWindow (GetDlgItem (hDlg, IDC_MINQUALITY), SW_HIDE); } // Set our min quality benchmark SendMessage (gpp->hwndMinQuality, PBM_SETPOS, options->mMinPassphraseQuality, 0); // Disable OK till we get a good passphrase if mins are active if(options->mMinPassphraseQuality!=0) // (options->mMinPassphraseLength!=0)) EnableWindow (GetDlgItem (hDlg, IDOK), FALSE); return FALSE; } case WM_COMMAND: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPConfirmationPassphraseDialogOptions *) gpp->options; switch(LOWORD (wParam)) { case IDOK: { FreePassphrases(gpp); // get passphrase i = SendDlgItemMessage (hDlg, IDC_PHRASE1, WM_GETTEXTLENGTH, 0, 0) +1; gpp->szDummy = (char *)secAlloc (gpp->context, i); if(gpp->szDummy) { gpp->pszPassPhrase = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhrase) { GetDlgItemText (hDlg, IDC_PHRASE1, gpp->szDummy, i); // get passphrase confirmation i = SendDlgItemMessage (hDlg, IDC_PHRASE2, WM_GETTEXTLENGTH, 0, 0) +1; gpp->pszPassPhraseConf = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhraseConf) { GetDlgItemText (hDlg, IDC_PHRASE2, gpp->szDummy, i); if(PassphraseLengthAndQualityOK(hDlg,options,gpp->pszPassPhrase)) { if (!lstrcmp (gpp->pszPassPhrase, gpp->pszPassPhraseConf)) { ClearPassphrases(hDlg,gpp); if(gpp->pszPassPhraseConf) { secFree(gpp->pszPassPhraseConf); gpp->pszPassPhraseConf=NULL; } SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } else { PGPsdkUIMessageBox (hDlg, IDS_PGPERROR, IDS_PHRASEMISMATCH, MB_OK|MB_ICONEXCLAMATION); } } // Badpassphrase/quality ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); SendMessage (gpp->hwndQuality, PBM_SETPOS, 0, 0); if(options->mMinPassphraseQuality!=0) EnableWindow (GetDlgItem (hDlg, IDOK), FALSE); break; } } } // Couldn't allocate passphrases ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); EndDialog (hDlg, kPGPError_OutOfMemory); break; } } break; } } return FALSE; }
BOOL CALLBACK pgpSigningPassphraseDlgProc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CPGPSigningPassphraseDialogOptions *options; GPP *gpp; INT i; DWORD Common; Common=DoCommonCalls (hDlg,uMsg,wParam,lParam); if(Common) return Common; switch (uMsg) { case WM_INITDIALOG: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPSigningPassphraseDialogOptions *) gpp->options; gpp->iNextTabControl = IDOK; gpp->wpOrigPhrase1Proc = (WNDPROC) SetWindowLong( GetDlgItem(hDlg, IDC_PHRASE1), GWL_WNDPROC, (LONG) PhraseSubclassProc); if (InitSigningKeyComboBox (hDlg, options)) { EnablePassPhraseControl (hDlg); } else { EndDialog (hDlg, kPGPError_UserAbort);//kPGPError_Win32_NoSecretKeys); } gpp->hwndOptionsControl=DisplayOptions(hDlg,options->mDialogOptions,130); return FALSE; } case WM_COMMAND: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPSigningPassphraseDialogOptions *) gpp->options; switch (LOWORD (wParam)) { case IDOK: { int ComboSelection; FreePassphrases(gpp); ComboSelection = SendDlgItemMessage (hDlg, IDC_SIGNKEYCOMBO, CB_GETCURSEL, 0, 0); if (ComboSelection == CB_ERR) { PGPsdkUIMessageBox (hDlg, IDS_PGPERROR, IDS_NOSIGNKEY, MB_OK | MB_ICONEXCLAMATION); break; } i = SendDlgItemMessage (hDlg, IDC_PHRASE1, WM_GETTEXTLENGTH, 0, 0) +1; gpp->szDummy = (char *)secAlloc (gpp->context, i); if(gpp->szDummy) { gpp->pszPassPhrase = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhrase) { PGPKeyRef key; PGPError err; PGPBoolean bShared; GetDlgItemText (hDlg, IDC_PHRASE1, gpp->szDummy, i); key = (PGPKeyRef)SendDlgItemMessage (hDlg, IDC_SIGNKEYCOMBO, CB_GETITEMDATA, ComboSelection, 0); err=PGPGetKeyBoolean( key, kPGPKeyPropIsSecretShared, &bShared); if(IsntPGPError(err) && bShared) { // So, they want to do a shared key.... ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); *(options->mPassphraseKeyPtr) = key; EndDialog (hDlg, kPGPError_KeyUnusableForSignature); break; } if(PassphraseLengthAndQualityOK(hDlg,options,gpp->pszPassPhrase)) { if (!options->mVerifyPassphrase) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } err=ValidateSigningPhrase(hDlg,gpp,gpp->pszPassPhrase,key); if(IsntPGPError(err)) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } } // Bad passphrase/quality ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); break; } } // Couldn't allocate passphrases ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); EndDialog (hDlg, kPGPError_OutOfMemory); break; } case IDC_SIGNKEYCOMBO : { if(HIWORD(wParam)==CBN_SELCHANGE) EnablePassPhraseControl (hDlg); break; } } } break; } return FALSE; }
BOOL CALLBACK pgpDecryptionPassphraseDlgProc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CPGPDecryptionPassphraseDialogOptions *options; GPP *gpp; INT i; DWORD Common; Common=DoCommonCalls (hDlg,uMsg,wParam,lParam); if(Common) return Common; switch (uMsg) { case WM_INITDIALOG: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPDecryptionPassphraseDialogOptions *) gpp->options; gpp->iNextTabControl = IDOK; InitEncryptedToKeyListBox (hDlg, options); gpp->wpOrigPhrase1Proc = (WNDPROC) SetWindowLong ( GetDlgItem (hDlg, IDC_PHRASE1), GWL_WNDPROC, (LONG) PhraseSubclassProc); gpp->hwndOptionsControl=DisplayOptions(hDlg,options->mDialogOptions,200); return FALSE; } case WM_COMMAND: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPDecryptionPassphraseDialogOptions *) gpp->options; switch(LOWORD (wParam)) { case IDC_KEYLISTBOX: { if(HIWORD(wParam)==LBN_DBLCLK) { if(!Working) { Working=TRUE; if(NULL!=(int)(options->mMissingKeyIDList)) { PGPError err; PGPBoolean haveNewKeys; err=options->SearchForMissingKeys( hDlg, &haveNewKeys ); PGPsdkUIErrorBox (hDlg,err); if( haveNewKeys ) { InitEncryptedToKeyListBox (hDlg, options); } } Working=FALSE; } } break; } case IDOK: { FreePassphrases(gpp); i = SendDlgItemMessage (hDlg, IDC_PHRASE1, WM_GETTEXTLENGTH, 0, 0) +1; gpp->szDummy = (char *)secAlloc (gpp->context, i); if(gpp->szDummy) { gpp->pszPassPhrase = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhrase) { CHAR sz[256]; GetDlgItemText (hDlg, IDC_PHRASE1, gpp->szDummy, i); if(PassphraseLengthAndQualityOK(hDlg,options,gpp->pszPassPhrase)) { if (!options->mFindMatchingKey) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } *(options->mPassphraseKeyPtr)= GetKeyForPassphrase(options->mKeySet, gpp->pszPassPhrase,FALSE); if (*(options->mPassphraseKeyPtr)!=NULL) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } else { PGPsdkUIMessageBox (hDlg, IDS_PGPERROR, IDS_BADDECRYPTPHRASE, MB_OK|MB_ICONEXCLAMATION); LoadString (gPGPsdkUILibInst, IDS_WRONGDECRYPTPHRASE, sz, sizeof (sz)); SetDlgItemText (hDlg, IDC_PROMPTSTRING, sz); } } // Bad passphrase/quality ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); break; } } // Couldn't allocate passphrases ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); EndDialog (hDlg, kPGPError_OutOfMemory); break; } } break; } } return FALSE; }
BOOL CALLBACK pgpPassphraseDlgProc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CPGPPassphraseDialogOptions *options; GPP *gpp; INT i; BOOL Common; Common=DoCommonCalls (hDlg,uMsg,wParam,lParam); if(Common) return Common; switch (uMsg) { case WM_INITDIALOG: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPPassphraseDialogOptions *) gpp->options; gpp->iNextTabControl = IDOK; gpp->wpOrigPhrase1Proc = (WNDPROC) SetWindowLong ( GetDlgItem (hDlg, IDC_PHRASE1), GWL_WNDPROC, (LONG) PhraseSubclassProc); gpp->hwndOptionsControl=DisplayOptions(hDlg,options->mDialogOptions,107); return FALSE; } case WM_COMMAND: { gpp=(GPP *)GetWindowLong (hDlg, GWL_USERDATA); options = (CPGPPassphraseDialogOptions *) gpp->options; switch(LOWORD (wParam)) { case IDOK: { FreePassphrases(gpp); i = SendDlgItemMessage (hDlg, IDC_PHRASE1, WM_GETTEXTLENGTH, 0, 0) +1; gpp->szDummy = (char *)secAlloc (gpp->context, i); if(gpp->szDummy) { gpp->pszPassPhrase = (char *)secAlloc (gpp->context, i); if (gpp->pszPassPhrase) { GetDlgItemText (hDlg, IDC_PHRASE1, gpp->szDummy, i); if(PassphraseLengthAndQualityOK(hDlg,options,gpp->pszPassPhrase)) { ClearPassphrases(hDlg,gpp); SaveOptionSettings(gpp->hwndOptionsControl); EndDialog (hDlg, kPGPError_NoErr); break; } // Passphrase quality not enough ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); break; } } // Couldn't allocate passphrases ClearPassphrases(hDlg,gpp); FreePassphrases(gpp); EndDialog (hDlg, kPGPError_OutOfMemory); break; } } break; } } return FALSE; }
int wmain(int iArgCnt, WCHAR ** argv) { if(!ProcessArguments(iArgCnt, argv)) { DisplayOptions(); return 1; } if (wcslen(wServerName) > 0) { //prompt for credentials for a remote connection DWORD dwRes = CredUICmdLinePromptForCredentialsW( (const WCHAR *) wServerName, NULL, 0, wFullUserName, sizeof(wFullUserName)/sizeof(WCHAR), wPassWord, sizeof(wPassWord)/sizeof(WCHAR), FALSE, CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_DO_NOT_PERSIST ); if (dwRes != NO_ERROR) { printf("Failed to retrieve credentials: error %d. Using the default credentials.", dwRes); } bUserNameSet = bPassWordSet = (dwRes == NO_ERROR); } else { //no server name passed in, assume local StringCbCopyW(wServerName, sizeof(wPath), L"."); } StringCbCopyW(wPath, sizeof(wPath), L"\\\\"); StringCbCatW(wPath, sizeof(wPath), wServerName); StringCbCatW(wPath, sizeof(wPath), L"\\"); StringCbCatW(wPath, sizeof(wPath), wNameSpace); IWbemLocator *pLocator = NULL; IWbemServices *pNamespace = 0; IWbemClassObject * pClass = NULL; // Initialize COM. HRESULT hr = CoInitialize(0); if (FAILED(hr)) { printf("\nCoInitialize returned 0x%x:", hr); return 1; } // This sets the default impersonation level to "Impersonate" which is what WMI // providers will generally require. // // DLLs cannot call this function. To bump up the impersonation level, they must // call CoSetProxyBlanket which is illustrated later on. // // When using asynchronous WMI API's remotely in an environment where the "Local System" account // has no network identity (such as non-Kerberos domains), the authentication level of // RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to // RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to // use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones. hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE 0); if (FAILED(hr)) { printf("\nCoInitializeSecurity returned 0x%x:", hr); return 1; } hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLocator); if (FAILED(hr)) { printf("\nCoCreateInstance for CLSID_WbemLocator returned 0x%x:", hr); return 1; } hr = pLocator->ConnectServer(wPath, (bUserNameSet) ? wFullUserName : NULL, (bPassWordSet) ? wPassWord : NULL, NULL, 0, NULL, NULL, &pNamespace); if(FAILED(hr)) { wprintf(L"\nConnectServer to %s failed, hr = 0x%x", wPath, hr); } else { printf("\nConnection succeeded"); hr = SetProxySecurity(pNamespace); if(SUCCEEDED(hr)) { ListClasses(pNamespace); ReadACL(pNamespace); } pNamespace->Release(); } CoUninitialize(); printf("\nTerminating normally"); return 0; }