Change-Id: I81c930da9fb908a32907065e428612a0a32db59d
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
/// </remarks>
public class ContactsDatabase
{
/// </remarks>
public class ContactsDatabase
{
+ private Object thisLock = new Object();
+ private Interop.Database.ContactsDBStatusChangedCallback _contactsDBStatusChangedCallback;
+ private event EventHandler<DBStatusChangedEventArgs> _dbStatusChanged;
+ private Dictionary<string, ContactsDBChangedDelegate> _callbackMap = new Dictionary<string, ContactsDBChangedDelegate>();
+ private Dictionary<string, Interop.Database.ContactsDBChangedCallback> _delegateMap = new Dictionary<string, Interop.Database.ContactsDBChangedCallback>();
+ private Interop.Database.ContactsDBChangedCallback _dbChangedDelegate;
/// <summary>
/// Delegete for detecting the contacts database changes
/// </summary>
/// <summary>
/// Delegete for detecting the contacts database changes
/// </summary>
/// </remarks>
/// <see cref="AddDBChangedDelegate"/>
public delegate void ContactsDBChangedDelegate(string uri);
/// </remarks>
/// <see cref="AddDBChangedDelegate"/>
public delegate void ContactsDBChangedDelegate(string uri);
- private Object thisLock = new Object();
- private Interop.Database.ContactsDBStatusChangedCallback _contactsDBStatusChangedCallback;
- private event EventHandler<DBStatusChangedEventArgs> _dbStatusChanged;
- private Dictionary<string, ContactsDBChangedDelegate> _callbackMap = new Dictionary<string, ContactsDBChangedDelegate>();
- private Dictionary<string, Interop.Database.ContactsDBChangedCallback> _delegateMap = new Dictionary<string, Interop.Database.ContactsDBChangedCallback>();
- private Interop.Database.ContactsDBChangedCallback _dbChangedDelegate;
internal ContactsDatabase()
{
internal ContactsDatabase()
{
/// </summary>
Name = 0x00000001,
/// <summary>
/// </summary>
Name = 0x00000001,
/// <summary>
- /// Search record from name and number
+ /// Search record from number
/// </summary>
Number = 0x00000002,
/// <summary>
/// </summary>
Number = 0x00000002,
/// <summary>
- /// Search record from name,number and data
+ /// Search record from data
/// </summary>
Data = 0x00000004,
/// <summary>
/// </summary>
Data = 0x00000004,
/// <summary>
- /// Search record from name,number,data and email. Now, support only PersonEmail view
+ /// Search record from email. Now, support only PersonEmail view
/// </summary>
Email = 0x00000008,
}
/// </summary>
Email = 0x00000008,
}
- /// The contacts database status.
+ /// The current contacts database version.
- DBStatus status;
- int error = Interop.Database.GetStatus(out status);
+ int version = -1;
+ int error = Interop.Database.GetVersion(out version);
if ((int)ContactsError.None != error)
{
if ((int)ContactsError.None != error)
{
- Log.Error(Globals.LogTag, "GetStatus Failed with error " + error);
+ Log.Error(Globals.LogTag, "Version Failed with error " + error);
- /// Gets current contacts database version.
+ /// The last successful changed contacts database version on the current connection.
- /// <returns>The current contacts database version</returns>
- /// <privilege>http://tizen.org/privilege/contact.read</privilege>
- /// <privilege>http://tizen.org/privilege/callhistory.read</privilege>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
- public int GetVersion()
+ public int LastChangeVersion
- int version = -1;
- int error = Interop.Database.GetVersion(out version);
- if ((int)ContactsError.None != error)
- Log.Error(Globals.LogTag, "GetVersion() Failed with error " + error);
- throw ContactsErrorFactory.CheckAndCreateException(error);
+ int version = -1;
+ int error = Interop.Database.GetLastChangeVersion(out version);
+ if ((int)ContactsError.None != error)
+ {
+ Log.Error(Globals.LogTag, "LastChangeVersion Failed with error " + error);
+ }
+ return version;
- /// Gets last successful changed contacts database version on the current connection.
+ /// The contacts database status.
- /// <returns>The last successful changed contacts database version on the current connection</returns>
- /// <privilege>http://tizen.org/privilege/contact.read</privilege>
- /// <privilege>http://tizen.org/privilege/callhistory.read</privilege>
- /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
- /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
- public int GetLastChangeVersion
- int version = -1;
- int error = Interop.Database.GetLastChangeVersion(out version);
+ DBStatus status = DBStatus.Normal;
+ int error = Interop.Database.GetStatus(out status);
if ((int)ContactsError.None != error)
{
if ((int)ContactsError.None != error)
{
- Log.Error(Globals.LogTag, "GetLastChangeVersion Failed with error " + error);
+ Log.Error(Globals.LogTag, "GetStatus Failed with error " + error);
/// <param name="keyword">The keyword</param>
/// <param name="offset">The index from which to get results</param>
/// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
/// <param name="keyword">The keyword</param>
/// <param name="offset">The index from which to get results</param>
/// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
- /// <param name="range">The search range</param>
+ /// <param name="range">The search range, it should be a element of SearchRange or bitwise OR operation of them</param>
/// <returns>The record list</returns>
public ContactsList Search(string viewUri, string keyword, int offset, int limit, int range)
{
IntPtr recordList;
/// <returns>The record list</returns>
public ContactsList Search(string viewUri, string keyword, int offset, int limit, int range)
{
IntPtr recordList;
- int error = Interop.Database.Search(viewUri, keyword, offset, limit, out recordList);
+ int error = Interop.Database.Search(viewUri, keyword, offset, limit, range, out recordList);
if ((int)ContactsError.None != error)
{
Log.Error(Globals.LogTag, "Search Failed with error " + error);
if ((int)ContactsError.None != error)
{
Log.Error(Globals.LogTag, "Search Failed with error " + error);
/// <param name="keyword">The keyword</param>
/// <param name="offset">The index from which to get results</param>
/// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
/// <param name="keyword">The keyword</param>
/// <param name="offset">The index from which to get results</param>
/// <param name="limit">The number to limit results(value 0 is used for get all records)</param>
- /// <param name="range">The search range</param>
+ /// <param name="range">The search range, it should be a element of SearchRange or bitwise OR operation of them</param>
/// <param name="startMatch">The text which is inserted into the fragment before the keyword(If NULL, default is "[")</param>
/// <param name="endMatch">The text which is inserted into the fragment after the keyword(If NULL, default is "]")</param>
/// <param name="tokenNumber">The one side extra number of tokens near keyword(If negative value, full sentence is printed. e.g. if token number is 3 with 'abc' keyword, "my name is [abc]de and my home")</param>
/// <param name="startMatch">The text which is inserted into the fragment before the keyword(If NULL, default is "[")</param>
/// <param name="endMatch">The text which is inserted into the fragment after the keyword(If NULL, default is "]")</param>
/// <param name="tokenNumber">The one side extra number of tokens near keyword(If negative value, full sentence is printed. e.g. if token number is 3 with 'abc' keyword, "my name is [abc]de and my home")</param>
- /// A class for managing contact information. It allows applications to use contacts service.
+ /// A class for managing contact information. It allows applications to access contacts database.
/// </summary>
public class ContactsManager : IDisposable
{
/// </summary>
public class ContactsManager : IDisposable
{