CHTTPImageHandler::CHTTPImageHandler(const HTTPRequest &request) : CHTTPFileHandler(request) { std::string file; int responseStatus = MHD_HTTP_BAD_REQUEST; // resolve the URL into a file path and a HTTP response status if (m_request.pathUrl.size() > 7) { file = m_request.pathUrl.substr(7); XFILE::CImageFile imageFile; const CURL pathToUrl(file); if (imageFile.Exists(pathToUrl)) { responseStatus = MHD_HTTP_OK; struct __stat64 statBuffer; if (imageFile.Stat(pathToUrl, &statBuffer) == 0) { SetLastModifiedDate(&statBuffer); SetCanBeCached(true); } } else responseStatus = MHD_HTTP_NOT_FOUND; } // set the file and the HTTP response status SetFile(file, responseStatus); }
void CHTTPFileHandler::SetFile(const std::string& file, int responseStatus) { m_url = file; m_response.status = responseStatus; if (m_url.empty()) return; // translate the response status into the response type if (m_response.status == MHD_HTTP_OK) m_response.type = HTTPFileDownload; else if (m_response.status == MHD_HTTP_FOUND) m_response.type = HTTPRedirect; else m_response.type = HTTPError; // try to determine some additional information if the file can be downloaded if (m_response.type == HTTPFileDownload) { // determine the content type std::string ext = URIUtils::GetExtension(m_url); StringUtils::ToLower(ext); m_response.contentType = CMime::GetMimeType(ext); // determine the last modified date XFILE::CFile fileObj; if (!fileObj.Open(m_url, XFILE::READ_NO_CACHE)) { m_response.type = HTTPError; m_response.status = MHD_HTTP_INTERNAL_SERVER_ERROR; } else { struct __stat64 statBuffer; if (fileObj.Stat(&statBuffer) == 0) SetLastModifiedDate(&statBuffer); } } // disable ranges and caching if the file can't be downloaded if (m_response.type != HTTPFileDownload) { m_canHandleRanges = false; m_canBeCached = false; } // disable caching if the last modified date couldn't be read if (!m_lastModified.IsValid()) m_canBeCached = false; }
nsresult nsAbIPCCard::ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard) { NS_ENSURE_ARG_POINTER(srcCard); mRecordId = srcCard->dwRecordId; mCategoryId = srcCard->dwCategoryId; mStatus = srcCard->dwStatus; nsAutoString str; // Each palm address field is allowed to have multiple lines // so replace CRLFs with spaces (since other than Notes field // moz only displays fields in a single line). CONVERT_ASSIGNTO_UNICODE(str, srcCard->firstName, PR_TRUE); SetFirstName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->lastName, PR_TRUE); SetLastName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->displayName, PR_TRUE); SetDisplayName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->nickName, PR_TRUE); SetNickName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->primaryEmail, PR_TRUE); SetPrimaryEmail(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->secondEmail, PR_TRUE); SetSecondEmail(str.get()); SetPreferMailFormat(srcCard->preferMailFormat); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workPhone, PR_TRUE); SetWorkPhone(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homePhone, PR_TRUE); SetHomePhone(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->faxNumber, PR_TRUE); SetFaxNumber(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->pagerNumber, PR_TRUE); SetPagerNumber(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->cellularNumber, PR_TRUE); SetCellularNumber(str.get()); // See if home address contains multiple lines. SplitHomeAndWorkAddresses(srcCard, PR_FALSE); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCity, PR_TRUE); SetHomeCity(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeState, PR_TRUE); SetHomeState(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeZipCode, PR_TRUE); SetHomeZipCode(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCountry, PR_TRUE); SetHomeCountry(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCity, PR_TRUE); SetWorkCity(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workState, PR_TRUE); SetWorkState(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workZipCode, PR_TRUE); SetWorkZipCode(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCountry, PR_TRUE); SetWorkCountry(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->jobTitle, PR_TRUE); SetJobTitle(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->department, PR_TRUE); SetDepartment(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->company, PR_TRUE); SetCompany(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage1, PR_TRUE); SetWebPage1(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage2, PR_TRUE); SetWebPage2(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthYear, PR_TRUE); SetBirthYear(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthMonth, PR_TRUE); SetBirthMonth(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthDay, PR_TRUE); SetBirthDay(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom1, PR_TRUE); SetCustom1(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom2, PR_TRUE); SetCustom2(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom3, PR_TRUE); SetCustom3(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom4, PR_TRUE); SetCustom4(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->notes, PR_FALSE); SetNotes(str.get()); SetLastModifiedDate(srcCard->lastModifiedDate); SetIsMailList(srcCard->isMailList); SetMailListURI(srcCard->mailListURI); return NS_OK; }
nsresult nsAbIPCCard::Copy(nsABCOMCardStruct * srcCard) { NS_ENSURE_ARG_POINTER(srcCard); mRecordId = srcCard->dwRecordId; mCategoryId = srcCard->dwCategoryId; mStatus = srcCard->dwStatus; srcCard->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == work, 1 == home PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::Copy using %d\n", srcCard->addressToUse)); // Each palm address field is allowed to have multiple lines // so replace CRLFs with spaces (since other than Notes field // moz only displays fields in a single line). nsAutoString str; CONVERT_CRLF_TO_SPACE(str, srcCard->firstName); SetFirstName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->lastName); SetLastName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->displayName); SetDisplayName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->nickName); SetNickName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->primaryEmail); SetPrimaryEmail(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->secondEmail); SetSecondEmail(str.get()); SetPreferMailFormat(srcCard->preferMailFormat); CONVERT_CRLF_TO_SPACE(str, srcCard->workPhone); SetWorkPhone(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homePhone); SetHomePhone(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->faxNumber); SetFaxNumber(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->pagerNumber); SetPagerNumber(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->cellularNumber); SetCellularNumber(str.get()); // See if home address contains multiple lines. SplitHomeAndWorkAddresses(srcCard, PR_TRUE); CONVERT_CRLF_TO_SPACE(str, srcCard->homeCity); SetHomeCity(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeState); SetHomeState(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeZipCode); SetHomeZipCode(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeCountry); SetHomeCountry(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workCity); SetWorkCity(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workState); SetWorkState(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workZipCode); SetWorkZipCode(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workCountry); SetWorkCountry(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->jobTitle); SetJobTitle(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->department); SetDepartment(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->company); SetCompany(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->webPage1); SetWebPage1(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->webPage2); SetWebPage2(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthYear); SetBirthYear(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthMonth); SetBirthMonth(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthDay); SetBirthDay(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom1); SetCustom1(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom2); SetCustom2(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom3); SetCustom3(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom4); SetCustom4(str.get()); SetNotes(srcCard->notes); SetLastModifiedDate(srcCard->lastModifiedDate); SetIsMailList(srcCard->isMailList); SetMailListURI(srcCard->mailListURI); return NS_OK; }