static void FormOpen (void) { FormGadgetType *notelistGadget = GetObjectFromActiveForm (ID_EditorNoteListGadget); FormGadgetType *midekeysGadget = GetObjectFromActiveForm (ID_EditorMidiKeysGadget); notelist_init(¬elist, notelistGadget); midikeys_init(&midikeys, midekeysGadget); SetFieldTextFromStr (ID_EditorNameField, &EditorMidi.name[0]); if (EditorMidi.dbID != 0) LoadSMF(EditorMidi, ¬elist); SeekScrollBar(SCL_BEGIN); FormUpdate(); }
static void SeekScrollBar(scl_seek_t to) { static Int16 pageSize = -1; Int16 scroll_max; if (pageSize == -1) pageSize = notelist.rect.extent.y/FntCharHeight(); scroll_max = (notelist.num > pageSize)? notelist.num - pageSize : 0; notelist.firstDisplaying = (to == SCL_BEGIN)? 0 : scroll_max; SclSetScrollBar (GetObjectFromActiveForm(ID_EditorNoteScrollBar), notelist.firstDisplaying /*pos*/, 0 /*min*/, scroll_max, pageSize); }
/******************************************************************************** * Description: this is the function responsible for checking the * input password value of the authentication form. * ******************************************************************************/ static void checkPassword (void) { MemPtr pass1, scratch = NULL; char *input; UInt16 index = 0; MemHandle rec; mdKey in; ListType *list; // compact text and get a pointer. FldCompactText (GetObjectFromActiveForm (PasswordField)); input = FldGetTextPtr (GetObjectFromActiveForm (PasswordField)); list = GetObjectFromActiveForm (selPopupList); // if SysPass is defined, free it. this happens when Strip locks // itself after the timeout. if (SysPass) MemPtrFree (SysPass); // if its the first time the user has used the program we need // to set some things up. if (input && StrLen (input)) { // read the password from the database, decrypt with the input text. if ((rec = DmQueryRecord (PasswordDB, index))) { pass1 = MemHandleLock (rec); if ((scratch = MemPtrNew (24))) { UInt16 chk = LstGetSelection (list); //printf("%d\n", LstGetSelection(list)); switch (chk) { case 0: UnpackPassword_old (pass1, scratch, input, 1); break; case 1: UnpackPassword_old (pass1, scratch, input, 2); break; case 2: UnpackPassword_old (pass1, scratch, input, 0); break; } } MemHandleUnlock (rec); } // the message digest of the password they provided should be exactly the // same as the message digest that was just decrypted out of the password // database. Do a MemCmp to make sure they are the same. md5_string (input, in); if ((!MemCmp (in, scratch, 16)) && input) { // if so, copy the password onto the system-password if ((SysPass = MemPtrNew (StrLen (input) + 1))) StrCopy (SysPass, input); if (scratch) MemPtrFree (scratch); md_string(SysPass, NewSysPass); cryptSwitch (LstGetSelection (list)); } else { // FAILURE!!!!!! // free the memory and tell the user they entered the wrong password. FieldType *fld = GetObjectFromActiveForm (PasswordField); FrmCustomAlert (GenericError, "The password you entered is incorrect", NULL, NULL); FldSetSelection (fld, 0, FldGetTextLength (fld)); LstDrawList (list); if (scratch) { MemPtrFree (scratch); SysPass = NULL; } } } // null string is always wrong!!! else { FrmCustomAlert (GenericError, "You forgot to enter a password!!", NULL, NULL); LstDrawList (list); } }