OP_STATUS PageBasedAutocompleteItem::GetItemData(OpTreeModelItem::ItemData* item_data) { switch (item_data->query_type) { case INIT_QUERY: { SetColumnsWidths(item_data); RETURN_IF_ERROR(GetFlags(item_data)); break; } case COLUMN_QUERY: { if (item_data->column_query_data.column == 0) { item_data->column_query_data.column_indentation = ICON_COLUMN_INDENTATION; } RETURN_IF_ERROR(GetContents(item_data)); break; } case ASSOCIATED_IMAGE_QUERY: { if (m_search_type == HISTORY || m_search_type == PAGE_CONTENT) { RETURN_IF_ERROR(item_data->associated_image_query_data.image->Set("Speeddial Close")); } break; } case SKIN_QUERY: { item_data->skin_query_data.skin = "Address Bar Drop Down Item"; break; } } return OpStatus::OK; }
/// Fetches contents of this file. String File::GetContents() { /// Contains the LastModified time when we last accessed this file. editTimeWhenReadLast; assert(LastModified(editTimeWhenReadLast)); return GetContents(path); }
// --------------------------------------- bool MTRecord::FormatShortMailDescription(std::string & str_output) { OTString strDescription; if (IsMail()) { if (!HasContents()) strDescription.Set("(empty message)"); else { std::string str_contents = GetContents(); if (str_contents.compare(0,8,"Subject:") == 0) { // Make the replacement. str_contents.replace(0, 8, ""); } // ----------------------------------- bool bTruncated = false; if (str_contents.size() > 30) { str_contents.erase(30, std::string::npos); bTruncated = true; } // ----------------------------------- strDescription.Format("\"%s%s\"", OTString::trim(str_contents).c_str(), bTruncated ? "..." : ""); } } // ----------------------------- str_output = strDescription.Get(); // ----------------------------- return (!str_output.empty()); }
/// Fetches contents from file in form of lines. (\r\n removed and used as tokenizers) List<String> File::GetLines() { String contents = GetContents(path); assert(LastModified(editTimeWhenReadLast)); List<String> lines = contents.GetLines(); return lines; }
ULONG CExMapi::GetContactCount() { BOOL doLog = m_pCtrl->IsEnableLog(); if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotactCount START:"); m_logHelper.LogPAB(L"------------------------------------"); } ULONG count = 0; LPMAPIFOLDER pFolder = NULL; LPMAPITABLE lpMsgStoreTable = NULL; lpMsgStoreTable = GetMessageStoresTable(); CString strFolder; int msgStoreCount = 0; wchar_t buffer[5]; while(OpenNextMessageStore(lpMsgStoreTable)) { //pFolder = GetContactCount(OpenRootFolder(),count); msgStoreCount++; _itow(msgStoreCount,buffer,10); if(doLog) { if(msgStoreCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Message Store No : "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } pFolder = OpenContacts(); if(pFolder && IsContactFolder(pFolder)) { strFolder = GetFolderName(pFolder); if(GetContents(pFolder)) { count += GetRowCount(); } pFolder = GetContactCount(pFolder,count,doLog); } if(m_pCtrl->IsPABContactCoutningAbort()) break; __recursionCount = 0; } if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotactCount END:"); m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.ClosePABLog(); } __recursionCount = 0; RELEASE(lpMsgStoreTable); return count; }
std::string PDFImageObject::ObjectEntry() { // if ( !ImageLen() ) // buffer = ObjectHeader(); buffer += "<<\r"; buffer += "/Type /XObject\r"; buffer += "/Subtype /Image\r"; buffer += "/Name /"; buffer += GetImageName(); buffer += "\r"; buffer += "/Width "; buffer += GetWidth(); buffer += "\r"; buffer += "/Height "; buffer += GetHeight(); buffer += "\r"; buffer += "/BitsPerComponent "; buffer += GetBitsPerComponent(); buffer += "\r"; buffer += "/ColorSpace "; // buffer += GetColorSpace(); // buffer += "\r"; buffer += GetColorSpaceObjIdStr(); if ( !GetFilter().empty() ) { buffer += "/Filter "; buffer += GetFilter(); buffer += "\r"; } buffer += "/Length "; if ( !ImageLen() ) buffer += intToStr( imageData.length() ); else buffer += intToStr( imageLen ); buffer += "\r"; buffer += ">>\r"; buffer += "stream\r"; if ( !ImageLen() ) { buffer += imageData; buffer += "\r% Trev2\rendstream\r"; } AddContents( buffer ); if ( !ImageLen() ) return PDFBodyObject::ObjectEntry(); else return GetContents(); }
long MTRecord::GetInitialPaymentAmount() { if (!IsPaymentPlan()) return 0; OTPaymentPlan thePlan; const OTString strPlan(GetContents().c_str()); if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment()) return thePlan.GetInitialPaymentAmount(); return 0; }
bool MTRecord::HasPaymentPlan() { if (!IsPaymentPlan()) return false; OTPaymentPlan thePlan; const OTString strPlan(GetContents().c_str()); if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan()) return true; return false; }
int MTRecord::GetMaximumNoPayments() { if (!IsPaymentPlan()) return 0; OTPaymentPlan thePlan; const OTString strPlan(GetContents().c_str()); if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan()) return thePlan.GetMaximumNoPayments(); return 0; }
void enqueueReadImage(v8::FunctionArgs args) { auto commandQueue = cl_command_queue(UnwrapPointer(args[0])); auto output = cl_mem(UnwrapPointer(args[1])); auto boolean = GetNumber(args[2]); auto origin = args[3].As<v8::TypedArray>(); auto region = args[4].As<v8::TypedArray>(); auto buffer = args[7].As<v8::ArrayBuffer>(); auto originPtr = (const size_t *)origin->Buffer()->GetContents().Data(); auto regionPtr = (const size_t *)region->Buffer()->GetContents().Data(); auto bufferPtr = buffer->GetContents().Data(); auto err = clEnqueueReadImage(commandQueue, output, boolean, originPtr, regionPtr, 0, 0, bufferPtr, 0, nullptr, nullptr); }
int BOARD::Scan( char Row, char Col ) { char i, j, Count = 0; CONT PlaceCont; if( !Row || !Col || Row >= (Rows - 1) || Col >= (Columns - 1)) return -1; if( GetContents( Row, Col ) == SHIP ){ SetDiscovered( Row, Col, (char)(ShipNumber + 10) ); return ShipNumber + 10; // this number will not be reached otherwise } // left for( i = Row, j = (char)(Col-1); !(PlaceCont = GetContents( i, j )); j-- ); if( PlaceCont == SHIP ) Count++; // left-top for( i = (char)(Row+1), j = (char)(Col-1); !(PlaceCont = GetContents( i, j )); i++, j-- ); if( PlaceCont == SHIP ) Count++; // top for( i = (char)(Row+1), j = Col; !(PlaceCont = GetContents( i, j )); i++ ); if( PlaceCont == SHIP ) Count++; // top-right for( i = (char)(Row+1), j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); i++, j++ ); if( PlaceCont == SHIP ) Count++; // right for( i = Row, j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); j++ ); if( PlaceCont == SHIP ) Count++; // right-bottom for( i = (char)(Row-1), j = (char)(Col+1); !(PlaceCont = GetContents( i, j )); i--, j++ ); if( PlaceCont == SHIP ) Count++; // bottom for( i = Row-1, j = Col; !(PlaceCont = GetContents( i, j )); i-- ); if( PlaceCont == SHIP ) Count++; // bottom-left for( i = Row-1, j = Col-1; !(PlaceCont = GetContents( i, j )); i--, j-- ); if( PlaceCont == SHIP ) Count++; SetDiscovered( Row, Col, Count ); MoveCount++; // if a ship is found, the move is not counted return Count; }
/// Static function to fetch all contents of a file as if it were just one big string. String File::GetContents(String fromFile) { String fileContents; std::fstream file; file.open(fromFile.c_str(), std::ios_base::in | std::ios_base::binary); if (file.is_open()) { fileContents = GetContents(file); } else { std::cout<<"\nFile::GetLines: Unable to open file: "<<fromFile; } file.close(); return fileContents; }
bool NetworkLog::Log( time_t time, NetworkSide side, int16_t node, unsigned int bytes_sent, unsigned int bytes_received, std::chrono::seconds seconds_elapsed, const std::string& network_name) { string previous_contents = GetContents(); string log_line = CreateLogLine( time, side, node, bytes_sent, bytes_received, seconds_elapsed, network_name); // Opening for "w" should truncate the existing file. TextFile file(gfiles_directory_, "NET.LOG", "w"); file.WriteLine(log_line); file.Write(previous_contents); return true; }
// --------------------------------------- bool MTRecord::FormatShortMailDescription(std::string & str_output) { OTString strDescription; if (IsMail()) { if (!HasContents()) strDescription.Set("(empty message)"); else { std::string str_temp_contents = GetContents(); std::string str_contents = OTString::trim(str_temp_contents); if (str_contents.compare(0,8,"Subject:") == 0) { // Make the replacement. str_contents.replace(0, 8, ""); } // ----------------------------------- bool bTruncated = false; if (str_contents.size() > 30) { str_contents.erase(30, std::string::npos); bTruncated = true; } // ----------------------------------- // Replace any newlines with spaces... // std::replace( str_contents.begin(), str_contents.end(), '\r', ' '); std::replace( str_contents.begin(), str_contents.end(), '\n', ' '); // str_contents.erase(std::remove(str_contents.begin(), str_contents.end(), '\n'), str_contents.end()); // str_contents.erase(std::remove(str_contents.begin(), str_contents.end(), '\r'), str_contents.end()); // ----------------------------------- strDescription.Format("%s%s", OTString::trim(str_contents).c_str(), bTruncated ? "..." : ""); } } // ----------------------------- str_output = strDescription.Get(); // ----------------------------- return (!str_output.empty()); }
void TextEditor::InsertNewLineWithSameIndentation() { GetContents(); char previousLine[MAX_USER_STRING_LENGTH]; if (GetPreviousLine(_caret, previousLine, MAX_USER_STRING_LENGTH) != -1) { int i = 0; while (previousLine[i] == ' ' || previousLine[i] == '\t') i++; previousLine[i] = '\0'; InsertNewLineWithText(previousLine); } else { InsertNewLineWithText(""); } }
BOOL COXHistoryCombo::SaveContents(LPCTSTR pszValueName, LPCTSTR pszCompany /* = NULL */, LPCTSTR pszApplication /* = NULL*/ , HKEY hKeyRoot /* = HKEY_CURRENT_USER */, BOOL bAddNewItem /* = TRUE */) { ASSERT_VALID(this); CString sValueName(pszValueName); CString sCompany(pszCompany); CString sApplication(pszApplication); CString sContents; if (sValueName.IsEmpty()) { TRACE0("COXHistoryCombo::SaveContents : No value name provided, failing\n"); return FALSE; } if (sCompany.IsEmpty()) sCompany = AfxGetApp()->m_pszRegistryKey; if (sCompany.IsEmpty()) { TRACE0("COXHistoryCombo::SaveContents : No valid company name is provided, failing\n"); return FALSE; } if (sApplication.IsEmpty()) sApplication = AfxGetApp()->m_pszProfileName; // Add the current contents of the dit control to the list (if not yet one) if (bAddNewItem) AddNewItem(); // Get the contents from the list sContents = GetContents(); BOOL bSuccess = SaveContentsToRegistry(hKeyRoot, sCompany, sApplication, sValueName, sContents); ASSERT_VALID(this); return bSuccess; }
void PlacingCreatures(worldADT world,creatureADT *creatureP,speciesADT *speciesP,int numcreature) { int i; pointT pt; for (i=0;i<=numcreature-1;i++) { while(TRUE) { pt.x=RandomInteger(0,WorldWidth(world)-1); pt.y=RandomInteger(0,WorldHeight(world)-1); if ( GetContents(world,pt) == NULL ) { creatureP[i]=NewCreature(speciesP[i],world,pt,RandomInteger(0,3)); SetContents(world,pt,creatureP[i]); break; } } } }
void BL_CDEngine::Play(int32 aTrackNumber) { if (IsDeviceOpened()) { if (GetState() == STATE_NO_DISC) { return; } scsi_play_track lTrack; if (aTrackNumber < 1) { lTrack.start_track = 1; } else if (aTrackNumber > 99) { lTrack.start_track = 99; } else { lTrack.start_track = aTrackNumber; } // If first track is data track, we skip it. GetContents(); if ((lTrack.start_track == 1) && (IsDataTrack(0))) { // If this CD doesn't contain any audio tracks, then we don't play. if (GetNumberOfTracks() <= 1) { return; } lTrack.start_track = 2; } lTrack.start_index = 1; lTrack.end_track = 99; lTrack.end_index = 1; status_t lResult = ioctl(mCurrentDevice, B_SCSI_PLAY_TRACK, &lTrack); if (lResult != B_OK) { } } }
// --------------------------------------- bool MTRecord::FormatMailSubject(std::string & str_output) { str_output.clear(); // ------------------------ if (IsMail()) { if (!HasContents()) str_output = "(empty subject)"; else { std::string str_temp_contents = GetContents(); if (str_temp_contents.compare(0,8,"Subject:") == 0) { // Make the replacement. str_temp_contents.replace(0, 8, ""); } // ----------------------------------- // Trim it, since there is probably a space after "Subject:" // (Plus we want it trimmed anyway.) std::string str_contents = OTString::trim(str_temp_contents); // ----------------------------------- // Cut the string at the first newline. // std::string::size_type pos_start = 0; std::string::size_type pos = str_contents.find("\r\n", pos_start); if (std::string::npos == pos) // Didn't find anything. pos = str_contents.find ("\n", pos_start); // ----------------------------------- if (std::string::npos != pos) // We found a newline. str_contents.erase(pos, std::string::npos); // ----------------------------------- // Trim it again, just for good measure. str_output = OTString::trim(str_contents); } } // ----------------------------- return (!str_output.empty()); }
bool VFolder::Contains( const XBOX::VString& inExtension) const { bool found = false; VArrayString* files = GetContents(FF_NO_FOLDERS); if (files) { VString name; for (sLONG i = 1; i <= files->GetCount(); ++i) { files->GetString(name, i); if (name.EndsWith(inExtension)) { found = true; break; } } delete files; } return found; }
ReturnCode ES::DeleteSharedContent(const std::array<u8, 20>& sha1) const { IOS::ES::SharedContentMap map{m_ios.GetFS()}; const auto content_path = map.GetFilenameFromSHA1(sha1); if (!content_path) return ES_EINVAL; // Check whether the shared content is used by a system title. const std::vector<u64> titles = GetInstalledTitles(); const bool is_used_by_system_title = std::any_of(titles.begin(), titles.end(), [&](u64 id) { if (!IOS::ES::IsTitleType(id, IOS::ES::TitleType::System)) return false; const auto tmd = FindInstalledTMD(id); if (!tmd.IsValid()) return true; const auto contents = tmd.GetContents(); return std::any_of(contents.begin(), contents.end(), [&sha1](const auto& content) { return content.sha1 == sha1; }); }); // Any shared content used by a system title cannot be deleted. if (is_used_by_system_title) return ES_EINVAL; // Delete the shared content and update the content map. const auto delete_result = m_ios.GetFS()->Delete(PID_KERNEL, PID_KERNEL, *content_path); if (delete_result != FS::ResultCode::Success) return FS::ConvertResult(delete_result); if (!map.DeleteSharedContent(sha1)) return ES_EIO; return IPC_SUCCESS; }
LPMAPIFOLDER CExMapi::GetContactCount(LPMAPIFOLDER pFolder,ULONG& count, BOOL doLog) { __recursionCount++; wchar_t buffer[5]; _itow(__recursionCount,buffer,10); if(doLog) { if(__recursionCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Recursive Call No: "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } CString strFolder; LPMAPIFOLDER pSubFolder=NULL; LPMAPITABLE pHierarchy; try { if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy) 1 START"); RELEASE(m_pHierarchy); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy) 1 END"); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder) START"); pHierarchy = GetHierarchy(pFolder); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder) END"); if(pHierarchy) { LPMAPIFOLDER pRecurse = NULL; do { if(doLog) m_logHelper.LogPAB(L"RELEASE(pSubFolder) 1 START"); RELEASE(pSubFolder); if(doLog) m_logHelper.LogPAB(L"RELEASE(pSubFolder) 1 END"); m_pHierarchy = pHierarchy; if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder) START"); pSubFolder = GetNextSubFolder(strFolder,pFolder); if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder) END"); if(pSubFolder) { if(strFolder == L"Deleted Items") continue; if(doLog) m_logHelper.LogPAB(L"if(IsContactFolder(pSubFolder)) START"); if(IsContactFolder(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) START"); if(GetContents(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"GetRowCount() START"); count += GetRowCount(); if(doLog) m_logHelper.LogPAB(L"GetRowCount() END"); } if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) END"); } if(doLog) m_logHelper.LogPAB(L"if(IsContactFolder(pSubFolder)) END"); m_pHierarchy = NULL; // so we don't release it in subsequent drilldown if(__recursionCount < m_pCtrl->GetSubFOlderLevel()) { if(doLog) m_logHelper.LogPAB(L"pRecurse = GetContactFolderCount(pSubFolder,count) START"); pRecurse = GetContactCount(pSubFolder,count,doLog); if(doLog) m_logHelper.LogPAB(L"pRecurse = GetContactFolderCount(pSubFolder,count) END"); } if(pRecurse) { if(doLog) m_logHelper.LogPAB(L"RELEASE(pSubFolder) 2 START"); RELEASE(pSubFolder); if(doLog) m_logHelper.LogPAB(L"RELEASE(pSubFolder) 2 END"); pSubFolder = pRecurse; break; } } else { __recursionCount = 1; } } while(pSubFolder&& !m_pCtrl->IsPABContactCoutningAbort()); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy) 2 START"); RELEASE(pHierarchy); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy) 2 END"); m_pHierarchy=NULL; } // this may occur many times depending on how deep the recursion is; make sure we haven't already assigned m_pFolder if(pSubFolder && m_pFolder!=pSubFolder) { if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pFolder) START"); RELEASE(m_pFolder); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pFolder) END"); m_pFolder=pSubFolder; } } catch(_com_error &e) { //TCHAR error[MAX_PATH]; //e->GetErrorMessage(error,MAX_PATH); if(doLog) { m_logHelper.LogPAB(L"GetContactCount Exception Catch START:"); m_logHelper.LogPAB(L"FolderName: " + strFolder ); m_logHelper.LogPAB(e.ErrorMessage()); m_logHelper.LogPAB(L"GetContactCount Exception Catch END:"); } } return pSubFolder; }
LPMAPIFOLDER CExMapi::GetContacts(LPMAPIFOLDER pFolder,LONG& folderCount,LONG& contactCount,LONG& skipCount,LONG& contactIndex,CObArray& contactArray,BOOL doLog) { __recursionCount++; wchar_t buffer[5]; _itow(__recursionCount,buffer,10); if(doLog) { if(__recursionCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Recursive Call No: "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } CString strFilterBy = m_pCtrl->GetPABSerachBy(); CString strStartWith = m_pCtrl->GetPABSerachStartWith(); strStartWith = strStartWith.MakeLower(); ULONG pageSize; m_pCtrl->get_PABPageSize(&pageSize); LONG pageNumber = m_pCtrl->GetPABPageNumber(); LONG startIndex = -1; if(pageSize>0) { startIndex = (pageSize * pageNumber) - pageSize; } LPMAPIFOLDER pSubFolder=NULL; LPMAPITABLE pHierarchy; CString strFolder; try { if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); START"); RELEASE(m_pHierarchy); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); END"); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); START"); pHierarchy = GetHierarchy(pFolder); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); END"); if(pHierarchy) { LPMAPIFOLDER pRecurse = NULL; do { RELEASE(pSubFolder); m_pHierarchy = pHierarchy; if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); START"); pSubFolder = GetNextSubFolder(strFolder,pFolder); if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); END"); if(pSubFolder) { //if(strFolder == L"Deleted Items") // continue; if(IsContactFolder(pSubFolder)) { folderCount++; if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) START"); if(GetContents(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) END"); SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME); //SortContents(TABLE_SORT_ASCEND,PR_SUBJECT); CString strText; CExMapiContact mapiContact; CString name; CString email; BOOL mustFilter = FALSE; mustFilter = strStartWith != ""; if(doLog) m_logHelper.LogPAB(L"Start Reading Contact properties"); while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) { if(pageSize > 0) { if(contactCount == pageSize) { break; } } contactIndex++; if(mustFilter) { if(strFilterBy == "Name") { mapiContact.GetName(name,PR_GIVEN_NAME); name = name.MakeLower(); if(name.Find(strStartWith) != 0) { continue; } } if(strFilterBy == "Email") { mapiContact.GetEmail(email); email = email.MakeLower(); if(email.Find(strStartWith) != 0) { continue; } } } if(startIndex > 0 && skipCount < startIndex) { skipCount++; continue; } CContact* pContact = new CContact(); pContact->SetId(contactIndex); pContact->SetFolderName(strFolder); mapiContact.GetName(strText); pContact->SetFullName(strText); mapiContact.GetCompany(strText); pContact->SetCompany(strText); mapiContact.GetIMAddress(strText); pContact->SetIMAddress(strText); mapiContact.GetName(strText,PR_GIVEN_NAME); pContact->SetFirstName(strText); mapiContact.GetName(strText,PR_MIDDLE_NAME); pContact->SetMiddleName(strText); mapiContact.GetName(strText,PR_SURNAME); pContact->SetLastName(strText); mapiContact.GetEmail(strText); pContact->SetEmail(strText); mapiContact.GetEmail(strText,2);//Email 2 pContact->SetEmail2(strText); mapiContact.GetEmail(strText,3);//Email 3 pContact->SetEmail3(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER); pContact->SetBusinessPhone(strText); mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER); pContact->SetCompanyPhone(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER); pContact->SetFax(strText); mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER); pContact->SetMobilePhone(strText); mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER); pContact->SetHomePhone(strText); if(m_pCtrl->FetchUnique()) { BOOL isContactExist = FALSE; for(int i=0;i<contactArray.GetCount();i++) { CContact* pTemp = (CContact*)contactArray.GetAt(i); if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail()) { isContactExist = TRUE; break; } else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName()) { isContactExist = TRUE; break; } else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone()) { isContactExist = TRUE; break; } else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone()) { isContactExist = TRUE; break; } else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone()) { isContactExist = TRUE; break; } } if(isContactExist) { continue; } } contactArray.Add(pContact); contactCount++; } } } m_pHierarchy = NULL; // so we don't release it in subsequent drilldown if(pageSize > 0) { if(contactCount == pageSize) break; } if(__recursionCount < m_pCtrl->GetSubFOlderLevel()) { pRecurse = GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog); } if(pRecurse) { RELEASE(pSubFolder); pSubFolder = pRecurse; break; } } else { __recursionCount = 1; } if(pageSize > 0) { if(contactCount == pageSize) break; } } while(pSubFolder && !m_pCtrl->IsPABSearchAbort()); RELEASE(pHierarchy); m_pHierarchy=NULL; } // this may occur many times depending on how deep the recursion is; make sure we haven't already assigned m_pFolder if(pSubFolder && m_pFolder!=pSubFolder) { RELEASE(m_pFolder); m_pFolder=pSubFolder; } } catch(_com_error &e) { if(doLog) { m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch START:"); m_logHelper.LogPAB(L"FolderName: " + strFolder ); m_logHelper.LogPAB(e.ErrorMessage()); m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch END:"); } } return pSubFolder; }
BOOL CExMapi::GetContacts(CObArray& contactArray,CTRError& error) { BOOL doLog = m_pCtrl->IsEnableLog(); if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotacts START:"); m_logHelper.LogPAB(L"------------------------------------"); } CString strFilterBy = m_pCtrl->GetPABSerachBy(); CString strStartWith = m_pCtrl->GetPABSerachStartWith(); strStartWith = strStartWith.MakeLower(); ULONG pageSize; m_pCtrl->get_PABPageSize(&pageSize); ULONG pageNumber = m_pCtrl->GetPABPageNumber(); LONG contactCount = 0; LONG skipCount = 0; LONG startIndex = -1; LONG contactIndex = 0; LONG folderCount = 0; if(pageSize>0) { startIndex = (pageSize * pageNumber) - pageSize; } CString strFolder; int msgStoreCount = 0; wchar_t buffer[5]; LPMAPIFOLDER pSubFolder=NULL; LPMAPITABLE lpMsgStoreTable = NULL; lpMsgStoreTable = GetMessageStoresTable(); if(lpMsgStoreTable) { while(OpenNextMessageStore(lpMsgStoreTable)) { //GetContacts(OpenRootFolder(),folderCount,contactCount,skipCount,contactIndex,contactArray); msgStoreCount++; _itow(msgStoreCount,buffer,10); if(doLog) { if(msgStoreCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Message Store No : "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } pSubFolder = OpenContacts(); if(pSubFolder && IsContactFolder(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"Open Main Contacts Folder"); strFolder = GetFolderName(pSubFolder); folderCount++; if(GetContents(pSubFolder)) { SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME); //SortContents(TABLE_SORT_ASCEND,PR_SUBJECT); CString strText; CExMapiContact mapiContact; CString name; CString email; BOOL mustFilter = FALSE; mustFilter = strStartWith != ""; if(doLog) m_logHelper.LogPAB(L"Start reading contacts from main contact fodler"); while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) { if(pageSize > 0) { if(contactCount == pageSize) { break; } } contactIndex++; if(mustFilter) { if(strFilterBy == "Name") { mapiContact.GetName(name,PR_GIVEN_NAME); name = name.MakeLower(); if(name.Find(strStartWith) != 0) { continue; } } if(strFilterBy == "Email") { mapiContact.GetEmail(email); email = email.MakeLower(); if(email.Find(strStartWith) != 0) { continue; } } } if(startIndex > 0 && skipCount < startIndex) { skipCount++; continue; } CContact* pContact = new CContact(); pContact->SetId(contactIndex); pContact->SetFolderName(strFolder); mapiContact.GetName(strText); pContact->SetFullName(strText); mapiContact.GetCompany(strText); pContact->SetCompany(strText); mapiContact.GetIMAddress(strText); pContact->SetIMAddress(strText); mapiContact.GetName(strText,PR_GIVEN_NAME); pContact->SetFirstName(strText); mapiContact.GetName(strText,PR_MIDDLE_NAME); pContact->SetMiddleName(strText); mapiContact.GetName(strText,PR_SURNAME); pContact->SetLastName(strText); mapiContact.GetEmail(strText); pContact->SetEmail(strText); mapiContact.GetEmail(strText,2);//Email 2 pContact->SetEmail2(strText); mapiContact.GetEmail(strText,3);//Email 3 pContact->SetEmail3(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER); pContact->SetBusinessPhone(strText); mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER); pContact->SetCompanyPhone(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER); pContact->SetFax(strText); mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER); pContact->SetMobilePhone(strText); mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER); pContact->SetHomePhone(strText); if(m_pCtrl->FetchUnique()) { BOOL isContactExist = FALSE; for(int i=0;i<contactArray.GetCount();i++) { CContact* pTemp = (CContact*)contactArray.GetAt(i); if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail()) { isContactExist = TRUE; break; } else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName()) { isContactExist = TRUE; break; } else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone()) { isContactExist = TRUE; break; } else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone()) { isContactExist = TRUE; break; } else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone()) { isContactExist = TRUE; break; } } if(isContactExist) { continue; } } contactArray.Add(pContact); contactCount++; } } if(doLog) m_logHelper.LogPAB(L"Open Sub Contacts Folder"); GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog); } if(pageSize > 0) { if(contactCount == pageSize) break; } if(m_pCtrl->IsPABSearchAbort()) break; __recursionCount = 0; } } if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotacts END:"); m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.ClosePABLog(); } __recursionCount = 0; RELEASE(lpMsgStoreTable); if(folderCount == 0 && !m_pCtrl->IsPABSearchAbort()) { error.code = 107; error.err = "TRContactFinder Cannot find private folders."; return FALSE; } return TRUE; }
string TextEditor::ReadContents() { GetContents(); return string(_contents); }
/// Static function to fetch all lines of text from a given file. List<String> File::GetLines(String fromFile) { String fileContents = GetContents(fromFile); List<String> lines = fileContents.GetLines(); return lines; }
void InventoryContainer::Equip(){ User::player->GetEquiped()->Equip(GetContents()); ClearContents(); };
virtual void WriteToFile(const wstring& path) { shared_ptr< vector<char> > contents = GetContents(); ofstream out(path, ios_base::binary|ios_base::out); out.write(&(*contents->begin()), contents->size()); };