/*********************************************************************** * * FUNCTION: TimTimeZoneToAscii * * DESCRIPTION: Convert the time zone passed to an ascii string. * * PARAMETERS: * timeZone -> time zone to show * localeP -> locale found in time zone to show. * stringP -> string in which to store ascii * (must fit timeZoneStringLength), * * RETURNED: nothing * * HISTORY: * 03/09/00 peter Created by Peter Epstein * 04/12/00 peter API changed to truncate to fit given width * 04/14/00 peter Add font argument * 04/27/00 peter Wait to delete form until listP is done being used * 08/01/00 kwk Modified to use time zone array. * 08/02/00 kwk Added countryInTimeZone to API. * 11/17/00 CS Change GetTimeZoneTriggerText's countryInTimeZone * parameter to localeInTimeZoneP, since CountryType is * only a UInt8, and this may change someday. * 12/11/00 peter Rename function and elminate width and font parameters * Caller should truncate and add ellipsis if needed. * ***********************************************************************/ void TimeZoneToAscii(Int16 timeZone, const LmLocaleType* localeP, Char* string) { TimeZoneEntryType* tzArrayP; UInt16 numTimeZones; MemHandle tzNamesH; Int16 timeZoneIndex; Boolean foundMatch = false; tzArrayP = PrvCreateTimeZoneArray(&tzNamesH, &numTimeZones); for (timeZoneIndex = 0; (timeZoneIndex < numTimeZones) && !foundMatch; timeZoneIndex++) { if ((tzArrayP[timeZoneIndex].tzOffset == timeZone) && (tzArrayP[timeZoneIndex].tzCountry == localeP->country)) { foundMatch = true; StrCopy(string, tzArrayP[timeZoneIndex].tzName); } } // If no match was found, display the time zone as an offset from GMT if (!foundMatch) { Char* s; SysCopyStringResource(string, UTCString); s = string + StrLen(string); // where to store offset from GMT when necessary if (timeZone != 0) { PrvOffsetToString(s, timeZone); } } PrvDeleteTimeZoneArray(tzArrayP, tzNamesH); }
/*********************************************************************** * * FUNCTION: PrvTimeZoneListDrawItem * * DESCRIPTION: Draw the itemNum item of the time zone list. Used as draw * callback routine for the time zone list object. * * PARAMETERS: * itemNum -> what item to draw * bounds -> rectangle to draw into * itemsText -> ptr to array of TimeZoneEntryType records. * * RETURNED: nothing * * HISTORY: * 03/07/00 peter initial revision * 07/31/00 kwk Modified to use TimeZoneEntryType records. * ***********************************************************************/ static void PrvTimeZoneListDrawItem(Int16 itemNum, RectanglePtr bounds, Char** itemsText) { const TimeZoneEntryType* tzList = (const TimeZoneEntryType*)itemsText; Char gmtOffset[maxGmtOffsetLength + 1]; // Skip to appropriate item to draw. tzList += itemNum; // Draw the name left-justified, and truncated. // DOLATER kwk - should we worry about the text in ZeroTimeZoneOffsetString // being wider than gmtOffsetColumnWidth? WinDrawTruncChars(tzList->tzName, StrLen(tzList->tzName), bounds->topLeft.x + descriptionColumnOffset, bounds->topLeft.y, usableListWidth - descriptionColumnOffset - gmtOffsetColumnWidth); // Draw the offset right-justified. if (tzList->tzOffset == 0) { SysCopyStringResource(gmtOffset, ZeroTimeZoneOffsetString); } else { PrvOffsetToString(gmtOffset, tzList->tzOffset); } WinDrawChars( gmtOffset, StrLen(gmtOffset), bounds->topLeft.x + usableListWidth - gmtColumnOffset - FntCharsWidth(gmtOffset, StrLen(gmtOffset)), bounds->topLeft.y); } // PrvTimeZoneListDrawItem
static void XferDoneListDrawFunc(Int16 item, RectangleType* b, Char** itemsText) { Char str[48]; const FontID old_font = FntSetFont(symbol11Font); if (d.xfer.status[d.xfer.choice_map[item]] & TRACKXFERDONE_ALWAYS) { FntSetFont(symbolFont); WinDrawChar('\23', b->topLeft.x + 3, b->topLeft.y); /* diamond */ } else if (d.xfer.status[d.xfer.choice_map[item]] & TRACKXFERDONE_CHECKED) { WinDrawChar('\01', b->topLeft.x, b->topLeft.y); /* completed checkbox */ } else { WinDrawChar('\00', b->topLeft.x, b->topLeft.y); /* empty checkbox */ } FntSetFont(old_font); SysCopyStringResource(str, XferMenuOptionsStrings + d.xfer.choice_map[item]); /* Draw the text label on the right pos (* 1.5 for HandEra) */ WinDrawChars(str, StrLen(str), b->topLeft.x + handera(15), b->topLeft.y); }
static void DrawSpecialEventForm() { FormPtr frmP; char theText[320]; frmP = FrmGetActiveForm(); setCurrentWinTitle( SpecialEvent[CURSYSTEM.Special].Title ); if (SpecialEvent[CURSYSTEM.Special].JustAMessage) { FrmHideObject( frmP, FrmGetObjectIndex( frmP, SpecialEventYesButton ) ); FrmHideObject( frmP, FrmGetObjectIndex( frmP, SpecialEventNoButton ) ); FrmShowObject( frmP, FrmGetObjectIndex( frmP, SpecialEventOKButton ) ); } else { FrmShowObject( frmP, FrmGetObjectIndex( frmP, SpecialEventYesButton ) ); FrmShowObject( frmP, FrmGetObjectIndex( frmP, SpecialEventNoButton ) ); FrmHideObject( frmP, FrmGetObjectIndex( frmP, SpecialEventOKButton ) ); } FrmDrawForm ( frmP ); SysCopyStringResource(theText, SpecialEvent[CURSYSTEM.Special].QuestStringID); DisplayPage(theText, 18); }
/* Populate list with bookmarks, return number of bookmarks in list */ static UInt16 InitBookmarkList ( ListType* list /* pointer to list */ ) { UInt16 entries; UInt16 extEntries; UInt16 extraListItems; UInt16 i; MemHandle handle; Char** nameList; UInt8* bookmarkPtr; handle = NULL; nameList = NULL; bookmarkPtr = NULL; /* default is "Add bookmark" and "View bookmarks" */ entries = 0; extraListItems = 2; extEntries = CountExtBookmarks(); handle = ReturnMetaHandle( INTERNAL_BOOKMARKS_ID, NO_PARAGRAPHS ); if ( handle != NULL ) { if ( isPopupList ) extraListItems = 2; else extraListItems = 0; bookmarkPtr = MemHandleLock( handle ); entries += GET_ENTRIES( bookmarkPtr ); bookmarkPtr += BOOKMARK_HEADER_LEN; } else { if ( ! isPopupList ) { extraListItems = 0; if ( extEntries == 0 ) { LstSetListChoices( list, nameList, NO_BOOKMARKS ); LstSetDrawFunction( list, DrawListItem ); return NO_BOOKMARKS; } } } entries += extraListItems + extEntries; /* Allocate arrays for name list */ nameListHandle = MemHandleNew( entries * sizeof( *nameList ) ); if ( nameListHandle == NULL ) { if ( extraListItems < entries - extEntries ) MemHandleUnlock( handle ); return NO_BOOKMARKS; } nameList = MemHandleLock( nameListHandle ); if ( isPopupList ) { SysCopyStringResource( addBookmark, strMainAddBookmark ); nameList[ ADD_BOOKMARK ] = addBookmark; SysCopyStringResource( editBookmark, strMainViewBookmark ); nameList[ EDIT_BOOKMARK ] = editBookmark; } if ( 0 < extEntries ) InitExtBookmarkList( nameList, extraListItems ); if ( handle != NULL ) { for ( i = extraListItems + extEntries; i < entries; i++ ) { nameList[ i ] = bookmarkPtr; bookmarkPtr += StrLen( bookmarkPtr ) + 1; } } LstSetListChoices( list, nameList, entries ); LstSetDrawFunction( list, DrawListItem ); if ( isPopupList ) LstSetHeight( list, entries ); if ( extraListItems < entries - extEntries ) MemHandleUnlock( handle ); return entries; }
/* ** TrackXferDone */ static void TrackXferDone(DynamicButtonType* btn) { RectangleType bounds[5], frame, popFrame, popShadowFrame; Boolean penDown, on_button; Int16 x, y, clicked_on = 0; Int16 state = 1; Int16 i = 0; WinHandle offscreenH = NULL; FormType* frm = FrmGetActiveForm(); const UInt16 listIdx = FrmGetObjectIndex(frm, XferDoneList); ListType* list = FrmGetObjectPtr(frm, listIdx); UInt16 width = 0, choices = 0; Err err = errNone; Char str[48]; Int16 n = 0; /* Save the old drawing context */ WinPushDrawState(); /* This should match the XferDoneButton bounds */ FrmGetObjectBounds(frm, FrmGetObjectIndex(frm, btn->id), &bounds[0]); /* Invert the done button */ SelectAndDrawButton(btn, true); SndPlaySystemSound(sndClick); /* Set the status of each menu pick */ for (; i < 4; i++) d.xfer.status[i] = 0x00; if (xferGotoIsAlways) d.xfer.status[0] = TRACKXFERDONE_ALWAYS; else if (xferGotoIsNever) d.xfer.status[0] = TRACKXFERDONE_NEVER; else if (p.flags&PFLAGS_XFER_GOTO) d.xfer.status[0] = TRACKXFERDONE_CHECKED; if (xferCompleteIsAlways) d.xfer.status[1] = TRACKXFERDONE_ALWAYS; else if (xferCompleteIsNever) d.xfer.status[1] = TRACKXFERDONE_NEVER; else if (d.xfer.complete) d.xfer.status[1] = TRACKXFERDONE_CHECKED; if (!d.linker_available) d.xfer.status[2] = TRACKXFERDONE_NEVER; else if (p.flags&PFLAGS_XFER_BACKLINK) d.xfer.status[2] = TRACKXFERDONE_CHECKED; if (p.flags&PFLAGS_XFER_DELETE) d.xfer.status[3] = TRACKXFERDONE_CHECKED; for (i = 0; i < 4; ++i) { if (!(d.xfer.status[i] & TRACKXFERDONE_NEVER)) { d.xfer.choice_map[choices] = i; ++choices; /* calculate list width */ SysCopyStringResource(str, XferMenuOptionsStrings + i); n = FntCharsWidth(str, StrLen(str)); width = Max(width, n); } } LstSetDrawFunction(list, XferDoneListDrawFunc); LstSetListChoices(list, 0, choices); LstSetHeight(list, Min(choices, 10)); FrmGetObjectBounds(frm, listIdx, &frame); frame.topLeft.y = 144 - frame.extent.y - 1; /* -1 to compensate for white border */ frame.extent.x = width + 15 + 6; FrmSetObjectBounds(frm, listIdx, &frame); WinGetFramesRectangle(popupFrame, &frame, &popFrame); WinGetFramesRectangle(rectangleFrame, &popFrame, &popShadowFrame); for (i = 0; i < choices; ++i) RctSetRectangle(&bounds[i+1], frame.topLeft.x, frame.topLeft.y + 10 * i, frame.extent.x, 10); /* Save the bits of the whole menu */ offscreenH = WinSaveBits(&popShadowFrame, &err); if (err) abort(); /* None selected */ LstSetSelection(list, -1); FrmShowObject(frm, listIdx); WinEraseRectangle(&popShadowFrame, 0); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); do { EvtGetPen(&x, &y, &penDown); if (!state || !RctPtInRectangle(x, y, &bounds[state-1])) { on_button = false; for (i = 1; i <= choices + 1; i++) { if ((state != i) && RctPtInRectangle(x, y, &bounds[i-1])) { /* Invert the new state */ LstSetSelection(list, i - 2); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); SelectAndDrawButton(btn, i == 1); state = i; on_button = true; } } if (state && !on_button) { /* Moved off the current button */ LstSetSelection(list, -1); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); if (state == 1) SelectAndDrawButton(btn, false); state = 0; } } } while (penDown); FrmHideObject(frm, listIdx); LstEraseList(list); /* Restore the framed rect */ WinRestoreBits(offscreenH, popShadowFrame.topLeft.x, popShadowFrame.topLeft.y); /* Unselect the button */ SelectAndDrawButton(btn, false); /* Finish up if we just tapped the button */ if (RctPtInRectangle(x, y, &bounds[0])) { FinishXferMode(); /* Restore the old draw state */ WinPopDrawState(); return; } /* Change the setting for goto or delete */ for (i = 1; i <= choices; i++) { if (RctPtInRectangle(x, y, &bounds[i])) { clicked_on = i; break; } } if (clicked_on) clicked_on = d.xfer.choice_map[clicked_on-1] + 1; switch (clicked_on) { case 1: /* Goto */ if (d.xfer.status[0] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_GOTO; else if (!d.xfer.status[0]) p.flags |= PFLAGS_XFER_GOTO; break; case 2: /* Complete */ if (d.xfer.status[1] & TRACKXFERDONE_CHECKED) d.xfer.complete = false; else if (!d.xfer.status[1]) d.xfer.complete = true; break; case 3: /* BackLink */ if (d.xfer.status[2] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_BACKLINK; else if (!d.xfer.status[2]) { p.flags |= PFLAGS_XFER_BACKLINK; p.flags &= ~PFLAGS_XFER_DELETE; /* No delete if backlink */ } break; case 4: /* Delete */ if (d.xfer.status[3] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_DELETE; else if (!d.xfer.status[3]) { p.flags |= PFLAGS_XFER_DELETE; p.flags &= ~PFLAGS_XFER_BACKLINK; /* No backlink if delete */ } break; } /* Click and redraw the button */ if (clicked_on) { DrawXferDoneButton(btn); DynBtnDraw(btn); if (d.xfer.status[clicked_on-1] & TRACKXFERDONE_ALWAYS) SndPlaySystemSound(sndWarning); else SndPlaySystemSound(sndClick); } /* Restore the old draw state */ WinPopDrawState(); }
Boolean Ln2SlFormHandleEvent(EventPtr e) { Boolean handled = false; DateType dt = {0, 0}; FormPtr frm = FrmGetFormPtr(Ln2SlForm); switch (e->eType) { case frmOpenEvent: if(gbVgaExists) VgaFormModify(frm, vgaFormModify160To240); DateSecondsToDate(TimGetSeconds(), &dt); DateToAsciiLong(dt.month, dt.day, dt.year + 1904, gPrefdfmts, gAppErrStr); SetFieldTextFromStr(Ln2SlFormInput, gAppErrStr); FrmDrawForm(frm); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case Ln2SlFormOk: FrmReturnToForm(0); handled = true; break; case Ln2SlFormConvert: { HappyDaysFlag dummy; Int16 year, month, day; Char* input; int ret; input = FldGetTextPtr(GetObjectPointer(frm, Ln2SlFormInput)); if ((ret = AnalysisHappyDays(input, &dummy, &year, &month, &day))) { int syear, smonth, sday; int leapyes = CtlGetValue(GetObjectPointer(frm, Ln2SlFormInputLeap)); ret = lunarL2S(lunarRefNum, year, month, day, leapyes, &syear, &smonth, &sday); if (ret == errNone) { Char temp[15]; SysCopyStringResource(temp, DayOfWeek(smonth, sday, syear) + SunString); DateToAsciiLong(smonth, sday, syear, gPrefdfmts, gAppErrStr); StrNCat(gAppErrStr, " [", AppErrStrLen); StrNCat(gAppErrStr, temp, AppErrStrLen); StrNCat(gAppErrStr, "]", AppErrStrLen); FldDrawField(SetFieldTextFromStr(Ln2SlFormResult, gAppErrStr)); } else DisplayInvalidDateErrorString(Ln2SlFormResult); } else { DisplayInvalidDateErrorString(Ln2SlFormResult); } handled = true; break; } default: break; } break; case menuEvent: handled = TextMenuHandleEvent(e->data.menu.itemID, Ln2SlFormInput); break; default: break; } return handled; }
static void DisplayInvalidDateErrorString(UInt16 id) { FldDrawField(ClearFieldText(Ln2SlFormResult)); SysCopyStringResource(gAppErrStr, InvalidDateString); FrmCustomAlert(ErrorAlert, gAppErrStr, " ", " "); }
/* Populate list with bookmarks, return number of bookmarks in list */ static UInt16 InitBookmarkList ( ListType* list /* pointer to list */ ) { UInt16 recordNum; UInt16 numRecords; UInt16 extEntries; UInt16 bookmarks; UInt16 extraListItems; UInt16 index; UInt16 i; if ( isPopupList ) { #ifdef SUPPORT_ANNOTATION extraListItems = 3; #else extraListItems = 2; #endif } else { extraListItems = 0; } ReleaseBookmarkList(); extEntries = CountExtBookmarks(); bookmarks = CountBookmarks(); numRecords = GetNumberOfAnnotations(); numEntries = extraListItems + extEntries + bookmarks; if ( numEntries == 0 ) { LstSetListChoices( list, nameList, NO_BOOKMARKS ); LstSetDrawFunction( list, DrawListItem ); return NO_BOOKMARKS; } bookmarkList = SafeMemPtrNew( numEntries * sizeof( BookmarkListEntry* ) ); for ( i = 0 ; i < numEntries ; i++ ) { bookmarkList[ i ] = SafeMemPtrNew( sizeof( BookmarkListEntry ) ); MemSet( bookmarkList[ i ], sizeof( BookmarkListEntry ), 0 ); } /* Allocate arrays for name list */ nameList = SafeMemPtrNew( numEntries * sizeof( Char* ) ); if ( isPopupList ) { SysCopyStringResource( addBookmark, strMainAddBookmark ); nameList[ ADD_BOOKMARK ] = addBookmark; bookmarkList[ ADD_BOOKMARK ]->kind = BOOKMARK_ADD_BOOKMARK; #ifdef SUPPORT_ANNOTATION SysCopyStringResource( addAnnotation, strMainAddAnnotation ); nameList[ ADD_ANNOTATION ] = addAnnotation; bookmarkList[ ADD_ANNOTATION ]->kind = BOOKMARK_ADD_ANNOTATION; #endif SysCopyStringResource( editBookmark, strMainViewBookmark ); nameList[ EDIT_BOOKMARK ] = editBookmark; bookmarkList[ EDIT_BOOKMARK ]->kind = BOOKMARK_EDIT_BOOKMARK; } if ( 0 < extEntries ) { InitExtBookmarkList( nameList, extraListItems ); for ( i = extraListItems ; i < extraListItems + extEntries ; i++ ) { bookmarkList[ i ]->kind = BOOKMARK_EXT_BOOKMARK; bookmarkList[ i ]->recordNum = i - extraListItems; } } index = extraListItems + extEntries; for ( recordNum = 0 ; recordNum < numRecords && index < numEntries ; recordNum++ ) { MemHandle h; h = GetAnnotationByRecordNum( recordNum ); if ( h != NULL ) { AnnotationEntry* entryP; entryP = MemHandleLock( h ); if ( 1 < entryP->dataLength && ! ( ! ( entryP->flags & ANNOTATION_BOOKMARK ) && Prefs()->noAnnotationsInBookmarkList ) ) { UInt32 labelSize; labelSize = entryP->dataLength - 1; if ( MAX_BOOKMARK_ENTRY_LENGTH < labelSize ) labelSize = MAX_BOOKMARK_ENTRY_LENGTH; bookmarkList[ index ]->text = MemPtrNew( labelSize + 1 ); if ( bookmarkList[ index ]->text != NULL ) { bookmarkList[ index ]->kind = ( entryP->flags & ANNOTATION_BOOKMARK ) ? BOOKMARK_BOOKMARK : BOOKMARK_ANNOTATION; bookmarkList[ index ]->recordNum = recordNum; StrNCopy( bookmarkList[ index ]->text, ( Char* )entryP + entryP->dataOffset, labelSize + 1 ); bookmarkList[ index ]->text[ labelSize ] = 0; nameList[ index ] = bookmarkList[ index ]->text; index++; } } MemHandleUnlock( h ); } } numEntries = index; LstSetListChoices( list, nameList, numEntries ); LstSetDrawFunction( list, DrawListItem ); if ( isPopupList ) LstSetHeight( list, numEntries ); return numEntries; }
void OpenTransliterations( void ) { DmSearchStateType stateInfo; Err err; UInt16 i; UInt16 cardNo; LocalID dbID; Char temp[ 100 ]; XlitEntry* entry; if ( alreadyOpened ) return; alreadyOpened = true; numXlits = 0; xlitDataList = ListCreate(); err = DmGetNextDatabaseByTypeCreator( true, &stateInfo, (UInt32) XlitDBType, (UInt32) ViewerAppID, false, &cardNo, &dbID ); while ( err == errNone ) { ProcessXlitDB( cardNo, dbID ); err = DmGetNextDatabaseByTypeCreator( false, &stateInfo, (UInt32) SkinResourceType, (UInt32) ViewerAppID, false, &cardNo, &dbID ); } if ( 0 < numXlits ) { xlitData = SafeMemPtrNew( sizeof( XlitEntry ) * numXlits ); i = 0; entry = ListFirst( xlitDataList ); while ( entry != NULL ) { xlitData[ i++ ] = *entry; SafeMemPtrFree( entry ); entry = ListNext( xlitDataList, entry ); } SysInsertionSort( xlitData, numXlits, sizeof( XlitEntry ), XlitCompare, 0 ); } ListDelete( xlitDataList ); xlitNames = SafeMemPtrNew( ( numXlits + 1 ) * sizeof( Char* ) ); SysCopyStringResource( temp, strNoTransliteration ); xlitNames[ 0 ] = SafeMemPtrNew( 1 + StrLen( temp ) ); StrCopy( xlitNames[ 0 ], temp ); for ( i = 1 ; i < numXlits + 1 ; i++ ) { Char* name; name = xlitData[ i - 1 ].header->name; xlitNames[ i ] = SafeMemPtrNew( 1 + StrLen( name ) ); StrCopy( xlitNames[ i ], name ); } }
/** * @brief Read the happydays information from address db, and insert into Happydays DB * @param frm StartForm to display indicator bars * @return If success, return true, or return false */ Boolean NewUpdateHappyDaysDB(FormPtr frm) { UInt16 currIndex = 0; PrvAddrPackedDBRecord *rp; AddrDBRecordType r; MemHandle recordH = 0; UInt16 recordNum; int i = 0, indicateNext; int step; // create the happydays cache db HappyDays hd; Boolean ignore = false; // ignore error record Char* hdField; UInt16 addrattr, index; Char *p, *q, *end; Int16 err; // display collecting information // FrmDrawForm(frm); // clean up old database // CleanupHappyDaysCache(MainDB); recordNum = DmNumRecords(AddressDB); indicateNext = step = recordNum / INDICATE_NUM; if (recordNum > 50) initIndicate(); while (1) { char *name1, *name2; Int8 whichField; // birthday field or note field? recordH = DmQueryNextInCategory(AddressDB, &currIndex, dmAllCategories); if (!recordH) break; if (i++ == indicateNext) { if (recordNum > 50) displayNextIndicate( (i-1) / step); indicateNext += step; } DmRecordInfo(AddressDB, currIndex, &addrattr, NULL, NULL); addrattr &= dmRecAttrCategoryMask; // get category info rp = (PrvAddrPackedDBRecord*)MemHandleLock(recordH); /* * Build the unpacked structure for an AddressDB record. It * is just a bunch of pointers into the rp structure. */ NewAddrUnpack(rp, &r); if ( (gHappyDaysField <= 0 || !r.fields[gHappyDaysField]) // there is no birthday info(trick. should check flags, but I think it is ok) // && DateToInt(r.birthdayInfo.birthdayDate) == 0 && !(gPrefsR.scannote && r.fields[note] && StrStr(r.fields[note], gPrefsR.notifywith) ) ) { // If there is not exist Happydays field or note field, or internal birthday field(in NEW PIMS) // MemHandleUnlock(recordH); currIndex++; continue; } MemSet(&hd, sizeof(hd), 0); hd.addrRecordNum = currIndex; if (DetermineRecordName(&r, gSortByCompany, &hd.name1, &hd.name2)) { // name 1 has priority; hd.flag.bits.priority_name1 = 1; } // =========================================================== // Process Birthday field first // =========================================================== if (DateToInt(r.birthdayInfo.birthdayDate) != 0) { hd.date = r.birthdayInfo.birthdayDate; hd.flag.bits.year = 1; hd.flag.bits.solar = 1; // maintain address book order(name order) // list order is determined by sort err = HDNewRecord(MainDB, &hd, &index); if (!err) { UInt16 attr; // set the category of the new record to the category // it belongs in DmRecordInfo(MainDB, index, &attr, NULL, NULL); attr &= ~dmRecAttrCategoryMask; attr |= addrattr; DmSetRecordInfo(MainDB, index, &attr, NULL); DmReleaseRecord(MainDB, index, true); } } // =========================================================== // save the temporary name name1 = hd.name1; name2 = hd.name2; if (gHappyDaysField >= 0 && r.fields[gHappyDaysField]) { whichField = gHappyDaysField; } else if (gPrefsR.scannote // scanNote & exists && r.fields[note] && StrStr(r.fields[note], gPrefsR.notifywith)) { whichField = note; } else whichField = -1; while (whichField >= 0) { if (whichField == note) { p = StrStr(r.fields[note], gPrefsR.notifywith) + StrLen(gPrefsR.notifywith) + 1; if ( StrLen(r.fields[note]) < (p - r.fields[note]) ) break; } else { p = r.fields[whichField]; } hdField = MemPtrNew(StrLen(r.fields[whichField]) - (p - r.fields[whichField])+1); SysCopyStringResource(gAppErrStr, NotEnoughMemoryString); ErrFatalDisplayIf(!hdField, gAppErrStr); p = StrCopy(hdField, p); if (whichField == note && (end = StrStr(p, gPrefsR.notifywith))) { // end delimeter // *end = 0; } while ((q = StrChr(p, '\n'))) { // multiple event // *q = 0; if (AnalizeOneRecord(addrattr, p, &hd, &ignore)) goto Update_ErrHandler; p = q+1; // restore the saved name hd.name1 = name1; hd.name2 = name2; // reset multiple flag hd.flag.bits.multiple_event = 0; while (*p == ' ' || *p == '\t' || *p == '\n') p++; // skip white space } // last record if (*p) { // check the null '\n' if (AnalizeOneRecord(addrattr, p, &hd, &ignore)) goto Update_ErrHandler; } if (whichField == gHappyDaysField // next is note field && (gPrefsR.scannote // scanNote & exists && r.fields[note] && StrStr(r.fields[note], gPrefsR.notifywith)) ) { whichField = note; } else whichField = -1; MemPtrFree(hdField); } MemHandleUnlock(recordH); currIndex++; } if (recordNum > 50) displayNextIndicate( INDICATE_NUM -1); return true; Update_ErrHandler: MemPtrFree(hdField); MemHandleUnlock(recordH); return false; }