From c2d114ba160841abc64c4941f8e8a14ca0d2fec8 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 27 May 2015 14:06:56 +0200 Subject: [PATCH] [Exif] Added logs in methods onEntered and onReturn Change-Id: If1ef537b4b7d28de43b0772c475cc65aebf87e23 Signed-off-by: Piotr Kosko --- src/exif/exif_gps_location.cc | 23 +++++++++++++++++++++++ src/exif/exif_information.cc | 7 ++++++- src/exif/exif_tag_saver.cc | 8 ++++++++ src/exif/get_exif_info.cc | 7 +++++++ src/exif/jpeg_file.cc | 5 +++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/exif/exif_gps_location.cc b/src/exif/exif_gps_location.cc index ab8ce801..c79fd748 100644 --- a/src/exif/exif_gps_location.cc +++ b/src/exif/exif_gps_location.cc @@ -28,6 +28,7 @@ namespace extension { namespace exif { GCSPosition::GCSPosition() { + LoggerD("Enter"); } GCSPosition::GCSPosition(Rational _degrees, Rational _minutes, @@ -35,9 +36,11 @@ GCSPosition::GCSPosition(Rational _degrees, Rational _minutes, degrees(_degrees), minutes(_minutes), seconds(_seconds) { + LoggerD("Enter"); } bool GCSPosition::isValid() const { + LoggerD("Enter"); if (!(degrees.isValid() && minutes.isValid() && seconds.isValid())) { return false; } @@ -52,6 +55,7 @@ bool GCSPosition::isValid() const { } double GCSPosition::toDouble() const { + LoggerD("Enter"); const double degrees_value = degrees.toDouble(); const double minutes_value = minutes.toDouble(); const double seconds_value = seconds.toDouble(); @@ -59,6 +63,7 @@ double GCSPosition::toDouble() const { } Rationals GCSPosition::toRationalsVector() const { + LoggerD("Enter"); Rationals vec; vec.push_back(degrees); vec.push_back(minutes); @@ -67,6 +72,7 @@ Rationals GCSPosition::toRationalsVector() const { } std::string GCSPosition::toDebugString() const { + LoggerD("Enter"); std::stringstream ss; ss << degrees.toString() << "d "; ss << minutes.toString() << "m "; @@ -121,12 +127,14 @@ ExifGPSLocation::ExifGPSLocation() : m_longitude_ref(GPS_LOCATION_WEST), m_latitude_ref(GPS_LOCATION_NORTH) { for (int i = 0; i < EXIF_GPS_LOCATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES; ++i) { + LoggerD("Enter"); m_is_set[i] = false; } LoggerE("ExifGPSLocation::ExifGPSLocation()"); } ExifGPSLocation::ExifGPSLocation(double longitude, double latitude) { + LoggerD("Enter"); for (int i = 0; i < EXIF_GPS_LOCATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES; ++i) { m_is_set[i] = false; } @@ -148,6 +156,7 @@ ExifGPSLocation::ExifGPSLocation(double longitude, double latitude) { } void ExifGPSLocation::setLongitude(const GCSPosition& longitude) { + LoggerD("Enter"); if (!longitude.isValid()) { LoggerW("longitude is not valid!"); return; @@ -158,19 +167,23 @@ void ExifGPSLocation::setLongitude(const GCSPosition& longitude) { } const GCSPosition& ExifGPSLocation::getLongitude() const { + LoggerD("Enter"); return m_longitude; } void ExifGPSLocation::setLongitudeRef(GPSLocationDirectionLongitude ref) { + LoggerD("Enter"); m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE_REF] = true; m_longitude_ref = ref; } GPSLocationDirectionLongitude ExifGPSLocation::getLongitudeRef() const { + LoggerD("Enter"); return m_longitude_ref; } void ExifGPSLocation::setLatitude(const GCSPosition& latitude) { + LoggerD("Enter"); if (!latitude.isValid()) { LoggerW("latitude is not valid!"); return; @@ -181,27 +194,33 @@ void ExifGPSLocation::setLatitude(const GCSPosition& latitude) { } const GCSPosition& ExifGPSLocation::getLatitude() const { + LoggerD("Enter"); return m_latitude; } void ExifGPSLocation::setLatitudeRef(GPSLocationDirectionLatitude ref) { + LoggerD("Enter"); m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LATITUDE_REF] = true; m_latitude_ref = ref; } GPSLocationDirectionLatitude ExifGPSLocation::getLatitudeRef() const { + LoggerD("Enter"); return m_latitude_ref; } bool ExifGPSLocation::isSet(ExifGPSLocationAttributes attribute) const { + LoggerD("Enter"); return m_is_set[attribute]; } void ExifGPSLocation::unset(ExifGPSLocationAttributes attribute) { + LoggerD("Enter"); m_is_set[attribute] = false; } void ExifGPSLocation::unsetAll() { + LoggerD("Enter"); m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE] = false; m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE_REF] = false; m_longitude = GCSPosition(); @@ -212,6 +231,7 @@ void ExifGPSLocation::unsetAll() { } bool ExifGPSLocation::isComplete() const { + LoggerD("Enter"); return m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE] && m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE_REF] && m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_LATITUDE] && @@ -220,10 +240,12 @@ bool ExifGPSLocation::isComplete() const { bool ExifGPSLocation::isValid() const { + LoggerD("Enter"); return isComplete() && m_latitude.isValid() && m_longitude.isValid(); } double ExifGPSLocation::getLongitudeValue() const { + LoggerD("Enter"); const double longitude_dir = (m_longitude_ref == GPS_LOCATION_WEST) ? -1.0f : 1.0f; const double longitude = m_longitude.toDouble() * longitude_dir; @@ -231,6 +253,7 @@ double ExifGPSLocation::getLongitudeValue() const { } double ExifGPSLocation::getLatitudeValue() const { + LoggerD("Enter"); const double latitude_dir = (m_latitude_ref == GPS_LOCATION_SOUTH) ? -1.0f : 1.0f; const double latitude = m_latitude.toDouble() * latitude_dir; diff --git a/src/exif/exif_information.cc b/src/exif/exif_information.cc index 3254803d..e42b05c1 100644 --- a/src/exif/exif_information.cc +++ b/src/exif/exif_information.cc @@ -51,6 +51,7 @@ constexpr unsigned int str2int(const char* str, int h = 0) { } IsoSpeedRatingsVector jsonArray2vector(const picojson::value& a) { + LoggerD("Enter"); if (!a.is()) { return IsoSpeedRatingsVector(); } @@ -69,6 +70,7 @@ IsoSpeedRatingsVector jsonArray2vector(const picojson::value& a) { } // namespace ExifInformation::ExifInformation() { + LoggerD("Enter"); for (int attr = 0; attr < EXIF_INFORMATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES; attr++) { unset(static_cast(attr)); @@ -76,6 +78,7 @@ ExifInformation::ExifInformation() { } ExifInformation::ExifInformation(const picojson::value& args) { + LoggerD("Enter"); for (int attr = 0; attr < EXIF_INFORMATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES; attr++) { unset(static_cast(attr)); @@ -91,7 +94,9 @@ ExifInformation::ExifInformation(const picojson::value& args) { } } -ExifInformation::~ExifInformation() { } +ExifInformation::~ExifInformation() { + LoggerD("Enter"); + } const std::string& ExifInformation::getUri() { LoggerD("Entered"); diff --git a/src/exif/exif_tag_saver.cc b/src/exif/exif_tag_saver.cc index 0571a5a5..590f57da 100644 --- a/src/exif/exif_tag_saver.cc +++ b/src/exif/exif_tag_saver.cc @@ -43,6 +43,7 @@ void ExifTagSaver::removeExifEntryWithTag(const ExifTag tag, void ExifTagSaver::saveToExif(long int value, ExifTag tag, ExifData* exif_data) { + LoggerD("Entered"); ExifEntry* entry = prepareEntry(exif_data, tag); if (!entry) { // TODO return PlatformResult and handle error @@ -81,6 +82,7 @@ void ExifTagSaver::saveToExif(long int value, ExifTag tag, void ExifTagSaver::saveToExif(const std::string& value, ExifTag tag, ExifData* exif_data, ExifFormat format, bool add_zero_character) { + LoggerD("Entered"); ExifEntry* entry = prepareEntry(exif_data, tag); if (!entry) { // TODO return PlatformResult and handle error @@ -113,6 +115,7 @@ void ExifTagSaver::saveToExif(const std::string& value, ExifTag tag, void ExifTagSaver::saveToExif(const Rational& value, ExifTag tag, ExifData* exif_data) { + LoggerD("Entered"); ExifEntry* entry = prepareEntry(exif_data, tag); if (!entry) { // TODO return PlatformResult and handle error @@ -143,6 +146,7 @@ void ExifTagSaver::saveToExif(const Rational& value, ExifTag tag, void ExifTagSaver::saveToExif(const Rationals& value, ExifTag tag, ExifData* exif_data) { + LoggerD("Entered"); ExifEntry* entry = prepareEntry(exif_data, tag); if (!entry) { // TODO return PlatformResult and handle error @@ -176,6 +180,7 @@ void ExifTagSaver::saveToExif(const Rationals& value, ExifTag tag, void ExifTagSaver::saveToExif(std::vector& value, ExifFormat store_as, ExifTag tag, ExifData* exif_data) { + LoggerD("Entered"); ExifEntry* entry = prepareEntry(exif_data, tag); if (!entry) { // TODO return PlatformResult and handle error @@ -256,6 +261,7 @@ void ExifTagSaver::saveToExif(std::vector& value, void ExifTagSaver::saveGpsLocationToExif(const ExifGPSLocation& gps_info, ExifData* exif_data) { + LoggerD("Entered"); if (gps_info.isSet(EXIF_GPS_LOCATION_ATTRIBUTE_LATITUDE)) { auto latitude = gps_info.getLatitude(); LoggerD("Saving latitude: %s", latitude.toDebugString().c_str()); @@ -319,6 +325,7 @@ ExifEntry* ExifTagSaver::createNewTag(ExifData* exif_data, ExifIfd ifd, } ExifIfd ExifTagSaver::deduceIfdSection(ExifTag tag) { + LoggerD("Entered"); // TODO EXIF_TAG_* and EXIF_TAG_GPS_* are sharing same values, // they shouldn't be used in one switch statement. @@ -363,6 +370,7 @@ ExifIfd ExifTagSaver::deduceIfdSection(ExifTag tag) { } ExifFormat ExifTagSaver::deduceDataFormat(ExifTag tag) { + LoggerD("Entered"); // TODO EXIF_TAG_* and EXIF_TAG_GPS_* are sharing same values, // they shouldn't be used in one switch statement. diff --git a/src/exif/get_exif_info.cc b/src/exif/get_exif_info.cc index 6a1551d6..5825aca3 100644 --- a/src/exif/get_exif_info.cc +++ b/src/exif/get_exif_info.cc @@ -39,6 +39,7 @@ struct ExifDataHolder { }; Rational GetRationalFromEntry(ExifEntry *entry, ExifData* exif_data) { + LoggerD("Entered"); if (EXIF_FORMAT_RATIONAL == entry->format && entry->components >= 1 && entry->data) { @@ -52,6 +53,7 @@ Rational GetRationalFromEntry(ExifEntry *entry, ExifData* exif_data) { bool GetRationalsFromEntry(ExifEntry* entry, ExifData* exif_data, unsigned long required_count, Rationals& out_rationals) { + LoggerD("Entered"); if (EXIF_FORMAT_RATIONAL == entry->format && entry->components >= required_count && entry->data) { @@ -72,6 +74,7 @@ bool GetRationalsFromEntry(ExifEntry* entry, ExifData* exif_data, bool GetGCSPositionFromEntry(ExifEntry* entry, ExifData* exif_data, GCSPosition& out_pos) { // RATIONAL - 3 + LoggerD("Entered"); if (EXIF_FORMAT_RATIONAL == entry->format && entry->components >= 3 && entry->data) { @@ -88,6 +91,7 @@ bool GetGCSPositionFromEntry(ExifEntry* entry, ExifData* exif_data, } bool DecomposeExifUndefined(ExifEntry* entry, std::string& type, std::string& value) { + LoggerD("Entered"); if (!entry || !entry->data) { LoggerW("exif entry is NULL/empty"); return false; @@ -108,6 +112,7 @@ bool DecomposeExifUndefined(ExifEntry* entry, std::string& type, std::string& va PlatformResult GetExifInfo::ProcessEntry(ExifEntry* entry, ExifData* exif_data, JsonObject* result_obj) { + LoggerD("Entered"); char buf[2000]; exif_entry_get_value(entry, buf, sizeof(buf)); ExifUtil::printExifEntryInfo(entry, exif_data); @@ -468,6 +473,7 @@ PlatformResult GetExifInfo::ProcessEntry(ExifEntry* entry, } void GetExifInfo::ContentForeachFunctionProxy(ExifEntry *entry, void *user_data) { + LoggerD("Entered"); ExifDataHolder* holder = static_cast(user_data); if (!holder) { LoggerE("holder is NULL"); @@ -493,6 +499,7 @@ void GetExifInfo::DataForeachFunction(ExifContent *content, void *user_data) { PlatformResult GetExifInfo::LoadFromURI(const std::string& uri, JsonValue* result) { + LoggerD("Entered"); // TODO(r.galka) it can be done on JS side const std::string& file_path = ExifUtil::convertUriToPath(uri); ExifData* ed = exif_data_new_from_file(file_path.c_str()); diff --git a/src/exif/jpeg_file.cc b/src/exif/jpeg_file.cc index 168575a0..9ab54c30 100644 --- a/src/exif/jpeg_file.cc +++ b/src/exif/jpeg_file.cc @@ -120,6 +120,7 @@ JpegFile::~JpegFile() { } PlatformResult JpegFile::loadFile(const std::string& path, JpegFilePtr* jpg_ptr) { + LoggerD("Entered"); JpegFile* new_jpg = new (std::nothrow) JpegFile(); if (!new_jpg) { LoggerE("Couldn't allocate Jpegfile!"); @@ -189,6 +190,7 @@ PlatformResult JpegFile::load(const std::string& path) { std::string JpegFile::getPartOfFile(const std::size_t offset, const std::size_t num_bytes_before, const std::size_t num_bytes_after) { + LoggerD("Entered"); long long int start = static_cast(offset) - num_bytes_before; if (start < 0) { start = 0; @@ -453,6 +455,7 @@ bool JpegFile::searchForTagInBuffer(const unsigned char* buffer_start, } PlatformResult JpegFile::setNewExifData(ExifData* new_exif_data) { + LoggerD("Entered"); AssertMsg(new_exif_data, "Trying to set NULL exif_data!"); JpegFileSectionPtr exif = getExifSection(); @@ -508,6 +511,7 @@ PlatformResult JpegFile::setNewExifData(ExifData* new_exif_data) { } ExifData* JpegFile::getExifData() { + LoggerD("Entered"); JpegFileSectionPtr exif = getExifSection(); if (!exif) { return NULL; @@ -717,6 +721,7 @@ PlatformResult JpegFile::saveToFilePriv(const std::string& out_path) { } JpegFileSectionPtr JpegFile::getExifSection() { + LoggerD("Entered"); std::size_t num_exif_sections = 0; JpegFileSectionPtr first_exif_section; -- 2.34.1