1 /* 2 =============================================== 3 Project: BeFar 4 File: BF_BetaTesting.cpp 5 Desc: Provides functions for checking and setting beta-testing mode 6 Author: Baza 7 Created: 20.11.99 8 Modified: 20.11.99 9 =============================================== 10 */ 11 12 13 #include <Application.h> 14 #include <InterfaceKit.h> 15 #include <Window.h> 16 #include <StorageKit.h> 17 #include <Roster.h> 18 19 #include "BF_Roster.h" 20 #include "BF_BetaTesting.h" 21 #include "BF_GUI_WinMain.h" 22 #include "BF_Msg.h" 23 #include "BF_GUI_Func.h" 24 #include "BF_GUI_DlgViews.h" 25 #include "BF_GUI_Setup.h" 26 27 uint32 iBetaTestingStatus=BF_BETATEST_OK; 28 #define BETA_FILE (const char*)"beta.settings" 29 30 31 void 32 BF_BetaTesting_InitStatus() /* */ 33 { 34 /* 35 if(B_OK!=BF_Roster_MakeDir(BEFAR_SETTINGS_DIR)){ 36 BF_Dialog_Alert_Sep("can`t make settings dir","",NULL,poWin->CurrentFocus()); 37 return; 38 } 39 // check first step 40 { 41 BL_String s; 42 s=BEFAR_SETTINGS_DIR; 43 s<< BETA_FILE; 44 status_t uRes; 45 BEntry oConfigEntry(s.String()); 46 if(B_OK!=oConfigEntry.InitCheck() || !oConfigEntry.Exists()){ 47 // ok...make first step... 48 { 49 // create config file 50 BFile oConfigFile(&oConfigEntry,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); 51 uRes = oConfigFile.InitCheck(); 52 if(B_OK!=uRes){ 53 Debug_Error("ups.I can`t create config file ",uRes); 54 iBetaTestingStatus = BF_BETATEST_QUIT; 55 return ; 56 } 57 } 58 // open intro doc 59 { 60 app_info uAppInfo; 61 be_app->GetAppInfo(&uAppInfo); 62 BEntry oEntry(&uAppInfo.ref); 63 oEntry.GetParent(&oEntry); 64 BPath oPath; 65 oEntry.GetPath(&oPath); 66 67 BL_String s(oPath.Path()); 68 s<<"/doc_beta_start.txt"; 69 70 BEntry oTextFile(s.String()); 71 uRes = BF_Roster_RunEntry(oTextFile); 72 iBetaTestingStatus = BF_BETATEST_QUIT; 73 if(uRes!=B_OK) Debug_Error("ups.I can`t run doc_beta_start.txt",uRes); 74 } 75 return ; 76 } 77 // check key 78 { 79 // open file 80 BFile oConfigFile(&oConfigEntry,B_READ_WRITE); 81 int32 iVersion; 82 // read attr 83 ssize_t iCount = oConfigFile.ReadAttr("beta_version",B_INT32_TYPE,0,(void*)&iVersion,sizeof(int32)); 84 if(iCount<=0){ 85 iBetaTestingStatus = BF_BETATEST_ASK_KEY; 86 return; 87 } 88 89 } 90 } 91 */ 92 } 93 94 void 95 BF_BetaTesting_CheckKey_Start(BView * po_ViewOwner) /* */ 96 { 97 /* 98 // disable panels 99 BF_GUI_Func_PanelsEnable(false); 100 // 101 BMessage oMessage(BF_MSG_FILEPANEL_BETATEST_INPUTPASSWORD); 102 oMessage.AddPointer("bf_focus",(void*)po_ViewOwner); 103 // 104 // make dialog 105 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0), 106 "Input betatest code","dialog",&oMessage,B_FOLLOW_NONE); 107 BRect oRect; 108 // insert edit 109 poDialog->LocalBounds(oRect); 110 oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight; 111 BF_GUI_ViewEdit *poEdit = new BF_GUI_ViewEdit(oRect,"edit", 112 "",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE); 113 poDialog->AddChild(poEdit); 114 // finish 115 poDialog->SetHeightFromLastChild(); 116 poDialog->MoveToCenter( poWinView ); 117 BF_GUI_Func_AddChildToMainView(poDialog); 118 */ 119 } 120 121 122 void 123 BF_BetaTesting_CheckKey_Finish(char *pc_Key) /* */ 124 { 125 /* 126 // check key 127 if(strcmp(pc_Key,"parol")==0){ 128 iBetaTestingStatus = BF_BETATEST_OK; 129 130 if(B_OK!=BF_Roster_MakeDir(BEFAR_SETTINGS_DIR)){ 131 BF_Dialog_Alert_Sep("can`t make settings dir","",NULL,poWin->CurrentFocus()); 132 return; 133 } 134 135 BL_String s; 136 s=BEFAR_SETTINGS_DIR; 137 s<< BETA_FILE; 138 139 BEntry oConfigEntry(s.String()); 140 if(B_OK==oConfigEntry.InitCheck() && oConfigEntry.Exists()){ 141 BFile oConfigFile(&oConfigEntry,B_READ_WRITE); 142 int32 iVersion = 1; 143 oConfigFile.WriteAttr("beta_version",B_INT32_TYPE,0,(void*)&iVersion,sizeof(int32)); 144 return; 145 } 146 } 147 // bad key, exit 148 { 149 Debug_Error("Wrong key",B_ERROR); 150 exit(-1); 151 return; 152 } 153 */