From: Young Ik Cho Date: Fri, 29 Nov 2013 06:41:43 +0000 (-0800) Subject: Merge "Added support for Event creation in worker thread" into tizen X-Git-Tag: submit/tizen/20131210.080830~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a776836d3262d7fd8409077dcd84e770db5b0118;hp=27181a9a38d62a84c89f4a34abae2a1d9d49000d;p=platform%2Fframework%2Fnative%2Fappfw.git Merge "Added support for Event creation in worker thread" into tizen --- diff --git a/inc/FBaseImmutableString.h b/inc/FBaseImmutableString.h new file mode 100644 index 0000000..f2eaf4b --- /dev/null +++ b/inc/FBaseImmutableString.h @@ -0,0 +1,766 @@ +// +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FBaseImmutableString.h + * @brief This is the header file for the %ImmutableString class. + * + * @since 3.0 + * @final This class is not intended for extension. + * + * This header file contains the declarations of the %ImmutableString class. + */ + +#ifndef _FBASE_IMMUTABLE_STRING_H_ +#define _FBASE_IMMUTABLE_STRING_H_ + +#include + +namespace Tizen { namespace Base +{ +/** + * @class ImmutableString + * @brief This class represents a immutable sequence of Unicode characters. + * + * @since 3.0 + * + * The %ImmutableString class represents a immutable sequence of Unicode characters. + * Mutation operation, such as Append(), Insert() and Remove(), do not change the current instance but return a new instance resulting from applying the operation. + * + * For more information on the class features, see ImmutableString. + * + * The following example demonstrates how to use the %ImmutableString class. + * + * @code + * + * #include + * + * using namespace Tizen::Base; + * + * void + * MyClass::ImmutableStringSample(void) + * { + * ImmutableString str(L"Test"); // str == L"Test" + * + * ImmutableString str1 = str.Append(L"String"); // str1 == L"TestString" + * + * ImmutableString str2 = str1.Insert(L"Immutable", 4); // str2 == L"TestImmutableString" + * + * ImmutableString str3 = str2.Remove(4, 5); // str3 == L"TestableString" + * + * ImmutableString str4 = str3.SubString(4, 4); // str4 == L"able" + * } + * @endcode + */ +class _OSP_EXPORT_ ImmutableString + : public Object +{ +public: + /** + * Initializes %ImmutableString instance with the specified Unicode string. + * + * @since 3.0 + * + * @param[in] pStr A pointer to an array of Unicode characters + * @remark If whcar_t* type null pointer is entered on parameter, the empty string is set. + */ + explicit ImmutableString(const wchar_t* pStr); + + /** + * Initializes %ImmutableString instance with the specified UTF-8 string. + * + * @since 3.0 + * + * @param[in] pStr A pointer to an array of UTF-8 characters + * @remark If char* type null pointer is entered on parameter, the empty string is set. + */ + explicit ImmutableString(const char* pStr); + + /** + * Initializes %ImmutableString instance with the specified %String. + * + * @since 3.0 + * + * @param[in] value An instance of %String + */ + ImmutableString(const String& value); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 3.0 + * + * @param[in] value An instance of %ImmutableString + */ + ImmutableString(const ImmutableString& value); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 3.0 + */ + virtual ~ImmutableString(void); + + /** + * Returns a Unicode character at the specified @c index. + * + * @since 3.0 + * + * @return A Unicode character + * @param[in] index An index within this string + */ + wchar_t operator [](int index) const; + + /** + * Returns a new %ImmutableString instance resulting from appending the specified %ImmutableString to the end of this string. + * + * @since 3.0 + * + * @return The concatenated %ImmutableString instance + * @param[in] str An instance of %ImmutableString to append + */ + ImmutableString Append(const ImmutableString& str) const; + + /** + * Compares the value of the current instance to the value of the specified instance of %ImmutableString. + * + * @since 3.0 + * + * @return A @c signed integer value + * @code + * < 0 if the value of the current instance is less than the value of the specified %ImmutableString instance + * == 0 if the value of the current instance is equal to the value of the specified %ImmutableString instance + * > 0 if the value of the current instance is greater than the value of the specified %ImmutableString instance + * @endcode + * @param[in] str An instance of %ImmutableString to compare + * @remarks + * - This method performs an ordinal comparison of each Unicode character. For instance, + * L"U+xxx" is greater than L"U+XXX", but smaller than L"U+yyy". + * - This method is not locale-dependent. + */ + int CompareTo(const ImmutableString& str) const; + + /** + * Checks whether this instance contains the specified substring. + * + * @since 3.0 + * + * @return @c true if this instance contains the specified substring, @n + * else @c false + * @param[in] str The string to match + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c str is an empty string. + */ + bool Contains(const ImmutableString& str) const; + + /** + * Checks whether the given string is present at the end of the calling instance. + * + * @since 3.0 + * + * @return @c true if this instance ends with the specified text, @n + * else @c false + * @param[in] str An instance to match + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c str is an empty string. + */ + bool EndsWith(const ImmutableString& str) const; + + /** + * Checks whether the value of the specified instance of Object is equal to the value of this string. + * + * @since 3.0 + * + * @return @c true if the value of the specified instance of Object is equal to the value of this string, @n + * else @c false + * @param[in] obj An instance of Object to compare + * @remarks This method returns @c false if the specified @c obj is not a string. + * @see Object::Equals() + */ + virtual bool Equals(const Object& obj) const; + + /** + * Checks whether the value of the specified instance is equal to the value of this string. @n + * Case sensitivity is ignored. + * + * @since 3.0 + * + * @return @c true if the values match, @n + * else @c false + * @param[in] str An instance to compare with the calling instance + * + * @remarks This method performs an ordinal comparison of each Unicode + * character contained in the two given %ImmutableString instances. + */ + bool EqualsCaseInsensitive(const ImmutableString& str) const; + + /** + * Formats the inputs as per the specified format and and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return An error code + * @param[in] length The maximum number of wide characters to write, including the terminating @c null character + * @param[in] pFormat The wide character format specifier + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: + * - The specified @c length is negative. + * - The specified @c pFormat is @c null. + * @remarks + * - If an "l" modifier is present in @c pFormat (for example, L"@%ls"), it is a pointer to an array of wide characters. + * - A pointer to an array of UTF-8 characters is not allowed in the Format() method (for example, Format(20, L"@%s", pUTF8Str)). + * The following format specifiers are supported in this method: + * @code + * specifier Output + * --------- ------ + * c single byte character + * d(or i) signed decimal integer + * u unsigned decimal integer + * x unsigned hexadecimal integer + * f decimal floating point + * e scientific notation using e character + * g use the shorter of %e or %f + * s single byte character string + * ls(or S) wide-character string + * lld 64-bit signed decimal integer + * + * @endcode + * + * The following example demonstrates how to use the %Format() method. + * @code + * + * int value = 10; + * wchar_t* testStr = L"TEST"; + * + * ImmutableString str = Tizen::Base::ImmutableString::Format(25, L"FORMAT %d %ls", value, testStr); // str == L"FORMAT 10 TEST" + * + * @endcode + */ + static ImmutableString Format(int length, const wchar_t* pFormat, ...); + + /** + * Gets the character at the specified position. + * + * @since 3.0 + * + * @return An error code + * @param[in] indexAt The position of the character + * @param[out] ch The character at the specified index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c indexAt is either greater than or equal to the length of the current instance. + * - The specified @c indexAt is less than @c 0. + * @remark This method does not guarantee a usable value of out-parameter when an error occurs. + */ + result GetCharAt(int indexAt, wchar_t& ch) const; + + /** + * Gets the hash value of the current instance. + * + * @since 3.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the hash function used must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Gets the length of the text contained in this %ImmutableString instance. + * + * @since 3.0 + * + * @return The length of this %ImmutableString instance + */ + int GetLength(void) const; + + /** + * Gets a pointer to the instance's internal buffer. + * + * @since 3.0 + * + * @return A Unicode pointer to the calling instance's internal buffer + */ + const wchar_t* GetPointer(void) const; + + /** + * Searches for a character in the calling instance. @n + * Gets the index of the first character that matches to the specified character in this instance. + * + * @since 3.0 + * + * @return An error code + * @param[in] ch The Unicode character to locate + * @param[in] startIndex The starting position of the search + * @param[out] indexOf The index of the character + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified character is not found. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * @remark This method does not guarantee a usable value of out-parameter when an error occurs. + */ + result IndexOf(wchar_t ch, int startIndex, int& indexOf) const; + + /** + * Searches for a specified substring in the calling instance. @n + * Gets the starting index of the first occurrence of the specified substring. + * + * @since 3.0 + * + * @return An error code + * @param[in] str An instance to locate + * @param[in] startIndex The starting position of the search + * @param[out] indexOf The index of the substring + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified string is not found. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * @remark This method does not guarantee a usable value of out-parameter when an error occurs. + */ + result IndexOf(const ImmutableString& str, int startIndex, int& indexOf) const; + + /** + * Returns a new instance resulting from inserting the specified string at the specified position. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * @param[in] str An instance to insert + * @param[in] indexAt The position to insert @c str + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c indexAt is either greater than or equal to the length of the current instance. + * - The specified @c indexAt is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString Insert(const ImmutableString& str, int indexAt) const; + + /** + * Checks whether the string is empty. + * + * @since 3.0 + * + * @return @c true if the current instance is a zero-length %ImmutableString instance L"", @n + * else @c false + */ + bool IsEmpty(void) const; + + /** + * Searches the calling instance for the last occurrence of the specified character and returns its index. @n + * The search begins at the @c startIndex position and proceeds backward towards the beginning. + * + * @since 3.0 + * + * @return An error code + * @param[in] ch The Unicode character to locate + * @param[in] startIndex The starting position of search + * @param[out] indexOf The index of character + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified character is not found. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * @remark This method does not guarantee a usable value of out-parameter when an error occurs. + * @code + * + * int indexOf; + * wchar_t ch = L'a'; + * ImmutalbeString str(L"ImmutableString"); + * + * str.LastIndexOf(ch, str.GetLength() - 1, indexOf); // indexOf == 5 + * + * @endcode + */ + result LastIndexOf(wchar_t ch, int startIndex, int& indexOf) const; + + /** + * Searches the calling instance for the last occurrence of the specified substring and returns its index. @n + * The search begins at the @c startIndex position and proceeds backward towards the beginning. + * + * @since 3.0 + * + * @return An error code + * @param[in] str An instance to locate + * @param[in] startIndex The starting position of search + * @param[out] indexOf The index of the substring + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified character is not found. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * + * @remarks + * - If the substring is empty, E_SUCCESS is returned and the value of @c indexOf is set to @c startIndex. + * - This method does not guarantee a usable value of out-parameter when an error occurs. + * @code + * + * int indexOf; + * ImmutableString testStr= L"mutable"; + * ImmutalbeString str(L"ImmutableString"); + * + * str.LastIndexOf(testStr, str.GetLength() - 1, indexOf); // indexOf == 2 + * + * @endcode + */ + result LastIndexOf(const ImmutableString& str, int startIndex, int& indexOf) const; + + /** + * Removes the characters within the specified range in the calling %ImmutableString instance + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * + * @param[in] startIndex The position where the removal begins + * @param[in] length The number of characters to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * - The specified @c length is greater than the length of the substring starting from @c startIndex. + * - The specified @c length is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString Remove(int startIndex, int length) const; + + /** + * Replaces all occurrences of the specified character in the calling %ImmutableString instance with the character to replace + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * + * @param[in] original The character to replace + * @param[in] replace The character to replace all occurrences of @c original by + */ + ImmutableString Replace(wchar_t original, wchar_t replace) const; + + /** + * Replaces all occurrences of the specified string in the calling %ImmutableString instance with string to replace + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * + * @param[in] original An instance to replace + * @param[in] replace An instance to replace all occurrences of @c original by + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c original is an empty string. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString Replace(const ImmutableString& original, const ImmutableString& replace) const; + + /** + * Replaces all occurrences of the specified string in the calling %ImmutableString instance from the specified starting position + * with string to replace and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * + * @param[in] original An instance to replace + * @param[in] replace An instance to replace all occurrences of @c original by + * @param[in] startIndex The starting position of the substring + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c original is an empty string. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString Replace(const ImmutableString& original, const ImmutableString& replace, int startIndex) const; + + /** + * Reverses the sequence of characters in the calling %ImmutableString instance and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + */ + ImmutableString Reverse(void) const; + + /** + * Sets the character at the specified index with the given character in the calling %ImmutableString instance + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + * + * @param[in] ch A new character + * @param[in] indexAt The position of the character + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c indexAt is either greater than or equal to the length of the current instance. + * - The specified @c indexAt is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString SetCharAt(wchar_t ch, int indexAt) const; + + /** + * Checks whether this instance contains the specified text from the given index. + * + * @since 3.0 + * + * @return @c true if this instance starts with the specified text, @n + * else @c false + * + * @param[in] str The string to match + * @param[in] startIndex The start position of the string + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + */ + bool StartsWith(const ImmutableString& str, int startIndex) const; + + /** + * Checks whether this instance contains the specified text. + * + * @since 3.0 + * + * @return @c true if this instance starts with the specified text, @n + * else @c false + * + * @param[in] str The string to match + */ + bool StartsWith(const ImmutableString& str) const; + + /** + * Finds a substring starting from the given index in the calling %ImmutableString instance + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance containing sub string + * + * @param[in] startIndex The starting index of the substring + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString SubString(int startIndex) const; + + /** + * Finds a substring of the given length starting from the specified index in the calling %ImmutableString instance + * and returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instancecontaining sub string + * + * @param[in] startIndex The starting position of the substring + * @param[in] length The length of the substring + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: + * - The specified @c startIndex is either greater than or equal to the length of the current instance. + * - The specified @c startIndex is less than @c 0. + * - The specified @c length is greater than the length of the substring starting from @c startIndex. + * - The specified @c length is less than @c 0. + * @remark This method returns an empty string when an exception occurs. + */ + ImmutableString SubString(int startIndex, int length) const; + + /** + * Converts the unicode characters to lowercase from the calling %ImmutableString instance and + * returns a new %ImmutableString instance. Unicode characters other than the English alphabets are also supported. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + */ + ImmutableString ToLowerCase(void) const; + + /** + * Converts the unicode characters to uppercase from the calling %ImmutableString instance and + * returns a new %ImmutableString instance. Unicode characters other than the English alphabets are also supported. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + */ + ImmutableString ToUpperCase(void) const; + + /** + * Trims the leading and trailing whitespace characters in the calling %ImmutableString instance and + * returns a new %ImmutableString instance. + * + * @since 3.0 + * + * @return The new %ImmutableString instance + */ + ImmutableString Trim(void) const; + +private: + // + // This constructor is intentionally declared as private so that only the platform can create an instance. + // + ImmutableString(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ImmutableString& operator =(const ImmutableString& rhs); + + // + // Overloaded constructor + // + ImmutableString(const wchar_t* pStr1, const wchar_t* pStr2); + + // + // Overloaded constructor + // + explicit ImmutableString(int capacity); + +private: + + class _StringBuffer* __pImpl; + friend class _StringBuffer; + + class _ImmutableStringImpl* __pImmutableStringImpl; +}; + +/** + * Checks two %ImmutableString instances for equality. + * + * @since 3.0 + * + * @return @c true if %lhs string is equal to %rhs string, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator performs an ordinal comparison of each Unicode character. + * - This operator is not locale-dependent. + */ +inline bool operator ==(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) == 0); +} + +/** + * Checks two %ImmutableString instances for inequality. + * + * @since 3.0 + * + * @return @c true if %lhs string is not equal to %rhs string, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator performs an ordinal comparison of each Unicode character. + * - This operator is not locale-dependent. + */ +inline bool operator !=(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) != 0); +} + +/** + * Checks the right-hand side %ImmutalbeString instance is greater than the left-hand side one. + * + * @since 3.0 + * + * @return @c true if the string of the right-hand side %ImmutableString instance is greater than the left-hand side one, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator compares texts by ordinal comparison. + * - This operator is not locale-dependent. + */ +inline bool operator <(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) < 0); +} + +/** + * Checks the right-hand side %ImmutalbeString instance is less than the left-hand side one. + * + * @since 3.0 + * + * @return @c true if the string of the right-hand side %ImmutableString instance is less than the left-hand side one, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator compares texts by ordinal comparison. + * - This operator is not locale-dependent. + */ +inline bool operator >(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) > 0); +} + +/** + * Checks the right-hand side %ImmutalbeString instance is greater than or equal to the left-hand side one. + * + * @since 3.0 + * + * @return @c true if the string of the right-hand side %ImmutableString instance is greater than or equal to the left-hand side one, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator compares texts by ordinal comparison. + * - This operator is not locale-dependent. + */ +inline bool operator <=(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) <= 0); +} + +/** + * Checks the right-hand side %ImmutalbeString instance is less than or equal to the left-hand side one. + * + * @since 3.0 + * + * @return @c true if the string of the right-hand side %ImmutableString instance is less than or equal to the left-hand side one, @n + * else @c false + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + * @remarks + * - The operator compares texts by ordinal comparison. + * - This operator is not locale-dependent. + */ +inline bool operator >=(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return (lhs.CompareTo(rhs) >= 0); +} + +/** + * Concatenates two strings. + * + * @since 3.0 + * + * @return The concatenated %ImmutableString instance + * @param[in] lhs An instance for the left-hand side of the operator + * @param[in] rhs An instance for the right-hand side of the operator + */ +inline ImmutableString operator +(const ImmutableString& lhs, const ImmutableString& rhs) +{ + return lhs.Append(rhs); +} + +}} // Tizen::Base +#endif // _FBASE_IMMUTABLE_STRING_H_ diff --git a/inc/FBaseLongLong.h b/inc/FBaseLongLong.h index d748f09..3207efd 100644 --- a/inc/FBaseLongLong.h +++ b/inc/FBaseLongLong.h @@ -274,6 +274,34 @@ public: static String ToString(long long value); /** + * Decodes a string into a @c signed @c long @c long value. + * + * @since 3.0 + * + * @return An error code + * @param[in] inputStr A string representing a numeric value + * @param[out] ret The result of the operation + * @exception E_SUCCESS The method is successful. + * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed. + * @exception E_OUT_OF_RANGE The decoded value is not between VALUE_MIN and VALUE_MAX range. + * @remarks + * - This method guarantees that the original value of out-parameter is not changed when the method returns error. + * - This method accepts decimal, hexadecimal, and octal numbers given by the + * following grammar: + * @code + * - DecodableString: + * Sign[opt] DecimalNumeral + * Sign[opt] 0x HexDigits + * Sign[opt] 0X HexDigits + * Sign[opt] # HexDigits + * Sign[opt] 0 OctalDigits + * - Sign: + * '-' + * @endcode + */ + static result Decode(const String& inputStr, long long& ret); + + /** * Parses the specified string representing a numeric value and * returns the value as a @c signed @c long @c long (as out parameter). * diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index f27cf1c..b558e20 100755 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -16,7 +16,6 @@ BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(appinfo) >= 0.1.0 BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(badge) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-appfw-application) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 932efac..b596a9f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,7 +15,6 @@ pkg_check_modules(pkgs REQUIRED ecore glib-2.0 haptic - badge icu-i18n iniparser libpcre diff --git a/src/app/FApp_AppSettingImpl.cpp b/src/app/FApp_AppSettingImpl.cpp index f7aabd9..d9aab4b 100644 --- a/src/app/FApp_AppSettingImpl.cpp +++ b/src/app/FApp_AppSettingImpl.cpp @@ -53,7 +53,6 @@ namespace Tizen { namespace App { const int APP_ID_LENTH = 10; -const int MAX_CONTENT_LEN = 512; const int MAX_LOCAL_BUFSIZE = 128; const char* DBUS_PATH = "/setting/dbus_handler"; const char* DBUS_SIGNAL_INTERFACE = "org.tizen.setting.signal"; @@ -664,7 +663,7 @@ result _AppSettingImpl::Load(void) { SysTryReturnResult(NID_APP, File::IsFileExist(__filePath), E_OBJ_NOT_FOUND, - "The instance of specified AppId does not have setting information."); + "The instance of specified AppId does not have setting information. %ls", __filePath.GetPointer()); result r = E_SUCCESS; std::unique_ptr pfilePath(Tizen::Base::Utility::StringUtil::StringToUtf8N(__filePath)); diff --git a/src/app/FApp_NotificationManagerImpl.cpp b/src/app/FApp_NotificationManagerImpl.cpp index 37bada6..a3b2224 100644 --- a/src/app/FApp_NotificationManagerImpl.cpp +++ b/src/app/FApp_NotificationManagerImpl.cpp @@ -19,89 +19,20 @@ * @brief This is the placeholder for _NotificationManagerImpl class. */ -#include - -#include -#include -#include -#include -#include -#include -#include - #include -#include -#include -#include +#include + #include "FApp_NotificationManagerImpl.h" -#include "FApp_AppInfo.h" -#include "FIoFile.h" -#include "FAppPkg_PackageManagerImpl.h" -#include "FApp_Aul.h" -#include "FApp_AppArg.h" -#include "FAppPkgPackageAppInfo.h" -#include "FAppPkg_PackageAppInfoImpl.h" +#include "FApp_INotificationManagerImpl.h" using namespace Tizen::Base; -using namespace Tizen::App; -using namespace Tizen::App::Package; -using namespace Tizen::Io; - -extern "C" int service_create_request(bundle *data, service_h *service); +using namespace Tizen::Base::Runtime; namespace { -result -ConvertNotificationResult(int error) -{ - switch (error) - { - case UI_NOTIFICATION_ERROR_NONE: - return E_SUCCESS; - case UI_NOTIFICATION_ERROR_INVALID_PARAMETER: - return E_INVALID_ARG; - case UI_NOTIFICATION_ERROR_OUT_OF_MEMORY: - return E_OUT_OF_MEMORY; - case UI_NOTIFICATION_ERROR_DB_FAILED: - return E_DATABASE; - case UI_NOTIFICATION_ERROR_NO_SUCH_FILE: - return E_SYSTEM; - case UI_NOTIFICATION_ERROR_INVALID_STATE: - return E_SYSTEM; - default: - return E_SYSTEM; - } -} - -bool -IsPosted(ui_notification_h handle) -{ - struct ui_notification_s - { - void* raw_handle; - bool ongoing; - bool posted; - bool removed; - char *icon; - struct tm *time; - char *title; - char *content; - service_h service; - char *sound; - bool vibration; - }; - - if (handle == NULL) - { - return false; - } - - ui_notification_s* pStruct = reinterpret_cast(handle); - - return pStruct->posted; -} +const wchar_t OSP_SHELL_SONAME[] = L"libosp-shell-core.so.1"; } @@ -109,512 +40,225 @@ namespace Tizen { namespace App { _NotificationManagerImpl::_NotificationManagerImpl(void) +: __pNotiImpl(null) { } -_NotificationManagerImpl::~_NotificationManagerImpl(void) -{ -} - -result -_NotificationManagerImpl::Construct(void) -{ - return E_SUCCESS; -} - -const _NotificationManagerImpl* -_NotificationManagerImpl::GetInstance(const NotificationManager& notiMgr) -{ - return notiMgr.__pNotificationManagerImpl; -} - -_NotificationManagerImpl* -_NotificationManagerImpl::GetInstance(NotificationManager& notiMgr) -{ - return notiMgr.__pNotificationManagerImpl; -} - -int -_NotificationManagerImpl::GetBadgeNumber(void) const -{ - unsigned int count = 0; - - badge_error_e badgeError = badge_get_count(appinfo_get_appid(), &count); - - if (badgeError == BADGE_ERROR_NONE) - { - SysLog(NID_APP, "badge_get_count(%d)", count); - } - else - { - SysLog(NID_APP, "badge_get_count failed(%d).", badgeError); - return -1; - } - return count; -} - -result -_NotificationManagerImpl::OngoingImpl(const String& messageText, const String& launchArguments) const -{ - return NotifyImpl(messageText, -1, launchArguments, true); -} - -result -_NotificationManagerImpl::OngoingImpl(const AppId& appId, const String& messageText, const String& launchArguments) const -{ - - return NotifyImpl(appId, messageText, -1, launchArguments, true); -} - -result -_NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber, - const String& launchArguments, - bool isOngoing) const -{ - result r = E_SUCCESS; - int retcode = 0; - char* pMsg = null; - char* pkgname = NULL; - char* pIcon = NULL; - bundle* pKb = NULL; - service_h svc = NULL; - _AppArg arg; - String iconPath; - ui_notification_h core = NULL; - PackageAppInfo* pPackageAppInfo = NULL; - - if (!messageText.IsEmpty()) - { - SysTryReturnResult(NID_APP, - messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); - - retcode = ui_notification_create(isOngoing, &core); - SysTryReturnResult(NID_APP, retcode == UI_NOTIFICATION_ERROR_NONE, E_SYSTEM, "Notification creation error : 0x%x.", retcode); - - pMsg = _StringConverter::CopyToCharArrayN(messageText); - - int ret = ui_notification_set_content(core, pMsg); - SysTryLog(NID_APP, ret == UI_NOTIFICATION_ERROR_NONE, "Setting notification content failure : %d.", ret); - - const String& currappId = _AppInfo::GetApplicationId(); - - pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId); - iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath(); - if (!iconPath.IsEmpty() && File::IsFileExist(iconPath)) - { - pIcon = _StringConverter::CopyToCharArrayN(iconPath); - r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r)); - } - - app_get_package(&pkgname); - SysTryCatch(NID_APP, pkgname != NULL, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Cannot acquire package name for current application."); - - r = arg.Construct(launchArguments); - if (IsFailed(r)) - { - SysPropagate(NID_APP, r); - goto CATCH; - } - - pKb = arg.GetBundle(); - service_create_request(pKb, &svc); - - service_set_package(svc, pkgname); - r = ConvertNotificationResult(ui_notification_set_service(core, svc)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set service failed.", GetErrorMessage(r)); - - SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname); - - r = ConvertNotificationResult(ui_notification_post(core)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r)); - } - - if (badgeNumber >= 0) - { - badge_error_e badgeError = badge_set_count(appinfo_get_appid(), badgeNumber); - SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError); - } - -CATCH: - delete pPackageAppInfo; - delete[] pMsg; - delete[] pIcon; - - if (pkgname) - { - free(pkgname); - } - if (core) - { - ui_notification_destroy(core); - } - service_destroy(svc); - return r; -} - -result -_NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageText, int badgeNumber, - const String& launchArguments, - bool isOngoing) const +_NotificationManagerImpl::~_NotificationManagerImpl(void) { - result r = E_SUCCESS; - int retcode = 0; - String iconPath; - char* pMsg = null; - char* pIcon = null; - char* pName = null; - ui_notification_h core = NULL; - char buffer[256]; - bundle* pKb = NULL; - service_h svc = NULL; - _AppArg arg; - PackageAppInfo* pPackageAppInfo = null; - - memset(buffer, 0, 256); - - bool inInstalled = _Aul::IsInstalled(appId); - SysTryReturnResult(NID_APP, inInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer()); - - if (!isOngoing || !messageText.IsEmpty()) + if (__pNotiImpl) { - SysTryReturnResult(NID_APP, - messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); - - retcode = ui_notification_create(isOngoing, &core); - SysTryReturnResult(NID_APP, retcode == UI_NOTIFICATION_ERROR_NONE, E_SYSTEM, "Notification creation error : 0x%x.", retcode); - - pMsg = _StringConverter::CopyToCharArrayN(messageText); - - int ret = ui_notification_set_content(core, pMsg); - SysTryLog(NID_APP, ret == UI_NOTIFICATION_ERROR_NONE, "Setting notification content failure : %d.", ret); - - snprintf(buffer, 256, "%ls", appId.GetPointer()); - - pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId); - if (pPackageAppInfo) - { - iconPath = pPackageAppInfo->GetAppNotificationIconPath(); - - if (!iconPath.IsEmpty() && File::IsFileExist(iconPath)) - { - pIcon = _StringConverter::CopyToCharArrayN(iconPath); - r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r)); - } - else - { - iconPath = pPackageAppInfo->GetAppMenuIconPath(); - pIcon = _StringConverter::CopyToCharArrayN(iconPath); - r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r)); - } - - const String& displayName = pPackageAppInfo->GetAppDisplayName(); - pName = _StringConverter::CopyToCharArrayN(displayName); - - r = ConvertNotificationResult(ui_notification_set_title(core, pName)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title failed.", GetErrorMessage(r)); - } - else - { - SysLog(NID_APP, "No packageInfo found for %ls", appId.GetPointer()); - } - + typedef void (*NotificationDeletor)(_INotificationManagerImpl*); - r = arg.Construct(launchArguments); - if (IsFailed(r)) + NotificationDeletor pDeleter = reinterpret_cast(__lib.GetProcAddress(L"DeleteNotificationManagerInstance")); + if (pDeleter) { - SysPropagate(NID_APP, r); - goto CATCH; + (*pDeleter)(__pNotiImpl); + SysLog(NID_APP, "NotificationManager stub deleted."); } - - pKb = arg.GetBundle(); - service_create_request(pKb, &svc); - - service_set_app_id(svc, buffer); - r = ConvertNotificationResult(ui_notification_set_service(core, svc)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set service failed.", GetErrorMessage(r)); - - SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), buffer); - - r = ConvertNotificationResult(ui_notification_post(core)); - SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r)); - } - - if (badgeNumber >= 0) - { - badge_error_e badgeError = badge_set_count(buffer, badgeNumber); - SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError); - } - -CATCH: - delete pPackageAppInfo; - delete[] pMsg; - delete[] pIcon; - delete[] pName; - - if (core) - { - ui_notification_destroy(core); } - service_destroy(svc); - return r; } result -_NotificationManagerImpl::RemoveImpl(const char* pAppId, notification_type_e type) +_NotificationManagerImpl::Construct(void) { - result r = E_SUCCESS; + result r = __lib.Construct(OSP_SHELL_SONAME, _LIBRARY_LOAD_OPTION_NODELETE | _LIBRARY_LOAD_OPTION_LAZY); + SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "A system error has occurred : %s.", GetErrorMessage(r)); - notification_error_e err = notification_delete_all_by_type(pAppId, type); - switch (err) - { - case NOTIFICATION_ERROR_NONE: - r = E_SUCCESS; - break; + typedef _INotificationManagerImpl* (*NotificationCreator)(void); + NotificationCreator pCreator = reinterpret_cast(__lib.GetProcAddress(L"CreateNotificationManagerInstance")); + SysTryReturnResult(NID_APP, pCreator != null, E_SYSTEM, "No notification instance factory found."); - case NOTIFICATION_ERROR_INVALID_DATA: - r = E_INVALID_ARG; - break; - - default: - r = E_SYSTEM; - break; - } + __pNotiImpl = (*pCreator)(); return r; } -result -_NotificationManagerImpl::RemoveImpl(const AppId& appId, bool isOngoing) +int +_NotificationManagerImpl::GetBadgeNumber(void) const { - const bool isValidAppId = _Aul::IsInstalled(appId); - SysTryReturnResult(NID_APP, isValidAppId, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer()); + SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error."); - std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); - const notification_type_e notiType = (isOngoing) ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI; - - return RemoveImpl(pAppId.get(), notiType); + return __pNotiImpl->GetBadgeNumber(); } + result _NotificationManagerImpl::Notify(int badgeNumber) const { - SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); String messageText = String(L""); String appMessage = String(L""); - return NotifyImpl(messageText, badgeNumber, appMessage, false); + return __pNotiImpl->Notify(messageText, badgeNumber, appMessage); } + result _NotificationManagerImpl::Notify(const String& messageText) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); String appMessage = String(L""); - return NotifyImpl(messageText, -1, appMessage, false); + return __pNotiImpl->Notify(messageText, -1, appMessage); } + result _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const { - SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); String appMessage = String(L""); - return NotifyImpl(messageText, badgeNumber, appMessage, false); + return __pNotiImpl->Notify(messageText, badgeNumber, appMessage); } + result _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const { - SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_APP, - launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG, - "launchArguments is less than 0."); - - SysTryReturnResult(NID_APP, - launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return NotifyImpl(messageText, badgeNumber, launchArguments, false); + return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments); } int _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const { - bool b = _Aul::IsInstalled(appId); - - SysTryReturn(NID_APP, b == true, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The application %ls is not installed", - appId.GetPointer()); - - char buffer[256]; - unsigned int count = 0; - - memset(buffer, 0, 256); - - snprintf(buffer, 256, "%ls", appId.GetPointer()); + SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error."); - std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); - - badge_error_e badgeError = badge_get_count(pAppId.get(), &count); - - if (badgeError == BADGE_ERROR_NONE) - { - SysLog(NID_APP, "badge_get_count(%d)", count); - } - else - { - SysLog(NID_APP, "badge_get_count failed(%d).", badgeError); - return -1; - } - - return count; + return __pNotiImpl->GetBadgeNumber(appId); } result _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const { + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); String messageText = String(L""); String appMessage = String(L""); - return NotifyImpl(appId, messageText, badgeNumber, appMessage); + + return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage); } + result _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return NotifyImpl(appId, messageText, -1, String(L"")); + return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L"")); } + result _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const { + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - return NotifyImpl(appId, messageText, badgeNumber, String(L"")); + return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L"")); } + result _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0."); - SysTryReturnResult(NID_APP, - launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return NotifyImpl(appId, messageText, -1, launchArguments); + return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments); } + result _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber, const String& launchArguments) const { + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0."); - SysTryReturnResult(NID_APP, - launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); - return NotifyImpl(appId, messageText, badgeNumber, launchArguments); + return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments); } + result _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return OngoingImpl(messageText, String(L"")); + return __pNotiImpl->NotifyOngoingActivity(messageText, String(L"")); } + result _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0."); - SysTryReturnResult(NID_APP, - launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return OngoingImpl(messageText, launchArguments); + return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments); } + result _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return OngoingImpl(appId, messageText, String(L"")); + return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L"")); } + result _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const { - SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0."); - SysTryReturnResult(NID_APP, - launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); - return OngoingImpl(appId, messageText, launchArguments); + return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments); } + result _NotificationManagerImpl::RemoveOngoingActivityNotification(void) { - return RemoveImpl(NULL, NOTIFICATION_TYPE_ONGOING); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); + + return __pNotiImpl->RemoveOngoingActivityNotification(); } + result _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId) { - return RemoveImpl(appId, true); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); + + return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId); } + result _NotificationManagerImpl::RemoveNotification(void) { - return RemoveImpl(NULL, NOTIFICATION_TYPE_NOTI); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); + + return __pNotiImpl->RemoveNotification(); } + result _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId) { - return RemoveImpl(appId, false); + SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error."); + + return __pNotiImpl->RemoveNotificationByAppId(appId); } }; diff --git a/src/app/FApp_NotificationManagerImpl.h b/src/app/FApp_NotificationManagerImpl.h index 77868e8..af580a0 100644 --- a/src/app/FApp_NotificationManagerImpl.h +++ b/src/app/FApp_NotificationManagerImpl.h @@ -22,16 +22,17 @@ #ifndef _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_ #define _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_ -#include - #include #include #include +#include + + namespace Tizen { namespace App { -class NotificationManager; +class _INotificationManagerImpl; class _NotificationManagerImpl { @@ -49,7 +50,7 @@ public: * * @since 1.0 */ - virtual ~_NotificationManagerImpl(void); + ~_NotificationManagerImpl(void); /** * Initializes this instance of %_NotificationManagerImpl. @@ -422,28 +423,14 @@ public: */ result RemoveNotificationOnBehalf(const AppId& appId); - static const _NotificationManagerImpl* GetInstance(const NotificationManager& notiMgr); - - static _NotificationManagerImpl* GetInstance(NotificationManager& notiMgr); - private: - result NotifyImpl(const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments, bool isOngoing = false) const; - - result NotifyImpl(const AppId& appId, const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments, bool isOngoing = false) const; - - inline result OngoingImpl(const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const; - - inline result OngoingImpl(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const; - - result RemoveImpl(const AppId& appId, bool isOngoing); - - result RemoveImpl(const char* pAppId, notification_type_e type); - _NotificationManagerImpl(const _NotificationManagerImpl& rhs); _NotificationManagerImpl& operator =(const _NotificationManagerImpl& rhs); private: + _INotificationManagerImpl* __pNotiImpl; + Tizen::Base::Runtime::_LibraryImpl __lib; }; //_NotificationManagerImpl } } // Tizen::App diff --git a/src/app/inc/FApp_INotificationManagerImpl.h b/src/app/inc/FApp_INotificationManagerImpl.h new file mode 100644 index 0000000..c481132 --- /dev/null +++ b/src/app/inc/FApp_INotificationManagerImpl.h @@ -0,0 +1,200 @@ +// +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FApp_INotificationManagerImpl.h + * @brief This is the header file for the _INotificationManagerImpl class. + * + * This file contains the declarations of _INotificationManagerImpl. + */ + +#ifndef _FAPP_INTERNAL_INOTIFICATION_MANAGER_IMPL_H_ +#define _FAPP_INTERNAL_INOTIFICATION_MANAGER_IMPL_H_ + +#include +#include +#include + + +namespace Tizen { namespace App +{ + +class _INotificationManagerImpl +{ +public: + virtual ~_INotificationManagerImpl(void) {} + + /** + * Gets the badge number of the application icon. + * + * @return The current badge number + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OBJ_NOT_FOUND The application is not installed. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual int GetBadgeNumber(void) const = 0; + + /** + * Notifies the user using a message and badge number. @n + * If the user checks the message, @c launchArguments is delivered to the application. @n + * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by + * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing(). + * + * @return An error code + * @param[in] messageText The notification message + * @param[in] badgeNumber The badge number + * @param[in] launchArguments The message for application + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - A specified input parameter is invalid. @n + * - The specified @c badgeNumber is less than @c 0. @n + * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n + * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUUNCH_ARGUMENTS_LENGTH. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The type of application calling this method is invalid as per the Tizen platform policy. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result Notify(const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments) = 0; + + /** + * Removes the notification message. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_STATE This instance is in an invalid state: @n + * - The Construct() method is not called. @n + */ + virtual result RemoveNotification(void) = 0; + + /** + * Notifies the user about the ongoing activity using a message. @n + * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by + * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing(). + * + * @return An error code + * @param[in] messageText The notification message + * @param[in] launchArguments The launch arguments for the application + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - A specified input parameter is invalid. @n + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The type of application calling this method is invalid as per the Tizen platform policy. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result NotifyOngoingActivity(const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) = 0; + + /** + * Removes the notification message for the ongoing activity. + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result RemoveOngoingActivityNotification(void) = 0; + + /** + * Gets the badge number of the application icon. + * + * @return The current badge number + * @param[in] appId The application ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OBJ_NOT_FOUND The application is not installed. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual int GetBadgeNumber(const Tizen::App::AppId& appId) const = 0; + + /** + * Notifies the user using a message and badge number on behalf of the specified application. @n + * If the user checks the message, the @c launchArguments is delivered to the application. + * + * @return An error code + * @param[in] appId The application ID + * @param[in] messageText The notification message + * @param[in] badgeNumber The badge number + * @param[in] launchArguments The launch arguments for the application + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - A specified input parameter is invalid. @n + * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n + * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_INVALID_OPERATION The target application with the specified application ID is not permitted to receive any notification as per the Tizen platform policy. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result NotifyByAppId(const Tizen::App::AppId& appId, const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments) = 0; + + /** + * Notifies the user about the ongoing activity using a message on behalf of the specified application. + * + * @return An error code + * @param[in] appId The application ID + * @param[in] messageText The notification message + * @param[in] launchArguments The launch arguments for application + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - A specified input parameter is invalid. @n + * - The length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n + * - The length of @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The type of application calling this method is invalid as per the Tizen platform policy. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result NotifyOngoingActivityByAppId(const Tizen::App::AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) = 0; + + /** + * Removes the notification message for ongoing activity on behalf of the specified application. + * + * @return An error code + * @param[in] appId The application ID + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + virtual result RemoveOngoingActivityNotificationByAppId(const Tizen::App::AppId& appId) = 0; + + /** + * Removes the notification message on behalf of the specified application. + * + * @return An error code + * @param[in] appId The application ID + * @exception E_SUCCESS The method was successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_STATE This instance is in an invalid state: @n + * - The Construct() method is not called. @n + */ + virtual result RemoveNotificationByAppId(const Tizen::App::AppId& appId) = 0; + +}; + +} } // Tizen::App + +#endif // _FAPP_INTERNAL_INOTIFICATION_MANAGER_IMPL_H_ diff --git a/src/base/FBaseLongLong.cpp b/src/base/FBaseLongLong.cpp index 995bf08..dfea06d 100644 --- a/src/base/FBaseLongLong.cpp +++ b/src/base/FBaseLongLong.cpp @@ -161,6 +161,16 @@ LongLong::ToString(long long value) } result +LongLong::Decode(const String& inputStr, long long& ret) +{ + long long value; + result r = _NumberUtil::Decode(inputStr, value); + SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "Propagating."); + ret = value; + return r; +} + +result LongLong::Parse(const String& s, long long& ret) { return Parse(s, Character::RADIX_DECIMAL, ret); diff --git a/src/security/cert/FSecCert_CertDbManager.cpp b/src/security/cert/FSecCert_CertDbManager.cpp index 71ddfe2..a49bb1e 100644 --- a/src/security/cert/FSecCert_CertDbManager.cpp +++ b/src/security/cert/FSecCert_CertDbManager.cpp @@ -152,7 +152,7 @@ _CertDbManager::RemoveCaCertificateByType(_CaCertType certType) char condition[_MAX_TYPE_CONST_SIZE] = {0, }; char installed[_MAX_TYPE_RECORD_SIZE] = "T\0"; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certType = %d and installed = '%s'", certType, installed); + snprintf(condition, sizeof(condition), "certType = %d and installed = '%s'", certType, installed); r = __caCertDbStore.RemoveAllCertificateByCondition(reinterpret_cast< byte* >(condition)); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "Failed to delete all the certificate tables in database."); @@ -167,7 +167,7 @@ _CertDbManager::RemoveUserCaCertificateByCertId(int certId) char condition[_MAX_TYPE_CONST_SIZE] = {0, }; char installed[_MAX_TYPE_RECORD_SIZE] = "T\0"; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certId = %d and certType = %d and installed = '%s'", certId, _CERT_TYPE_ROOT_CA_BY_USER, installed); + snprintf(condition, sizeof(condition), "certId = %d and certType = %d and installed = '%s'", certId, _CERT_TYPE_ROOT_CA_BY_USER, installed); r = __caCertDbStore.RemoveAllCertificateByCondition(reinterpret_cast< byte* >(condition)); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "Failed to delete all the certificate tables in database."); @@ -227,8 +227,8 @@ _CertDbManager::InsertCaCertificateFromBuffer(_CaCertType certType, _CertFormat SysTryReturnResult(NID_SEC_CERT, lenSubjectName < _MAX_ISSUER_SUBJECT_NAME_SIZE, E_SYSTEM, "Subject name is more then maximum specified length."); SysTryReturnResult(NID_SEC_CERT, lenIssuerName < _MAX_ISSUER_SUBJECT_NAME_SIZE, E_SYSTEM, "Subject name is more then maximum specified length."); - strncpy(subjectName, reinterpret_cast< const char* >(pTbsCert->GetSubjectName()),lenSubjectName); - strncpy(issuerName, reinterpret_cast< const char* >(pTbsCert->GetIssuerName()),lenIssuerName); + snprintf(subjectName, sizeof(subjectName), "%s", reinterpret_cast< const char* >(pTbsCert->GetSubjectName())); + snprintf(issuerName, sizeof(issuerName), "%s", reinterpret_cast< const char* >(pTbsCert->GetIssuerName())); pTbsCert->GetSerialNumber(pSerial, reinterpret_cast< int& >(lenSerialNo)); if ((lenSerialNo <= 0) || (lenSerialNo > _MAX_SERIAL_NUMBER_SIZE)) @@ -302,7 +302,7 @@ _CertDbManager::InsertCaCertificateFromBuffer(_CaCertType certType, _CertFormat SysTryReturnResult(NID_SEC_CERT, pFileName != null, E_SYSTEM, "Failed to get file attributes."); int len = strlen(pFileName.get()); - strncpy(certRecord.fileName, pFileName.get(), len); + snprintf(certRecord.fileName, sizeof(certRecord.fileName), "%s", pFileName.get()); certRecord.subjectNameLen = lenSubjectName; memcpy(certRecord.subjectName, subjectName, lenSubjectName); @@ -379,7 +379,7 @@ _CertDbManager::UpdateCaCertificateFromBuffer(_CaCertType certType, _CertFormat r = _Base64::Encode(pTbsCert->GetSubjectName(), lenSubjectName, subjectNameBase64, subjNameB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, certType, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, certType, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates record.", GetErrorMessage(r)); @@ -399,11 +399,8 @@ _CertDbManager::UpdateCaCertificateFromBuffer(_CaCertType certType, _CertFormat pNewTbsCert = pNewCert->GetTbsCertInstance(); SysTryReturnResult(NID_SEC_CERT, pNewTbsCert != null, E_SYSTEM, "Failed to get certificate to be signed instance."); - lenSubjectName = strlen(reinterpret_cast< char* >(pNewTbsCert->GetSubjectName())); - lenIssuerName = strlen(reinterpret_cast< char* >(pNewTbsCert->GetIssuerName())); - - strncpy(newSubjectName, reinterpret_cast< const char* >(pNewTbsCert->GetSubjectName()),lenSubjectName); - strncpy(newIssuerName, reinterpret_cast< const char* >(pNewTbsCert->GetIssuerName()),lenIssuerName); + snprintf(newSubjectName, sizeof(newSubjectName), "%s", reinterpret_cast< const char* >(pNewTbsCert->GetSubjectName())); + snprintf(newIssuerName, sizeof(newIssuerName), "%s", reinterpret_cast< const char* >(pNewTbsCert->GetIssuerName())); lenNewSubjectName = strlen(newSubjectName); lenNewIssuerName = strlen(newIssuerName); @@ -430,7 +427,7 @@ _CertDbManager::UpdateCaCertificateFromBuffer(_CaCertType certType, _CertFormat SysTryReturnResult(NID_SEC_CERT, pFileName != null, E_OPERATION_FAILED, "Failed to get file name."); int len = strlen(pFileName.get()); - strncpy(certRecord1.fileName, pFileName.get(), len); + snprintf(certRecord1.fileName, sizeof(certRecord1.fileName), "%s", pFileName.get()); certRecord1.subjectNameLen = lenNewSubjectName; memcpy(certRecord1.subjectName, newSubjectName, lenNewSubjectName); @@ -509,7 +506,7 @@ _CertDbManager::RemoveCertificateChainByCertId(int certId) memset(&userCertRecord, 0, sizeof(userCertRecord)); memset(condition, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "certId = %d", certId); + snprintf(condition, sizeof(condition), "certId = %d", certId); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &userCertRecord); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r) || r == E_DATA_NOT_FOUND, E_SYSTEM, "Failed to get certificate record."); SysTryReturnResult(NID_SEC_CERT, r != E_DATA_NOT_FOUND, E_SUCCESS, "No such record found."); @@ -554,22 +551,22 @@ _CertDbManager::GetCaCertificateId(byte* pSubjectName, int subjectNameSize, byte if (certType == _CERT_TYPE_NOT_BOUNDED) { - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and issuerName = '%s' and installed = '%s'", subjectNameBase64, issuerNameBase64, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and issuerName = '%s' and installed = '%s'", subjectNameBase64, issuerNameBase64, installed); } else { - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and issuerName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, issuerNameBase64, certType, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and issuerName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, issuerNameBase64, certType, installed); } } else { if (certType == _CERT_TYPE_NOT_BOUNDED) { - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installed); } else { - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, certType, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and certType = %d and installed = '%s'", subjectNameBase64, certType, installed); } } @@ -612,11 +609,11 @@ _CertDbManager::GetUserCertificateId(byte* pSubjectName, int subjectNameSize, by r = _Base64::Encode(reinterpret_cast< byte* >(pIssuerName), issuerNameSize, issuerNameBase64, issuerB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_ISSUER_SUBJECT_NAME_SIZE), "subjectName = '%s' and issuerName = '%s' and installed = '%s'", subjectNameBase64, issuerNameBase64, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and issuerName = '%s' and installed = '%s'", subjectNameBase64, issuerNameBase64, installed); } else { - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_ISSUER_SUBJECT_NAME_SIZE), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installed); } r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &userCertRecord); @@ -652,7 +649,8 @@ _CertDbManager::DeleteCertificateChain(int devCertId, int devParentCA) memset(condition, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "parentCa = %d and installed = '%s'", devParentCA, installed); + snprintf(condition, sizeof(condition), "parentCa = %d and installed = '%s'", devParentCA, installed); + //Check if any other device certificate has same parent as of referred device certificare. If it is yes then we //delete only device certificate and return. We cannot disturb another chain. __userCertDbStore.GetCountByCondition(reinterpret_cast< byte* >(&condition), recCount); @@ -708,7 +706,7 @@ _CertDbManager::DeleteCertificateChain(int devCertId, int devParentCA) } caCertId = caParentCa; // Now look for next certificate in chain memset(condition, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "certId = %d and installed = '%s'", devParentCA, installed); + snprintf(condition, sizeof(condition), "certId = %d and installed = '%s'", devParentCA, installed); memset(&certRecord, 0, sizeof(certRecord)); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r) || r == E_DATA_NOT_FOUND, E_SYSTEM, "Failed to get certificate record."); @@ -734,7 +732,7 @@ _CertDbManager::GetCertificateListByFormat(_CertFormat certFormat, _CertificateL char installed[_MAX_TYPE_RECORD_SIZE] = "T\0"; char condition[_MAX_TYPE_CONST_SIZE] = {0, }; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certFormat = %d and certType != %d and installed = '%s'", certFormat, _CERT_TYPE_INTERMIDIATE_CA, installed); + snprintf(condition, sizeof(condition), "certFormat = %d and certType != %d and installed = '%s'", certFormat, _CERT_TYPE_INTERMIDIATE_CA, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r) || r == E_DATA_NOT_FOUND, E_SYSTEM, "Failed to get certificate record."); @@ -805,7 +803,7 @@ _CertDbManager::GetUserCertificateListByFormat(_CertFormat certFormat, _Certific *ppCertList = null; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certFormat = %d and installed = '%s'", certFormat, installed); + snprintf(condition, sizeof(condition), "certFormat = %d and installed = '%s'", certFormat, installed); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r) || r == E_DATA_NOT_FOUND, E_SYSTEM, "Failed to get certificate record."); @@ -873,7 +871,7 @@ _CertDbManager::GetCaCertificateListByCertId(int certId, _CertificateListInfo** char condition[_MAX_TYPE_CONST_SIZE] = {0, }; *ppCertList = null; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certId = %d and certType != %d and installed = '%s'", certId, _CERT_TYPE_INTERMIDIATE_CA, installed); + snprintf(condition, sizeof(condition), "certId = %d and certType != %d and installed = '%s'", certId, _CERT_TYPE_INTERMIDIATE_CA, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificate record.", GetErrorMessage(r)); @@ -916,7 +914,7 @@ _CertDbManager::GetUserCertificateListByCertId(int certId, _CertificateListInfo* SysTryReturnResult(NID_SEC_CERT, ppCertList != null, E_INVALID_ARG, "Invalid input arguments."); SysTryReturnResult(NID_SEC_CERT, certId > 0, E_INVALID_ARG, "Invalid input arguments."); - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certId = %d and installed = '%s'", certId, installed); + snprintf(condition, sizeof(condition), "certId = %d and installed = '%s'", certId, installed); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificate record.", GetErrorMessage(r)); @@ -995,7 +993,7 @@ _CertDbManager::FindIssuerCertificateAndTypeN(_CertFormat certFormat, char* pIss r = _Base64::Encode(reinterpret_cast< byte* >(pIssuerName), strlen(pIssuerName), issuerNameBase64, issuerNameB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_OFFSET_CONST_SIZE), "subjectName = '%s' and certFormat = %d and installed = '%s'", issuerNameBase64, certFormat, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and certFormat = %d and installed = '%s'", issuerNameBase64, certFormat, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificate record.", GetErrorMessage(r)); @@ -1041,7 +1039,7 @@ _CertDbManager::FindIssuerCertificateByTypeN(_CertFormat certFormat, _CaCertType r = _Base64::Encode(reinterpret_cast< byte* >(pIssuerName), strlen(pIssuerName), issuerNameBase64, issuerNameB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_ISSUER_CONDITION_SIZE), "subjectName = '%s' and certFormat = %d and certType = %d and installed = '%s'", issuerNameBase64, certFormat, certType, installed); + snprintf(condition, sizeof(condition), "subjectName = '%s' and certFormat = %d and certType = %d and installed = '%s'", issuerNameBase64, certFormat, certType, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificate record.", GetErrorMessage(r)); @@ -1099,7 +1097,7 @@ _CertDbManager::FindCertType(_CertFormat certFormat, char* pIssuerName, char* pS r = _Base64::Encode(reinterpret_cast< byte* >(pSubjectName), strlen(pSubjectName), subjectNameBase64, subjectNameB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_CONDITION_CONST_SIZE), "certFormat = %d and issuerName = '%s' and subjectName = '%s' and installed = '%s'", certFormat, issuerNameBase64, subjectNameBase64, installed); + snprintf(condition, sizeof(condition), "certFormat = %d and issuerName = '%s' and subjectName = '%s' and installed = '%s'", certFormat, issuerNameBase64, subjectNameBase64, installed); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificate record.", GetErrorMessage(r)); @@ -1596,8 +1594,8 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC SysTryReturnResult(NID_SEC_CERT, lenSubjectName < _MAX_ISSUER_SUBJECT_NAME_SIZE, E_DATABASE, "Length is greater than maximum allowed length."); SysTryReturnResult(NID_SEC_CERT, lenIssuerName < _MAX_ISSUER_SUBJECT_NAME_SIZE, E_DATABASE, "Length is greater than maximum allowed length."); - strncpy(subjectNameBuffer, reinterpret_cast< char* >(pTbsCert->GetSubjectName()),lenSubjectName); - strncpy(szIssuerName, reinterpret_cast< char* >(pTbsCert->GetIssuerName()),lenIssuerName); + snprintf(subjectNameBuffer, sizeof(subjectNameBuffer), "%s", reinterpret_cast< char* >(pTbsCert->GetSubjectName())); + snprintf(szIssuerName, sizeof(szIssuerName), "%s", reinterpret_cast< char* >(pTbsCert->GetIssuerName())); pTbsCert->GetSerialNumber(pSerial, static_cast< int& >(lenSerialNo)); if ((lenSerialNo <= 0) || (lenSerialNo > _MAX_SERIAL_NUMBER_SIZE)) @@ -1663,7 +1661,8 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC SysTryReturnResult(NID_SEC_CERT, pFileName != null, E_SYSTEM, "Failed to get attributes."); int len = strlen(pFileName.get()); - strncpy(certRecord.fileName, pFileName.get(), len); + snprintf(certRecord.fileName, sizeof(certRecord.fileName), "%s", pFileName.get()); + certRecord.subjectNameLen = lenSubjectName; memcpy(certRecord.subjectName, subjectNameBuffer, lenSubjectName); @@ -1674,7 +1673,7 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC SysTryReturnResult(NID_SEC_CERT, pPriKeyFileName != null, E_SYSTEM, "Failed to get attributes."); len = strlen(pPriKeyFileName.get()); - strncpy(certRecord.prvKeyPath, pPriKeyFileName.get(), len); + snprintf(certRecord.prvKeyPath, sizeof(certRecord.prvKeyPath), "%s", pPriKeyFileName.get()); certRecord.prvKeyLen = privateKeyLen; certRecord.parentCa = certId; strcpy(certRecord.installed, installedRecord); @@ -1739,14 +1738,14 @@ _CertDbManager::GetUserCertificateChain(char* pIssuerName, int issuerNameLen, ch memset(subjectNameBase64, 0, sizeof(subjectNameBase64)); r = _Base64::Encode(reinterpret_cast< byte* >(pSubjectName), subjectNameLen, reinterpret_cast< char* >(subjectNameBase64), subjectNameBase64Len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); + snprintf(condition, sizeof(condition), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); } else { r = __userCertDbStore.GetNumberOfCertificates(recordCount); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates.", GetErrorMessage(r)); SysTryReturnResult(NID_SEC_CERT, recordCount > 0, E_OBJ_NOT_FOUND, "Failed to get certificate records."); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "installed = '%s'", installedRecord); + snprintf(condition, sizeof(condition), "installed = '%s'", installedRecord); } memset(&userCertRecord, 0, sizeof(userCertRecord)); @@ -1895,7 +1894,7 @@ _CertDbManager::GetUserCertificateChain(char* pIssuerName, int issuerNameLen, ch memset(subjectNameBase64, 0, sizeof(subjectNameBase64)); r = _Base64::Encode(reinterpret_cast< byte* >(subName), subNameLen, reinterpret_cast< char* >(subjectNameBase64), subjectNameBase64Len); SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to encode data in base 64 encoding.", GetErrorMessage(r)); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); + snprintf(condition, sizeof(condition), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); if (strcmp(reinterpret_cast< char* >(issuerNameBase64), reinterpret_cast< char* >(subjectNameBase64)) == 0) { @@ -1981,7 +1980,7 @@ _CertDbManager::GetUserCertificateChain(char* pIssuerName, int issuerNameLen, ch } memset(condition, 0, sizeof(condition)); - snprintf(condition, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "installed = '%s'", installedRecord); + snprintf(condition, sizeof(condition), "installed = '%s'", installedRecord); count++; @@ -2037,7 +2036,7 @@ _CertDbManager::GetUserCertificateChain(_CertFormat certFormat, _CertChain* pCer memset(subjectNameBase64, 0, sizeof(subjectNameBase64)); r = _Base64::Encode(reinterpret_cast< byte* >(pSubjectName), strlen(pSubjectName), subjectNameBase64, subjNameB64len); SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_ENCODING_FAILED, "Failed to encode data in base 64 encoding."); - snprintf(conditonRecord, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); + snprintf(conditonRecord, sizeof(conditonRecord), "subjectName = '%s' and installed = '%s'", subjectNameBase64, installedRecord); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(conditonRecord), &userCertRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates record.", GetErrorMessage(r)); @@ -2056,7 +2055,7 @@ _CertDbManager::GetUserCertificateChain(_CertFormat certFormat, _CertChain* pCer { memset(&caCertRecord, 0, sizeof(caCertRecord)); memset(conditonRecord, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE); - snprintf(conditonRecord, (_MAX_ISSUER_SUBJECT_NAME_SIZE + _MAX_SUBJECT_OFFSET_SIZE), "certId = %d and installed = '%s'", parentCa, installedRecord); + snprintf(conditonRecord, sizeof(conditonRecord), "certId = %d and installed = '%s'", parentCa, installedRecord); r = __caCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(conditonRecord), &caCertRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates record.", GetErrorMessage(r)); @@ -2082,7 +2081,7 @@ _CertDbManager::GetUserCertificateInfoByCertId(int certId, int* pSubjectLength, char installedRecord[_MAX_TYPE_RECORD_SIZE] = "T\0"; char condition[_MAX_TYPE_CONST_SIZE] = {0, }; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certId = %d and installed = '%s'", certId, installedRecord); + snprintf(condition, sizeof(condition), "certId = %d and installed = '%s'", certId, installedRecord); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &userCertRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates record.", GetErrorMessage(r)); @@ -2120,7 +2119,7 @@ _CertDbManager::GetUserCertificateInfoByCertId(int certId, _CertEncodingType enc *ppUserCertInfo = null; SysTryReturnResult(NID_SEC_CERT, certId > 0, E_INVALID_ARG, "Invalid input parameter."); - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certId = %d and installed = '%s'", certId, installedRecord); + snprintf(condition, sizeof(condition), "certId = %d and installed = '%s'", certId, installedRecord); r = __userCertDbStore.GetFirstRecordByConditions(reinterpret_cast< byte* >(condition), &certRecord); SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to get certificates record.", GetErrorMessage(r)); diff --git a/src/security/cert/FSecCert_CertFileStore.cpp b/src/security/cert/FSecCert_CertFileStore.cpp index 1bfe0c0..bcf222d 100644 --- a/src/security/cert/FSecCert_CertFileStore.cpp +++ b/src/security/cert/FSecCert_CertFileStore.cpp @@ -191,7 +191,7 @@ _CertFileStore::GetFileNameFromHandle(CertIdNo hCert, _CertPathType pathType, St SysTryReturnResult(NID_SEC_CERT, hCert != null, E_INVALID_ARG, "Invalid input parameter."); - snprintf(temp, _MAX_CERT_EXT_PATH_SIZE, "%03d", hCert); + snprintf(temp, sizeof(temp), "%03d", hCert); tempStr.Append(temp); switch (pathType) diff --git a/src/security/cert/FSecCert_CertManager.cpp b/src/security/cert/FSecCert_CertManager.cpp index eb0e3d1..d2d97f5 100644 --- a/src/security/cert/FSecCert_CertManager.cpp +++ b/src/security/cert/FSecCert_CertManager.cpp @@ -383,7 +383,7 @@ _CertManager::GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _C int len = strlen(pSigAlg); if (len <= _MAX_CERT_ALGORITHM_SIZE) { - strncpy(pCertInfo->sigAlgorithm, pSigAlg, len); + snprintf(pCertInfo->sigAlgorithm, sizeof(pCertInfo->sigAlgorithm), "%s", pSigAlg); } else { @@ -421,7 +421,7 @@ _CertManager::GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _C memset(pCertInfo->subjectName, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1); if (subLen <= _MAX_ISSUER_SUBJECT_NAME_SIZE + 1) { - strncpy(pCertInfo->subjectName, reinterpret_cast< const char* >(pSubjectName), subLen); + snprintf(pCertInfo->subjectName, sizeof(pCertInfo->subjectName), "%s", reinterpret_cast< const char* >(pSubjectName)); } ParseCertTitle(reinterpret_cast< char* >(pSubjectName), pCertInfo->certTitle); ClearLastResult(); @@ -433,7 +433,7 @@ _CertManager::GetCertInfo(CertificateHandle certHandle, _CertFieldType field, _C memset(pCertInfo->issuerName, 0, _MAX_ISSUER_SUBJECT_NAME_SIZE + 1); if (issuerLen <= _MAX_ISSUER_SUBJECT_NAME_SIZE + 1) { - strncpy(pCertInfo->issuerName, reinterpret_cast< const char* >(pIssuerName), issuerLen); + snprintf(pCertInfo->issuerName, sizeof(pCertInfo->issuerName), "%s", reinterpret_cast< const char* >(pIssuerName)); } ParseCertTitle(reinterpret_cast< char* >(pIssuerName), pCertInfo->certSubTitle); ClearLastResult(); @@ -762,8 +762,8 @@ _CertManager::GetCertificateType(CertificateHandle certHandle, _CaCertType* pCer SysTryReturnResult(NID_SEC_CERT, lenSubjectName > 0, E_SYSTEM, "Subject length is not valid."); SysTryReturnResult(NID_SEC_CERT, lenIssuerName > 0, E_SYSTEM, "Issuer length is not valid."); - strncpy(subjectName, reinterpret_cast< const char* >(pTbsCert->GetSubjectName()), lenSubjectName); - strncpy(issuerName, reinterpret_cast< const char* >(pTbsCert->GetIssuerName()), lenIssuerName); + snprintf(subjectName, sizeof(subjectName), "%s", reinterpret_cast< const char* >(pTbsCert->GetSubjectName())); + snprintf(issuerName, sizeof(issuerName), "%s", reinterpret_cast< const char* >(pTbsCert->GetIssuerName())); pCertDb = _CertDbManager::GetInstance(); SysTryReturnResult(NID_SEC_CERT, pCertDb != null, E_SYSTEM, "Failed to get instance of certificate database manager."); @@ -794,7 +794,7 @@ _CertManager::ParseCertTitle(char subject[_MAX_ISSUER_SUBJECT_NAME_SIZE + 1], ch char* pSubStr = null; char tempSubject[_MAX_ISSUER_SUBJECT_NAME_SIZE + 1] = {0, }; - strncpy(tempSubject, subject, strlen(subject + 1)); + snprintf(tempSubject, sizeof(tempSubject), "%s", subject); pPivotPtr = tempSubject; for (;; pSubStr = null) { @@ -1107,7 +1107,7 @@ _CertManager::OpenUserCertificateStore(int& totalCount) totalCount = 0; - snprintf(condition, _MAX_TYPE_CONST_SIZE, "installed = '%s'", installedRecord); + snprintf(condition, sizeof(condition), "installed = '%s'", installedRecord); std::unique_ptr< _UserCertDbStore > pUserCertDbStore(new (std::nothrow) _UserCertDbStore()); SysTryReturn(NID_SEC_CERT, pUserCertDbStore != null, certificateStoreCtx, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory."); @@ -1185,7 +1185,7 @@ _CertManager::OpenRootCaStore(_CaCertType type, int& totalCount) // _CERT_TYPE_T SysTryReturn(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, certificateStoreCtx, E_INVALID_ARG, "[E_INVALID_ARG] Invalid certificate type."); SysTryReturn(NID_SEC_CERT, type < _CERT_TYPE_MAX, certificateStoreCtx, E_INVALID_ARG, "[E_INVALID_ARG] Invalid certificate type."); - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certType = %d and installed = '%s'", static_cast< int >(type), installedRecord); + snprintf(condition, sizeof(condition), "certType = %d and installed = '%s'", static_cast< int >(type), installedRecord); std::unique_ptr< _CaCertDbStore > pCaCertDbStore(new (std::nothrow) _CaCertDbStore()); SysTryReturn(NID_SEC_CERT, pCaCertDbStore != null, certificateStoreCtx, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory."); @@ -1256,7 +1256,7 @@ _CertManager::CheckRootCaIntegrity(void) ClearLastResult(); - snprintf(condition, _MAX_TYPE_CONST_SIZE, "certType = %d and installed = '%s'", _CERT_TYPE_ROOT_CA, installedRecord); + snprintf(condition, sizeof(condition), "certType = %d and installed = '%s'", _CERT_TYPE_ROOT_CA, installedRecord); std::unique_ptr< _CaCertDbStore > pCaCertDbStore(new (std::nothrow) _CaCertDbStore()); SysTryReturnResult(NID_SEC_CERT, pCaCertDbStore != null, E_OUT_OF_MEMORY, "Failed to allocate memory."); diff --git a/src/security/cert/FSecCert_X509CertificateStoreImpl.cpp b/src/security/cert/FSecCert_X509CertificateStoreImpl.cpp index 1df2b3b..ca25fc4 100644 --- a/src/security/cert/FSecCert_X509CertificateStoreImpl.cpp +++ b/src/security/cert/FSecCert_X509CertificateStoreImpl.cpp @@ -381,8 +381,6 @@ _X509CertificateStoreImpl::Update(CertificateType certificateType, const Tizen:: oldBufferLen = pOldEncodedData->GetRemaining(); SysTryReturnResult(NID_SEC_CERT, oldBufferLen > 0, E_INVALID_ARG, "Input old certificate length is not positive."); - pOldEncodedData.reset(null); - std::unique_ptr< ByteBuffer > pNewEncodedData(newCert.GetEncodedDataN()); SysTryReturnResult(NID_SEC_CERT, pNewEncodedData != null, E_INVALID_ARG, "Failed to get encoded data on new input certificate.");