void ServerApp::_LaunchAddOnServer() { // Try to launch media_addon_server by mime signature. // If it fails (for example on the Live CD, where the executable // hasn't yet been mimesetted), try from this application's // directory status_t err = be_roster->Launch(B_MEDIA_ADDON_SERVER_SIGNATURE); if (err == B_OK) return; app_info info; BEntry entry; BDirectory dir; entry_ref ref; err = GetAppInfo(&info); err |= entry.SetTo(&info.ref); err |= entry.GetParent(&entry); err |= dir.SetTo(&entry); err |= entry.SetTo(&dir, "media_addon_server"); err |= entry.GetRef(&ref); if (err == B_OK) be_roster->Launch(&ref); if (err == B_OK) return; (new BAlert("media_server", "Launching media_addon_server failed.\n\n" "media_server will terminate", "OK"))->Go(); fprintf(stderr, "Launching media_addon_server (%s) failed: %s\n", B_MEDIA_ADDON_SERVER_SIGNATURE, strerror(err)); exit(1); }
VisionApp::VisionApp(void) : BApplication("application/x-vnd.Ink-Vision"), fAboutWin(NULL), fSetupWin(NULL), fClientWin(NULL), fPrefsWin(NULL), fNetWin(NULL), fDccFileWin(NULL), fVisionSettings(NULL), fIdentThread(-1), fWinThread(-1), fIdentSocket(-1), fActiveTheme(new Theme("active theme", MAX_COLORS + 1, MAX_COLORS + 1, MAX_FONTS + 1)) { // some setup fSettingsLoaded = false; fDebugRecv = false; fDebugSend = false; fDebugSettings = false; fNumBench = false; fShuttingDown = false; fDebugShutdown = false; fDisableAutostart = false; fStartupTime = system_time(); app_info info; if (GetAppInfo(&info) == B_OK) fAppRef = info.ref; URLCrunch::UpdateTagList(); }
MyApplication::MyApplication(const char *sig) : BApplication(sig) { file_panel = NULL; main_window = NULL; title_window = NULL; project_window = NULL; logger_window = NULL; state = StateNoProjectLoaded; GetAppInfo(&appinfo); launchFromAppIcon(); }
// Show some information about this software. void app::AboutRequested() { AboutWindow *aw=new AboutWindow(BRect(0,0,300,180), "About"); app_info info; if (GetAppInfo(&info)==B_OK) { BBitmap bmp(BRect(0,0,31,31), B_CMAP8); if (BNodeInfo::GetTrackerIcon(&info.ref, &bmp, B_LARGE_ICON)==B_OK) aw->SetIcon(&bmp); } aw->SetApplicationName("ImageMounter"); aw->SetVersionNumber("0.3"); aw->SetCopyrightString(B_UTF8_COPYRIGHT" by Maurice Michalski"); aw->SetText("ImageMounter is freeware.\nThanks to Brent \"misza\" Miszalski."); aw->Show(); }
void kanBeApp::handle_set_target(BMessage* msg) { BMessenger target; status_t err; err = msg->FindMessenger("target", &target); if (!err) { app_info info; GetAppInfo(&info); be_roster->ActivateApp(info.team); if (mWindow->Lock()) { mView->SetTarget(target); mWindow->Unlock(); } } }
virtual void ReadyToRun() { if (refs.HasRef("refs")) { get_ref_for_path(getcwd(NULL,0), &ref); process_refs(ref, &refs, NULL); PostMessage(B_QUIT_REQUESTED); } else { app_info info; GetAppInfo(&info); (new TrackerScriptEditorWindow(&info.ref))->Show(); } }
void MyApplication::MessageReceived(BMessage *message) { switch (message->what){ case SAVE_AUDIO: if (Pool.save_selection && Pool.selection != NONE){ save_start = Pool.pointer; // save selection save_end = Pool.r_sel_pointer; }else{ save_start = 0; // save the whole memory save_end = Pool.size; } Save(message); break; case B_SIMPLE_DATA: case B_MIME_DATA: if (Pool.size == 0){ // drop on empty is load RefsReceived(message); }else{ app_info info; GetAppInfo(&info); be_roster->Launch(info.signature, message); } break; case UPDATE_MENU: Pool.UpdateMenu(); break; case DROP_PASTE: case B_PASTE: case CHANGE_LANGUAGE: mainWindow->PostMessage(message); break; default: BApplication::MessageReceived(message); break; } }
UAE::UAE() : BApplication(kApplicationSignature) { /* Disable this for just now - it screws specifying * a config file on the command line. We need to get * OS-specific arguments in a different way. */ #if 0 // Find application directory and cwd to it app_info appInfo; GetAppInfo(&appInfo); BEntry appEntry(&appInfo.ref); BEntry appDirEntry; appEntry.GetParent(&appDirEntry); BPath appPath; appDirEntry.GetPath(&appPath); chdir(appPath.Path()); #endif RegisterMimeTypes(); // Initialize other variables fEmulationWindow = NULL; }
void ModificationsApp::ReadyToRun() { printf("Début du test.\n"); // détermination du répertoire de l'application app_info l_MyAppInfo; GetAppInfo(&l_MyAppInfo); BEntry l_Application(&l_MyAppInfo.ref); BDirectory l_AppDir; l_Application.GetParent(&l_AppDir); printf("Création du bloc mémoire..."); BMallocIO *l_MyFile = new BMallocIO; printf("OK\n"); printf("Création de la librarie..."); CSLibrary *l_MyLibrary = new CSLibrary(l_MyFile); if (l_MyLibrary->InitCheck() == B_OK) printf("OK\n"); else { printf("Erreur!\n"); return; } printf("Début du parsing.\n"); BPath l_MyPath(&l_AppDir,"Modifications.h"); status_t l_Error; while(true) { l_Error = l_MyLibrary->Parse(l_MyPath.Path(),false,0,true); switch(l_Error) { case B_OK: printf("OK!\n"); break; case CSP_NOT_MODIFIED: printf("Fichier non modifié\n"); break; default: printf("Erreur!\n"); break; } // restitution printf("Restitution.\n"); DumpClass(l_MyLibrary,"ModificationsApp"); printf("Appuyez sur une touche pour recommencer\n"); getchar(); } // destruction des objets printf("Desctruction..."); delete l_MyLibrary; delete l_MyFile; printf("Fini!\n"); Quit(); }
Shisen::Shisen(): BApplication("application/x-vnd.KWS-BShisen") { system_info info; union split sp; app_info app; #ifdef USE_YLANGUAGE Language.SetName("English"); if (Language.InitCheck() != B_OK) printf("error loading language file (English\n"); BuildLanguageList(); #endif REGISTERED = false; NAG = false; get_system_info(&info);get_system_info(&info); // if (info.id[0] && info.id[1]) // P3 ? // { // sp.i32[0] = info.id[0]; // sp.i32[1] = info.id[1]; KEY = sp.i64; // } // else // make a KEY from the CPU TYPE & the speed // { // KEY = info.cpu_clock_speed; // KEY |= info.cpu_revision; // } // sanity check if (!KEY) KEY = 0xbebebebe; //printf("key is %lx\n", KEY); /* * 1) Check the creation time * 2) Check the last accessed time * 3) subtract * if > 3 days, nag++ */ // check ~/config/settings/BShisen_prefs BPath path; BEntry entry; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK && path.Append(PREFS_FILE_NAME, true) == B_OK && entry.SetTo(path.Path(), true) == B_OK) { time_t t_t = 0; time_t c_t; if (entry.GetCreationTime(&c_t) == B_OK) { //ok, file exists. Check the creation date & see if it was > 7 days ago t_t = (time_t)real_time_clock(); if (t_t > c_t) { t_t -= c_t; // t_t == # of secs between when file was created & now if (t_t > 7 * 24 * 60 * 60) NAG = true; } } } #if 0 if (GetAppInfo(&app) == B_OK) { BEntry entry; struct stat st; time_t t_t; entry.SetTo(&app.ref, true); entry.GetStat(&st); t_t = st.st_atime - st.st_ctime; if (t_t > 5 * 24 * 60 * 60) NAG = true; } #endif game = new GameWindow; game->Show(); }
PApp::PApp() : BApplication("application/x-vnd.dw-PalEdit") { try { try { BPath settings; FailOSErr(find_directory(B_USER_SETTINGS_DIRECTORY, &settings, true)); BDirectory e; FailOSErrMsg(e.SetTo(settings.Path()), "~/config/settings directory not found ?!?!?"); if (!e.Contains("PalEdit", B_DIRECTORY_NODE)) FailOSErr(e.CreateDirectory("PalEdit", &gPrefsDir)); else { BEntry d; FailOSErr(e.FindEntry("PalEdit", &d, B_DIRECTORY_NODE)); FailOSErr(gPrefsDir.SetTo(&d)); } } catch (HErr& e) { e.DoError(); } gPrefs = new HPreferences("PalEdit/settings"); gPrefs->ReadPrefFile(); app_info ai; GetAppInfo(&ai); BEntry entry(&ai.ref); FailOSErr(gAppFile.SetTo(&entry, B_READ_ONLY)); BPath appName; FailOSErr(entry.GetPath(&appName)); BPath dir; FailOSErr(appName.GetParent(&dir)); FailOSErr(gAppDir.SetTo(dir.Path())); fOpenPanel = new BFilePanel(); FailNil(fOpenPanel); entry_ref cwd_ref; fOpenPanel->GetPanelDirectory(&cwd_ref); FailOSErr(gCWD.SetTo(&cwd_ref)); PDoc::LoadAddOns(); InitUTFTables(); SetColor(kColorLow, prf_C_Low, 0xff, 0xff, 0xff); SetColor(kColorText, prf_C_Text, 0x00, 0x00, 0x00); SetColor(kColorSelection, prf_C_Selection, 0xd1, 0xd1, 0xff); SetColor(kColorMark, prf_C_Mark, 0x00, 0x00, 0xff); SetColor(kColorKeyword1, prf_C_Keyword1, 0x00, 0x00, 0xff); SetColor(kColorKeyword2, prf_C_Keyword2, 0x00, 0x00, 0xff); SetColor(kColorComment1, prf_C_Comment1, 0x1e, 0x93, 0x1e); SetColor(kColorComment2, prf_C_Comment2, 0x1e, 0x93, 0x1e); SetColor(kColorString1, prf_C_String1, 0x7e, 0x7e, 0x7e); SetColor(kColorString2, prf_C_String2, 0x7e, 0x7e, 0x7e); SetColor(kColorNumber1, prf_C_Number1, 0x85, 0x0a, 0x48); SetColor(kColorNumber2, prf_C_Number2, 0x85, 0x0a, 0x48); SetColor(kColorOperator1, prf_C_Operator1, 0x00, 0x00, 0x00); SetColor(kColorOperator2, prf_C_Operator2, 0x00, 0x00, 0x00); SetColor(kColorSeparator1, prf_C_Separator1, 0x00, 0x00, 0x00); SetColor(kColorSeparator2, prf_C_Separator2, 0x00, 0x00, 0x00); SetColor(kColorPreprocessor1, prf_C_Preprocessor1, 0x00, 0x00, 0xff); SetColor(kColorPreprocessor2, prf_C_Preprocessor2, 0x00, 0x00, 0xff); SetColor(kColorError1, prf_C_Error1, 0xff, 0x00, 0x00); SetColor(kColorError2, prf_C_Error2, 0xff, 0x00, 0x00); SetColor(kColorIdentifierSystem,prf_C_IdentifierSystem, 0x39, 0x79, 0x79); SetColor(kColorCharConst, prf_C_CharConst, 0x7e, 0x7e, 0x7e); SetColor(kColorIdentifierUser, prf_C_IdentifierUser, 0x00, 0x00, 0x00); SetColor(kColorTag, prf_C_Tag, 0x88, 0x88, 0x88); SetColor(kColorAttribute, prf_C_Attribute, 0xff, 0x00, 0x00); SetColor(kColorUserSet1, prf_C_UserSet1, 0x00, 0x00, 0x00); SetColor(kColorUserSet2, prf_C_UserSet2, 0x00, 0x00, 0x00); SetColor(kColorUserSet3, prf_C_UserSet3, 0x00, 0x00, 0x00); SetColor(kColorUserSet4, prf_C_UserSet4, 0x00, 0x00, 0x00); SetColor(kColorInvisibles, prf_C_Invisibles, 0xC8, 0x64, 0x64); DefineInvColors(gColor[kColorSelection]); gAutoIndent = gPrefs->GetPrefInt(prf_I_AutoIndent, 1); gSyntaxColoring = gPrefs->GetPrefInt(prf_I_SyntaxColoring, 1); gSpacesPerTab = gPrefs->GetPrefInt(prf_I_SpacesPerTab, 4); gBalance = gPrefs->GetPrefInt(prf_I_BalanceWhileTyping, 1); gBlockCursor = gPrefs->GetPrefInt(prf_I_BlockCursor, 0); gFlashCursor = gPrefs->GetPrefInt(prf_I_FlashCursor, 1); gSmartBrace = gPrefs->GetPrefInt(prf_I_SmartBraces, 1); gPopupIncludes = gPrefs->GetPrefInt(prf_I_ShowIncludes, 1); gPopupProtos = gPrefs->GetPrefInt(prf_I_ShowPrototypes, 1); gPopupFuncs = gPrefs->GetPrefInt(prf_I_ShowTypes, 1); gPopupSorted = gPrefs->GetPrefInt(prf_I_SortPopup, 0); gRedirectStdErr = gPrefs->GetPrefInt(prf_I_RedirectStdErr, 1); gUseWorksheet = gPrefs->GetPrefInt(prf_I_Worksheet, 0); gRestorePosition = gPrefs->GetPrefInt(prf_I_RestorePosition, 1); gRestoreFont = gPrefs->GetPrefInt(prf_I_RestoreFont, 1); gRestoreSelection = gPrefs->GetPrefInt(prf_I_RestoreSelection, 1); gRestoreScrollbar = gPrefs->GetPrefInt(prf_I_RestoreScrollbar, 1); gRestoreCWD = gPrefs->GetPrefInt(prf_I_RestoreCwd, 1); gSavedState = gPrefs->GetPrefInt(prf_I_SavedState, 1); if (gPrefs->GetIxPrefString(prf_X_Mimetype, 0) == NULL) { gPrefs->SetIxPrefString(prf_X_Mimetype, 0, "text/plain"); gPrefs->SetIxPrefString(prf_X_Mimetype, 1, "text/html"); gPrefs->SetIxPrefString(prf_X_Mimetype, 2, "text/x-source-code"); } strcpy(gTabChar, gPrefs->GetPrefString(prf_S_TabChar, "»")); strcpy(gReturnChar, gPrefs->GetPrefString(prf_S_ReturnChar, "¬")); strcpy(gSpaceChar, gPrefs->GetPrefString(prf_S_SpaceChar, ".")); strcpy(gControlChar, gPrefs->GetPrefString(prf_S_ControlChar, "¿")); gUid = getuid(); gGid = getgid(); gRecentBufferSize = gPrefs->GetPrefInt(prf_I_RecentSize, 10); RestoreRecentMenu(); fFindDialog = DialogCreator<CFindDialog>::CreateDialog("Find", NULL, PDoc::TopWindow()); fFindDialog->Run(); InitSelectedMap(); CLanguageInterface::SetupLanguageInterfaces(); fIsQuitting = false; fPrefsDialog = NULL; CPrefOpener *prefOpener = new CPrefOpener; fPrefOpener = prefOpener->Thread(); if (gUseWorksheet) OpenWorksheet(); // prefOpener->Run(); } catch (HErr& e) { e.DoError(); exit(1); } catch(...) { beep(); exit(1); } } /* PApp::PApp */
CSumItApplication::CSumItApplication() : BApplication(kOpenSumItSignature) { #if PRERELEASE // { // time_t now, expire; // time(&now); // expire = parsedate("nov 1, 1997", now); // printf("expire at %08x\n", expire); // expire = 0x345a62f0; // if (difftime(now, expire) > 0) { // MAlert *a = new MWarningAlert("This version of sum-it has expired"); // a->Go(); // exit(1); // } // TimeLimit limit; // } #endif try { gApp = this; app_info ai; GetAppInfo(&ai); BEntry entry(&ai.ref); entry.GetPath(&gAppName); BPath dir; gAppName.GetParent(&dir); gAppDir = new BDirectory(dir.Path()); gCWD = new BDirectory(*gAppDir); gResourceManager.SetTo( &gAppName ) ; InitFunctions(); srand((int)(system_time() % INT_MAX)); try { gPrefs = new CPreferences("Sum-It.Prefs"); gPrefs->ReadPrefFile(); } catch (CErr& e) { CATCHED; if (e != errIOOpen) { e.DoError(); exit(1); } } gErrorNan = Nan(1); gRefNan = Nan(3); gCircleNan = Nan(4); gSqrtNan = Nan(5); gPowerNan = Nan(6); gValueNan = Nan(7); gDivNan = Nan(8); gAddNan = Nan(9); gFinanceNan = Nan(10); gEvalNan = Nan(11); gInvTrigNan = Nan(12); gLogNan = Nan(13); gMulNan = Nan(14); gNANan = Nan(15); gDateNan = Nan(16); gTimeNan = Nan(17); // gCellNan = Nan(18); gFuncNan = Nan(19); gNameNan = Nan(20); font_family fam; font_style sty; float siz; be_plain_font->GetFamilyAndStyle(&fam, &sty); siz = be_plain_font->Size(); gFontSizeTable.GetFontID( gPrefs->GetPrefString("defdoc font family", fam), gPrefs->GetPrefString("defdoc font style", sty), gPrefs->GetPrefDouble("defdoc font size", siz), kBlack); InitFormatter(); fOpenPanel = NULL; gClipboard = new CClipboard; gClipboard->Run(); fFindDialog = CFindDialog::Construct(); fFindDialog->Run(); gWithEqualSign = gPrefs->GetPrefInt("formula starts with equal", 0); gGridColor = gPrefs->GetPrefInt("dark gridlines") ? 10 : 6; InstallMimeType(); SetPulseRate(1000000); } catch (CErr& e) { CATCHED; e.DoError(); exit(1); } catch (...) { CATCHED; ASSERT(false); } }