void ns_planed_get_second_point ( const NsPlaned *plane, const NsPoint3d *P1, NsPoint3d *P2 ) { NsVector3d P3; NsVector3d CP; NsVector3d T; ns_assert( NULL != plane ); ns_assert( NULL != P1 ); ns_assert( NULL != P2 ); /* Displace P1 by the smallest component of the normal(a new point P3) and take cross product N x P3-P1 to get a vector parallel to the plane. Add this vector to P1 to get a point on the plane P2. (P2) (P3) \ / CP \ / \ / (P1)------- N */ ns_vector3d( &T, NS_ABS( plane->N.x ), NS_ABS( plane->N.y ), NS_ABS( plane->N.z ) ); P3 = *P1; if( T.x < T.y ) { if( T.x < T.z ) P3.x += 1.0; else P3.z += 1.0; } else if( T.y < T.z ) P3.y += 1.0; else P3.z += 1.0; /* P2 = P1 + ( N x ( P3 - P1 ) ) */ ns_vector3d_add( P2, P1, ns_vector3d_cross( &CP, &plane->N, ns_vector3d_sub( &T, &P3, P1 ) ) ); }
NS_IMETHODIMP nsMsgBrkMBoxStore::IsSummaryFileValid(nsIMsgFolder *aFolder, nsIMsgDatabase *aDB, bool *aResult) { NS_ENSURE_ARG_POINTER(aFolder); NS_ENSURE_ARG_POINTER(aDB); NS_ENSURE_ARG_POINTER(aResult); // We only check local folders for db validity. nsCOMPtr<nsIMsgLocalMailFolder> localFolder(do_QueryInterface(aFolder)); if (!localFolder) { *aResult = true; return NS_OK; } nsCOMPtr<nsIFile> pathFile; nsresult rv = aFolder->GetFilePath(getter_AddRefs(pathFile)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDBFolderInfo> folderInfo; rv = aDB->GetDBFolderInfo(getter_AddRefs(folderInfo)); NS_ENSURE_SUCCESS(rv, rv); uint64_t folderSize; uint32_t folderDate; int32_t numUnreadMessages; *aResult = false; folderInfo->GetNumUnreadMessages(&numUnreadMessages); folderInfo->GetFolderSize(&folderSize); folderInfo->GetFolderDate(&folderDate); int64_t fileSize = 0; uint32_t actualFolderTimeStamp = 0; GetMailboxModProperties(aFolder, &fileSize, &actualFolderTimeStamp); if (folderSize == fileSize && numUnreadMessages >= 0) { if (!folderSize) { *aResult = true; return NS_OK; } if (!gGotGlobalPrefs) { nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (pPrefBranch) { rv = pPrefBranch->GetIntPref("mail.db_timestamp_leeway", &gTimeStampLeeway); gGotGlobalPrefs = true; } } // if those values are ok, check time stamp if (gTimeStampLeeway == 0) *aResult = folderDate == actualFolderTimeStamp; else *aResult = NS_ABS((int32_t) (actualFolderTimeStamp - folderDate)) <= gTimeStampLeeway; } return NS_OK; }